5.0.0
RuStore allows you to integrate payments into your mobile app.
Implementation example
See the example app to learn how to integrate rating and feedback SDK correctly.
Prerequisites
- The current version of RuStore is installed on the user's device.
- The user is authorized in RuStore.
- The user and the app should not be blocked in RuStore.
- In-app purchases should be enabled for the app in RuStore Console.
The service has some restrictions to work outside of Russia.
Getting started
- Copy the project plugin and sample app from the official RuStore repository to GitFlic.
- In your IDE, open the Android project from the
godot_plugin_libraries
folder. - Save the package
godot-lib.xxx.yyy.template_release.aar
, wherexxx.yyy
is the version of your Godot Engine edition, in the foldergodot_plugin_libraries/libs
. - Build your project with the command
gradle assemble
.
If the build is successful, the following files will be created in godot_example/android/plugins
.
RuStoreGodotBilling.gdap
;RuStoreGodotBilling.aar
;RuStoreGodotCore.gdap
;RuStoreGodotCore.aar
.
⚠️ Note that the plugin libraries must be built for your version of the Godot engine.
- Copy the contents of the
godot_example/android/plugins
folder toyour_project/android/plugins
. - Inn the Plugins list, select RuStore Godot Billing and RuStore Godot Core plugins.
Deeplink processing
To redirect a user to your app after payment via third-party apps (the Faster Payments System (SBP), SberPay and others), you need to properly implement deep linking in your app. Specify the intent-filter
in AndroidManifest.xml
with scheme
of your project (see below).
<activity
android:name=".GodotApp"
android:label="@string/godot_project_name_string"
android:theme="@style/GodotAppSplashTheme"
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.LAUNCHER" />
</intent-filter>
<!-- your app 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="yourappscheme" />
</intent-filter>
</activity>
where yourappscheme
— your deeplink scheme, it can be changed to another one.
This scheme must match the deeplinkSheme value specified during the billing client library initialization.
Initialization
Initialize the library before calling its methods.
For initialisation, call theinit
method.
const APPLICATION_ID = "123456"
const DEEPLINK_SCHEME = "yourappscheme"
const DEBUG_LOGS = false
var _billing_client: RuStoreGodotBillingClient = null
func _ready():
_billing_client = RuStoreGodotBillingClient.get_instance()
_billing_client.init(APPLICATION_ID, DEEPLINK_SCHEME, DEBUG_LOGS)
APPLICATION_ID
— application code from RuStore Console (example:https://console.rustore.ru/apps/123456
).DEEPLINK_SCHEME
— deeplink scheme required to return to your app upon payment via a third-party application (for example, SberPay or SBP). SDK generates its host for this scheme.DEBUG_LOGS
— flag that regulates logging (logs will be automatically disabled for Release builds).
- The
ApplicationId
specified inbuild.gradle
must match theapplicationId
of the apk file you published to RuStore Console.. - The
deeplinkScheme
schema passed to deeplinkScheme must match the schema specified inAndroidManifest.xml
in the Deeplink Processing section. - The
keystore
signature must be the same as the one used to sign the application published to RuStore Console. Make sure that thebuildType
(eg:debug
) uses the same signature as the published application (eg:release
).
It is required to perform the plugin initialization to connect to all available signals.
How payments work
Checking purchases availability
Please ensure compliance with the conditions below to check whether your app supports payment functions.
- The current version of RuStore is installed on the user's device.
- RuStore app supports payment functionality.
- The user is authorized in RuStore.
- The user and the app should not be blocked in RuStore.
- In-app purchases should be enabled for the app in RuStore Console.
check_purchases_availability
method.
You need to subscribe to the events once before calling the methods
on_check_purchases_availability_success
;on_check_purchases_availability_failure
.
func _ready():
# Initialization _billing_client
_billing_client.on_check_purchases_availability_success(_on_check_purchases_availability_success)
_billing_client.on_check_purchases_availability_failure(_on_check_purchases_availability_failure)
func _on_check_purchases_availability_success(result: RuStoreFeatureAvailabilityResult):
pass
func _on_check_purchases_availability_failure(error: RuStoreError):
pass
_billing_client.check_purchases_availability()
The on_check_purchases_availability_success
callback returns a RuStoreFeatureAvailabilityResult
object with service availability information.
class_name RuStoreFeatureAvailabilityResult extends Object
var isAvailable: bool
var cause: RuStoreError
func _init(json: String = ""):
if json == "":
isAvailable = false
cause = RuStoreError.new()
else:
var obj = JSON.parse_string(json)
isAvailable = obj["isAvailable"]
cause = RuStoreError.new(json)
-
isAvailable
— whether payment conditions are met (true
/false
). -
cause
— error information.
The on_check_purchases_availability_failure
callback returns a RuStoreError
object with all other errors, for example - "No internet connection".
Working with SDK
Getting products list
Use thegetProducts
method to get a list of products.
You need to subscribe to the events once before calling the methods
on_get_products_success
;on_get_products_failure
.
func _ready():
# Initialization _billing_client
_billing_client.on_get_products_success(_on_get_products_success)
_billing_client.on_get_products_failure(_on_get_products_failure)
func _on_get_products_success(products: Array):
pass
func _on_get_products_failure(error: RuStoreError):
pass
const PRODUCT_IDS = [
"123",
"non_con",
"con",
"sub"]
_billing_client.get_products(PRODUCT_IDS)
PRODUCT_IDS
— list of products IDs. Maximum length is 2083 symbols in a list.
The on_get_products_success
callback returns a list of RuStoreProduct
objects with product information.
class_name RuStoreProduct extends Object
var productId: String = ""
var productStatus: ERuStoreProductStatus.Item = 0
var productType: ERuStoreProductType.Item = 0
var priceLabel: String = ""
var price: int = 0
var currency: String = ""
var language: String = ""
var title: String = ""
var description: String = ""
var imageUrl: String = ""
var promoImageUrl: String = ""
var subscription: RuStoreProductSubscription = null
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
productId = obj["productId"]
productStatus = ERuStoreProductStatus.Item.get(obj["productStatus"])
if obj.has("productType"):
productType = ERuStoreProductType.Item.get(obj["productType"])
if obj.has("priceLabel"):
priceLabel = obj.get("priceLabel")
if obj.has("price"):
price = int(obj["price"])
if obj.has("currency"):
currency = obj.get("currency")
if obj.has("language"):
language = obj.get("language")
if obj.has("title"):
title = obj.get("title")
if obj.has("description"):
description = obj.get("description")
if obj.has("imageUrl"):
imageUrl = ""#obj["imageUrl"]
if obj.has("promoImageUrl"):
promoImageUrl = ""#obj["promoImageUrl"]
if obj.has("subscription"):
subscription = RuStoreProductSubscription.new(str(obj["subscription"]))
Available fields:
-
productId
— product ID.. -
productType
— product type.:NON_CONSUMABLE
— non-consumables (one-time purchases, such as disabling ads in an app);
;CONSUMABLE
— consumables (multiple-time purchases, such as crystals in the app);SUBSCRIPTION
— subscription (can be purchased for a period of time, such as a streaming service subscription)..
-
productStatus
— product status.:ACTIVE
— product available for purchase;INACTIVE
— product not available for purchase.
-
priceLable
— formatted purchase price, including the currency symbol inlanguage
. -
price
— price in minor units (in kopecks).. -
currency
— ISO 4217 currency code. -
language
— language specified with the BCP 47 encoding.. -
title
— product name inlanguage
. -
description
— product description inlanguage
. -
imageUrl
— link to an image.. -
promoImageUrl
— promotional picture link.. -
subscription
— subscription description, returned only for products withsubscription
.
Subscription structure
class_name RuStoreProductSubscription extends Object
var subscriptionPeriod: RuStoreSubscriptionPeriod = null
var freeTrialPeriod: RuStoreSubscriptionPeriod = null
var gracePeriod: RuStoreSubscriptionPeriod = null
var introductoryPrice: String = ""
var introductoryPriceAmount: String = ""
var introductoryPricePeriod: RuStoreSubscriptionPeriod = null
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("subscriptionPeriod"):
subscriptionPeriod = RuStoreSubscriptionPeriod.new(str(obj["subscriptionPeriod"]))
if obj.has("freeTrialPeriod"):
freeTrialPeriod = RuStoreSubscriptionPeriod.new(obj["freeTrialPeriod"])
if obj.has("gracePeriod"):
gracePeriod = RuStoreSubscriptionPeriod.new(obj["gracePeriod"])
if obj.has("introductoryPrice"):
introductoryPrice = obj["introductoryPrice"]
if obj.has("introductoryPriceAmount"):
introductoryPriceAmount = obj["introductoryPriceAmount"]
if obj.has("introductoryPricePeriod"):
introductoryPricePeriod = RuStoreSubscriptionPeriod.new(obj["introductoryPricePeriod"])
subscriptionPeriod
— subscription period..freeTrialPeriod
— trial subscription period..gracePeriod
— grace period..introductoryPrice
— formatted introductory subscription price, including the currency symbol, inproduct:language
.introductoryPriceAmount
— introductory price in minor units of currency (in kopecks).introductoryPricePeriod
— calculated period of the introductory price..
Structure of the subscription period
class_name RuStoreSubscriptionPeriod extends Object
var days: int = 0
var months: int = 0
var years: int = 0
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
days = int(obj["days"])
months = int(obj["months"])
years = int(obj["years"])
days
— number of days..months
— number of days..years
— number of years..
The on_get_products_failure
callback returns a RuStoreError
object with error information. All possible RuStoreException errors are described in Error Handling.
Purchasing product
Use thepurchaseProduct
method to call a product purchase.
You need to subscribe to the events once before calling the methods
on_purchase_product_success
;on_purchase_product_failure
func _ready():
# Initialization _billing_client
_billing_client.on_purchase_product_success(_on_purchase_product_success)
_billing_client.on_purchase_product_failure(_on_purchase_product_failure)
func _on_purchase_product_success(result: RuStorePaymentResult):
pass
func _on_purchase_product_failure(error: RuStoreError):
pass
const PRODUCT_ID = "123"
const PARAMS = {
"order_id": "example_id",
"quantity": 1,
"payload": "Some payload"
}
_billing_client.purchase_product(PRODUCT_ID, PARAMS)
-
PRODUCT_ID
— product ID.; -
PARAMS
— optional parameters:orderId
— order ID, generated by AnyApp. (optional. If not specified, it is generated automatically);quantity
— product quantity. (optional);developerPayload
— уline specified by the developer that contains additional information about the order..
The on_purchase_product_success
callback returns a RuStorePaymentResult
object with purchase info.
Success
- successful purchase result..Failure
- error occurred when sending a payment request or receiving a payment status, it is not possible to set the purchase status..Cancelled
— a purchase request has been sent, but the user has closed the "payment window" on their device, so the payment result is unknown..
.InvalidPaymentState
— Billing SDK error.. May occur in case of an incorrect reverse deeplink.
class_name RuStorePaymentResult extends Object
class Success extends RuStorePaymentResult:
var orderId: String = ""
var purchaseId: String = ""
var productId: String = ""
var invoiceId: String = ""
var subscriptionToken: String = ""
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("orderId"):
purchaseId = obj["orderId"]
purchaseId = obj["purchaseId"]
productId = obj["productId"]
invoiceId = obj["invoiceId"]
if obj.has("subscriptionToken"):
purchaseId = obj["subscriptionToken"]
orderId
— unique payment identifier generated by the application (uuid); (optional. If not specified, it is generated automatically);purchaseId
— purchase ID.;productId
— product ID.;invoiceId
— invoice ID.;subscriptionToken
— subscription token. Consists of the purchaseinvoiceId
and theuserId
of RuStore, divided by a dot:invoiceId.userId
.
class Cancelled extends RuStorePaymentResult:
var purchaseId: String
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
purchaseId = obj["purchaseId"]
purchaseId
— purchase ID..
class Failure extends RuStorePaymentResult:
var purchaseId: String = ""
var invoiceId: String = ""
var orderId: String = ""
var quantity: int = 0
var productId: String = ""
var errorCode: int = 0
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("purchaseId"): purchaseId = obj["purchaseId"]
if obj.has("invoiceId"): invoiceId = obj["invoiceId"]
if obj.has("orderId"): orderId = obj["orderId"]
if obj.has("quantity"): quantity = int(obj["quantity"])
if obj.has("productId"): productId = obj["productId"]
if obj.has("errorCode"): errorCode = int(obj["errorCode"])
purchaseId
— purchase ID..invoiceId
— invoice ID..orderId
— unique payment identifier generated by the application (uuid);.quantity
— product quantity..productId
— product ID..errorCode
— error code..
class InvalidPaymentState extends RuStorePaymentResult:
pass
The on_purchase_product_failure
callback returns a RuStoreError
object with error information. All possible RuStoreException errors are described in Error Handling.
Getting purchase info
Use theget_purchase_info
method to retrive purchase details.
You need to subscribe to the events once before calling the methods
on_get_purchase_info_success
;on_get_purchase_info_failure
.
func _ready:
# Initialization _billing_client
_billing_client.on_get_purchase_info_success(_on_get_purchase_info_success)
_billing_client.on_get_purchase_info_failure(_on_get_purchase_info_failure)
func _on_get_purchase_info_success(purchase: RuStorePurchase):
pass
func _on_get_purchase_info_failure(error: RuStoreError):
pass
#Your implementation
func _on_confirm_purchase_pressed(purchase: RuStorePurchase):
_billing_client.get_purchase_info(purchase.purchaseId)
purchase.purchaseId
— purchase ID..
The on_get_purchase_info_success
callback returns a RuStorePurchase
object with purchase information.
class_name RuStorePurchase extends Node
var purchaseId: String = ""
var productId: String = ""
var productType: ERuStoreProductType.Item = ERuStoreProductType.Item.NON_CONSUMABLE
var invoiceId: String = ""
var description: String = ""
var language: String = ""
var purchaseTime: String = ""
var orderId: String = ""
var amountLabel: String = ""
var amount: int = 0
var currency: String = ""
var quantity: int = 0
var purchaseState: ERuStorePurchaseState.Item = ERuStorePurchaseState.Item.CANCELLED
var developerPayload: String = ""
var subscriptionToken: String = ""
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("purchaseId"): purchaseId = obj["purchaseId"]
productId = obj["productId"]
if obj.has("productType"): productType = ERuStoreProductType.Item.get(obj["productType"])
if obj.has("invoiceId"): invoiceId = obj["invoiceId"]
if obj.has("description"): description = obj["description"]
if obj.has("language"): language = obj["language"]
if obj.has("purchaseTime"): purchaseTime = obj["purchaseTime"]#RuStoreDateTime
if obj.has("orderId"): orderId = obj["orderId"]
if obj.has("amountLabel"): amountLabel = obj["amountLabel"]
if obj.has("amount"): amount = int(obj["amount"])
if obj.has("currency"): currency = obj["currency"]
if obj.has("quantity"): quantity = int(obj["quantity"])
if obj.has("purchaseState"): purchaseState = ERuStorePurchaseState.Item.get(obj["purchaseState"])
if obj.has("developerPayload"): developerPayload = obj["developerPayload"]
if obj.has("subscriptionToken"): subscriptionToken = obj["subscriptionToken"]
-
purchaseId
— purchase ID.. -
productId
— product ID.. -
productType
— product type.:NON_CONSUMABLE
— non-consumables (one-time purchases, such as disabling ads in an app);
;CONSUMABLE
— consumables (multiple-time purchases, such as crystals in the app);SUBSCRIPTION
— subscription (can be purchased for a period of time, such as a streaming service subscription)..
-
invoiceId
— invoice ID.. -
description
— product description inlanguage
. -
language
— language specified with the BCP 47 encoding.. -
:purchaseTime
— time of purchase.MMM
— abbreviated name of the month (January - Jan);dd
— day of the month.;yyyy
— year;h
— hour in 12-hour format;mm
— minutes.;ss
— seconds;
.a
— AM/PM time indicator.
-
orderId
— unique payment identifier generated by the application (uuid);. -
amountLable
— formatted purchase price, including the currency symbol inlanguage
. -
amount
— price in minor units of currency.. -
currency
— ISO 4217 currency code. -
quantity
— product quantity.. -
purchaseState
— purchase state.:
;CREATED
- purchase created.INVOICE_CREATED
— created, waiting for payment.;
;PAID
— consumable purchases only - intermediate status, funds reserved in buyer's account. Purchase pending confirmation from developer.CONFIRMED
— final status, purchase confirmed (for subscriptions and non-consumable items). Funds sent to the developer. Repeat item purchase is blocked by the store;
;CONSUMED
— for consumable items - final status, purchase consumption confirmed. You can re-purchase an item.CANCELLED
— purchase cancelled - payment has not been made or a refund has been made to the buyer (for subscriptions, once refunded, the purchase does not becomeCANCELLED
);
;PAUSED
- for subscriptions - subscription shifted to HOLD period.
.TERMINATED
— subscription closed.
-
developerPayload
— уline specified by the developer that contains additional information about the order.. -
subscriptionToken
— token for server validation..
Status model (purchaseState
)
A status-based consumables subscription (CONSUMABLES
)
![img](/help/en/assets/images/CONSUMABLES-v0-bf7aa17ffc46aac0531f9898aadeea55.png)
A status-based non-consumables subscription (NON-CONSUMABLES
):
![img](/help/en/assets/images/NON-CONSUMABLES-v0-a78cd9b635ef5c2d972c41265a1380df.png)
A status-based subscription purchase model (SUBSCRIPTIONS
)
![img](/help/en/assets/images/SUBSCRIPTIONS-v0-ee95282f22314f22bed73f8e5a9b256c.png)
The on_get_purchase_info_failure
callback returns a RuStoreError
object with error information. All possible RuStoreException errors are described in Error Handling.
Getting purchases list
The method only returns purchases with statuses from the table below.
Type/Status | INVOICE_CREATED | CONFIRMED | PAID | PAUSED |
---|---|---|---|---|
consumable | + | + | ||
non-consumable | + | + | ||
subscription | + | + | + |
The method returns incomplete purchase and purchase consumable states that require processing. Apart from that, it shows confirmed purchases for subscriptions and non-consumable items - those that cannot be purchased again.
get_purchases
method to get the user's list of purchases.
You need to subscribe to the events once before calling the methods
on_get_purchases_success
;on_get_purchases_failure
.
func _ready:
# Initialization _billing_client
_billing_client.on_get_purchases_success(_on_get_purchases_success)
_billing_client.on_get_purchases_failure(_on_get_purchases_failure)
func _on_get_purchases_success(purchases: Array):
pass
func _on_get_purchases_failure(error: RuStoreError):
pass
_billing_client.get_purchases()
The on_get_purchases_success
callback returns an array of RuStorePurchase
objects with information about purchases.
class_name RuStorePurchase extends Node
var purchaseId: String = ""
var productId: String = ""
var productType: ERuStoreProductType.Item = ERuStoreProductType.Item.NON_CONSUMABLE
var invoiceId: String = ""
var description: String = ""
var language: String = ""
var purchaseTime: String = ""
var orderId: String = ""
var amountLabel: String = ""
var amount: int = 0
var currency: String = ""
var quantity: int = 0
var purchaseState: ERuStorePurchaseState.Item = ERuStorePurchaseState.Item.CANCELLED
var developerPayload: String = ""
var subscriptionToken: String = ""
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("purchaseId"): purchaseId = obj["purchaseId"]
productId = obj["productId"]
if obj.has("productType"): productType = ERuStoreProductType.Item.get(obj["productType"])
if obj.has("invoiceId"): invoiceId = obj["invoiceId"]
if obj.has("description"): description = obj["description"]
if obj.has("language"): language = obj["language"]
if obj.has("purchaseTime"): purchaseTime = obj["purchaseTime"]#RuStoreDateTime
if obj.has("orderId"): orderId = obj["orderId"]
if obj.has("amountLabel"): amountLabel = obj["amountLabel"]
if obj.has("amount"): amount = int(obj["amount"])
if obj.has("currency"): currency = obj["currency"]
if obj.has("quantity"): quantity = int(obj["quantity"])
if obj.has("purchaseState"): purchaseState = ERuStorePurchaseState.Item.get(obj["purchaseState"])
if obj.has("developerPayload"): developerPayload = obj["developerPayload"]
if obj.has("subscriptionToken"): subscriptionToken = obj["subscriptionToken"]
-
purchaseId
— purchase ID.. -
productId
— product ID.. -
productType
— product type.:NON_CONSUMABLE
— non-consumables (one-time purchases, such as disabling ads in an app);
;CONSUMABLE
— consumables (multiple-time purchases, such as crystals in the app);SUBSCRIPTION
— subscription (can be purchased for a period of time, such as a streaming service subscription)..
-
invoiceId
— invoice ID.. -
description
— product description inlanguage
. -
language
— language specified with the BCP 47 encoding.. -
.purchase_time
— time of purchase.MMM
— abbreviated name of the month (January - Jan);dd
— day of the month.;yyyy
— year;h
— hour in 12-hour format;mm
— minutes.;ss
— seconds;
.a
— AM/PM time indicator.
-
orderId
— unique payment identifier generated by the application (uuid);. -
amountLable
— formatted purchase price, including the currency symbol inlanguage
. -
amount
— price in minor units of currency.. -
currency
— ISO 4217 currency code. -
quantity
— product quantity.. -
purchaseState
— purchase state.:
;CREATED
- purchase created.INVOICE_CREATED
— created, waiting for payment.;
;PAID
— consumable purchases only - intermediate status, funds reserved in buyer's account. Purchase pending confirmation from developer.CONFIRMED
— final status, purchase confirmed (for subscriptions and non-consumable items). Funds sent to the developer. Repeat item purchase is blocked by the store;
;CONSUMED
— for consumable items - final status, purchase consumption confirmed. You can re-purchase an item.CANCELLED
— purchase cancelled - payment has not been made or a refund has been made to the buyer (for subscriptions, once refunded, the purchase does not becomeCANCELLED
);
;PAUSED
- for subscriptions - subscription shifted to HOLD period.
.TERMINATED
— subscription closed.
-
developerPayload
— уline specified by the developer that contains additional information about the order.. -
subscriptionToken
— token for server validation..
The on_get_purchases_failure
callback returns a RuStoreError
object with error info. All possible RuStoreException errors are described in Error Handling.
Confirming purchase
Products that require confirmation
The RuStore application consists of the following types of products:
SUBSCRIPTION
— subscription (can be purchased for a period of time, such as a streaming service subscription)..NON_CONSUMABLE
— non-consumables (one-time purchases, such as disabling ads in an app).
.CONSUMABLE
— consumables (multiple-time purchases, such as crystals in the app);
Only CONSUMABLE
type products require confirmation if they are in ERuStorePurchaseState.Item.PAID
state.
Calling confirmation method
Use theconfirm_purchase
method to call a product purchase. The release of the goods must be accompanied by a purchase confirmation request. Once the confirmation is called, the purchase will have a CONSUMED
status.
You need to subscribe to the events once before calling the methods
on_confirm_purchase_success
;on_confirm_purchase_failure
.
func _ready:
# initialisation _billing_client
_billing_client.on_confirm_purchase_success(_on_confirm_purchase_success)
_billing_client.on_confirm_purchase_failure(_on_confirm_purchase_failure)
func _on_confirm_purchase_success(purchase_id: String):
pass
func _on_confirm_purchase_failure(purchase_id: String, error: RuStoreError):
pass
# Your implementation
func _on_confirm_purchase_pressed(purchase: RuStorePurchase):
_billing_client.confirm_purchase(purchase.purchaseId)
purchase.purchaseId
— purchase ID..
The on_confirm_purchase_failure
callback returns a String
type purchase ID and a RuStoreError
object with error information. All possible RuStoreException errors are described in Error Handling.
Canceling purchase
Use thedelete_purchase
method to cancel a purchase.
You need to subscribe to the events once before calling the methods
on_delete_purchase_success
;on_delete_purchase_failure
.
func _ready:
# Initialization _billing_client
_billing_client.on_delete_purchase_success(_on_delete_purchase_success)
_billing_client.on_delete_purchase_failure(_on_delete_purchase_failure)
func _on_delete_purchase_success(purchase_id: String):
pass
func _on_delete_purchase_failure(purchase_id: String, error: RuStoreError):
_core_client.show_toast(purchase_id + " " + error.description)
#Your implementation
func _on_delete_purchase_pressed(purchase: RuStorePurchase):
_billing_client.delete_purchase(purchase.purchaseId)
purchase.purchaseId
— purchase ID.
- The callback
on_delete_purchase_info_success
returns the purchase ID. - The
on_delete_purchase_info_failure
callback returns aString
type purchase ID and aRuStoreError
object with error information. All possible RuStoreException errors are described in Error Handling.
Logging
If you want to log payment library events, add optional parameter debugLogs
to init
call and subscribe to the events once:
on_payment_logger_debug
;on_payment_logger_error
;on_payment_logger_info
;on_payment_logger_verbose
;on_payment_logger_warning
.
Logging will only work for Debug builds of the application and *.aar
plugin packages. Logs will be automatically disabled for Release builds.
func _ready():
_billing_client = RuStoreGodotBillingClient.get_instance()
_billing_client.on_payment_logger_debug.connect(_on_payment_logger_debug)
_billing_client.on_payment_logger_error.connect(_on_payment_logger_error)
_billing_client.on_payment_logger_info.connect(_on_payment_logger_info)
_billing_client.on_payment_logger_verbose.connect(_on_payment_logger_verbose)
_billing_client.on_payment_logger_warning.connect(_on_payment_logger_warning)
# Вызов метода init
func _on_payment_logger_debug(error: RuStoreError, message: String, tag: String):
_core_client.show_toast(tag + ": " + message)
func _on_payment_logger_error(error: RuStoreError, message: String, tag: String):
_core_client.show_toast(tag + ": " + message)
func _on_payment_logger_info(error: RuStoreError, message: String, tag: String):
_core_client.show_toast(tag + ": " + message)
func _on_payment_logger_verbose(error: RuStoreError, message: String, tag: String):
_core_client.show_toast(tag + ": " + message)
func _on_payment_logger_warning(error: RuStoreError, message: String, tag: String):
_core_client.show_toast(tag + ": " + message)
Please see below for the returned parameters.
error
— error info. All possible RuStoreException errors are described in Error Handling.message
— logging message.tag
— log tag.
Dynamic theme change
To dynamically change theme, useset_theme
.
[Calling the theme setup method
func _ready():
_billing_client = RuStoreGodotBillingClient.get_instance()
var theme = ERuStoreTheme.Item.DARK
theme
- theme type from the ERuStoreTheme
enumeration.
DARK
— dark theme.LIGHT
— light theme.
Errors processing
Possible errors
RuStoreNotInstalledException
— RuStore not installed on user's device;RuStoreOutdatedException
— RuStore, installed on the user's device, does not support payment processing functions.;RuStoreUserUnauthorizedException
— user not authorized on RuStore;RuStoreRequestLimitReached
— not enough time has passed since the process was last shown.;RuStoreReviewExists
— this user has already rated your app.;RuStoreInvalidReviewInfo
— problems withReviewInfo
;RuStoreException
— basic RuStore error, from which all other errors are inherited..
Error structure
class_name RuStoreError extends Object
var name: String = ""
var description: String = ""
func _init(json: String = ""):
if json != "":
var obj = JSON.parse_string(json)
if obj.has("simpleName"):
name = obj["simpleName"]
if obj.has("detailMessage"):
description = obj["detailMessage"]
name
– error name..description
– error description..
Auto error handling
When calling the product purchase method purchase_product
, errors are handled automatically.
To display the error dialogue to the user, use set_error_handling
(see below).
func _ready():
_billing_client = RuStoreGodotBillingClient.get_instance()
_billing_client.set_error_handling(true)
true
— show dialogue;false
— hide dialogue.