Skip to main content

Billing

Configure

Configuration by using the Settings Inspector.

iOS

To use App Store Billing in the SDK, you need to add products. Add products id to array in the settings inspector (ask your release manager for those parameters):

  • Billing SKU - list of ID's of products available in the game

Android

To set up Google Play Billing in the SDK, you need to configure the following setting in the settings inspector (ask your release manager for those parameters):

  • Billing Enabled - turn on/of the billing function
  • Billing SKU - list of ID's of products available in the game
  • Billing Public Key - public key of the app from Google Play Developer Console

Usage

Get Products Info

To get products list use:

List<Product> currentProducts = P101XP.GetInstance().GetAllProducts();

To get product information use:

Product product = P101XP.GetInstance().GetProduct("some_product");

Purchase

To make purchase use:

P101XP.GetInstance().PurchaseProduct(productId, serverId, purchaseProperty);

Parameters serverId and properties are sent to 101XP Billing Server and to the game server.

The result of the method PurchaseProduct is passed to purchase event handler.

Finish Purchase

For consumable products one needs to finish purchase:

private void PurchaseProductHandler(PurchaseResult purchaseResult)
{
P101XP.GetInstance().FinishPurchase(purchaseResult);
}

The result of the method FinishPurchase is passed to finish purchase event handler.

Restore products

To restore purchased products, use the RestoreProducts() method:

P101XP.GetInstance().RestoreProducts();

The result of the method RestoreProducts is passed to restore products event handler.

Purchase Event

To get the purchase result, please, subscribe on:

private void PurchaseProductHandler(PurchaseResult purchaseResult)
{
}

P101XP.GetInstance().PurchaseResultEvent += PurchaseProductHandler;

Finish Purchase Event

To get the finish purchase result, please, subscribe on:

private void FinishPurchaseHandler(PurchaseResult purchaseResult)
{
}

P101XP.GetInstance().FinishPurchaseResultEvent += FinishPurchaseHandler;

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.