This page will help you get started with NSDL AADHAAR KYC SDK ANDROID.Installation and Usage Guide
Card91 NSDL AADHAAR KYC Android Library
Card91 NSDL AADHAAR KYC Android Library Integration with Native Android Apps
Description
Purpose of this document is to illustrate the method to add Card91 ‘Card91KYC’ library to any android native application written in Kotlin invoked either from an activity.
Card91 Card91KYC library allows developers to launch the Card91KYC activity from their application to process and complete the aadhaar XML full KYC for NSDL cards.
Developers need to launch Card91KYCActivity from their activity with some required parameters mentioned below and a library completing the aadhaar KYC for the NSDL cards.
Installation (Gradle and Manifest Configuration)
Android Minimum Requirements :
Gradle Version - 7.3.3
minSdkVersion - 26
compileSdkVersion - 33
targetSdkVersion - 33
Android Permission on Manifest:
<uses-permission android:name="android.permission.INTERNET" />
Update gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
Gradle dependencies
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation(name: 'aadhaarsdk2-1.0.7', ext: 'aar' )
implementation(name: 'nsdlkyc_card', ext: 'aar' )
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.3'
//JSON CONVERTOR
implementation('com.squareup.moshi:moshi-kotlin:1.12.0')
//kotlin reflect
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.6.10'
implementation "androidx.security:security-crypto:1.1.0-alpha03"
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.3'
implementation 'com.scottyab:rootbeer-lib:0.1.0'
implementation "androidx.room:room-runtime:2.5.2"
annotationProcessor "androidx.room:room-compiler:2.5.2"
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.github.bastiaanjansen:jwt-java:1.2.0'
implementation 'com.auth0:java-jwt:4.0.0'
implementation 'com.auth0.android:jwtdecode:2.0.1'
implementation 'com.squareup.retrofit2:converter-scalars:2.4.0'
implementation 'org.greenrobot:eventbus:3.3.0'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
Also enable the binding on the same app gradle file under android tag if the binding has been used
buildFeatures {
viewBinding true
}
}
Below is the Manifest permission which needs to be added on Manifest file of the main application
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
Usage
Below steps is defined to followed to integrate the Library
Add AAR (Android Library Files)
Add the .aar file provided by us at the libs folder on the project eg. card91KYC.aar
Keep the aar file at location {Client project location}/app/src/main/libs
Add below line on the app gradle
implementation files('../app/src/main/libs/card91KYC.aar')
implementation files('../app/libs/aadhaarsdk2-1.0.7.aar')
or
implementation(name: 'card91KYC', ext: 'aar' )
Note
Clean and Build the android app to get the dependencies added on to the application
Launch Card91KYCActivity from the activity of the main application
Library class will be ready to use after their adding on gradle.
Launch Card91KYCActivity from the activity of the main application.
Make sure to register the launch so as to get the result from the library when the library gets finish(), after completing the KYC process.
Below is the code snippet which will help developer understand how its supposed to be handled.
Prepare a call back listener.
Eg: Activity Result Listener
private val aadhaarLauncher = registerForActivityResult( ActivityResultContracts.StartActivityForResult())
{ res ->
if (res.resultCode ==Activity.RESULT_OK)
{
val bundle: Bundle? = res.data?.extras
if (bundle != null) {
val type = bundle.getString("COMPLETE_KYC_SUCCESS")
val code = bundle.getString("KYC_RESPONSE_DATA")
val message = bundle.getString("KYC_RESPONSE_CODE")
}
}
}
Eg: Launch SDK activity on a button click
aadhaarButton.setOnClickListener(View.OnClickListener
{
val intent = Intent(this, Card91KYCActivity::class.java)
intent.putExtra("MOBILE","919810***197")// User registered mobile number
intent.putExtra("AUTH_TOKEN","C91CH55swEXsHUBaWpDeyn3qjC09Xqx237YymGZyVwvWqse8=")
intent.putExtra("ENV","PROD_SANDBOX") // "PROD_SANDBOX" for sandbox and "PROD" production environment
intent.putExtra("PAN","") // Keep this empty always
intent.putExtra("ORG_ID","220425061100289ID1OID5154067") // Business org id
aadharLauncher.launch(intent)
})
Important
Note
In order to make sure a registered user successful aadhaar KYC completion, user must invoke the SDK with same mobile number which is linked to aadhaar number and name should be same on PAN number and aadhaar number.
NSDL AADHAAR KYC PROCESS EVENTS
SDK went to through several steps to make sure KYC happens successfully.
KYC can be completed either through already downloaded aadhaar XML or by validating the aadhaar number through OTP.
Finally SDK validate all the information provided is correct and hence result in FAILED or SUCCESS event call back.
Below some event with meaning.
val bundle: Bundle? = res.data?.extras
if (bundle != null) {
val type = bundle.getString("COMPLETE_KYC_SUCCESS")
val message = bundle.getString("KYC_RESPONSE_DATA")
val code = bundle.getString("KYC_RESPONSE_CODE")
}
INPUT PARAMETER DETAILS WHICH LAUNCHING THE SDK ACTIVITY
Name | Type | Required | Description |
---|---|---|---|
MOBILE | string | true | Registered card holder mobile number (12 digit) with 91 |
AUTH_TOKEN | string | true | Card Holder auth token (Card91 API) |
ORD_ID | string | true | Business org id |
ENV | string | true | "PROD_SANDBOX" for sandbox and "PROD" production environment |
DIFFERENT CALLBACLK EVENTS
The events are as follows:
Event Name | Description |
---|---|
COMPLETE_KYC_SUCCESS | On successful aadhaar KYC completion, developer needs to parse "bundle.getString("COMPLETE_KYC_SUCCESS")" for the same. There is two state of the status which needs to be considered "FAILED" and "SUCCESS" "FAILED" status will be considered as KYC failed cased and "SUCCESS" as success case. |
KYC_RESPONSE_DATA | Both on "FAILED" and "SUCCESS" case calling app will receive message which they have to show. |
KYC_RESPONSE_CODE | In case of SDK exception code (string) will range from (600-990) and in case of api exception it will range from (400-500) Eg- 00 as success 401 is auth exception 403 permission exception 400 format exception 404 service not found 500 service error |