In-App Payment SDK for Godot (version 9.0.1)
With RuStore you can integrate payments in your mobile app.
-
If you don't know where to start read the instruction.
-
If you migrate to Pay SDK from billingClient SDK, see the migration instructions. For more details, see here.
Getting Started
- Copy the plugin and the sample app projects from the official RuStore repository on GitFlic.
- Copy the contents of
godot_example/android/pluginstoyour_project/android/plugins. - In the Plug-ins list of the Android build preset select Ru Store Godot Pay and Ru Store Godot Core.
Deeplink Handling
A deeplink in the RuStore Payments SDK is required for proper interaction with third-party payment applications. It helps users complete purchases faster in an external app and return to your application.
To set up deeplink support in your application and the RuStore SDK, specify the deeplinkScheme inside your AndroidManifest file and override the onNewIntent method of your Activity. Additionally, for the SDK to work, you need to specify sdk_pay_scheme_value in your Manifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.godot.game"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto" >
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true" />
<uses-feature
android:glEsVersion="0x00030000"
android:required="true" />
<application
android:label="@string/godot_project_name_string"
tools:replace="android:label"
android:allowBackup="false"
android:icon="@mipmap/icon"
android:appCategory="game"
android:isGame="true"
android:hasFragileUserData="false"
android:requestLegacyExternalStorage="false"
tools:ignore="GoogleAppIndexingWarning" >
<meta-data
android:name="org.godotengine.editor.version"
android:value="${godotEditorVersion}" />
<meta-data
android:name="console_app_id_value"
android:value="@string/rustore_PayClientSettings_consoleApplicationId" />
<meta-data
android:name="internal_config_key"
android:value="@string/rustore_PayClientSettings_internalConfigKey" />
<!-- Deeplink scheme -->
<meta-data
android:name="sdk_pay_scheme_value"
android:value="@string/rustore_PayClientSettings_deeplinkScheme" />
<!-- Your activity -->
<activity
android:name=".GodotApp"
android:label="@string/godot_project_name_string"
android:theme="@style/GodotAppSplashTheme"
android:launchMode="singleInstancePerTask"
android:excludeFromRecents="false"
android:exported="true"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
android:resizeableActivity="false"
tools:ignore="UnusedAttribute" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity-alias
android:enabled="true"
android:exported="true"
android:name=".RuStoreDeeplink"
android:targetActivity=".GodotApp" >
<!-- Deeplink scheme -->
<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="@string/rustore_PayClientSettings_deeplinkScheme" />
</intent-filter>
</activity-alias>
</application>
</manifest>
The values for sdk_pay_scheme_value and data android:scheme should be placed in a resource file, for example: your_project/android/build/res/values/rustore_values.xml.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="rustore_PayClientSettings_consoleApplicationId" translatable="false">198332</string>
<string name="rustore_PayClientSettings_internalConfigKey" translatable="false">godot</string>
<!-- Deeplink scheme -->
<string name="rustore_PayClientSettings_deeplinkScheme" translatable="false">yourappscheme</string>
</resources>
package com.godot.game;
import android.app.Application;
import android.content.Intent;
import android.os.Bundle;
import org.godotengine.godot.GodotActivity;
import ru.rustore.sdk.pay.IntentInteractor;
import ru.rustore.sdk.pay.RuStorePayClient;
public class GodotApp extends GodotActivity {
private IntentInteractor intentInteractor = RuStorePayClient.Companion.getInstance().getIntentInteractor();
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.GodotAppMainTheme);
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
intentInteractor.proceedIntent(getIntent());
}
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
intentInteractor.proceedIntent(intent);
}
}
SDK Initialization
Initialize the library before calling its methods. The initialization itself is done automatically, however, for your SDK to work, in your Manifest.xml file define console_app_id_value and internal_config_key.
<!-- Initializing sdk -->
<meta-data
android:name="console_app_id_value"
android:value="@string/rustore_PayClientSettings_consoleApplicationId" />
<meta-data
android:name="internal_config_key"
android:value="@string/rustore_PayClientSettings_internalConfigKey" />
Both values must be placed inside the <application> tag. Also, add the attribute tools:replace="android:label" to the <application> tag.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.godot.game"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto" >
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true" />
<uses-feature
android:glEsVersion="0x00030000"
android:required="true" />
<application
android:label="@string/godot_project_name_string"
<!-- Additional attribute -->
tools:replace="android:label"
android:allowBackup="false"
android:icon="@mipmap/icon"
android:appCategory="game"
android:isGame="true"
android:hasFragileUserData="false"
android:requestLegacyExternalStorage="false"
tools:ignore="GoogleAppIndexingWarning" >
<meta-data
android:name="org.godotengine.editor.version"
android:value="${godotEditorVersion}" />
<activity
android:name=".GodotApp"
android:label="@string/godot_project_name_string"
android:theme="@style/GodotAppSplashTheme"
android:launchMode="singleInstancePerTask"
android:excludeFromRecents="false"
android:exported="true"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
android:resizeableActivity="false"
tools:ignore="UnusedAttribute" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Initializing sdk -->
<meta-data
android:name="console_app_id_value"
android:value="@string/rustore_PayClientSettings_consoleApplicationId" />
<meta-data
android:name="internal_config_key"
android:value="@string/rustore_PayClientSettings_internalConfigKey" />
</application>
</manifest>
console_app_id_value — product ID form the RuStore Console.
Where are app IDs in the RuStore Console?
- Navigate to the Applications tab and selected the needed app.
- Copy the ID from the URL address of the app page — it is a set of numbers between
apps/and/versions. FOr example, for URL addresshttps://console.rustore.ru/apps/123456/versionsthe app ID is123456.

