In-App Payment SDK for Kotlin/Java (version 8.0.0 Beta)
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
Adding the Repository
Adding repository
Add our repository as shown in the example below.
repositories {
maven {
url = uri("https://artifactory-external.vkpartner.ru/artifactory/maven")
}
}
Adding the Dependency
Connecting the dependency
Add the following code to your configuration file to add the dependency.
dependencies {
implementation(platform("ru.rustore.sdk:bom:2025.05.01"))
implementation("ru.rustore.sdk:pay")
}
Deeplink Handling
Deeplink handling in the RuStore SDK enables efficient interaction with third-party applications when processing payments through banking apps (SBP, SberPay, T-Pay, etc.). This allows you to redirect the user to the payment screen and, after the transaction is completed, return them to your application.
To set up deeplink support in your application and Pay SDK, specify the deeplinkScheme
using sdk_pay_scheme_value
in your AndroidManifest.xml
file and override the onNewIntent
method of your Activity
.
When using deeplinks, specifying the scheme is mandatory. If a payment is attempted without specifying the scheme, an error will occur.
Specifying deeplinkScheme:
<?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="your.app.package.name">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.App"
tools:targetApi="n">
<!-- ... -->
<activity
android:name=".YourPayActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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>
<meta-data
android:name="sdk_pay_scheme_value"
android:value="yourappscheme" />
</application>
</manifest>
Replace yourappscheme
with the name of your scheme. For example, ru.package.name.rustore.scheme
.
Next, add the following code to the Activity
you want to return to after the payment is completed (your application page):
class YourPayActivity: AppCompatActivity() {
private val intentInteractor: IntentInteractor by lazy {
RuStorePayClient.instance.getIntentInteractor()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
intentInteractor.proceedIntent(intent)
}
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
intentInteractor.proceedIntent(intent)
}
}
To restore the state of your application when returning via deeplink, add the android:launchMode="singleTop"
attribute to your AndroidManifest.xml
.
Specifying launchMode:
<?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="your.app.package.name">
<!-- ... -->
<application>
<!-- ... -->
<activity
android:name=".YourPayActivity"
android:launchMode="singleTop"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
<!-- ... -->
</activity>
<!-- ... -->
</application>
</manifest>
SDK Initialization
Initialize the library before calling its methods.
The initialization itself is done automatically, however, for your SDK to work, define console_app_id_key
in your manifest.xml
.
You can so it the following way:
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="your.app.package.name">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.App"
tools:targetApi="n">
...
<meta-data
android:name="console_app_id_value"
android:value="@string/CONSOLE_APPLICATION_ID" />
</application>
</manifest>
-
Example:CONSOLE_APPLICATION_ID
— product ID form the RuStore Console.https://console.rustore.ru/apps/111111
.
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/versions
the app ID is123456
.
- The
ApplicationId
specified inbuild.gradle
must match theapplicationId
of the APK file that you published in the RuStore Console. -
The
keystore
signature must match the signature that was used to sign the app published in the RuStore Console. Make sure thatbuildType
used (example:debug
) uses the same signature as the published app (example:release
).
For security purposes, the SDK sets android:usesCleartextTraffic="false"
by default to prevent data transmission over unencrypted 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 this increases the chance of data interception and substitution. We recommend allowing unencrypted traffic only in exceptional cases and for trusted domains, preferring HTTPS for all network interactions.
SDK Methods
Available public interactors:
PurchaseInteractor
– an interactor that allows you to work with payments and provides several public methods.getPurchase(purchaseId: PurchaseId): Task<Purchase>
– allows you to get information about a purchase by its ID.getPurchases(productType: ProductType? = null): Task<List<Purchase>>
– allows you to get the user's purchases. This method supports optional filtering by product type (consumable or non-consumable products). By default, the filter is disabled and will return all user purchases (regardless of product type) with statusesPAID
andCONFIRMED
.getPurchaseAvailability(): Task<PurchaseAvailabilityResult>
– returns the result of checking payment availability.purchase(params: ProductPurchaseParams, preferredPurchaseType: PreferredPurchaseType = PreferredPurchaseType.ONE_STEP): Task<ProductPurchaseResult>
– allows you to make a product purchase with the desired payment type specified: single-stage (ONE_STEP
) or two-stage (TWO_STEP
). For this payment method, all payment options are available on the payment sheet. If the parameter is not specified, single-stage payment is used by default.
Important!If the payment type
TWO_STEP
is specified, an attempt will be made to initiate a two-stage payment, but the final result will directly depend on the payment method (card, SBP, etc.) selected by the user. 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.purchaseTwoStep(params: ProductPurchaseParams): Task<ProductPurchaseResult>
– initiates a guaranteed two-stage purchase scenario. When using this method, the payment sheet presents the user only with payment methods that support two-stage payment. During the payment process, the buyer's funds are first held and are debited only after the purchase is confirmed using theconfirmTwoStepPurchase
method.confirmTwoStepPurchase(purchaseId: PurchaseId, developerPayload: DeveloperPayload? = null)
– confirms a purchase made using two-stage payment.cancelTwoStepPurchase(purchaseId: PurchaseId)
– cancels a purchase made using two-stage payment.
ProductInteractor
– an interactor that allows you to work with products:getProducts(productsId: List<ProductId>): Task<List<Product>>
– allows you to get information about active products published in the RuStore console.
ImportantThis method returns no more than 1000 products and works without authorization or the RuStore app being installed on the user's device.
IntentInteractor
– an interactor that allows you to handle intents:proceedIntent(intent: Intent?)
– a method for handling deeplinks used for payments in banking applications. Calling this method is necessary for the correct display of the payment sheet when returning to the app from the banking application.
RuStoreUtils
block – a set of public methods, such as:isRuStoreInstalled
– checks if the RuStore app is installed on the user's device.openRuStoreDownloadInstruction
– opens a web page for downloading the RuStore app.openRuStore
– launches the RuStore app.openRuStoreAuthorization
– launches the RuStore app for authorization. After successful user authorization, the RuStore app will automatically close.
Retrieving Product List
- Kotlin
- Java
You checked that payments are available and the users are able to make purchases. Now you can request products list. Use the getProducts
method to request the information about products added to your app in RuStore Console.
RuStorePayClient.instance.getProductInteractor().getProducts(productsId = listOf(ProductId("id1"), ProductId("id2")))
.addOnSuccessListener { products: List<Product> ->
// Process success
}
.addOnFailureListener { throwable: Throwable ->
// Process error
}
productsId: List<ProductId>
— 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.
public class Product internal constructor(
public val productId: ProductId,
public val type: ProductType,
public val amountLabel: AmountLabel,
public val price: Price?,
public val currency: Currency,
public val imageUrl: Url,
public val title: Title,
public val description: Description?,
)
productId
— product ID assigned to product in RuStore Console (mandatory).type
— product type.CONSUMABLE/NON-CONSUMABLE
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.
Response examples
Product(
productId = ProductId("conProduct1"),
type = ProductType.CONSUMABLE_PRODUCT,
amountLabel = AmountLabel("100.00 rub."),
price = Price(10000),
currency = Currency("RUB"),
imageUrl = Url("https://your_image_consumable_product.png"),
title = Title("Title of a Consumable product"),
description = Description("Description of a Consumable product"),
)
Product(
productId = ProductId("nonConProduct1"),
type = ProductType.NON_CONSUMABLE_PRODUCT,
amountLabel = AmountLabel("200.00 rub."),
price = Price(20000),
currency = Currency("RUB"),
imageUrl = Url("https://your_image_non_consumable_product.png"),
title = Title("Title of a Non-consumable product"),
description = Description("Description of a Non-consumable product"),
)
You checked that payments are available and the users are able to make purchases. Now you can request products list. Use the getProducts
method to request the information about products added to your app in RuStore Console.
List<ProductId> productIds = Arrays.asList(new ProductId("id1"), new ProductId("id2"));
ProductInteractor productInteractor = RuStorePayClient.Companion.getInstance().getProductInteractor();
productInteractor.getProducts(productsId)
.addOnSuccessListener(products -> {
// Process success
})
.addOnFailureListener(throwable -> {
// Process error
});
productsId: List<ProductId>
— 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:
public class Product {
private final ProductId productId;
private final ProductType type;
private final AmountLabel amountLabel;
private final Price price;
private final Currency currency;
private final Url imageUrl;
private final Title title;
private final Description description;
public Product(ProductId productId, ProductType type, AmountLabel amountLabel, @Nullable Price price, Currency currency, Url imageUrl, Title title, @Nullable Description description) {
this.productId = productId;
this.type = type;
this.amountLabel = amountLabel;
this.price = price;
this.currency = currency;
this.imageUrl = imageUrl;
this.title = title;
this.description = description;
}
public ProductId getProductId() {
return productId;
}
public ProductType getType() {
return type;
}
public AmountLabel getAmountLabel() {
return amountLabel;
}
public @Nullable Price getPrice() {
return price;
}
public Currency getCurrency() {
return currency;
}
public Url getImageUrl() {
return imageUrl;
}
public Title getTitle() {
return title;
}
public @Nullable Description getDescription() {
return description;
}
}
productId
— product ID assigned to product in RuStore Console (mandatory).type
— product type.CONSUMABLE/NON-CONSUMABLE
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.
Response examples
Product(
productId = ProductId("conProduct1"),
type = ProductType.CONSUMABLE_PRODUCT,
amountLabel = AmountLabel("100.00 rub."),
price = Price(10000),
currency = Currency("RUB"),
imageUrl = Url("https://your_image_consumable_product.png"),
title = Title("Title of a Consumable product"),
description = Description("Description of a Consumable product"),
)
Product(
productId = ProductId("nonConProduct1"),
type = ProductType.NON_CONSUMABLE_PRODUCT,
amountLabel = AmountLabel("200.00 rub."),
price = Price(20000),
currency = Currency("RUB"),
imageUrl = Url("https://your_image_non_consumable_product.png"),
title = Title("Title of a Non-consumable product"),
description = Description("Description of a Non-consumable product"),
)
Product Purchase
- When using a 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 a 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.
Not all payment methods support two-stage payment.
- Kotlin
- Java
Payment with Purchase Type Selection
To initiate a product purchase with the option to select the payment stage, use the purchase
method.
val params = ProductPurchaseParams(
productId = ProductId("productId"),
orderId = null,
quantity = null,
developerPayload = null,
appUserId = null,
)
RuStorePayClient.instance.getPurchaseInteractor()
.purchase(params = params, preferredPurchaseType = PreferredPurchaseType.ONE_STEP)
.addOnSuccessListener { result ->
// Process result
}
.addOnFailureListener { throwable: Throwable ->
when (throwable) {
is RustorePaymentException.ProductPurchaseException -> {
// Handle failed purchase
}
is RustorePaymentException.ProductPurchaseCancelled -> {
// Handle cancelled purchase
}
else -> {
// Handle other error
}
}
}
productId
— product ID assigned to product in RuStore Console (mandatory).quantity
— product amount (optional, value1
will 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.
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 = PreferredPurchaseType.ONE_STEP
), i.e., without funds being held.
For two-stage payment, you need to specify preferredPurchaseType = PreferredPurchaseType.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)
To initiate a product purchase using the two-stage scenario, use the purchaseTwoStep
method.
When calling this method, the user will only have access to payment methods that support two-stage payment.
val params = ProductPurchaseParams(
productId = ProductId("productId"),
orderId = null,
quantity = null,
developerPayload = null,
appUserId = null,
)
RuStorePayClient.instance.getPurchaseInteractor()
.purchaseTwoStep(params)
.addOnSuccessListener { result ->
// Process result
}
.addOnFailureListener { throwable: Throwable ->
when (throwable) {
is RustorePaymentException.ProductPurchaseException -> {
// Handle failed purchase
}
is RustorePaymentException.ProductPurchaseCancelled -> {
// Handle cancelled purchase
}
else -> {
// Handle other error
}
}
}
Purchase Parameters Structure
public class ProductPurchaseParams(
public val productId: ProductId,
public val quantity: Quantity? = null,
public val orderId: OrderId? = null,
public val developerPayload: DeveloperPayload? = null,
public val appUserId: AppUserId? = null,
)
productId
— product ID assigned to product in RuStore Console (mandatory).quantity
— product amount (optional, value1
will 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.
Payment with Purchase Type Selection
To initiate a product purchase with the option to select the payment stage, use the purchase
method.
ProductPurchaseParams params = new ProductPurchaseParams(new ProductId("productId"), null, null, null, null);
RuStorePayClient ruStorePayClient = RuStorePayClient.Companion.getInstance();
PurchaseInteractor purchaseInteractor = ruStorePayClient.getPurchaseInteractor();
purchaseInteractor.purchase(params, PreferredPurchaseType.ONE_STEP)
.addOnSuccessListener(result -> {
// Process result
})
.addOnFailureListener(throwable -> {
if (throwable instanceof RustorePaymentException.ProductPurchaseException) {
// Handle failed purchase
} else if (throwable instanceof RustorePaymentException.ProductPurchaseCancelled) {
// Handle cancelled purchase
} else {
// Handle other error
}
});
productId
— product ID assigned to product in RuStore Console (mandatory).quantity
— product amount (optional, value1
will 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.
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 = PreferredPurchaseType.ONE_STEP
), i.e., without funds being held.
For two-stage payment, you need to specify preferredPurchaseType = PreferredPurchaseType.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)
To initiate a product purchase using the two-stage scenario, use the purchaseTwoStep
method.
When calling this method, the user will only have access to payment methods that support two-stage payment.
ProductPurchaseParams params = new ProductPurchaseParams(new ProductId("productId"), null, null, null, null);
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.purchaseTwoStep(params)
.addOnSuccessListener(result -> {
// Process ProductPurchaseResult
})
.addOnFailureListener(throwable -> {
if (throwable instanceof RustorePaymentException.ProductPurchaseException) {
// Handle failed purchase
} else if (throwable instanceof RustorePaymentException.ProductPurchaseCancelled) {
// Handle cancelled purchase
} else {
// Handle other error
}
});
Purchase Parameters Structure
public class ProductPurchaseParams {
private final ProductId productId;
private final Quantity quantity;
private final OrderId orderId;
private final DeveloperPayload developerPayload;
private final AppUserId appUserId;
public ProductPurchaseParams(ProductId productId, @Nullable Quantity quantity, @Nullable OrderId orderId, @Nullable DeveloperPayload developerPayload, @Nullable AppUserId appUserId) {
this.productId = productId;
this.quantity = quantity;
this.orderId = orderId;
this.developerPayload = developerPayload;
this.appUserId = appUserId;
}
public ProductId getProductId() {
return productId;
}
public @Nullable Quantity getQuantity() {
return quantity;
}
public @Nullable OrderId getOrderId() {
return orderId;
}
public @Nullable DeveloperPayload getDeveloperPayload() {
return developerPayload;
}
public @Nullable AppUserId getAppUserId() {
return appUserId;
}
}
productId
— product ID assigned to product in RuStore Console (mandatory).quantity
— product amount (optional, value1
will 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.
Purchase Confirmation
- Kotlin
- Java
Only purchases initiated using the two-stage payment scenario (i.e., with funds being held) require confirmation. Such purchases, after successful holding, will have the status PurchaseStatus.PAID
.
To debit funds from the buyer's card, the purchase must be confirmed. For this, you should use the confirmTwoStepPurchase
method.
RuStorePayClient.instance.getPurchaseInteractor().confirmTwoStepPurchase(
purchaseId = PurchaseId("purchaseId"),
developerPayload = null,
)
.addOnSuccessListener {
// Process success
}.addOnFailureListener { throwable: Throwable ->
// Process error
}
purchaseId
— product ID.developerPayload
— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization. Maximum 250 characters. If provided, it replaces the value set at the start of the purchase via thepurchase
/purchaseTwoStep
method.
Only purchases initiated using the two-stage payment scenario (i.e., with funds being held) require confirmation. Such purchases, after successful holding, will have the status PurchaseStatus.PAID
.
To debit funds from the buyer's card, the purchase must be confirmed. For this, you should use the confirmTwoStepPurchase
method.
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.confirmTwoStepPurchase(
new PurchaseId("purchaseId"),
null
).addOnSuccessListener(success -> {
// Process success
}).addOnFailureListener(throwable -> {
// Process error
});
purchaseId
— product ID.developerPayload
— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization. Maximum 250 characters. If provided, it replaces the value set at the start of the purchase via thepurchase
/purchaseTwoStep
method.
Purchase Cancellation
With our SDK you can cancel only the purchases that undergo a two-stage payment process, i.e. when the user's money is put on hold. After a successful hold, such purchases are in the PurchaseStatus.PAID
status. If a purchase is canceled it has the PurchaseStatus.REVERSED
status.
Cancel purchases if you cannot deliver your product after payment is made (when the user's money is put on hold).
To cancel a purchase (put the user's money off hold), use the cancelTwoStepPurchase
method.
- Kotlin
- Java
RuStorePayClient.instance.getPurchaseInteractor().cancelTwoStepPurchase(
purchaseId = PurchaseId("purchaseId"),
)
.addOnSuccessListener {
// Process success
}.addOnFailureListener { throwable: Throwable ->
// Process error
}
purchaseId
— product ID.
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.cancelTwoStepPurchase(
new PurchaseId("purchaseId")
).addOnSuccessListener(success -> {
// Process success
}).addOnFailureListener(throwable -> {
// Process error
});
purchaseId
— product ID.
Retrieving Purchase Details
- Kotlin
- Java
getPurchase
method.
RuStorePayClient.instance.getPurchaseInteractor().getPurchase(PurchaseId("purchaseId"))
.addOnSuccessListener { purchase: Purchase ->
// Process success
}
.addOnFailureListener { throwable: Throwable ->
// Process error
}
The method returns information about a specific purchase in any status. The purchase model is shown below.
public class Purchase internal constructor(
public val purchaseId: PurchaseId,
public val productId: ProductId,
public val invoiceId: InvoiceId,
public val orderId: OrderId?,
public val purchaseType: PurchaseType,
public val productType: ProductType,
public val description: Description,
public val purchaseTime: Date?,
public val price: Price,
public val amountLabel: AmountLabel,
public val currency: Currency,
public val quantity: Quantity,
public val status: PurchaseStatus,
public val developerPayload: DeveloperPayload?,
public val sandbox: Boolean,
)
purchaseId
— product ID. Used to obtain purchase information in the SDK via the purchase information retrieval method.productId
— product ID assigned to product in RuStore Console (mandatory).invoiceId
— invoice ID. 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
).PurchaseType
— purchase type:ONE_STEP
- one-stage payment;TWO_STEP
- two-stage payment;UNDEFINED
— number of payment stages is undefined.
productType
— product type. (CONSUMABLE
/NON-CONSUMABLE
- consumable/non-consumable.)description
- purchase description.purchaseTime
— purchase time.price
— price in minimum currency units.amountLabel
— formatted purchase price, including currency symbol.currency
— ISO 4217 currency code.quantity
— product quantity.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;REFUNDING
— refunding initiated, request sent to the acquirer;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.
-
developerPayload
— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization -
— test payment flag.
true
— test payment,false
— actual payment
Example response:
Purchase(
purchaseId = PurchaseId("purchaseId"),
productId = ProductId("productId"),
invoiceId = InvoiceId("invoiceId"),
orderId = OrderId("orderId"),
purchaseType = PurchaseType.ONE_STEP,
productType = ProductType.CONSUMABLE_PRODUCT,
description = Description("description"),
purchaseTime = Date(123123123124),
price = Price(14100),
amountLabel = AmountLabel("141,00 ₽"),
currency = Currency("RUB"),
quantity = Quantity(1),
status = PurchaseStatus.CONFIRMED,
developerPayload = DeveloperPayload("developerPayload"),
sandbox = false,
)
getPurchase
method.
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.getPurchase(new PurchaseId("purchaseId"))
.addOnSuccessListener(purchase -> {
// Process success
})
.addOnFailureListener(throwable -> {
// Process error
});
The method returns information about a specific purchase in any status. The purchase model is shown below.
public class Purchase {
private final PurchaseId purchaseId;
private final ProductId productId;
private final InvoiceId invoiceId;
private final OrderId orderId;
private final PurchaseType purchaseType;
private final ProductType productType;
private final Description description;
private final Date purchaseTime;
private final Price price;
private final AmountLabel amountLabel;
private final Currency currency;
private final Quantity quantity;
private final PurchaseStatus status;
private final DeveloperPayload developerPayload;
private boolean sandbox;
public Purchase(PurchaseId purchaseId, ProductId productId, InvoiceId invoiceId, OrderId orderId, PurchaseType purchaseType, ProductType productType, Description description, Date purchaseTime, Price price, AmountLabel amountLabel, Currency currency, Quantity quantity, PurchaseStatus status, @Nullable DeveloperPayload developerPayload, boolean sandbox) {
this.purchaseId = purchaseId;
this.productId = productId;
this.invoiceId = invoiceId;
this.orderId = orderId;
this.purchaseType = purchaseType;
this.productType = productType;
this.description = description;
this.purchaseTime = purchaseTime;
this.price = price;
this.amountLabel = amountLabel;
this.currency = currency;
this.quantity = quantity;
this.status = status;
this.developerPayload = developerPayload;
this.sandbox = sandbox;
}
public PurchaseId getPurchaseId() {
return purchaseId;
}
public ProductId getProductId() {
return productId;
}
public InvoiceId getInvoiceId() {
return invoiceId;
}
public @Nullable OrderId getOrderId() {
return orderId;
}
public PurchaseType getPurchaseType() {
return purchaseType;
}
public ProductType getProductType() {
return productType;
}
public Description getDescription() {
return description;
}
public Date getPurchaseTime() {
return purchaseTime;
}
public Price getPrice() {
return price;
}
public AmountLabel getAmountLabel() {
return amountLabel;
}
public Currency getCurrency() {
return currency;
}
public Quantity getQuantity() {
return quantity;
}
public PurchaseStatus getStatus() {
return status;
}
public @Nullable DeveloperPayload getDeveloperPayload() {
return developerPayload;
}
public boolean isSandbox() {
return sandbox;
}
}
purchaseId
— product ID. Used to obtain purchase information in the SDK via the purchase information retrieval method.productId
— product ID assigned to product in RuStore Console (mandatory).invoiceId
— invoice ID. 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
).PurchaseType
— purchase type:ONE_STEP
- one-stage payment;TWO_STEP
- two-stage payment;UNDEFINED
— number of payment stages is undefined.
productType
— product type. (CONSUMABLE
/NON-CONSUMABLE
- consumable/non-consumable.)description
- purchase description.purchaseTime
— purchase time.price
— price in minimum currency units.amountLabel
— formatted purchase price, including currency symbol.currency
— ISO 4217 currency code.quantity
— product quantity.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;REFUNDING
— refunding initiated, request sent to the acquirer;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.
-
developerPayload
— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization -
— test payment flag.
true
— test payment,false
— actual payment
Example response:
Purchase(
purchaseId = PurchaseId("purchaseId"),
productId = ProductId("productId"),
invoiceId = InvoiceId("invoiceId"),
orderId = OrderId("orderId"),
purchaseType = PurchaseType.ONE_STEP,
productType = ProductType.CONSUMABLE_PRODUCT,
description = Description("description"),
purchaseTime = Date(123123123124),
price = Price(14100),
amountLabel = AmountLabel("141,00 ₽"),
currency = Currency("RUB"),
quantity = Quantity(1),
status = PurchaseStatus.CONFIRMED,
developerPayload = DeveloperPayload("developerPayload"),
sandbox = false,
)
Retrieving Purchase List
- Kotlin
- Java
Go get the user's purchases list, use the getPurchases
method.
RuStorePayClient.instance.getPurchaseInteractor().getPurchases()
.addOnSuccessListener { purchases: List<Purchase> ->
// Process success
}
.addOnFailureListener { throwable: Throwable ->
// Process error
}
This method supports optional filtering by product type (consumable or non-consumable products). By default, the filter is disabled and will return all user purchases (regardless of product type) with statuses PAID
and CONFIRMED
. The PAID
status means that the funds have been successfully held and the purchase is awaiting confirmation from the developer.
RuStorePayClient.instance.getPurchaseInteractor().getPurchases(productType = ProductType.CONSUMABLE_PRODUCT)
.addOnSuccessListener { purchases: List<Purchase> ->
// Process success
}
.addOnFailureListener { throwable: Throwable ->
// Process error
}
Below is the purchase model.
public class Purchase internal constructor(
public val purchaseId: PurchaseId,
public val productId: ProductId,
public val invoiceId: InvoiceId,
public val orderId: OrderId?,
public val purchaseType: PurchaseType,
public val productType: ProductType,
public val description: Description,
public val purchaseTime: Date?,
public val price: Price,
public val amountLabel: AmountLabel,
public val currency: Currency,
public val quantity: Quantity,
public val status: PurchaseStatus,
public val developerPayload: DeveloperPayload?,
public val sandbox: Boolean,
)
purchaseId
— product ID. Used to obtain purchase information in the SDK via the purchase information retrieval method.productId
— product ID assigned to product in RuStore Console (mandatory).invoiceId
— invoice ID. 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
).PurchaseType
— purchase type:ONE_STEP
- one-stage payment;TWO_STEP
- two-stage payment;UNDEFINED
— number of payment stages is undefined.
productType
— product type. (CONSUMABLE
/NON-CONSUMABLE
- consumable/non-consumable.)description
- purchase description.purchaseTime
— purchase time.price
— price in minimum currency units.amountLabel
— formatted purchase price, including currency symbol.currency
— ISO 4217 currency code.quantity
— product quantity.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;REFUNDING
— refunding initiated, request sent to the acquirer;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.
-
developerPayload
— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization -
— test payment flag.
true
— test payment,false
— actual payment
Go get the user's purchases list, use the getPurchases
method.
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.getPurchases(null)
.addOnSuccessListener(purchases -> {
// Process PaymentResult
})
.addOnFailureListener(error -> {
// Process error
});
This method supports optional filtering by product type (consumable or non-consumable products). By default, the filter is disabled and will return all user purchases (regardless of product type) with statuses PAID
and CONFIRMED
. The PAID
status means that the funds have been successfully held and the purchase is awaiting confirmation from the developer.
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.getPurchases(ProductType.CONSUMABLE_PRODUCT)
.addOnSuccessListener(purchases -> {
// Process PaymentResult
})
.addOnFailureListener(error -> {
// Process error
});
Below is the purchase model.
public class Purchase {
private final PurchaseId purchaseId;
private final ProductId productId;
private final InvoiceId invoiceId;
private final OrderId orderId;
private final PurchaseType purchaseType;
private final ProductType productType;
private final Description description;
private final Date purchaseTime;
private final Price price;
private final AmountLabel amountLabel;
private final Currency currency;
private final Quantity quantity;
private final PurchaseStatus status;
private final DeveloperPayload developerPayload;
private boolean sandbox;
public Purchase(PurchaseId purchaseId, ProductId productId, InvoiceId invoiceId, OrderId orderId, PurchaseType purchaseType, ProductType productType, Description description, Date purchaseTime, Price price, AmountLabel amountLabel, Currency currency, Quantity quantity, PurchaseStatus status, @Nullable DeveloperPayload developerPayload, boolean sandbox) {
this.purchaseId = purchaseId;
this.productId = productId;
this.invoiceId = invoiceId;
this.orderId = orderId;
this.type = type;
this.description = description;
this.purchaseTime = purchaseTime;
this.price = price;
this.amountLabel = amountLabel;
this.currency = currency;
this.quantity = quantity;
this.status = status;
this.developerPayload = developerPayload;
this.sandbox = sandbox;
}
public PurchaseId getPurchaseId() {
return purchaseId;
}
public ProductId getProductId() {
return productId;
}
public InvoiceId getinvoiceId() {
return invoiceId;
}
public @Nullable OrderId getOrderId() {
return orderId;
}
public PurchaseType getPurchaseType() {
return purchaseType;
}
public ProductType getProductType() {
return productType;
}
public Description getDescription() {
return description;
}
public Date getPurchaseTime() {
return purchaseTime;
}
public Price getPrice() {
return price;
}
public AmountLabel getAmountLabel() {
return amountLabel;
}
public Currency getCurrency() {
return currency;
}
public Quantity getQuantity() {
return quantity;
}
public PurchaseStatus getStatus() {
return status;
}
public @Nullable DeveloperPayload getDeveloperPayload() {
return developerPayload;
}
public boolean isSandbox() {
return sandbox;
}
}
purchaseId
— product ID. Used to obtain purchase information in the SDK via the purchase information retrieval method.productId
— product ID assigned to product in RuStore Console (mandatory).invoiceId
— invoice ID. 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
).PurchaseType
— purchase type:ONE_STEP
- one-stage payment;TWO_STEP
- two-stage payment;UNDEFINED
— number of payment stages is undefined.
productType
— product type. (CONSUMABLE
/NON-CONSUMABLE
- consumable/non-consumable.)description
- purchase description.purchaseTime
— purchase time.price
— price in minimum currency units.amountLabel
— formatted purchase price, including currency symbol.currency
— ISO 4217 currency code.quantity
— product quantity.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;REFUNDING
— refunding initiated, request sent to the acquirer;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.
-
developerPayload
— a string with additional order information that you can set when confirming the purchase. This string overrides the value set during initialization -
— test payment flag.
true
— test payment,false
— actual payment
Checking for RuStore on the Device
The isRuStoreInstalled
methods is used to check whether RuStore is installed on the user's device. This check is needed to correctly implement handling of products and purchase. The below SDK methods require user authorization:
If RuStore is not installed on the user's device, each time the authorization screen will be displayed that might have a negative effect on user experience. Thus, if the check shows that RuStore is not installed on the user's device, it makes sense to limit the number of requests that require authorization (for more details see section Receiving payments without RuStore app).
- Kotlin
- Java
public fun isRuStoreInstalled(context: Context): Boolean
RuStoreUtils.INSTANCE.isRuStoreInstalled(context);
Checking Payment Availability
To check payment availability, call the getPurchaseAvailability
method on PurchaseInteractor. When called, the following conditions are checked.
- The company has monetization enabled via the RuStore Developer Console.
- The application must not be banned in RuStore.
- The RuStore app must be installed on the user's device.
- The user must be authorized in RuStore.
- The user must not be banned in RuStore.
If all conditions are met, PurchaseAvailabilityResult.Available
is returned. Otherwise,
PurchaseAvailabilityResult.Unavailable(val cause: Throwable)
is returned, where cause
is the error indicating the unmet condition. To check the reason for this result, you should
check the error type for RuStoreException
(these errors are described in the
Error Handling section).
- Kotlin
- Java
RuStorePayClient.instance.getPurchaseInteractor().getPurchaseAvailability()
.addOnSuccessListener { result ->
when (result) {
is PurchaseAvailabilityResult.Available -> {
// Process purchases available
}
is PurchaseAvailabilityResult.Unavailable -> {
// Process purchases unavailable
}
}
}
.addOnFailureListener { throwable ->
// Process failure error
}
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.getPurchaseAvailability()
.addOnSuccessListener(result -> {
if (result instanceof PurchaseAvailabilityResult.Available) {
// Process purchases available
} else if (result instanceof PurchaseAvailabilityResult.Unavailable) {
RuStoreException exception = ((PurchaseAvailabilityResult.Unavailable) result).getCause();
// Process purchases unavailable
}
})
.addOnFailureListener(throwable -> {
// Process errors
});
Purchase Status Model
One-stage payment status model.
Two-stage payment status model.
Purchase Result Structure
- Kotlin
- Java
public class ProductPurchaseResult internal constructor(
public val orderId: OrderId?,
public val purchaseId: PurchaseId,
public val productId: ProductId,
public val invoiceId: InvoiceId,
public val purchaseType: PurchaseType,
public val sandbox: Boolean,
)
public class ProductPurchaseResult {
private final OrderId orderId;
private final PurchaseId purchaseId;
private final ProductId productId;
private final InvoiceId invoiceId;
private final PurchaseType purchaseType;
private final boolean sandbox;
// Constructor
public ProductPurchaseResult(OrderId orderId, PurchaseId purchaseId, ProductId productId, InvoiceId invoiceId, PurchaseType purchaseType, boolean sandbox) {
this.orderId = orderId;
this.purchaseId = purchaseId;
this.productId = productId;
this.invoiceId = invoiceId;
this.purchaseType = purchaseType;
this.sandbox = sandbox;
}
// Getters
public OrderId getOrderId() {
return orderId;
}
public PurchaseId getPurchaseId() {
return purchaseId;
}
public ProductId getProductId() {
return productId;
}
public InvoiceId getInvoiceId() {
return invoiceId;
}
public PurchaseType getPurchaseType() {
return purchaseType;
}
public boolean isSandbox() {
return sandbox;
}
}
-
ProductPurchaseResult
— the result of a successful digital product payment (for single-stage payment) or successful funds holding (for two-stage payment).purchaseId
- purchase identifier. Used to obtain purchase information in the SDK via the purchase information retrieval method.productId
- identifier of the purchased product, specified when created in the RuStore developer console.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).purchaseType
- purchase type (ONE_STEP
/TWO_STEP
- single-stage/two-stage).sandbox
- flag indicating a test payment in the sandbox. IfTRUE
, the purchase was made in test mode.
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:
- Kotlin
- Java
public class ProductPurchaseException internal constructor(
public val orderId: OrderId?,
public val purchaseId: PurchaseId?,
public val productId: ProductId?,
public val invoiceId: InvoiceId?,
public val quantity: Quantity?,
public val purchaseType: PurchaseType?,
public override val cause: Throwable,
) : RustorePaymentException(message = "Error purchase product", cause = cause)
public class ProductPurchaseCancelled internal constructor(
public val purchaseId: PurchaseId?,
public val purchaseType: PurchaseType?,
)
public class ProductPurchaseException extends RustorePaymentException {
private final OrderId orderId;
private final PurchaseId purchaseId;
private final ProductId productId;
private final InvoiceId invoiceId;
private final Quantity quantity;
private final PurchaseType purchaseType;
public ProductPurchaseException(OrderId orderId, PurchaseId purchaseId, ProductId productId, InvoiceId invoiceId, Quantity quantity, PurchaseType purchaseType, Throwable cause) {
super("Error purchase product", cause);
this.orderId = orderId;
this.purchaseId = purchaseId;
this.productId = productId;
this.invoiceId = invoiceId;
this.quantity = quantity;
this.purchaseType = purchaseType;
}
public OrderId getOrderId() {
return orderId;
}
public PurchaseId getPurchaseId() {
return purchaseId;
}
public ProductId getProductId() {
return productId;
}
public InvoiceId getInvoiceId() {
return invoiceId;
}
public Quantity getQuantity() {
return quantity;
}
public PurchaseType getPurchaseType() {
return purchaseType;
}
}
public class ProductPurchaseCancelled {
private final PurchaseId purchaseId;
private final PurchaseType purchaseType;
public ProductPurchaseCancelled(PurchaseId purchaseId, PurchaseType purchaseType) {
this.purchaseId = purchaseId;
this.purchaseType = purchaseType;
}
public PurchaseId getPurchaseId() {
return purchaseId;
}
public PurchaseType getPurchaseType() {
return purchaseType;
}
}
Server Validation of Purchase
- Kotlin
- Java
If you need to validate a successful purchase on the RuStore server, you can use the invoiceId
from the ProductPurchaseResult.SuccessProductPurchaseResult
model returned after a successful product purchase.
val params = ProductPurchaseParams(ProductId("productId"))
RuStorePayClient.instance.getPurchaseInteractor()
.purchase(params = params, preferredPurchaseType = PreferredPurchaseType.TWO_STEP)
.addOnSuccessListener { result ->
if (result is ProductPurchaseResult.SuccessProductPurchaseResult) {
val invoiceId = result.invoiceId.value
yourApi.validate(invoiceId)
}
}
You can also get the invoiceId
in the Purchase
model. The Purchase
model can be obtained using the getPurchases()
method or the getPurchase
method.
RuStorePayClient.instance.getPurchaseInteractor().getPurchases()
.addOnSuccessListener { purchases ->
purchases.forEach { purchase ->
yourApi.validate(purchase.invoiceId.value)
}
}
If you need to validate a successful purchase on the RuStore server, you can use the invoiceId
from the ProductPurchaseResult.SuccessProductPurchaseResult
model returned after a successful product purchase.
ProductInteractor productInteractor = RuStorePayClient.Companion.getInstance().getProductInteractor();
ProductPurchaseParams params = new ProductPurchaseParams(new ProductId("productId"), null, null, null);
productInteractor.purchase(params, PreferredPurchaseType.TWO_STEP)
.addOnSuccessListener(result -> {
if (result instanceof ProductPurchaseResult.SuccessProductPurchaseResult) {
ProductPurchaseResult.SuccessProductPurchaseResult successResult = (ProductPurchaseResult.SuccessProductPurchaseResult) result;
String invoiceId = successResult.getinvoiceId().getValue();
yourApi.validate(invoiceId);
}
});
You can also get the invoiceId
in the Purchase
model. The Purchase
model can be obtained using the getPurchases()
method or the getPurchase
method.
PurchaseInteractor purchaseInteractor = RuStorePayClient.Companion.getInstance().getPurchaseInteractor();
purchaseInteractor.getPurchases()
.addOnSuccessListener(purchases -> {
for (Purchase purchase : purchases) {
yourApi.validate(purchase.getinvoiceId().getValue());
}
})
.addOnFailureListener(error -> {
// Process error
});
Error Handling
RuStorePaymentNetworkException
— SDK network communication error;RuStorePaymentCommonException
— general SDK error;RuStorePayClientAlreadyExist
— duplicate initialization error SDK;RuStorePayClientNotCreated
— attempt to access public SDK interface before initialisation;RuStorePayInvalidActivePurchase
— payment initiated for unknown product type;RuStorePayInvalidConsoleAppId
— the required parameterconsole_app_id_value
for SDK initialization is not specified;RuStorePaySignatureException
— invalid signature (occurs because of fraud actions);EmptyPaymentTokenException
— error receiving payment token;RuStoreNotInstalledException
— RuStore is not installed on the user's device;RuStoreOutdatedException
— RuStore version installed on the user's device does not support this SDK;RuStoreUserUnauthorizedException
— user is not authorized in RuStore;RuStoreApplicationBannedException
— app is banned in RuStore RuStore;RuStoreUserBannedException
— user is blocked in RuStore;ProductPurchaseException
— product purchase error;ProductPurchaseCancelled
— product purchase was cancelled (the user closed the payment sheet);RuStoreException
— basic RuStore error from which other errors are inherited.