Skip to main content
Version: 1.49.x

Billing

Configure

To set up Google Play Billing dit the AndroidManifest.xml and add required permissions:

<uses-permission android:name="com.android.vending.BILLING" />

Add permissions to <application> section too:

<meta-data android:name="com.platform101xp.sdk.billing.enabled"
android:value="@bool/billing_enabled"/>
<meta-data android:name="com.platform101xp.sdk.billing.sku"
android:value="@string/billing_sku"/>
<meta-data android:name="com.platform101xp.sdk.billing.public_key"
android:value="@string/billing_public_key"/>
<meta-data android:name="com.platform101xp.sdk.billing.reconnect_enabled"
android:value="@bool/billing_reconnect_enabled"/>
<meta-data android:name="com.platform101xp.sdk.billing.reconnect_count"
android:value="@integer/billing_reconnect_count"/>
<meta-data android:name="com.platform101xp.sdk.billing.reconnect_time"
android:value="@integer/billing_reconnect_time"/>
<meta-data android:name="com.platform101xp.sdk.billing.xsolla_enabled"
android:value="@bool/billing_xsolla_enabled" />
<meta-data android:name="com.platform101xp.sdk.billing.yookassa_enabled"
android:value="@bool/billing_yookassa_enabled" />
<meta-data android:name="com.platform101xp.sdk.billing.yookassa_client_id"
android:value="@string/billing_yookassa_client_id" />
<meta-data android:name="com.platform101xp.sdk.billing.yookassa_show_log"
android:value="@bool/billing_yookassa_show_log" />
<meta-data android:name="com.platform101xp.sdk.billing.robokassa_enabled"
android:value="@bool/billing_robokassa_enabled" />

For Robokassa in manifest add in application level

<activity
android:name="com.platform101xp.sdk.internal.billing.robokassa.RobokassaBillingActivity"
android:exported="true" />

For Yookassa in manifest in YourMainActivity inside <intent-filter> need add <data android:scheme="mobilesdkxp"/>

<activity
android:name="YourMainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

...
...
<data android:scheme="mobilesdkxp"/>
</intent-filter>
</activity>

And add in your build.gradle(application level)

android {
...
defaultConfig {
...
resValue "string", "ym_app_scheme", "mobilesdkxp"
}
}

@bool/billing_enabled - switching-on of the billing function

@string/billing_sku - list of ID's of products available in the game (from Google Play Developer Console) separation by ",". For example: "product1,product2,product3"

@string/billing_public_key - public key of the app from Google Play Developer Console.

@bool/billing_reconnect_enabled - switching-on of the billing recconect else internet disconnected or error connection

@integer/billing_reconnect_count - count try for recconect purchase complete

@integer/billing_reconnect_time - time between recconect try

@bool/billing_yookassa_enabled - switching enable/disable show of yokassa_sdk logs

@bool/billing_yookassa_client_id - authCenterClientId identifier received when registering the application on the site https://yookassa.ru, just ask your manager for this ID.

@bool/billing_yookassa_show_log - switching-on billing from yookassa (default: false)

@bool/billing_xsolla_enabled - switching-on billing from xsolla (default: false)

@bool/billing_robokassa_enabled - switching-on billing from robokassa (default: false)

Checking payment on 101XP Billing Server

Payments handler

Usage

Initialization

Use a method onBillingInitializeResult() in your listener object:

@Override
public void onBillingInitializeResult(Platform101XPError error) {
if (error == null) {
// Success initialization!
}
}

Restoring purchases

To restore purchases, use the restoreProducts() method:

Platform101XP.restoreProducts();

The result will be returned to onPurchaseProductResult() method in listener, as with a regular purchase.

Getting product information

You can get product by id (from AndroidManifest in com.platform101xp.sdk.billing.sku) with method getProductById:

Platform101XPProduct product = getProductById("com.101xp.product");

Make payment

To make payments, use the Platform101XP.purchaseProduct() method.

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

Map<String, String> properties = new HashMap<String, String>();
properties.put("first_purchase_property", your_purchase_property);

String serverId = your_server_id;
Platform101XP.purchaseProduct(product, serverId, properties);

The result of purchaseProduct() is sent to the method of listener.

void onPurchaseProductResult(Platform101XPPurchase purchase, Platform101XPError error);

Completion of payment

For consumable products, after successful purchase and processing, you need to call the finishPurchase() method.

void finishPurchase(Platform101XPPurchase purchase);

The result of finishPurchase() is sent to the method of listener.

void onFinishPurchaseResult(Platform101XPPurchase purchase, Platform101XPError error);
danger

Consumable products

Without calling finishPurchase() you'll get the following error on the second purchase:

Item already owned

Robokassa

In purchase from Google Play for User's from Russian and Belarus when product info return from store in currency (RUB or BYN) auto redirect to purchase items from Robokassa.

The result of purchaseProduct() is sent to the method of listener.

void onPurchaseProductInternalOrderResult(String productId, Platform101XPBillingConfig.InternalOrderStatus status, Platform101XPError error){
}

For enable/disable purchase from Robokassa use

<meta-data android:name="com.platform101xp.sdk.billing.robokassa_enabled"
android:value="@bool/billing_robokassa_enabled" />

[default:false] in manifest files. Or billing_robokassa_enabled flag in remote config.

Yookassa

In purchase from Google Play for User's from Russian and Belarus when product info return from store in currency (RUB or BYN) auto redirect to purchase items from Yookassa.

The result of purchaseProduct() is sent to the method of listener.

void onPurchaseProductInternalOrderResult(String productId, Platform101XPBillingConfig.InternalOrderStatus status, Platform101XPError error){
}

For enable/disable purchase from Yookassa use

<meta-data android:name="com.platform101xp.sdk.billing.yookassa_enabled"
android:value="@bool/billing_yookassa_enabled" />

[default:false] in manifest files. Or billing_yookassa_enabled flag in remote config.

Add in manifest billing_yookassa_client_id, ask your managert for this ID

<meta-data android:name="com.platform101xp.sdk.billing.yookassa_client_id"
android:value="@string/billing_yookassa_client_id" />

For enable/disable logs from Yookassa SDK use

<meta-data android:name="com.platform101xp.sdk.billing.yookassa_show_log"
android:value="@bool/billing_yookassa_show_log" />

[default:false] in manifest files. Or billing_yookassa_show_log flag in remote config.

Xsolla

In purchase from Google Play for User's from Russian and Belarus when product info return from store in currency (RUB or BYN) auto redirect to purchase items from Xsolla.

The result of purchaseProduct() is sent to the method of listener.

void onPurchaseProductInternalOrderResult(String productId, Platform101XPBillingConfig.InternalOrderStatus status, Platform101XPError error){
}

For enable/disable purchase from Xsolla use

<meta-data android:name="com.platform101xp.sdk.billing.xsolla_enabled"
android:value="@bool/billing_xsolla_enabled" />

[default:false] in manifest files. Or billing_xsolla_enabled flag in remote config.

InternalOrderStatus

Platform101XPBillingConfig.InternalOrderStatus enum state description

valuedescription
PLACEDinitial status of the created purchase transaction
ERRORerror, if something went wrong, look $error(Platform101XPError)
PAYEDsuccessfully purchased
CANCELtransaction refund
CALLBACK_ERRORit was not possible to send the result to the game, but the purchase was paid
USER_CANCELThe user closed the purchase window or canceled it