- The
ApplicationIdspecified inbuild.gradlemust match theapplicationIdof the APK file you published in the RuStore Console. -
The
keystoresignature must match the signature that was used to sign the app published in the RuStore Console. Make sure thatbuildTypeused (example:debug) uses the same signature as the published app (example:release).
debug) of the app must match the signature of the app build that was uploaded to the console and passed moderation (for example, release)For security purposes, the SDK sets android:usesCleartextTraffic="false" by default to prevent data transmission over unsecured HTTP and protect against "Man-in-the-Middle" attacks. If your application requires the use of HTTP, you can change this attribute to true, but do so at your own risk, as it increases the chance of data interception and tampering. We recommend allowing unsecured traffic only in exceptional cases and for trusted domains, preferring HTTPS for all network interactions.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Initializing sdk -->
<string name="rustore_PayClientSettings_consoleApplicationId" translatable="false">198332</string>
<string name="rustore_PayClientSettings_internalConfigKey" translatable="false">godot</string>
</resources>
SDK Methods
Create a RuStoreGodotPayClient instance before using the plugin methods.
var _pay_client: RuStoreGodotPayClient = RuStoreGodotPayClient.get_instance()
Retrieving Product List
You checked that payments are available and the users are able to make purchases. Now you can request products list. Use the get_products method to request the information about products added to your app in RuStore Console.
You must subscribe to events once before using this method:
on_get_products_success;on_get_products_failure.
func _ready():
# _pay_client initialization
_pay_client.on_get_products_success.connect(_on_get_products_success)
_pay_client.on_get_products_failure.connect(_on_get_products_failure)
func _on_get_products_success(products: Array[RuStorePayProduct]):
pass
func _on_get_products_failure(error: RuStoreError):
pass
var PRODUCT_IDS: Array[RuStorePayProductId] = [
RuStorePayProductId.new("con_1"),
RuStorePayProductId.new("non_con_1"),
]
_pay_client.get_products(PRODUCT_IDS)
product_ids — the list of product IDs that are set when products are created in the RuStore Console. The list is limited by 1000 items.
Where are product IDs in the RuStore Console?
- Navigate to the Applications tab and selected the needed app.
- Select Monetization in the left menu.
- Select product type: Subscriptions or In-App purchases.
- Copy the IDs of the required products.

