Non-Seamless Flow - Android
This section provides step-by-step procedure for integrating the Tridentity SDK into an Android application using the non-seamless flow. In this approach, the SDK handles both the business logic and the UI rendering while supporting configuration for app-specific themes.
1. Gradle Changes
Add the required dependencies to your app's build.gradle
file:
android {
dependencies {
implementation files('libs/<Tridentity_SDK>.aar')
// Other required dependencies for Tridentity SDK
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'org.bouncycastle:bcprov-jdk15+:1.46'
implementation 'com.nimbusds:nimbus-jose-jwt:7.4'
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation 'com.scottyab:rootbeer-lib:0.1.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.23'
implementation 'com.romainpiel.shimmer:library:1.4.0@aar'
implementation 'com.airbnb.android:lottie:5.0.3'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
}
}
2. Manifest Changes
Tridentity SDK supports different modes of authenticating a transaction. As per business needs, permission has to be provided in App manifest to proceed with Tridentity SDK services. Table 1.1 shows the permissions needed as per the modes enabled
Modes supported in the SDK:
-
Push Notification
-
Push with Biometric
-
Biometric based
-
Offline OTP
Permission | Description | Mandatory for Modes |
---|---|---|
Post notification | Mandatory for version13 and above to receive push notification |
|
Phone State | Mandatory to detect sim swap scenarios |
|
SMS | For auto send of SMS if SDK is enabled for binding the device |
|
Add the following permissions to your app's AndroidManifest.xml
file:
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
3. Configuration of SDK
Invoke the following method of the SDK to configure the client details. All the security checks and mandatory permissions required for the SDK will be validated during this call. In case if any security check fails or permission not granted, specific error message will be provided in the callback and the calling app should terminate the flow by showing appropriate message to the user. Configure the SDK with client details using the appropriate parameters. This configuration validates security checks and permissions.
Parameters
Parameter & Constraints | Remarks | Mandatory for Modes |
---|---|---|
context
| Application Context | All |
clientId
| Will be shared offline | All |
env
| Default - UAT. For production, to be passed as "PROD" | All |
authType
| To be passed as "Biometric", if authentication mode enabled is Biometric based. | Biometric |
biometricRetryCount
| Default count configured in the SDK is 3. Can be in the range of 0-3 To be passed if authentication mode enabled is Biometric based or for push with biometric mode. |
|
BIN | First 6 digit of the card used for the transaction | Biometric |
bankLogoUrl | Logo of the issuer against which card has been issued | Biometric |
merchantName | Name of the recipient | Biometric |
Note:From the response event in the onSuccess method check for the message flag to get Configuration status.
Sample Configuration
val configObject = JSONObject()
configObject.put("env", "UAT") // UAT or PROD
configObject.put("clientId", "")
TridentitySDK.getInstance().configSdk(
context,
configObject,
object : ConfigStatusCallback {
override fun onSuccess(event: JSONObject) {
// Handle success
}
override fun onError(errorCode: Int, errorDesc: String) {
// Handle error
}
}
)
4. Initialization of FCM
This section details how to pass the FCM token to the SDK for sending push notifications. This method should be called before initiating registration and whenever a new FCM token is generated. It is applicable only if the authentication mode enabled is either "Push notification" or "Push with Biometric."
Parameters
Parameter | Description |
---|---|
context
| Application Context |
fcmToken
| Token generated by Firebase Messaging service |
Code Example
TridentitySDK.getInstance().registerFCM(applicationContext, token,
object : FCMRegistrationCallback {
override fun onSuccess(event: JSONObject) {
Log.d("TAG", "onSuccess: $event")
}
override fun onError(code: Int, error: String) {
// Handle error
}
}
)
5. Customer Enrolment
This section details the process of enrolling a user for Tridentity authentication.
Parameters
Parameter | Description |
---|---|
activity
| Instance of AppCompatActivity |
mobileNumber
| Mobile number of the user prefixed with country code |
uid
| Unique identifier for the user if BIN is passed in SDK configuration |
Note:From the response object in the onSuccess method, check for the message flag to get the status.
Code Example
val regObject = JSONObject()
regObject.put("mobileNumber", "919876543210")
TridentitySDK.getInstance().initiateRegistration(
activity,
regObject,
object : RegistrationStatusCallBack {
override fun onSuccess(event: JSONObject) {
// Handle success
}
override fun onError(code: Int, error: String) {
// Handle error
}
}
)
6. Check Registration Status
Use this method to check the current registration status of a user in the Tridentity system.
Parameters
Parameter | Description |
---|---|
context
| Application Context |
clientId
| Client ID |
mobileNumber
| Mobile number of the user against which the card is registered prefixed with country code |
uid
| Any other unique identifier of the user if BIN is passed as part of configuring the SDK |
Code Example
TridentitySDK.getInstance().checkRegistrationStatus(context,
object : RegistrationStatusCallBack {
override fun onSuccess(event: JSONObject) {
// Handle the registration status response
// Check for specific status codes or messages
}
override fun onError(code: Int, error: String) {
// Handle error
}
}
)
7. Process Transaction
This method is used to authenticate transactions through the Tridentity SDK.
Parameters
Parameter & Constraints | Remarks | Mandatory for Modes |
---|---|---|
context
| Context of the transaction. | All |
remoteMessage | Message received from push notification |
|
buildNotification | Default value: False |
|
jsonObject | Refer to Parameters for jsonObject | Biometric |
Parameters for jsonObject
Parameter | Description |
---|---|
txnId
| Unique transaction identifier |
clientID
| Client identifier |
amount
| Transaction amount |
merchantName
| Name of the merchant |
Code Example
TridentitySDK.getInstance().processTransaction(
applicationContext,
remoteMessage.data,
false,
object : UpdateTransactionCallback {
override fun onSuccess(event: JSONObject) {
Log.v("processTransaction", event.toString())
}
override fun onError(error: String) {
Log.e("processTransaction", error)
}
}
)
8. Transaction History
Invoke this method to get the transaction data authenticated via Tridentity SDK. By default, 50 transactions can be viewed, with a limit of 10 and an offset of 4.
Parameters
Parameter | Description |
---|---|
activity
| Instance of AppCompatActivity |
limit
| Number of transaction records fetched per single request. Default is 10 records per request. |
offset
| Page index. Default is 0-4. |
Sample JSON
val historyObject = JsonObject()
historyObject.addProperty("limit", 10)
historyObject.addProperty("offset", 0)
Code Example
val historyObject = JsonObject()
historyObject.addProperty("limit", 10) // Removed extra space after "limit"
historyObject.addProperty("offset", 0)
TridentitySDK.getTransactionHistory(
activity as AppCompatActivity,
historyObject,
object : TransactionHistoryCallback { // Assuming this is the correct callback interface
override fun onSuccess(event: JSONObject) {
// Handle success
}
override fun onError(error: String) {
// Handle error
}
}
)
9. De-Registration
Invoke this method to deregister a customer from Tridentity.
TridentitySDK.getInstance().deRegistration(
context,
object : DeregisterCallBack {
override fun onSuccess(event: JSONObject) {
// Handle success
}
override fun onError(code: Int, error: String) {
// Handle error
}
}
)
Updated 26 days ago