App Store
The AppStore Service provides access to Product / Pricing / Promotion features, as well as integrations with supported AppStores.
This service replaces the deprecated Product Service for purchases and product / pricing data. Currency operations have been moved to the new VirtualCurrency Service.
It includes APIs for:
- Handling In-app Purchases (IAP)
- Querying Products and Promotions
API Summary
Verifying In-app Purchases
The specifics of processing in-app purchases from platform to platform vary slightly, but the overall flow is as follows:
- Client app requests the list of products to display from brainCloud ( GetSalesInventory ), and keeps each product's
payloadand store product ID / SKU (priceData.id; for Apple, theitunesIdinpriceData.ids) - Client app displays the in-app store to the user. Each item keeps its store product ID and its payload
- User selects a store item to purchase
- For Google Play, Apple and Meta Horizon, client app caches the selected item's payload with brainCloud ( CachePurchasePayloadContext ). Other stores skip this step
- Client app invokes the purchase API from the AppStore. AppStore performs the purchase, and sends back a response with the receipt to the client
- Client sends the receipt to brainCloud for validation ( VerifyPurchase )
- brainCloud performs a back-channel verification of the receipt with the AppStore, and uses the receipt info together with the cached payload to resolve the purchase to the proper product item, with the proper pricing, promotions and campaign info. If all is good, it makes any required changes to virtual currency balances
- Step 4 applies to Google Play, Apple and Meta Horizon, and is recommended for every purchase on those stores: the payload identifies the product, and records the price, promotion and any live-ops campaign the user was shown. It is also what tells several products sharing one store product ID apart, so a purchase of a shared ID without one is rejected by default. Other stores do not use the cached payload — see CachePurchasePayloadContext for details.
The following calls request the list of products for sale:
This method caches the payload of the item being purchased:
- CachePurchasePayloadContext - for Google Play, Apple and Meta Horizon purchases: call it when the user selects an item, before starting the store purchase
This method is used to confirm store receipts:
- VerifyPurchase - standardized receipt verification for Apple, Google, Facebook and Steam purchases
Performing Two-part Purchases
Some AppStores, like Steam, do a real-time two-part purchase. The following new API methods handle this requirement:
- StartPurchase - Generic version of start purchase.
- FinalizePurchase - Generic version of finalize purchase.
Store Configuration and User Tokens
Some stores, like Xsolla, need configuration and a user token on the client to open their checkout. The following API methods provide them:
- GetStoreInfo - Returns the store's client-side configuration.
- GetUserToken - Returns a store user token (JWT) for the current user.
Promotions
In addition to the above purchase flows, the app can also query to see if any promotions are currently active (for display in banners, etc.), using the GetEligiblePromotions call – and can make manual adjustments to virtual currency balances.
The promotions API(s) are:
- GetEligiblePromotions - Retrieves eligible promotions.
📄️ CachePurchasePayloadContext
Caches a payload context to retrieve as fallback if the store API cannot provide the payload. Used for Google Play, Apple and Meta Horizon purchases only.
📄️ FinalizePurchase
Finalize a two-part purchase transaction. Currently only used for Steam purchases. On success, the player will be awarded the associated currencies.
📄️ GetEligiblePromotions
Get eligible promotions.
📄️ GetSalesInventory
Method gets the active sales inventory for the passed-in currency type and platform.
📄️ GetSalesInventoryByCategory
Method gets the active sales inventory for the passed-in currency type, platform, and category.
📄️ GetStoreInfo
Returns the client-side configuration of the given store, such as the API and pay station URLs a client needs to open the store's checkout. Currently only Xsolla returns store info.
📄️ GetUserToken
Returns a store user token (JWT) for the current user, generated on the server. The client can use it to call the store's APIs on the user's behalf. Currently only supported for Xsolla.
📄️ RefreshPromotions
Returns up-to-date eligible 'promotions' for the user and a 'promotionsRefreshed' flag indicating whether the user's promotion info required refreshing.
📄️ ReturnPurchase
Mock version of return purchase, use for test purpose.
📄️ StartPurchase
Initialize a two-part purchase transaction. Currently only used for Steam purchases.
📄️ SysAwardProduct
Awards the current user the product item rewards without requiring a purchase (free, no purchase transaction recorded).
📄️ SysAwardProductToUser
Awards the specified user the product item rewards without requiring a purchase (free, no purchase transaction recorded).
📄️ SysGenerateAzureADAccessToken
Generates an Azure AD access token.
📄️ SysGetTransactionDetails
Returns details of the identified product transaction.
📄️ SysGetTransactionsPage
Gets the page of product transactions information from the server based on the specified context.
📄️ SysGetTransactionsPageOffset
Gets the page of product transactions information from the server based on the encoded context and specified page offset.
📄️ SysRecordTransaction
Records a manual transaction. Useful for stores that are not yet directly supported -- or for apps that doing purchases via other means - but still want to record them in brainCloud for reporting purposes.