The method returns products list. Below is the product pattern.
class_name RuStorePayProduct extends Object
var productId: RuStorePayProductId = null
var type: ERuStorePayProductType.Item = 0
var amountLabel: RuStorePayAmountLabel = null
var price: RuStorePayPrice = null
var currency: RuStorePayCurrency = null
var imageUrl: RuStorePayUrl = null
var title: RuStorePayTitle = null
var description: RuStorePayDescription = null
productId— product ID assigned to product in RuStore Console (mandatory).type— product type:CONSUMABLE/NON-CONSUMABE.-
amountLabel— formatted purchase price, including currency symbol price— price in minimum currency units.currency— ISO 4217 currency code.title— product name inlanguage.description— descriptions inlanguage.imageUrl— image URL.
Product Purchase
- When using single-stage payment, the purchase does not require confirmation; the funds are immediately debited from the buyer’s account, and a commission is charged to the developer. In this case, if a refund to the customer is required (for example, if the product cannot be delivered for some reason), a refund can only be processed via the RuStore Console, and the funds will be returned to the buyer within a few days. The full purchase amount is refunded, but the commission previously withheld from the developer is not reimbursed.
- In the case of two-stage payment, the funds are first held (authorized) on the buyer’s account. No commission is charged at this stage. After the hold, the purchase requires either confirmation or cancellation. The commission is charged to the developer upon purchase confirmation. Cancelling the purchase releases the hold, and the funds instantly become available to the buyer again.
Two-stage payment is available only for a specific set of payment methods (currently — only for cards). SBP technologies do not support two-stage payment. If a payment method that does not support holding is selected, the purchase will be processed using the single-stage scenario.
Payment with Purchase Type Selection
To initiate a product purchase with the option to select the payment stage, use the purchase method.
Before using the method, you need to subscribe to the events once:
on_purchase_success;on_purchase_failure.
func _ready():
# Initialization of _pay_client
_pay_client.on_purchase_success(_on_purchase_success)
_pay_client.on_purchase_failure(_on_purchase_failure)
func _on_purchase_success(result: RuStorePayProductPurchaseResult):
pass
func _on_purchase_failure(product_id: RuStorePayProductId, error: RuStoreError):
pass
var parameters = RuStorePayProductPurchaseParams.new(
RuStoreProductId.new("product_id"), # productId
null, # appUserEmail
null, # appUserId
null, # developerPayload
null, # orderId
RuStoreQuantity.new(1)); # quantity
var preferredPurchaseType = ERuStorePayPreferredPurchaseType.Item.ONE_STEP
_pay_client.purchase(parameters, preferredPurchaseType)
productId— product ID assigned to product in RuStore Console (mandatory).quantity— product amount (optional, value1will be used if not specified).orderId— payment ID generated by the app (optional). If you specify this parameter in your system, you will receive it via our API. If not specified, will be generated automatically (uuid). 150 characters max.developerPayload— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization. Maximum length is 250 characters.-
appUserId— the internal user ID in your application (optional parameter). A string with a maximum length of 128 characters.tipFor example, this parameter can be used to detect cases of fraud in your application, which will help improve its security.
appUserEmail— this is an optional parameter that allows you to specify the user's email address in your application. If the buyer's email address was provided during registration in the app, it can be passed for automatic filling of theemailfield when sending a receipt — both for payments outside RuStore and in cases where the user is not authorized in RuStore. This saves the user from having to manually enter their email, shortens the purchase flow, and helps increase conversion.preferredPurchaseType— the desired purchase type: single-stage (ONE_STEP) or two-stage (TWO_STEP).
This method is launched by default using the single-stage payment scenario (preferredPurchaseType = ERuStorePayPreferredPurchaseType.Item.ONE_STEP), i.e., without funds being held.
For two-stage payment, you need to specify preferredPurchaseType = ERuStorePayPreferredPurchaseType.Item.TWO_STEP. Two-stage payment (i.e., payment with funds being held) is not guaranteed for this method and directly depends on the payment method (card, SPB, etc.) selected by the user.
When launching this method (with the preferred preferredPurchaseType = twoStep), until the user selects a payment method, the purchase stage will be UNDEFINED. Please take this behavior into account when handling purchase cancellation results (ProductPurchaseCancelled) or purchase errors (ProductPurchaseException).
Two-stage payment (with funds holding)
When calling this method, the user will only have access to payment methods that support two-stage payment.
purchase_two_step method.
Before using the method, you need to subscribe to the events once:
on_purchase_two_step_success;on_purchase_two_step_failure.
func _ready():
# Initialization of _pay_client
_pay_client.on_purchase_two_step_success(_on_purchase_two_step_success)
_pay_client.on_purchase_two_step_failure(_on_purchase_two_step_failure)
func _on_purchase_two_step_success(result: RuStorePayProductPurchaseResult):
pass
func _on_purchase_two_step_failure(product_id: RuStorePayProductId, error: RuStoreError):
pass
var parameters = RuStorePayProductPurchaseParams.new (
RuStoreProductId.new("product_id"), # productId
null, # appUserEmail
null, # appUserId
null, # developerPayload
null, # orderId
RuStoreQuantity.new(1)); # quantity
);
_pay_client.purchase_two_step(parameters)
Purchase Parameters Structure
class_name RuStorePayProductPurchaseParams extends Object
var productId: RuStorePayProductId = null
var appUserEmail: RuStorePayAppUserEmail = null
var appUserId: RuStorePayAppUserId = null
var developerPayload: RuStorePayDeveloperPayload = null
var orderId: RuStorePayOrderId = null
var quantity: RuStorePayQuantity = null
func _init(
productId: RuStorePayProductId,
appUserEmail: RuStorePayAppUserEmail = null,
appUserId: RuStorePayAppUserId = null,
developerPayload: RuStorePayDeveloperPayload = null,
orderId: RuStorePayOrderId = null,
quantity: RuStorePayQuantity = null
):
self.productId = productId
self.appUserEmail = appUserEmail
self.appUserId = appUserId
self.developerPayload = developerPayload
self.orderId = orderId
self.quantity = quantity
productId— product ID assigned to product in RuStore Console (mandatory).quantity— product amount (optional, value1will be used if not specified).orderId— payment ID generated by the app (optional). If you specify this parameter in your system, you will receive it via our API. If not specified, will be generated automatically (uuid). 150 characters max.developerPayload— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization. Maximum length is 250 characters.-
appUserId— the internal user ID in your application (optional parameter). A string with a maximum length of 128 characters.tipFor example, this parameter can be used to detect cases of fraud in your application, which will help improve its security.
appUserEmail— this is an optional parameter that allows you to specify the user's email address in your application. If the buyer's email address was provided during registration in the app, it can be passed for automatic filling of theemailfield when sending a receipt — both for payments outside RuStore and in cases where the user is not authorized in RuStore. This saves the user from having to manually enter their email, shortens the purchase flow, and helps increase conversion.
class_name RuStorePayProductPurchaseResult extends Object
var invoiceId: RuStorePayInvoiceId = null
var orderId: RuStorePayOrderId = null
var productId: RuStorePayProductId = null
var purchaseId: RuStorePayPurchaseId = null
var purchaseType: ERuStorePayPurchaseType.Item = 0
var quantity: RuStorePayQuantity = null
var sandbox: bool = false
invoiceId— invoice identifier. Used for server-side payment validation, searching payments in the developer console, and is also displayed to the user in the payment history in the RuStore mobile app.orderId— unique payment identifier specified by the developer or generated automatically (uuid).productId— identifier of the purchased product, specified when created in the RuStore developer console.purchaseId— purchase identifier. Used to obtain purchase information in the SDK via the purchase information retrieval method.purchaseType— purchase type (ONE_STEP/TWO_STEP/UNKNOWN— single-stage/two-stage/unknown).quantity— product quantity.sandbox— flag indicating a test payment in the sandbox. IfTRUE, the purchase was made in test mode.
Purchase Confirmation (Consumption)
Us theconsume_purchase method to confirm a purchase. Purchase confirmation request must be accompanied by the delivery of the product. After calling the confirmation method the purchase changes its state to CONSUMED.
You must subscribe to events once before using this method:
on_confirm_two_step_purchase_success;on_confirm_two_step_purchase_failure.
func _ready:
# _pay_client initialization
_pay_client.on_confirm_two_step_purchase_success(_on_confirm_two_step_purchase_success)
_pay_client.on_confirm_two_step_purchase_failure(_on_confirm_two_step_purchase_failure)
func _on_confirm_two_step_purchase_success(purchase_id: RuStorePayPurchaseId):
pass
func _on_confirm_two_step_purchase_failure(purchase_id: RuStorePayPurchaseId, error: RuStoreError):
pass
var id: RuStorePayPurchaseId = ...
var payload: RuStorePayDeveloperPayload = ...
_pay_client.confirm_two_step_purchase(id, payload)
id— product ID.-
payload— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization
Purchase Cancellation
To cancel a purchase, use thecancel_two_step_purchase method.
You must subscribe to events once before using this method:
on_cancel_two_step_purchase_success;on_cancel_two_step_purchase_failure.
func _ready:
# _pay_client initialization
_pay_client.on_cancel_two_step_purchase_success(_on_cancel_two_step_purchase_success)
_pay_client.on_cancel_two_step_purchase_failure(_on_cancel_two_step_purchase_failure)
func _on_cancel_two_step_purchase_success(purchase_id: String):
pass
func _on_cancel_two_step_purchase_failure(purchase_id: String, error: RuStoreError):
pass
# Your purchase cancellation UI implementation
func _on_cancel_two_step_purchase_pressed(purchaseId: RuStorePayPurchaseId):
_pay_client.cancel_two_step_purchase(purchaseId)
purchaseId — product ID
- The
on_cancel_two_step_purchase_successcallback returns purchase ID. - The
on_cancel_two_step_purchase_failurecallback returns purchase ID of theStringtype and theRuStoreErrorobject with error information. The error structure is described in Error Handling.
Retrieving Purchase Details
Go get purchase information, use theget_purchase method.
func _ready:
# _pay_client initialization
_pay_client.on_get_purchase_success(_on_get_purchase_success)
_pay_client.on_get_purchase_failure(_on_get_purchase_failure)
func _on_get_purchase_success(purchase: RuStorePayPurchase):
pass
func _on_get_purchase_failure(purchase_id: RuStorePayPurchaseId, error: RuStoreError):
pass
var purchase_id: RuStorePayPurchaseId = ...
_pay_client.get_purchase(purchase_id)
This method returns information about a specific purchase in any status. Below is the purchase pattern:
class_name RuStorePayPurchase extends Object
var amountLabel: RuStorePayAmountLabel = null
var currency: RuStorePayCurrency = null
var description: RuStorePayDescription = null
var developerPayload: RuStorePayDeveloperPayload = null
var invoiceId: RuStorePayInvoiceId = null
var orderId: RuStorePayOrderId = null
var price: RuStorePayPrice = null
var productId: RuStorePayProductId = null
var productType: ERuStorePayProductType.Item = 0
var purchaseId: RuStorePayPurchaseId = null
var purchaseTime: RuStorePayTime = null
var purchaseType: ERuStorePayPurchaseType.Item = 0
var quantity: RuStorePayQuantity = null
var status: ERuStorePayPurchaseStatus.Item = 0
var subscriptionToken: RuStorePaySubscriptionToken = null
-
amountLabel— formatted purchase price, including currency symbol. -
currency— ISO 4217 currency code. -
description— descriptions inlanguage. -
developerPayload— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization -
invoiceId— invoice ID. -
orderId— payment ID generated by the app (optional). If you specify this parameter in your system, you will receive it via our API. If not specified, will be generated automatically (uuid). 150 characters max. -
price— price in minimum currency units. -
productId— product ID assigned to product in RuStore Console (mandatory). -
productType— product type. -
purchaseId— product ID. -
purchaseTime— purchase time. -
PurchaseType— purchase type:ONE_PHASE- one-stage payment;TWO_PHASE- two-stage payment;UNKNOWN- number of stages is undefined.
-
quantity— product amount (optional, value1will be used if not specified). -
status— purchase state:INVOICE_CREATED— purchase invoice is created and awaiting payment;CANCELLED— purchase canceled by the user;PROCESSING— payment initiated;REJECTED— purchase rejected (for example: due to insufficient funds);EXPIRED— payment time expired;PAID— only for two-stage payments, intermediate status, funds are put on hold on the user's account, the purchase is awaiting confirmation from the developer;CONFIRMED— purchase successfully paid for;REFUNDED— purchase successfully refunded;REVERSED— only for two-stage payment: wither the purchase was canceled by the developer or there was no payment within 6 hours, the funds on the user's account are put off hold.
Retrieving Purchase List
To get the user's purchase list, use the get_purchases method.
Before using the methods, you need to subscribe to the events once:
on_get_purchases_success;on_get_purchases_failure.
func _ready:
# Initialization of _pay_client
_pay_client.on_get_purchases_success.connect(_on_get_purchases_success)
_pay_client.on_get_purchases_failure.connect(_on_get_purchases_failure)
func _on_get_purchases_success(purchases: Array[RuStorePayPurchase]):
pass
func _on_get_purchases_failure(error: RuStoreError):
pass
# Initialization of _pay_client
# Call without filter
_pay_client.get_purchases()
# Call with filter
var productType = ERuStorePayProductType.Item.CONSUMABLE_PRODUCT
var purchase_status = ERuStorePayPurchaseStatus.Item.CONFIRMED
_pay_client.get_purchases(productType, purchase_status)
Below is the purchase model:
class_name RuStorePayPurchase extends Object
var amountLabel: RuStorePayAmountLabel = null
var currency: RuStorePayCurrency = null
var description: RuStorePayDescription = null
var developerPayload: RuStorePayDeveloperPayload = null
var invoiceId: RuStorePayInvoiceId = null
var orderId: RuStorePayOrderId = null
var price: RuStorePayPrice = null
var productId: RuStorePayProductId = null
var productType: ERuStorePayProductType.Item = 0
var purchaseId: RuStorePayPurchaseId = null
var purchaseTime: RuStorePayTime = null
var purchaseType: ERuStorePayPurchaseType.Item = 0
var quantity: RuStorePayQuantity = null
var status: ERuStorePayPurchaseStatus.Item = 0
var subscriptionToken: RuStorePaySubscriptionToken = null
amountLabel— formatted purchase price, including currency symbol.currency— ISO 4217 currency code.description— descriptions inlanguage.-
developerPayload— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization invoiceId— invoice ID.orderId— payment ID generated by the app (optional). If you specify this parameter in your system, you will receive it via our API. If not specified, will be generated automatically (uuid). 150 characters max.price— price in minimum currency units.productId— product ID assigned to product in RuStore Console (mandatory).productType— product type.
purchaseId— product ID.purchaseTime— purchase time.PurchaseType— purchase type:ONE_PHASE- one-stage payment;TWO_PHASE- two-stage payment.
quantity— product amount (optional, value1will be used if not specified).status— purchase state:INVOICE_CREATED— purchase invoice is created and awaiting payment;CANCELLED— purchase canceled by the user;PROCESSING— payment initiated;REJECTED— purchase rejected (for example: due to insufficient funds);PAID— only for two-stage payments, intermediate status, funds are put on hold on the user's account, the purchase is awaiting confirmation from the developer;CONFIRMED— purchase successfully paid for;REFUNDED— purchase successfully refunded;REVERSED— only for two-stage payment: wither the purchase was canceled by the developer or there was no payment within 6 hours, the funds on the user's account are put off hold.
Checking for RuStore on the Device
To check whether the RuStore app is installe don the user's device, call the is_rustore_installed method.
var is_rustore_installed: bool = _pay_client.is_rustore_installed()
true– RuStore is installed.false– RuStore is not installed.
Checking User Authorization
To check the user's authorization status, call the get_user_authorization_status method. The result of this method is a value from the ERuStorePayUserAuthorizationStatus.Item enumeration:
AUTHORIZED— the user is authorized in RuStore.UNAUTHORIZED— the user is not authorized in RuStore. This value will also be returned if the user does not have the RuStore app installed on the device.
Before using the method, you need to subscribe to the events once:
on_get_user_authorization_status_success;on_get_user_authorization_status_failure.
func _ready():
# Initialization of _pay_client
_pay_client.on_get_user_authorization_status_success.connect(_on_get_user_authorization_status_success)
_pay_client.on_get_user_authorization_status_failure.connect(_on_get_user_authorization_status_failure)
func _on_get_user_authorization_status_success(result: ERuStorePayUserAuthorizationStatus.Item):
pass
func _on_get_user_authorization_status_failure(error: RuStoreError):
pass
_pay_client.get_user_authorization_status()
Checking Payment Availability
To check purchase availability, call the get_purchase_availability method. On calling, the following conditions are checked.
- The company has monetization enabled via the RuStore Developer Console.
- The application must not be banned in RuStore.
- The user must not be banned in RuStore.
RuStorePayGetPurchaseAvailabilityResult.isAvailable == true is returned.
Otherwise, RuStorePayGetPurchaseAvailabilityResult.isAvailable == false and RuStorePayGetPurchaseAvailabilityResult.cause are returned, where cause is the error indicating the unmet condition (possible errors are described in the Error Handling section).
Before using the method, you need to subscribe to the events once:
on_get_purchases_availability_success;on_get_purchases_availability_failure.
func _ready():
# Initialization of _pay_client
_pay_client.on_get_purchase_availability_success.connect(_on_get_purchase_availability_success)
_pay_client.on_get_purchase_availability_failure.connect(_on_get_purchase_availability_failure)
func _on_get_purchase_availability_success(result: RuStorePayGetPurchaseAvailabilityResult):
pass
func _on_get_purchase_availability_failure(error: RuStoreError):
pass
_pay_client.get_purchase_availability()
Purchase Status Model
One-stage payment status model.
Two-stage payment status model.
Error Handling
If an error occurs during payment or the user cancels the purchase, the execution of the payment method (both with purchase type selection and the two-stage method) will complete with an error:
ProductPurchaseException— product purchase error.ProductPurchaseCancelled— error caused by purchase cancellation (the user closed the payment sheet) before receiving the purchase result. In this case, it is recommended to additionally check the purchase status using the purchase information retrieval method.
Error and cancellation structure:
class ProductPurchaseException extends RuStorePaymentException:
var invoiceId: RuStorePayInvoiceId = null
var orderId: RuStorePayOrderId = null
var productId: RuStorePayProductId = null
var purchaseId: RuStorePayPurchaseId = null
var purchaseType: ERuStorePayPurchaseType.Item = 0
var quantity: RuStorePayQuantity = null
var sandbox: bool = false
class ProductPurchaseCancelled extends RuStorePaymentException:
var purchaseId: RuStorePayPurchaseId = null
var purchaseType: ERuStorePayPurchaseType.Item = 0
func _on_any_purchase_failure(product_id: RuStorePayProductId, error: RuStoreError):
if is_instance_of(error, RuStorePaymentException.ProductPurchaseCancelled):
var cancelled_error = error as RuStorePaymentException.ProductPurchaseCancelled
OS.alert(cancelled_error.purchaseId.value, error.name)
elif is_instance_of(error, RuStorePaymentException.ProductPurchaseException):
var exception_error = error as RuStorePaymentException.ProductPurchaseException
OS.alert(exception_error.purchaseId.value, error.name)
else:
OS.alert(error.description, error.name)
Server Validation of Purchase
If you need to validate a purchase on the RuStore server, you can use subscriptionToken in SuccessProductPurchaseResult, that is returned on successful purchase.
func _on_purchase_two_step_success(result: RuStorePayProductPurchaseResult):
if result is RuStorePayProductPurchaseResult.SuccessProductPurchaseResult:
yourApi.validate(result.subscriptionToken);
You can also get a subscriptionToken from the Purchase entity. The Purchase entity can be retrieved using the get_purchases method.
func _on_get_purchases_success(purchases: Array[RuStorePayPurchase]):
for item in purchases:
yourApi.validate(item.subscriptionToken);
Error Handling
RuStorePaymentNetworkException— SDK network communication error;RuStorePaymentCommonException— general SDK error;RuStorePayClientAlreadyExist— SDK re-initialization error;RuStorePayClientNotCreated— attempt to access public SDK interfaces before initialization;RuStorePayInvalidActivePurchase— payment initiated for unknown product type;RuStorePayInvalidConsoleAppId— required parameterconsole_application_idfor SDK initialization is not specified;RuStorePaySignatureException— invalid response signature. Occurs when attempting fraudulent actions;EmptyPaymentTokenException— error obtaining payment token;InvalidCardBindingIdException— error paying with a saved card;ApplicationSchemeWasNotProvided— scheme for the return deeplink is not specified;ProductPurchaseException— product purchase error. The model structure is described in the section purchase result structure;ProductPurchaseCancelled— product purchase was cancelled (the user closed the payment sheet). The model structure is described in the section purchase result structure;ProductPurchaseException— product purchase error;RuStoreNotInstalledException— RuStore is not installed on the user's device;RuStoreOutdatedException— the installed version of RuStore on the device does not support payments;RuStoreUserUnauthorizedException— the user is not authorized in RuStore;RuStoreApplicationBannedException— the application is banned in RuStore;RuStoreUserBannedException— the user is banned in RuStore.