For the complete documentation index, see llms.txt. This page is also available as Markdown.

Basic reward delivery pattern

This is a basic rewards system that utilizes the InGameCart and Deliverables helpers included with our SDK.

This is only an example and not a requirement for using the SDK. You can implement your own reward delivery per your requirements. Tebex also supports delivery with game server commands via the Plugin API and Webhooks sent to a backend you control.

using Tebex.TebexUnity;
using Tebex.Headless;
using UnityEngine;

public class RewardManager : MonoBehaviour
{
    [SerializeField] Deliverables deliverables;
    [SerializeField] InGameCart cart;

    // Assume you have these packages (fetched from Tebex.Packages or Tebex.PackageLookup)
    [SerializeField] int goldPackageId = 1001;
    [SerializeField] int mountPackageId = 1002;

    void Start()
    {
        // Register what to do when each package is purchased.
        deliverables.RegisterDeliverableAction(goldPackageId, OnGoldPurchased);
        deliverables.RegisterDeliverableAction(mountPackageId, OnMountPurchased);
    }

    // After the player creates a basket and proceeds to checkout,
    // hand the basket to Deliverables so it starts polling.
    public void BeginWaitingForPayment()
    {
        Basket basket = cart.ActiveBasket;
        if (basket != null)
        {
            deliverables.SetActiveBasket(basket);
        }
    }

    void OnGoldPurchased(BasketPackage package)
    {
        int qty = package.in_basket.quantity;
        Debug.Log($"Player bought {qty}x {package.name}. Awarding gold...");
        // PlayerInventory.AddGold(qty * 1000);
    }

    void OnMountPurchased(BasketPackage package)
    {
        Debug.Log($"Player purchased: {package.name}. Unlocking mount...");
        // PlayerMounts.Unlock("DragonMount");
    }
}

Last updated

Was this helpful?