- Prerequisites
- Required parameters
- Configure example app
- Use scenario
- Deeplink handling
- Distribution terms
- Technical support
For in-app payments to work, the following requirements must be met.
-
The RuStore app must be installed on the user's device.
-
The user and the app are not banned in RuStore.
-
In-app purchases for the app are enabled in RuStore Console.
The service has some restrictions to work outside of Russia.
To correctly configure the example app, you need to have the following parameters:
-
consoleApplicationId
- application code from RuStore Console (example: https://console.rustore.ru/apps/123456), in our exampleconsoleApplicationId
= 123456 -
applicationId
- value from the app you published in the RuStore Console, it is in the build.gradle of your projectandroid { defaultConfig { applicationId = "ru.rustore.sdk.billingexample" } }
-
availableProductIds
- subscriptions and single purchases available in your app -
release.keystore
- signature that was used to sign your app in the RuStore Console. -
release.properties
- this file must contain the parameters of the signature that was used to sign your app published in the RuStore Console. Working with signature keys for APK files
To test your app, you can use our sandbox.
-
Specify
consoleApplicationId
of your app inRuStoreBillingClientFactory.INSTANCE.create()
:private static RuStoreBillingClient ruStoreBillingClient = RuStoreBillingClientFactory.INSTANCE.create( app, "2063535084", // consoleApplicationId "ru.edudin.rustoreqrscanner", // deeplinkScheme null, null, true );
-
Replace
applicationId
in build.gradle, with applicationId of the APK file that you published in the RuStore Console:android { defaultConfig { applicationId = "ru.rustore.sdk.billingexample" } }
-
In the
cert
folder replace therelease.keystore
certificate with the certificate of your app, also, inrelease.properties
configure parameterskey_alias
,key_password
, andstore_password
. Therelease.keystore
signature must match the signature tha 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). -
In
StartFragment
of thegetProducts
method list subscriptions and consumable products available in your app:Arrays.asList( "productId1", "productId2", "productId3" )
-
Run your project and test your app performance
On app start, in the onViewCreated
method of StartFragment
, payments availability is checked.
Pressing the 'getProducts()' button triggers retrieving and displaying the products list
Pressing the 'getPurchases()' buttion triggers retrieving and displaying the purchases list
Pressing an item with a product name triggers the product purchase scenario with the payment method screen display. Then, if PaymentResult.Success -> is returned, purchase confirmation is triggered.
This section does not apply to the example app configuration. It contains the information on how to correctly configure deeplink
in your app.
deeplinkScheme
— a deeplink scheme required to return the user to your app after making a payment in a third-party app (for example: in SberPay or SBP). SDK generates its host for this scheme.
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. To achieve this, specify intent-filter with the scheme of your project in AndroidManifest.xml
.
-
In the data android:scheme parameter of your
AndroidManifest.xml
file specify the deeplink URL address (it must matchdeeplinkScheme
from item 1)<activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <data android:scheme="rustoresdkexamplescheme" /> // Replace with your deeplink </intent-filter> </activity>
-
Specify
deeplinkScheme
of your app inRuStoreBillingClientFactory.INSTANCE.create
:private static RuStoreBillingClient ruStoreBillingClient = RuStoreBillingClientFactory.INSTANCE.create( app, "184050", "rustoresdkexamplescheme", null, null, null, true );
-
Next, add the following code to the Activity you need to return to after making the payment (your store page):
public class MainActivity extends AppCompatActivity { private static final RuStoreBillingClient billingClient = YourDependencyInjection.provideRuStorebillingClient(); public MainActivity() { super(R.layout.activity_main); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { billingClient.onNewIntent(getIntent()); } } @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); billingClient.onNewIntent(intent); } }
-
To restore your app state after returning from deeplink, add android:launchMode="singleTask" to your
AndroidManifest.xml
<activity android:name=".MainActivity" android:launchMode="singleTask" android:exported="true" android:screenOrientation="portrait" android:windowSoftInputMode="adjustResize">
This software, including its source code, binary libraries, and other files is distributed under the MIT license. The license information is available in the MIT-LICENSE.txt
document
If you have any questions regarding SDK Billing, please, follow this link.