CARD91 NSDL AADHAAR KYC ANDROID

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.9.0'
    implementation 'androidx.appcompat:appcompat:1.5.0'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation files('../app/libs/aadhaarsdk2-1.0.7.aar')
 		implementation files('../app/libs/card91KYC.aar')// Name of the provided AAR file from Card91
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.squareup.okhttp3:okhttp:4.5.0'
    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 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.8.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.5.3'
    implementation 'androidx.navigation:navigation-ui:2.5.3'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.github.bumptech.glide:glide:4.12.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","AZ****058B")
    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

NameTypeRequiredDescription
MOBILEstringtrueRegistered card holder mobile number (12 digit) with 91
AUTH_TOKENstringtrueCard Holder auth token (Card91 API)
ENVstringtrue"PROD_SANDBOX" for sandbox and "PROD" production environment
PANstringtrueRegistered card holder valid pan number

DIFFERENT CALLBACLK EVENTS

The events are as follows:

Event NameDescription
SUCCESSOn successful aadhaar KYC completion, developer needs to parse "bundle.getString("COMPLETE_KYC_SUCCESS")" for the same. In this scenario "KYC_RESPONSE_CODE" will comes as 00 and "COMPLETE_KYC_SUCCESS" key value will be "SUCCESS"
FAILEDOn un successful aadhaar KYC completion, developer needs to parse the key "COMPLETE_KYC_SUCCESS" from the bundle, value be "FAILED". In this scenario "KYC_RESPONSE_CODE" will not comes as 00 and detail reason will on the key "KYC_RESPONSE_DATA"