iOS PayVault Provider
Setting up your iTunes Connect account
- Log on to iTunes Connect at https://itunesconnect.apple.com with your Apple Id.
- Make sure you have accepted all contracts for Paid Applications, and have your Contact Info, Bank Info and Tax Info submitted and approved. You can view this under Agreements, Tax, and Banking when logged on to iTunes Connect.
- Setup a new app or pick an existing one. Make sure the Bundle ID you use has In-App Purchase enabled in the provisioning portal.
- When viewing your app, click the Features tab to get to the In-App Purchases interface.
- For each amount of coins you wish to sell, you need to create a corresponding In-App Purchase item:
- Click the plus sign and create a Consumable item.
- The Product ID must end in .coins + amount. Since they must also be globally unique within the iTunes store, we recommend that you prefix each item with your Bundle ID, so for example com.example.mygame.coins500 would be an item that awards the user 500 coins.
- Select a Price Tier to set a sales price for your coins.
- Add a Display Name and a Description for your app's primary localization language. The Display Name will appear in in the purchase interface which asks the user:
"Do you want to buy one [Display Name] for [Price]?"
Make sure it fits that sentence, for example by setting it to Chest of 500 Coins or similar.
- For each PayVault item you wish to sell, you need to create a corresponding In-App Purchase item:
- Click the plus sign and create a Consumable item.
- The Product ID must end in .item + itemkey. Since they must also be globally unique within the iTunes store, we recommend that you prefix each item with your Bundle ID, so for example com.example.mygame.itemsupercar would be an item that awards the user the PayVault item with the itemkey supercar.
- Select a Price Tier to set a sales price for your coins.
- Add a Display Name and a Description for your app's primary localization language. The Display Name will appear in in the purchase interface which asks the user:
"Do you want to buy one [Display Name] for [Price]?"
Make sure it fits that sentence, for example by setting it to Super Car or similar.
- For testing, we recommend that you create one or more Sandbox Testers, which you can do under Users and Roles when logged on to iTunes Connect.
Configuring PayVault on PlayerIO
- Enable iOS in the PayVault Control Panel for your game.
- Enter your app's Bundle Id that you've setup in iTunes Connect.
Buying Coins and Items: UseBuyInfo()
Unlike the other PayVault providers, buying coins and items through iOS 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 an iOS 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 iOS app, there are different ways of handling in-app purchases:
- If you are building a native iOS app, you should use StoreKit directly, and you can find help in the In-App Purchase Programming Guide.
- If you are building an iOS app with Unity, you can use the Unity IAP service
- If you are building an iOS 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:
- You must retrieve product information for the product(s) that you want to offer the user to buy, before you can request payment for that product.
- 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.
- Finish the transaction, which will remove the consumable items from the receipt. Failure to do this will result in the user being awarded a single consumable item multiple times.
Example of buying coins with iOS in AS3:
Required UseBuyInfo() Arguments | |
---|---|
transactionReceipt | The transactionReceipt received in the eventlistener. |
Result Values | |
success | Should be "true" if the transaction was successfully completed. You can refresh the vault and access the updated contents at this point. |
productid | The productid of the receipt that was sent in, that now needs to be removed from the purchase queue. |
Optional Result Values | |
coins | The amount of coins purchased, if any. |
quantity | The number of items purchased, if any. |
item | The itemkey of the item purchased, if any. |