Skip to main content
Version: 5.7.0

Product

The Product Service manages virtual currencies and handles receipt processing for the various app stores.

caution

WARNING: As of brainCloud 3.9, the Product service is being deprecated in favor of two replacement services: AppStore for in-app purchases and product/promotions/pricing requests and VirtualCurrency for currency operations. The APIs in the replacement services are similar, but improved; more generic method names and cleaner, more standardized response formats. The Product service and APIs will continue to be available until the end of 2019. We strongly recommend that all new apps use the AppStore and VirtualCurrency services instead.

The Product service includes APIs for:

  • Managing Virtual Currencies
  • Handling In-app Purchases (IAP)
  • Querying Promotions

Virtual Currencies

The following API calls are used to manage a user's currency balances:

  • [GetCurrency](/api/capi/product/getcurrency) - get current currency balances
  • [AwardCurrency](/api/capi/product/awardcurrency) - call when currency is awarded. Note that
  • [ConsumeCurrency](/api/capi/product/consumecurrency) - call when currency is consumed
  • [ResetCurrency](/api/capi/product/resetcurrency) - resets the users currency to zero

Note that there are Parent and Peer versions of these APIs available as well.

tip

For security reasons, the above calls are normally only available via cloud code. You can make them client callable by enabling the [x] Allow Currency Calls from Client compatibility flag on the Design | Core App Info | Advanced Settings page of the Design Portal.

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 a list of products from brainCloud
  • Client app requests the localized pricing details for the products from the AppStore
  • Client app displays the products with prices to the user
  • User chooses to purchase a product
  • Client app invokes the purchase API from the AppStore. AppStore performs the purchase, and sends back a receipt to the client
  • Client sends the receipt to brainCloud for validation. brainCloud performs a back-channel verification of the receipt with the AppStore – and if all is good, makes any required changes to virtual currency balances

The follow call requests the list of products for sale:

  • [GetSalesInventory](/api/capi/product/getsalesinventory)
  • [GetSalesInventoryByCategory](/api/capi/product/getsalesinventorybycategory)

These methods are used to confirm store receipts:

These methods are for performing Steam purchases:

  • [StartSteamTransaction](/api/capi/product/startsteamtransaction)
  • [FinalizeSteamTransaction](/api/capi/product/finalizesteamtransaction)

Promotions

In addition to the above purchase flow, 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 APIs are:

  • [GetEligiblePromotions](/api/capi/product/geteligiblepromotions)

📄️ AwardCurrency

WARNING: This call, AwardCurrency(), is included in the client libraries for convenience and backwards compatibility, but for app security reasons we recommend it only be called server-side via Cloud Code. By default the servers will block any client-side invocations of currency altering methods. To enable client-side support (not recommended), you need to enable the [x] Allow Currency Calls from Client compatibility setting on the Design | Core App Info | Advanced Settings page of the portal.