Risk Android SDK
Last updated: April 30, 2025
The checkout-risk-sdk-android
SDK captures advanced fraud signals that are leveraged in our machine-learning model for fraud scoring.
Information
To enable access to the Risk Android SDK, contact your account manager or [email protected].
You must generate a public API key from your Dashboard.
The minimum requirements to use the SDK are:
- Android API level 21 (Android 5.0) or later as a build target
- Compatibility with targetSdk versions
21
to33
- Import the SDK.
- Initialize the SDK.
- Publish the device data.
- Complete the data safety questionnaire.
- Add the Risk Android SDK as a dependency from GitHub.
Information
For the installation steps and available versions, see the jitpack.io/frames-android documentation.
- Add the JitPack repository to your project-level
build.gradle
file:
1// project gradle file23allprojects {4repositories {5maven { url 'https://jitpack.io' }6maven { url = uri("https://maven.fpregistry.io/releases") }7}8}
- Add the Risk SDK dependency to the module gradle file:
1// module gradle file23dependencies {4implementation 'com.github.checkout:checkout-risk-sdk-android:<latest_version>'5}
To ensure you have the correct build configuration, make sure you:
- Add the Jitpack repository to the project gradle file.
- Add the dependency to the module gradle file.
To initialize the package, call the Risk.getInstance()
method and pass the following:
- API key
- Environment
1// Example usage of package23val yourConfig = RiskConfig(publicKey = "pk_qa_xxx", environment = RiskEnvironment.QA)45// Initialize the package with the getInstance method early-on6val riskInstance =7Risk.getInstance(8context,9RiskConfig(10BuildConfig.SAMPLE_MERCHANT_PUBLIC_KEY,11RiskEnvironment.QA,12false,13),14).let {15it?.let {16it17} ?: run {18null19}20}
When the customer selects to pay, publish the device data by calling the publishData()
method on the Risk instance and retrieve the deviceSessionId
:
1// Publish the device data with the publishData method23riskInstance?.publishData().let {4if (it is PublishDataResult.Success) {5println("Device session ID: ${it.deviceSessionId}") // dsid_XXXX6}7}
The getInstance
method returns a single instance of Risk
. When you call the method, Checkout.com performs preliminary checks and retrieves the public keys to initialize the package to collect device data.
If the checks fail or the merchant is disabled, the method returns null
.
If the checks are successful, the method returns an instance of Risk
to the package consumer.
- Call the
publishData()
method on the instance to publish the data.
1data class RiskConfig(val publicKey: String, val environment: RiskEnvironment, val framesMode: Boolean = false)23// Instance creation of Risk Android package4public class Risk private constructor(...) {5public companion object {6...7public suspend fun getInstance(applicationContext: Context, config: RiskConfig): Risk? {8...9}10}11}1213enum class RiskEnvironment {14SANDBOX,15PROD16}
1class Risk private constructor(...) {2companion object {3...4suspend fun publishData(...): ... {5...6}7}8}
Call the publishData()
method to publish and persist the device data.
1public suspend fun publishData(cardToken: string? = null): PublishDataResult {2...3}
1public sealed class PublishDataResult {2public data class Success(val deviceSessionId: String) : PublishDataResult()34public data object PublishFailure : PublishDataResult()5}
1// Example usage of package2val yourConfig = RiskConfig(publicKey = "pk_qa_xxx", environment = RiskEnvironment.QA)34// Initialize the package with the getInstance method5val riskInstance =6Risk.getInstance(7context,8RiskConfig(9BuildConfig.SAMPLE_MERCHANT_PUBLIC_KEY,10RiskEnvironment.QA,11false,12),13).let {14it?.let {15it16} ?: run {17null18}19}2021// Publish the device data with the publishData method when the user selects the option to pay2223riskInstance?.publishData().let {24if (it is PublishDataResult.Success) {25println("Device session ID: ${it.deviceSessionId}") // dsid_XXXX26}27}
When you submit your app to Google Play, provide the required responses in your Data safety form.