Migrating to Pay SDK
Pay SDK works differently than billingClient SDK.
This section contains key differences with billingClient SDK that are worth paying attention to. All the details with code examples can be found in our documentation for a specific Pay SDK version.
# List of dependencies
Pay SDK has a shorter list of dependencies.
Connecting to project
On connecting a dependency, keep in mind that the SDK name is different (pay
instead of billingclient
):
- BillingClient SDK:
implementation("ru.rustore.sdk:billingclient")
. - Pay SDK:
implementation("ru.rustore.sdk:pay")
.
Initialization
The way consoleApplicationId
is specified is different during the initialization:
- BillingClient SDK: in the
build.gradle
file, call theRuStoreBillingClientFactory.create()
method and passconsoleApplicationId
inside this method. - Pay SDK: in the
manifest.xml
file, includemeta-data
withconsole_app_id_key
.deeplinkScheme
,themeProvider
,externalPaymentLoggerFactory
, anddebugLogs
are not specified.
Payments availability check
-
The method to check purchase availability changed:
- BillingClient SDK:
RuStoreBillingClient.Companion.checkPurchasesAvailability()
. - Pay SDK:
RuStorePayClient.getPurchaseInteractor().getPurchaseAvailability()
.
- BillingClient SDK:
-
Method responses changed:
- BillingClient SDK:
FeatureAvailabilityResult.Available
andFeatureAvailabilityResult.Unavailable(val cause: RuStoreException)
. - Pay SDK:
PurchaseAvailabilityResult.Available
andPurchaseAvailabilityResult.Unavailable(val cause: Throwable)
.
- BillingClient SDK:
Retrieving products list
-
Getting products list in Pay SDK does not require user authorization.
-
You can request up to 1000 items per request as compared to 100 in billingClient SDK.
-
The method for receiving products list changed:
- BillingClient SDK:
billingClient.products productsUseCase.getProducts()
. - Pay SDK:
RuStorePayClient.getProductInteractor().getProducts()
.
- BillingClient SDK:
-
The structure of the returned product model changed. The table below contains the lists of fields returned from both SDKs. To view fields descriptions, see the billingClient SDK documentation and Pay SDK documentation.
BillingClient SDK | Pay SDK |
---|---|
productId | productId |
productType | type |
productStatus | — |
priceLable | amountLabel |
price | price |
currency | currency |
language | — |
title | title |
description | description |
imageUrl | imageUrl |
promoImageUrl | — |
subscription | — |
Retrieving list of purchases
Changed method for retrieving purchases list:
- BillingClient SDK:
billingClient.purchases purchasesUseCase.getPurchases()
. - Pay SDK:
RuStorePayClient.getPurchaseInteractor().getPurchases()
.
Retrieving purchase information
-
Changed method for retrieving purchase information:
- BillingClient SDK:
billingClient.purchases purchasesUseCase.getPurchaseInfo()
. - Pay SDK:
RuStorePayClient.getPurchaseInteractor().getPurchase()
.
- BillingClient SDK:
-
The structure of the returned purchase model changed. The table below contains the lists of fields returned from both SDKs. To view fields descriptions, see the billingClient SDK documentation and Pay SDK documentation.
BillingClient SDK | Pay SDK |
---|---|
purchaseId | purchaseId |
productId | productId |
invoiceId | invoiceId |
language | — |
purchaseTime | purchaseTime |
orderId | orderId |
— | purchaseType |
— | productType |
— | description |
amountLable | amountLable |
amount | price |
currency | currency |
quantity | quantity |
purchaseState | Status |
developerPayload | developerPayload |
subscriptionToken | subscriptionToken |
-
Purchase status model (
Status
) and available statuses list changed.Now, there are no different statuses for consumable and non-consumable products. Instead, one-stage and two-stage purchase models are used.
The table below contains possible statuses for each SDK. To view the status model and status values, see the billingClient SDK documentation and Pay SDK documentation.
BillingClient SDK | Pay SDK |
---|---|
CREATED | — |
INVOICE_CREATED | INVOICE_CREATED |
PAID | PAID |
CONFIRMED | CONFIRMED |
CONSUMED | — |
CANCELLED | CANCELLED |
PAUSED | — |
TERMINATED | — |
— | PROCESSING |
— | EXPIRED |
— | REJECTED |
— | REVERSED |
— | REFUNDED |
Product purchase
-
Product purchase method is replaced with two new methods:
-
BillingClient SDK:
billingClient.purchases purchasesUseCase.purchaseProduct()
. -
Pay SDK:
RuStorePayClient.instance.getPurchaseInteractor().purchaseOneStep()
— one-stage payment with no money hold period. The money is withdrawn from the buyer's account and the commission fee is applied instantly. In case of a refund, the money will be returned to the buyer but the commission fee will not be returned to the developer.RuStorePayClient.instance.getPurchaseInteractor().purchaseTwoStep()
— two-stage payment with a money hold period. The buyer authorizes payment and their money is put on hold on their account. What the payment is confirmed, the money is withdrawn from the buyers account and the commission fee is applied to the developer. Otherwise, the money is released from hold on the buyer's account and no commission fee is applied to the developer.
-
-
Method responses changed:
- BillingClient SDK:
Success
,Failure
,Cancelled
, andInvalidPaymentState
. - Pay SDK:
SuccessProductPurchaseResult
,FailureProductPurchaseResult
, andCancelProductPurchaseResult
.
- BillingClient SDK:
Server validation
For server validation of single purchases, the following is used:
- BillingClient SDK:
subscriptionToken
that can be retrieved on a successful payment fromPaymentResult.Success
. - Pay SDK:
invoiceId
. See API: Getting payment data by ID (v2).
Confirming purchase
Changed method to confirm purchase:
- BillingClient SDK:
billingClient.purchases purchasesUseCase.confirmPurchase()
. - Pay SDK:
RuStorePayClient.getPurchaseInteractor().confirmTwoStepPurchase()
— confirm a two-step purchase.
Purchase cancellation
Changed method to cancel purchase:
- BillingClient SDK:
billingClient.purchases purchasesUseCase.deletePurchase()
- Pay SDK:
RuStorePayClient.getPurchaseInteractor().cancelTwoStepPurchase()
— cancel a two-stage purchase.
Feature is under development
Pay SDK is in beta and it does not include some billingClient SDK features, such as:
- purchasing without RuStore installed on the user's device;
- working with app subscriptions;
- test payments (sandbox);
- payment methods other than bank card;
- dark theme for payment screen.
We will inform you about adding new features. Check for updates.
See also
- Pay SDK description
- List of dependencies
- Pay SDK Kotlin/Java
- Pay SDK Godot
- Pay SDK Unity
- Pay SDK Flutter
Release Notes
Migrating to Pay SDK 7.0.0
Instruction on migrating from BillingClient SDK to Pay SDK 7.0.0. Differences from the previous version:
- Single payment method is now replaced with two new methods for one-stage and two-stage payment.
- One-stage and two-stage purchase status models are used instead of consumable and non-consumable purchase status models.
- The
CONSUMED
status is now replaced with theCONFIRMED
status. - The
consumePurchase
method is now replaced with theconfirmTwoStepPurchase
method for two-stage payments. - New method for purchase cancellation in case of a two-stage payment.
Migrating to Pay SDK 6.1.0
The first version of migration instruction from BillingClient SDK to Pay SDK 6.1.0.