The Secure Share SDK simplifies user verification workflows for Android, iOS, and web applications. You can include a script tag, initialise the SDK with a session ID, and manage verification processes easily. Success and error callbacks handle responses, and you can close the SDK programmatically if needed. This topic includes the following sections:

Integration

To integrate Secure Share:

  1. Log in to the Merchant Dashboard and create a Secure Share template.

  2. Follow the workflow below:

    1. Verify user data using the Data Availability API to check user data availability using a mobile number. This step is mandatory.

    2. Initiate OAuth by calling the Initiate OAuth API with the mobile number to obtain a session_id for opening the SDK.

    3. Collect user consent by opening the SDK using the session_id. Once the user provides consent, a callback returns an auth_code.

    4. Generate an access token using the auth_code with the OAuth Access Token Generation API to get a token valid for one hour.

    5. Retrieve user details using the access token with the Fetch User Details API to access user details.

Refer to the image below for a sample workflow:

Initializing SDKs

The SDK communicates with Cashfree and provides updates via the callbacks. Initialize the applicable SDK from the options below:

Web

To initiate the web SDK, pass the sessionId and callback functions. Refer to the JavaScript example below:

const cf = CFSecureShare({
  sessionId: newId,
  successCb: successCallback,
  errorCb: errorCallback,
  mode: "production" // default: "sandbox"
});

const successCallback = (data) => {
  console.log("Success: ", data);
};

const errorCallback = (error) => {
  console.error("Error: ", error);
};

// Close the SDK programmatically
cf.closeSDK();

Importing hosted JS SDK

Include the appropriate SDK version in your HTML document:

  • Use the following for the production environment:
    <script src="https://vssdk-prod.cashfree.com/vsvault/prod/1.0.0/index.js"></script>
    
  • Use the following for the sandbox environment:
    <script src="https://vssdk-prod.cashfree.com/vsvault/gamma/1.0.0/index.js"></script>
    

Refer to the code snippet below for the HTML structure:

<html>
  <head>
    <title>Secure Share</title>
    <script src="https://vssdk-prod.cashfree.com/vsvault/prod/1.0.0/index.js"></script>
  </head>
  <body>
    <div id="cf-sdk"></div>
  </body>
</html>

Android native

To set up the Android native SDK:

  1. Add the Maven repository to settings.gradle.kts:
    repositories {
        google()
        mavenCentral()
        maven { url = URI("https://maven.cashfree.com/release") }
    }
    
  2. Add SDK dependency in build.gradle.kts:
    dependencies {
        implementation("com.cashfree.vrs:kyc-verification:1.0.0")
    }
    
  3. Click Sync Now in Android Studio to sync the project.

To initialise and use the Android native SDK:

  1. Create an instance of the verification service:
    val verificationService = CFVerificationService.Builder()
        .setContext(this) // Pass the context
        .build()
    
  2. Configure the callback to handle verification responses, errors, and user drop scenarios:
    verificationService.setSecureShareCallback(object : CFSecureShareCallback {
        override fun onVerification(response: CFSecureShareResponse) {
            // Handle response
        }
    
        override fun onVerificationError(error: CFSecureShareErrorResponse) {
            // Handle error
        }
    
        override fun onUserDrop(error: CFUserDropResponse) {
            // Handle user drop
        }
    })
    
  3. Initiate the SecureShare SDK:
    verificationService.openSecureShare(sessionId, Environment.TEST)
    

It consists of the following parameters:

  • sessionId: Unique session identifier.
  • Environment: SDK environment. Possible values are:
    • Environment.TEST
    • Environment.PROD

iOS native

To set up the iOS native SDK:

  1. Add the SDK to your project by updating your Podfile:
    pod 'KycVerificationSdk', '~> 1.0.1'
    
  2. Run pod install to install the SDK.

To initialise and use the iOS native SDK:

  1. Create an instance of the CFVerificationService class:
    let kycService = CFVerificationService.getInstance()
    
  2. Set up callback handlers to manage events after verification processing. Implement the CFSecureShareResponseDelegate protocol to handle responses and errors:
    extension ViewController: CFResponseDelegate {
        func onVerification(_ verificationResponse: KycVerificationSdk.CFSecureShareResponse) {
            showErrorAlert(title: "Verification Success", message: verificationResponse.verificationId ?? "N/A")
        }
    
        func onVerificationError(_ errorResponse: KycVerificationSdk.CFSecureShareErrorResponse) {
            showErrorAlert(title: "Verification Error", message: errorResponse.status ?? "N/A")
        }
    
        func onUserDrop(_ userDropResponse: KycVerificationSdk.CFUserDropResponse) {
            showErrorAlert(title: "User Dropped", message: userDropResponse.verificationId ?? "N/A")
        }
    }
    
  3. Initiate the SecureShare SDK using the following code:
    do {
        let environment = Environment.PROD
        try kycService.openSecureShare(sessionId, environment, self, self)
    } catch let e {
        let error = e as! VerificationError
        print(error)
    }
    

It consists of the following parameters:

  • sessionId: A unique identifier for the session.
  • environment: Specifies the environment in which the SDK operates. Possible values are:
    • Environment.TEST
    • Environment.PROD

Callback structure

Refer to the sample response below:

{
  "verification_id": "verification_id_value",
  "auth_code": "auth_code_value",
  "status": "SUCCESS"
}

Refer to the table below for the possible statuses:

StatusDescription
SESSION_EXPIREDThe session ID is invalid.
SESSION_ID_MISSINGNo session ID is provided during initialization.
DIV_MISSINGThe <div> with ID cf-sdk is missing.
SUCCESSThe operation is completed successfully.
CLOSEDThe SDK closes.

Notes:

  • Ensure the <div> with ID cf-sdk exists in your HTML.

  • The SDK applies default styling for consistent behaviour; custom styling is not supported.

  • The iframe uses sandboxing for secure interactions.

For detailed API documentation, refer to Secure Share API Integration.