Implementation Guide

How to implement Tebex into your Unity game from start-to-finish.

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.

circle-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.

2. Adding Packages

Packages are created in your Tebex store panel at: https://creator.tebex.io/arrow-up-right

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()

For a Unity specific drop-in solution, see the Store Browser and In Game Cart.

3. Checkout Options

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

Baskets include a links property where the user must be directed to complete checkout.

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

triangle-exclamation

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.

See QR Code Generator 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

a. Apply on Checkout

You can use the Deliverables 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.

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

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 Webhooksfor implementation guides.

Tebex provides SDKs in various languages on popular package managers. See our available SDKs

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

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

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

Last updated