MIN KYC NSDL Android Library

Card91 Min KYC NSDL Android Library

Card91 Min KYC NSDL Android Library Integration
with Native Android Apps

Description

Purpose of this document is to illustrate the method to add Card91 ‘Min KYC NSDL’ library to any android native application written in Kotlin invoked either from a fragment or an activity.

Card91 Min KYC NSDL library allows developers to add the custom webview component into their layout as per design.

Developers need to get the view onto their activity and through invoking the init() method with certain required parameters mentioned below and a library for completing the min KYC of the card holder.

Installation (Gradle and Manifest Configuration)

Android Minimum Requirements :

Gradle Version - 7.3.3
minSdkVersion - 21
compileSdkVersion - 32
targetSdkVersion - 32

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/src/main/libs/card91SDK.aar') // add the card91 sdk aar file here
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    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'
    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 'com.squareup.retrofit2:converter-gson:2.9.0'
    //
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.4.0'

}



Also enable the binding on the same app gradle file under android tag if the binding has been used

buildFeatures {
       viewBinding true
   }
}

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.(card91SDK.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/card91SDK.aar')

or

implementation(name: 'card91SDK', ext: 'aar' )

📘

Note

Clean and Build the android app to get the dependencies added on to the application

ADD CARD91 ISSUE CARD VIEW COMPONENT ON LAYOUT

Library class will be ready to use after their adding on gradle.
Add Card91KYCWebView onto the layout where the developer wants to use it .
Make sure not to keep any background colour of the webview since it is supposed to be transparent.

<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".CardKYC"
    android:padding="15dp"
    android:id="@+id/main_layout">
    <com.card91.common.Card91KYCWebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/cardkyc"
        android:layout_marginBottom="60dp"/>


</androidx.appcompat.widget.LinearLayoutCompat>

SETUP CARD VIEW COMPONENT

Get the instance of the added Card91KYCWebView onto your activity or fragment.
As shown in the example below .
Set the Listener as given below

import android.os.Bundle
import android.util.Log
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.card91.common.Card91KYCWebView
import java.text.DateFormat
import java.util.*


class CardKYC  : AppCompatActivity(), Card91KYCWebView.Listener{
    private lateinit var mWebView: Card91KYCWebView
    private lateinit var nextbutton: Button
    private lateinit var previousButton: Button
    private lateinit var submit: Button
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_kyc)
        mWebView = findViewById<Card91KYCWebView>(R.id.cardkyc)

        mWebView.setListener(this, this)
        mWebView.settings.loadsImagesAutomatically=true;
        val mobile = "918610260465" //  Card holder card id for which details needs to be shown
        val env="PROD_SANDBOX" // "PROD" in case of production and "PROD_SANDBOX" on sandbox environment
        val templateId= "xoltt" // Template id by default its "xoltt" or "default"
        mWebView.init(this,mobile,templateId,env)

    }

    override fun onPageStarted(url: String?) {
        Log.w("Page Started", url.toString())
    }

    override fun onPageFinished(url: String?) {
        Log.w("Page onPageFinished", url.toString())
    }

    override fun onPageError(errorCode: Int, description: String?, failingUrl: String?) {
        Log.w("Page onPageError", description.toString())
    }

    override fun onCard91Event(type: String?, payload: String) {
        Log.w("SDK res Type and Payload", type.toString()+"+ payload.toString()) 
              /// Refer the section DIFFERENT CALLBACLK EVENTS for all event type 
              // on successfull card creation payload will have the customer id which has been created
    }
 }

INPUT PARAMETER DETAILS

Call the init() method of the Card91SDKWebView with the below parameter .

NameTypeRequiredDescription
mobilestringtrueCard holder mobile number
envstringfalseUse "PROD_SANDBOX" for production sandbox environment and "PROD" for production environment .
templateIdstringtrueUse to indicate key for design template eg. "xoltt"

SUBSCRIBE FOR LISTENING CALLBACK EVENTS

Implement Interface Card91ResetAtmPin.Listener for listening to the call back event from the Reset Atm Pin library .

Interface has below and their usage .

  override fun onPageStarted(url: String?) {
        Log.w("Page Started", url.toString())
    }

    override fun onPageFinished(url: String?) {
        Log.w("Page onPageFinished", url.toString())
    }

    override fun onPageError(errorCode: Int, description: String?, failingUrl: String?) {
        Log.w("Page onPageError", description.toString())
    }

    override fun onCard91Event(type: String?, payload: String) {
        Log.w("SDK res Type and Payload", type.toString()+"+ payload.toString()) 
              /// Refer the section DIFFERENT CALLBACLK EVENTS for all event type 
              // on successfull card creation payload will have the customer id which has been created
    }

onPageStarted is called when the webpage is loaded.
onPageFinished is called when webpage loading is finished .
onPageError is called when there is any error while loading the page.
onCard91Event is called when issue card is initialised, error occurred, on successful card creation.

DIFFERENT CALLBACLK EVENTS

Call Back Event Type Description

Event NameDescription
C91_MIN_KYC_INITIALISEDThe NSDL MIN KYC screen has been initialised.
C91_MIN_KYC_SUCCESSThe API request related to the NSDL MIN KYC screen was successful.
C91_MIN_KYC_API_FAILUREThe API request related to theNSDL MIN KYC screen has failed.
C91_MIN_KYC_AUTHENTICATION_FAILUREAuthentication for the NSDL MIN KYC screen has failed.
C91_MIN_KYC_SERVER_FAILUREThe server encountered an error while processing the NSDL MIN KYC request.
C91_MIN_KYC_MISSING_PARAMETERA required parameter is missing in the NSDL MIN KYC request.
C91_MIN_KYC_OTP_SEND_FAILThe API request for generating the OTP for the NSDL MIN KYC has failed.
C91_MIN_KYC_OTP_VERIFICATION_FAILThe API request for validating the OTP has failed for the NSDL MIN KYC
C91_MIN_KYC_MOBILE_ALREADY_EXIST_OR_INVALIDKYC for this mobile number is already done or the mobile number is not valid.
Payload of both these event will be different.