Skip to main content

Billing

Configure

Configuration by using the Unity 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;

Purchase Result

var namedescription
order_idstring variable, purchase order id value
package_namestring variable, package name value
product_idstring variable, product id value
tokenstring variable, purchase token value
transaction_idint variable, transaction id value
signaturestring variable, purchase signature
originalJsonstring variable, purchase original json string
error_messagestring variable, error message of purchase if the string is not null