Skip to main content
Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

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 the RuStoreBillingClientFactory.create() method and pass consoleApplicationId inside this method.
  • Pay SDK: in the manifest.xml file, include meta-data with console_app_id_key. deeplinkScheme, themeProvider, externalPaymentLoggerFactory, and debugLogs are not specified.

Payments availability check

  • The method to check purchase availability changed:

    • BillingClient SDK: RuStoreBillingClient.Companion.checkPurchasesAvailability().
    • Pay SDK: RuStorePayClient.getPurchaseInteractor().getPurchaseAvailability().
  • Method responses changed:

    • BillingClient SDK: FeatureAvailabilityResult.Available and FeatureAvailabilityResult.Unavailable(val cause: RuStoreException).
    • Pay SDK: PurchaseAvailabilityResult.Available and PurchaseAvailabilityResult.Unavailable(val cause: Throwable).

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().
  • 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 SDKPay SDK
productIdproductId
productTypetype
productStatus
priceLableamountLabel
priceprice
currencycurrency
language
titletitle
descriptiondescription
imageUrlimageUrl
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().
  • 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 SDKPay SDK
purchaseIdpurchaseId
productIdproductId
invoiceIdinvoiceId
language
purchaseTimepurchaseTime
orderIdorderId
purchaseType
productType
description
amountLableamountLable
amountprice
currencycurrency
quantityquantity
purchaseStateStatus
developerPayloaddeveloperPayload
subscriptionTokensubscriptionToken
  • 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 SDKPay SDK
CREATED
INVOICE_CREATEDINVOICE_CREATED
PAIDPAID
CONFIRMEDCONFIRMED
CONSUMED
CANCELLEDCANCELLED
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, and InvalidPaymentState.
    • Pay SDK: SuccessProductPurchaseResult, FailureProductPurchaseResult, and CancelProductPurchaseResult.

Server validation

For server validation of single purchases, the following is used:

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

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 the CONFIRMED status.
  • The consumePurchase method is now replaced with the confirmTwoStepPurchase 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.