Playtolia Store API allows you to list, query, and search store items. Store API supports different types of items such as NonConsumable, Consumable, and Subscription. Store API also provides a simple function to start the purchase flow for any item in your store. Store API works with Play Store and App Store APIs in order to securely process payments, grant items to your players, and handle failures.
Store data is only available after successful authentication. PlaytoliaStore functions will return empty lists or null values until the player is logged in.
Import the PlaytoliaSDK.Runtime to your script by adding the using directive
StoreController.cs
Copy
using PlaytoliaSDK.Runtime;
Call the GetItems function to retrieve all available store items
StoreController.cs
Copy
// Get all itemsvar allItems = PlaytoliaStore.GetItems();
Once you authenticate your user, PlaytoliaStore will automatically refresh and fetch the latest available items. If you need to refresh the store items manually, simply use PlaytoliaStore.Refresh() function.
Call the SearchItems function to search items by their name, description, or SKU
StoreController.cs
Copy
// Search for items with "Gold" in their name, description, or skuvar searchResult = PlaytoliaStore.SearchItems("Gold");// Get items by typevar consumables = PlaytoliaStore.GetItemsByType("Consumable");var subscriptions = PlaytoliaStore.GetItemsByType("NonConsumable");var nonConsumables = PlaytoliaStore.GetItemsByType("Subscription");
PlaytoliaStore includes two getter functions to help you get a specific StoreItem by item ID or SKU
StoreController.cs
Copy
// Get an item by IDvar itemById = PlaytoliaStore.GetItemById("gold_500");// Get an item by SKUvar itemBySku = PlaytoliaStore.GetItemBySku("com.mygame.coinpack_500");
When your player is ready to purchase an item, simply use the BeginPurchaseFlow function and pass a StoreItem
StoreController.cs
Copy
StoreItem item = PlaytoliaStore.GetItemBySku("com.mygame.coinpack_500");PlaytoliaStore.BeginPurchaseFlow(item);// Or purchase by item IDPlaytoliaStore.BeginPurchaseFlow("gold_500");
Purchase flows are a composition of several requests:
Client validation: Calls to App Store or Google Play Store to ensure billing is available, fetch the item, and display the IAP dialog
Server verification: A verification call to Playtolia servers to check purchase integrity and update user wallets, subscriptions, and entitlements
Purchase acknowledgment: A final call to the billing clients to acknowledge (or consume) the purchase
The SDK makes all necessary requests and calls with a single BeginPurchaseFlow function. Most of the process is handled in different threads in an asynchronous manner, in order to prevent your game from lagging or freezing.EventBus component offers a fast, non-blocking, and safe way to consume results of async flows by storing and passing references of local callback objects named EventHandles.