Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.playtolia.com/llms.txt

Use this file to discover all available pages before exploring further.

PlaytoliaStore provides the item catalog and purchase flow. It syncs automatically after login.

Fetching items

var allItems    = PlaytoliaStore.GetItems();
var consumables = PlaytoliaStore.GetItemsByType("Consumable");
var nonConsum   = PlaytoliaStore.GetItemsByType("NonConsumable");
var subs        = PlaytoliaStore.GetItemsByType("Subscription");
var results     = PlaytoliaStore.SearchItems("Gold");

var item = PlaytoliaStore.GetItemById("gold_500");
var item = PlaytoliaStore.GetItemBySku("com.mygame.gold500");

StoreItem fields

Id, Name, Sku, Type (Consumable/NonConsumable/Subscription), Grants[] Each Grant has: GrantId, GrantType, GrantAmount, Currency?

Making a purchase

PlaytoliaStore.BeginPurchaseFlow("gold_500",
    onSuccess: (receipt) =>
    {
        Debug.Log($"Purchase succeeded! Transaction: {receipt.ReceiptId}");
        Debug.Log($"Store: {receipt.Store}");
        Debug.Log($"Item: {receipt.Item.Name} ({receipt.Item.Sku})");
    },
    onError: (error) =>
    {
        Debug.LogError($"Purchase failed [{error.Code}]: {error.Message}");

        if (error.Code == "USER_CANCELLED")
        {
            // User backed out — no action needed
            return;
        }

        if (error.Stage == "ACKNOWLEDGEMENT")
        {
            // Player was charged, SDK will retry automatically
            ShowMessage("Your purchase is being processed.");
            return;
        }

        ShowMessage("Purchase failed: " + error.Message);
    }
);

// Also accepts a StoreItem directly
var item = PlaytoliaStore.GetItemById("gold_500");
PlaytoliaStore.BeginPurchaseFlow(item,
    onSuccess: (receipt) => { /* grant confirmed */ },
    onError: (error) => { /* handle error */ }
);
The onSuccess callback receives a PurchaseReceipt with the transaction ID, store, and purchased item. The onError callback receives a PurchaseError with a machine-readable error code, stage, and message. Both callbacks are optional. When the purchase completes successfully, the SDK automatically updates the player’s wallet, entitlements, and subscriptions.

PurchaseReceipt

FieldTypeDescription
ItemStoreItemThe purchased store item
ReceiptIdstringPlatform transaction ID
Storestring"google_play" or "apple_app_store"

PurchaseError

FieldTypeDescription
CodestringMachine-readable error code
MessagestringHuman-readable description
StagestringPURCHASE, VERIFICATION, or ACKNOWLEDGEMENT
ReceiptIdstring?Set if the platform purchase succeeded
ItemIdstring?Playtolia store item ID
ItemSkustring?Platform SKU

Error codes

CodeStageWhen
BILLING_UNAVAILABLEPURCHASEPlatform billing not available on device
ITEM_NOT_FOUNDPURCHASEItem ID not found in store
USER_CANCELLEDPURCHASEUser dismissed the purchase dialog
PURCHASE_FAILEDPURCHASEPlatform billing error
VERIFICATION_FAILEDVERIFICATIONBackend verification failed
ACKNOWLEDGEMENT_FAILEDACKNOWLEDGEMENTPlatform acknowledgement failed after verification
Store data is empty until the player is authenticated. All item getters return null or empty lists before login.
When Stage is ACKNOWLEDGEMENT, the user has been charged but acknowledgement failed. The SDK automatically retries on next app launch. Show a reassuring message like “Your purchase is being processed.”

Listening to changes

void Start()    => PlaytoliaStore.AddListener(OnStoreChanged);
void OnDestroy() => PlaytoliaStore.RemoveListener(OnStoreChanged);

Wallets

Track currency after purchases

Entitlements

Track non-consumable unlocks