Getting Started with Verification Suite SDK

You can consume APIs in your application using a script tag imported from the Verification Suite SDK. The clientId and clientSecret information generated from the Developers section is utilised to make server calls and obtain token from Cashfree Payments.

You have to pass this token in the SDK. The SDK communicates the received token to Verification Suite App. There is a provision to receive status and details from the app through SDK using callbacks.

Merchants also have access to a function which helps to close Verification Client App from their end.

Event TypeDescriptionMessage
UNAUTHORIZEDWhen the token is not valid and 401 is received during Verify Call.Invalid Token.
MISSING_TOKENWhen token is not passed during SDK initialization.Token not passed.
MISSING_DIVWhen the div tag with the ID 'cf-sdk' that is responsible to show the Verification Client App is missing.Div with id cf-sdk not present.
SUCCESSWhen response is sent by Verification Client App to SDK, It can be consumed with success callback.
ERRORWhen an error scenario during verification occurs on Verification Client App, it can be consumed with error callback.

Importing the Hosted JS SDK in HTML

In an HTML document, include a Div with id 'cf-sdk' and a script tag with Cashfree's CDN below:

<html>
  <head>
    <title>demo app</title>
    <script src="https://sdk.cashfree.com/js/common/production/1.0.0/cf-common.prod.js"></script>
  </head>
  <body>
    ...
    <div id="cf-sdk"></div>
    ...
  </body>
</html>

Initialise JS SDK

Initialise SDK by passing token in the Javascript file. Two callbacks are passed - success and error. This helps provide information from Verification Client App.

const cf = Cashfree("<TOKEN>", success, failure)

const success = function (data) {
  console.log("on success data >>> ", data);
};

const failure = function (data) {
  console.log("on failure data >>> ", data);
};

// To close the SDK from merchant's end

cf.closeSDK()

JSON Structure

1. Server to server API call with clientId and clientSecret 

// Request 
curl -X POST \
  'http://{{Base URL}}/verification/sdk/auth' \
  -H 'x-client-id: {{client id}}' \
  -H 'x-client-secret: {{client secret}}' \
  --data-raw '{
    "sdk_instance_id":"xyz"
}'
  
// Response   
{
  
    "token": "eyJ0eXA...fWStg",
    "message": "Token generated"
  
}