Payment practical guide
To implement a single payment feature in your app, you must combine Hive Console settings, Hive Axyl SDK calls, store plugin calls, Hive Axyl Server API calls, and recipe code calls. First select the feature to implement, and then follow its procedure in order.
Implementation scope
The work required to implement a single payment feature starts with getting credentials from the store console and ends with delivering the product to the user and recording the result.
The work in each step falls into one of the following eight categories.
| Category | Owner | Description |
|---|---|---|
| Store console | App operator | Settings you configure in the Google Play Console, App Store Connect, Steamworks, or the PG provider's console. |
| Hive Console | App operator | Settings you configure in the Hive Console. |
| Hive Axyl SDK | App developer | Hive Axyl SDK methods the app calls. |
| Store plugin | App developer | Store payment plugin methods the app calls. |
| Recipe code | App developer | Recipe methods the app calls. |
| App code | App developer | Parts the app implements directly without going through Hive Axyl. |
| Hive Axyl Server API | App server developer | Hive Axyl Server APIs the app server calls. |
| App server | App server developer | Parts the app server handles with its own logic. |
Some steps involve more than one category.
For the meaning of parameters and response fields, see the detailed procedure linked in each step.
Recipe
The Hive Axyl SDK provides payment features as fine-grained methods. There are separate methods to record a purchase, confirm a payment, and finish a transaction. The app server handles receipt verification with the Hive Axyl Server API. Even to sell a single product, the app must combine the call order, the branching for each market, and the handling of intermediate failures itself.
A recipe is source code that completes that combination in advance. Instead of installing it as a package, you copy it into your project. The recipe does not request receipt verification, and it finishes the transaction only after the app server responds that it has verified the receipt and delivered the product.
| Category | Location | Characteristics |
|---|---|---|
| Hive Axyl SDK | Unity packages com.com2usplatform.hiveaxyl.* | You install and use it. It provides payment features as fine-grained methods. |
| Recipe | Assets/Recipes/ | You copy and use it. It is plain C# code that groups SDK calls by purpose. |
| Usage example | Assets/RecipeExamples/Payments/ | Code to read for reference. Along with the call order of the payment recipes, it shows the parts the app implements, such as saving purchase information and verification and delivery on the app server, through the IPurchaseApplication interface. This interface is defined by the usage example; it is not a type of the SDK or the recipes. |
Recipes are code you copy and use
Recipes are copied into your app and become your app's code. You can use them as is or modify them to fit your app's policies.
Select a feature to implement
Recipes are available for three features: consumable product payment, subscription payment, and restoration of undelivered purchases.
Consumable product payment
The basic payment in which the app delivers a product after the user purchases it. Select the market where you sell.
| Implementation procedure | Market | Where the user pays |
|---|---|---|
| Implement Google Play payments | Google Play | Play payment window |
| Implement Apple App Store payments | Apple App Store | StoreKit payment window |
| Implement Steam payments | Steam | Steam overlay |
| Implement PG payments | PG | Payment page in an external browser |
Subscription payment
A payment that renews automatically every cycle after the user starts a subscription. The subscription recipes support only Google Play and Apple App Store; none exist for Steam or PG.
Restore undelivered purchases
A feature that finds consumable product purchases whose payment the user completed but whose product delivery did not finish, and completes the remaining product delivery and transaction finishing. For restored purchases as well, the app server verifies the receipt again before delivering the product. You need it when delivery was interrupted because the app terminated midway or the network disconnected. Subscription payments are not handled by this restoration.
Where the list of undelivered purchases comes from differs by market.
- Restore undelivered Google Play purchases: the Play Billing Library on the device
- Restore undelivered Apple App Store purchases: StoreKit on the device
- Restore undelivered Steam purchases: the Hive Axyl server
- Restore undelivered PG purchases: the Hive Axyl server
Features without recipes
You implement the following features without recipes by calling the Hive Axyl SDK or the Hive Axyl Server API directly. Check how to implement them in the payment implementation procedure for the market where you sell.
- Get the product list
- Record product delivery results
- Get the purchase history
Common prerequisites
Whichever market you choose, you must prepare the following items first.
| Item to prepare | Required | Category | Where to check |
|---|---|---|---|
| Create a project and an App ID | Required | Hive Console | Create an App ID |
| Activate the login session | Required | Hive Axyl SDK | Log in |
| Prepare the app server to call the Hive Axyl Server API | Required | Hive Console, Hive Axyl Server API | Before calling |
| Register the app server | Optional | Hive Console | App server |
What to check for each item is as follows.
- Activate the login session: The session of the logged-in user who is the payer. Without a session, payment-related server calls are rejected with an authentication error, so check that the session is valid before you open the in-app store screen
- Prepare the app server to call the Hive Axyl Server API: Preparation for the app server to verify receipts with the Hive Axyl Server API
- Register the app server: An optional setting separate from the preparation for calling the Hive Axyl Server API. Register only when you run multiple app servers and need to tell which server a purchase came from
Next steps
Implement the payment products you want in the market where you sell. To start with Google Play payments, see Implement Google Play payments.