Using HeadlessAPI directly (advanced)
If you need basket operations outside of the pre-built components, we provide all mappings for HeadlessAPI and PluginAPI. See their dedicated sections for more details.
using Tebex.Headless;
using UnityEngine;
public class CustomStoreFlow : MonoBehaviour
{
HeadlessApi api;
async void Start()
{
api = HeadlessApi.GetInstance(new UnityHeadlessAdapter(), "your-public-token");
// Fetch all categories with their packages
await api.GetAllCategoriesIncludingPackagesAsync(
onSuccess: categories =>
{
foreach (var cat in categories)
Debug.Log($"{cat.name}: {cat.packages.Count} packages");
},
onApiError: err => Debug.LogError($"API Error: {err.detail}"),
onServerError: err => Debug.LogError($"Server Error {err.Code}: {err.Body}")
);
// Create a basket for a player
var payload = new CreateBasketPayload
{
username = "PlayerOne",
complete_url = "https://yoursite.com/thanks",
cancel_url = "https://yoursite.com/store"
};
await api.CreateBasketAsync(
payload: payload,
onSuccess: basket =>
{
Debug.Log($"Basket created: {basket.ident}");
Debug.Log($"Checkout: {basket.links.checkout}");
},
onApiError: err => Debug.LogError(err.detail),
onServerError: err => Debug.LogError(err.Body)
);
}
}Last updated
Was this helpful?

