Google Play PayVault Provider
Setting up your app in the Google Play Developer console
- Log on to the Google Play Developer Console at https://play.google.com/apps/publish with your Google Account.
- Setup a new app or pick an existing one.
- When viewing your app, click on In-app Products. Make sure you have uploaded an APK with the BILLING permission, and that you have setup a Google Checkout merchant account. If you haven't, the In-app products page will remind you to do that.
- For each amount of coins you wish to sell, you need to create a corresponding product:
- Create a Managed Product.
- The Product ID must be coins + amount, so for example coins500 would be a product that awards the user 500 coins.
- Give the product a title, description, and default price.
- Add additional translations and local prices as needed.
- For each item you wish to sell, you need to create a corresponding purchase item:
- Create an Unmanaged Product.
- The Product ID must be item + itemkey, so for example itemsupercar would be a product that awards the user the PayVaultItem 'supercar'.
- Give the product a title, description, and default price.
- Add additional translations and local prices as needed.
- For testing, we recommend that your create one or more test users, which you can do by following the instruction on this page: https://developer.android.com/google/play/billing/billing_admin.html#billing-testing-setup
Configuring PayVault on PlayerIO
- Enable Google Play in the PayVault Control Panel for your game.
- Enter your app's base64-encoded RSA public key. You can find this on the Services & APIs tab when editing your app in the Google Play Developer Console.
Buying Coins and Items: UseBuyInfo()
Unlike the other PayVault providers, buying coins and items through Google Play doesn't require you to first call the GetBuyCoinsInfo() or GetBuyItemsInfo() methods, and you also can't specify a payload when purchasing items.
Instead, you trigger a Google Play In-app Purchase, and send the resulting receipt of that through the UseBuyInfo() method, which will then verify and update the user's vault.
Depending on how you are building your Android app, there are different ways of handling in-app purchases:
- If you are building a native Android app, integrate the Billing Service directly, using the instructions in the Google Play In-App Billing documentation.
- If you are building an Android app with Unity, you can use the Unity IAP service
- If you are building an Android app with Adobe AIR, you can use an Air Native Extension like FreshPlanet's In App Purchases ANE.
Regardless of method, here's the general sequence of events you need to follow:
- After requesting a payment, and it was succesful, you must retrieve the transaction receipt, which will now contain the consumable product the user purchased.
- Pass this receipt into the PayVault method to add the purchased coins or items to the user's Vault.
- Consume the in-app product from Google Play, otherwise the item will not be available for purchase again.
Example of buying coins with Google Play in Android:
Required UseBuyInfo() Arguments | |
---|---|
inapp_signed_data | The signed data received in the eventlistener. |
inapp_signature | The signature received in the eventlistener. |
Result Values | |
success | Should be "true" if all orders were successfully completed. A value of "false" means that some or all orders had issues. |
Repeating Result Values | |
<orderid> | The status of each order in the signed data. Contains the Product ID if everything went ok, otherwise a short error message. |