Billing
Configure
Configuration is done via the Settings Inspector in Unity.
Configuration is applied automatically at build time for each platform.
Platform markers
The following markers are used to indicate platform availability of parameters and features:
- (no marker) — Shared parameter or feature
- 🍏 — iOS-specific parameter or feature
- 🤖 — Android-specific parameter or feature
- ⚠️ — Not implemented in the Unity plugin yet
Ask your release manager for the required parameters before configuring the SDK.
Core Billing Settings
| Field | Description |
|---|---|
| Billing Enabled 🤖 | Turns billing functionality on/off |
| Billing SKU | List of product IDs available in the game |
| Billing Public Key 🤖 | Public key of the app from Google Play Developer Console |
Billing SKU values must exactly match the product identifiers configured in the store.
Billing Reconnect 🤖⚠️
| Field | Description |
|---|---|
| Billing Reconnect Enabled 🤖 | Enables reconnect attempts if billing connection fails |
| Billing Reconnect Count 🤖 | Number of reconnect attempts |
| Billing Reconnect Time 🤖 | Time between reconnect attempts |
Alternative Payment Providers
These options enable/disable alternative payment flows (when applicable).
| Field | Description |
|---|---|
| Xsolla Billing Enabled 🍏⚠️ | Enables Xsolla purchase flow |
| Xsolla Billing Enabled 🤖⚠️ | Enables Xsolla purchase flow |
| Robokassa Billing Enabled 🤖 | Enables Robokassa purchase flow |
| YooKassa Billing Enabled 🤖⚠️ | Enables YooKassa purchase flow |
| YooKassa Client ID 🤖⚠️ | YooKassa Client ID |
| YooKassa Show Log 🤖⚠️ | Enables/disables YooKassa SDK logs |
Usage
Get Products Info
To get the full products list:
List<Product> currentProducts = P101XP.GetInstance().GetAllProducts();
To get a single product by ID:
Product product = P101XP.GetInstance().GetProduct("some_product");
Purchase
To make a purchase:
P101XP.GetInstance().PurchaseProduct(productId, serverId, purchaseProperty);
Parameters serverId and purchaseProperty are sent to the 101XP Billing Server and to the game server.
The result of PurchaseProduct is delivered via the Purchase Event or (for alternative payment providers) via the Internal Order Event.
PurchaseProduct Signature
void PurchaseProduct(string productId, string serverId, Dictionary<string, string> properties);
Finish Purchase
For consumable products, you must finish the purchase after a successful purchase result:
private void PurchaseProductHandler(PurchaseResult purchaseResult)
{
if (purchaseResult.error == null)
{
P101XP.GetInstance().FinishPurchase(purchaseResult);
}
}
The result of FinishPurchase is delivered via the Finish Purchase Event.
Restore Products
To restore previously purchased products:
P101XP.GetInstance().RestoreProducts();
The result of RestoreProducts is delivered via the Purchase Event.
Purchase Event
Subscribe to receive purchase and restore results:
private void PurchaseProductHandler(PurchaseResult purchaseResult)
{
// Handle result
}
P101XP.GetInstance().PurchaseResultEvent += PurchaseProductHandler;
Finish Purchase Event
Subscribe to receive finish purchase results:
private void FinishPurchaseHandler(PurchaseResult purchaseResult)
{
// Handle result
}
P101XP.GetInstance().FinishPurchaseEvent += FinishPurchaseHandler;
Internal Order Event
When an alternative payment provider flow is used (Xsolla / Robokassa / YooKassa), the SDK returns an internal order result.
Subscribe to receive internal order results:
private void PurchaseInternalOrderHandler(PurchaseProductInternalOrderResult purchaseResult)
{
// Handle result
}
P101XP.GetInstance().OnPurchaseProductInternalOrder += PurchaseInternalOrderHandler;
Product
The Product class contains store product metadata.
public class Product
{
public string productId;
public string productType;
public string price;
public string priceValue;
public string currencyCode;
public string title;
public string description;
}
Fields
| Name | Type | Description |
|---|---|---|
| productId | string | Store product identifier |
| productType | string | Product type (for example: consumable / non-consumable / subscription) |
| price | string | Localized formatted price string (for example: $0.99) |
| priceValue | string | Numeric price value (string form) |
| currencyCode | string | ISO currency code (for example: USD, JPY) |
| title | string | Localized product title |
| description | string | Localized product description |
PurchaseResult
The PurchaseResult class contains information returned after a purchase attempt.
public class PurchaseResult
{
public string orderId;
public string packageName;
public string productId;
public string token;
public int transactionId;
public string signature;
public string originalJson;
public string error;
}
Fields
| Name | Type | Description |
|---|---|---|
| orderId | string | Unique purchase order identifier |
| packageName | string | Application package name |
| productId | string | Identifier of the purchased product |
| token | string | Purchase token returned by the store |
| transactionId | int | Internal transaction identifier |
| signature | string | Signature of the purchase (used for validation) |
| originalJson | string | Original purchase data in JSON format (as provided by the store) |
| error | string | Error message if the purchase failed. null means no error |
PurchaseProductInternalOrderResult
The PurchaseProductInternalOrderResultStatus class contains information returned after a purchase attempt in internal shop.
public enum PurchaseProductInternalOrderResultStatus
{
Completed,
Canceled,
Unknown
}
public class PurchaseProductInternalOrderResult
{
public string productId;
public PurchaseProductInternalOrderResultStatus status;
public string error;
}