# Implementation Guide

This guide will demonstrate the general steps you'll need to take to implement a Tebex-powered checkout flow and the implementation options available in Unity.

## 1. Creating a Basket

All transactions originate from a **Basket**.

You create a basket when you want to add packages the player will purchase. You can provide a `username` and/or `email` with your creation request to identify the player.

If your game doesn't use emails or usernames, use the `custom` field at basket creation to provide any identifying information. This data will be made available in the Tebex panel and via webhooks.

{% hint style="info" %}
You are not required to show a Basket / implement a cart system into your game. It is a very typical flow to create the basket, add the desired package, and direct to checkout all at the same time.
{% endhint %}

## 2. Adding Packages

Packages are created in your Tebex store panel at: <https://creator.tebex.io/>

These are the sellable items in-game, their associated pricing, and general configuration.

You can get the list of Packages available for purchase in your game's store using: `Tebex.TebexUnity.HeadlessAPI.GetPackages()`&#x20;

For a Unity specific drop-in solution, see the [store-browser](https://docs.tebex.io/developers/unity-engine/features/store-browser "mention") and [in-game-cart](https://docs.tebex.io/developers/unity-engine/features/in-game-cart "mention").

## 3. Checkout Options

When the user is ready to checkout and pay, the general options available are:

### a. Link Out

`Baskets` include a `links` property where the user must be directed to complete checkout.&#x20;

Tebex inclludes a utility function to open a basket's checkout link in the user's default browser: `Tebex.TebexUnity.Utilities.OpenCheckoutLink()`&#x20;

{% hint style="danger" %}
Check the legal terms of your publishing platforms before adding link-out into your game.
{% endhint %}

### b. QR Code / Mobile

You can display a QR code the user can scan with a mobile device. This will direct them to the basket's checkout page on their device's browser.&#x20;

See [qr-code-generator](https://docs.tebex.io/developers/unity-engine/features/qr-code-generator "mention") for implementation details.

## 4. Deliverables

Deliverables refer to delivering the purchased item to the customer.

You can check a basket's status by ID to see when it is completed. On completion, the client-side will still have full access to the purchase details via the **Basket**.

You may handle applying deliverables manually, or use the included **Deliverables** utility&#x20;

### a. Apply on Checkout

You can use the [deliverables](https://docs.tebex.io/developers/unity-engine/features/deliverables "mention") utility to run logic for the packages purchased after checkout. This automatically runs `Actions` you define per-package when a `Basket` is complete.

### b. Apply on Load

When your game loads, you can check which packages the player has purchased and unlock/apply their features by using: `Tebex.TebexUnity.Utilities.GetPurchases(id)`. Where `id` This will return the purchases Tebex has on record for the identified user.

At minimum this requires a `username` or `email` identifier for the player.&#x20;

If your game does not use usernames or emails, it is acceptable to use a UUID/numeric ID for the `username`.&#x20;

### c. Webhooks

If you have an API or backend, Tebex can send webhooks about purchase events to URLs you specify. These will include your basket's `custom` properties, as well as any customer/identifying information relevant for the player as a **PaymentSubject**.

See [webhooks](https://docs.tebex.io/developers/webhooks "mention")for implementation guides.

Tebex provides SDKs in various languages on popular package managers. See our available [sdks](https://docs.tebex.io/developers/sdks "mention")

### d. Game Server Plugins

If your game uses public or private servers, **Plugin API** can apply purchases as game server commands executed in-game. An example plugin is included in `TebexPlugin.cs`&#x20;

Game server commands are deliverables attached to packages, defined by the seller in the creator panel.&#x20;

A plugin is expected to periodically check the queue and execute commands due according to their conditions.

Available conditions include:

* Inventory slots available
* Time delay before execution
* Online / offline status of the player


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tebex.io/developers/unity-engine/implementation-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
