ClearSale SDK (Android)

The Yuno ClearSale SDK provides device fingerprinting and fraud prevention capabilities by integrating with ClearSale. This SDK is distributed separately as com.yuno.fraud-prevention:clearsale and is designed to complement the Yuno Payments SDK.

By collecting device information and generating a sessionId, the ClearSale SDK helps enhance fraud prevention during the payment flow.

Requirements

Before starting the integration:

  • Ensure you have an active ClearSale account and obtain your ClearSale App Key. This key is required to initialize the SDK.
  • Have a working integration of the Yuno Payments SDK in your Android project.
  • Ensure the project meets the general requirements for Yuno Android SDKs.

Adding the YunoAntiFraud ClearSale library to the project

Add the YunoAntiFraud ClearSale dependency to the application build.gradle file:

dependencies {
    implementation 'com.yuno.fraud-prevention:clearsale:{last_version}'
}

Permissions

We include the INTERNET permission by default as ClearSale needs them,

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

Optional

If you want to include location data, you must add the location permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

And you must add the location dependencies to your app's build.gradle:

dependencies {
    implementation 'com.google.android.gms:play-services-location:17.0.0'
}

Step 1: Include the library

Add the ClearSale SDK as a dependency in your Gradle configuration:

dependencies {
    implementation "com.yuno.fraud-prevention:clearsale:{last_version}"
}

You must also include the Yuno Payments SDK to handle payment flows.

Step 2: Initialize ClearSale SDK

The ClearSale SDK requires explicit lifecycle integration. You must call the provided functions from your Activity or Fragment lifecycle methods.

Initialize the SDK

Call onCreateYunoClearSale() in your onCreate() method (Activity) or onCreateView() (Fragment):

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    onCreateYunoClearSale("<your-clear-sale-app-key>")
}

Start session and collect device information

Call onResumeYunoClearSale() in your onResume() method. This function generates a new sessionId, starts data collection, and returns the sessionId string:

override fun onResume() {
    super.onResume()
    val sessionId = onResumeYunoClearSale()
}

You should persist this sessionId (for example, in your app state or backend) so it can later be passed to the Yuno Payments SDK.

Stop ClearSale session

Call onStopYunoClearSale() in your onStop() method to release resources:

override fun onStop() {
    super.onStop()
    onStopYunoClearSale()
}

Step 3: Share the ClearSale Session ID with Yuno Payments

The sessionId generated by ClearSale must be shared with the Yuno Payments SDK to complete the fraud-prevention integration. Pass the sessionId to the merchantSessionId parameter when starting the checkout flow:

startPayment(
    callbackOTT = { oneTimeToken ->
        // ...
    },
    merchantSessionId = sessionId,
    // ...
)

// or

startPaymentLite(
    callbackOTT = { oneTimeToken ->
        // ...
    },
    merchantSessionId = sessionId,
    // ...
)

Summary of Lifecycle Calls

  • onCreateYunoClearSale(appKey) → Call once in onCreate()
  • onResumeYunoClearSale() → Call in onResume() to generate and retrieve sessionId
  • onStopYunoClearSale() → Call in onStop() to stop session tracking