Appearance
Appearance
When testing your game's in-app purchases before releasing it into production, you'll typically perform sandbox purchases instead of actual real-money purchases. The Metaplay SDK supports sandbox purchases and tracks whether a purchase was a sandbox or normal purchase. This document describes how you can configure the server to enable the full functionality.
After the game server has validated a purchase, InAppPurchaseEvent.PaymentType
will be set to indicate whether it was a sandbox or normal purchase. Generally, you should treat sandbox purchases the same as normal purchases (since they're used for testing), but you may wish to omit sandbox purchases from revenue analytics, for example. You can detect a sandbox purchase by checking if purchaseEvent.PaymentType == InAppPurchasePaymentType.Sandbox
.
Note that PaymentType
can be null
if the server was unable to determine whether it was a sandbox purchase; in that case, it is likely appropriate to assume it was a normal purchase (since most production purchases tend to be).
How the server detects sandbox purchases for each store platform is described below. For certain store platforms, configuration is needed to enable the detection.
For Google Play, sandbox purchases are detected by making a request to Google's Android Publisher API. In order to enable this, you need to create and configure a service account for the server to access the API. Unless you've already done this, please follow the instructions in section Google Play of the Auto-Renewing Subscriptions guide. You can ignore the rest of the subscriptions documentation, however.
For App Store, you do not need to configure anything to enable the detection of sandbox purchases. Purchases are validated by sending a request to Apple's server. Production and sandbox purchases use different validation endpoints. The game server's detection of sandbox purchases is simply based on which endpoint was used to successfully validate the purchase.