Setting up the environment
Warning
Supported Android SDK version: 7.0 and higher.
If your project's minSdkVersion is 23 or lower, see Setup for devices with Android version lower than 7.0.
Before you start the integration, obtain the following IDs and add them to your project:
- Merchant ID
- SHA256 Fingerprints
- Client ID (
YANDEX_CLIENT_ID
) - Android package name (
applicationId
)
Step 1. Obtain the required IDs
-
Get the SHA256 Fingerprints hash value using the
keytool
utility:keytool -list -v -alias <your-key-name> -keystore <path-to-production-keystore>
Once you enter the command, the hash value will be shown under
Certificate fingerprints: SHA256
. -
To register the app, go to Yandex OAuth.
-
In the Service name field, enter the name to be displayed to users on the authorization screen.
-
Under Platforms, select Android app and set its parameters:
- Android package name: Unique app name from the project config file's
applicationId
. - SHA256 Fingerprints: SHA256 hash value from step 1.
- Android package name: Unique app name from the project config file's
-
Make sure that your app has access to Yandex Payadded in Yandex OAuth. To do this, select Paying via Yandex Pay in the Permission name field of the Data access section.
-
Click Create app and copy the Client ID field value.
-
On the Settings page of the Yandex Pay dashboard, specify the Client ID, SHA256, and Android package name values in the Client ID, SHA256 Fingerprint, and Android package name fields, respectively.
Step 2. Enable the Client ID
Specify the resulting Client ID in the build.gradle
build script as the YANDEX_CLIENT_ID
value in manifestPlaceholders
:
android {
defaultConfig {
manifestPlaceholders = [
// Use your Client ID
YANDEX_CLIENT_ID: "12345678901234567890",
]
}
}
Step 3. Initialize FirebaseApp in all the app's workflows
The Mobile SDK uses AppMetrica services to ensure the stable operation of the SDK. This step helps fix the Firebase and AppMetrica service compatibility issues.
If Firebase is used along with the Yandex Pay SDK, call FirebaseApp.initialize(context)
in all the app's workflows.
If you use AppMetrica in your app, be sure to activate YandexMetrica after Firebase is initialized.
Example
// don`t forget declare MyApplication in AndroidManifest.xml in <application/> block using android:name
class MyApplication: Application() {
override fun onCreate() {
// inited at every app processes
FirebaseApp.initializeApp(this)
}
}
For more information about the interaction, see AppMetrica stopped working after Firebase was updated.
Setup for devices with Android version lower than 7.0
Owners of devices with Android 7.0 (API level 24) or higher can use the Yandex Pay SDK without any restrictions. There may be restrictions for devices with Android version lower than 7.0:
- No official support.
- Limited SDK library functionality.
- Additional environment setup is required as described below.
-
Enable the SDK library distribution in your project's
build.gradle
file:dependencies{ ... implementation "com.yandex.pay:*pay/token/other*:*version*" ... }
-
Sync the project and try to build it. This should result in the manifest merger error:
Manifest merger failed : uses-sdk:minSdkVersion *Your min version* cannot be smaller than version 24 declared in library
-
Open the AndroidManifest.xml file of the module where you're adding the dependency and list all the libraries this error refers to.
Example:
<manifest xmlns:tools="http://schemas.android.com/tools"> <uses-sdk tools:overrideLibrary="com.yandex.pay, ...* other libraries *... ,com.yandex.pay.base"/> </manifest>
-
Check if the SDK is supported via the YPay object and initialize all the necessary components after the check:
if (YPay.isSupported){ // init Yandex pay } else { // do some other logic }
Warning
Run the
YPay.isSupported
availability check each time the Yandex Pay SDK is accessed.