Skip to main content
Version: 1.6.0

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​

FieldDescription
Billing Enabled 🤖Turns billing functionality on/off
Billing SKUList 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 🤖⚠️​

FieldDescription
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).

FieldDescription
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​

NameTypeDescription
productIdstringStore product identifier
productTypestringProduct type (for example: consumable / non-consumable / subscription)
pricestringLocalized formatted price string (for example: $0.99)
priceValuestringNumeric price value (string form)
currencyCodestringISO currency code (for example: USD, JPY)
titlestringLocalized product title
descriptionstringLocalized 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​

NameTypeDescription
orderIdstringUnique purchase order identifier
packageNamestringApplication package name
productIdstringIdentifier of the purchased product
tokenstringPurchase token returned by the store
transactionIdintInternal transaction identifier
signaturestringSignature of the purchase (used for validation)
originalJsonstringOriginal purchase data in JSON format (as provided by the store)
errorstringError 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;
}