Skip to main content

Events and Callbacks

The start() method in the ShuftiPro Web SDK initiates the verification process and provides a mechanism to capture the response through a callback function. This response object contains valuable information about the verification flow, allowing you to handle different verification stages.

There are two ways to listen to response:

arrow Callback Function
arrow Event Listeners

Using a Callback Function

arrowPass a callback function as an argument to the `start()` method.
arrowThe SDK will execute this function once the verification process reaches a stage or encounters an error.
arrowThe callback function receives a single argument, which is the response object containing details about the verification flow.
shuftiPro.start((response) => {
console.log('Verification response:', response);
// Update your application UI based on the response event (e.g., display success/failure message)
});

Using Event Listeners

arrowAlternatively, you can subscribe to specific verification events using the `on()` method.
arrowThe SDK will trigger these events as the verification process progresses.
arrowEvent listeners typically don't receive a response object directly, but you can access the current verification state through the ShuftiPro instance.
   shuftiPro.on('shuftiResponse', (response) => {
console.log('Verification response:', response);
});

Response

In case of WebSDK initialization with a journey_id, a callback function can be passed to the start() method. This will return a response containing information about the verification process.

The response includes the following key properties:

ParametersDescription
status_codeType: int
Shufti Pro Verification API uses conventional HTTP response codes to indicate the success or failure of an API request. Details can be found here.
eventType: String
Events are sent in responses that show the status of the request. These events are sent in callbacks for both onsite and offsite verifications.
bodyType: Object
Contains additional details related to the verification request.
verification_urlType: String
URL for the verification flow if applicable (e.g., for redirecting the user)

Example Response Object

response-object
{
"body": {
"reference": "sp-bc-prod-xyz",
"event": "request.pending",
"verification_url": "https://app.shuftipro.com/verification/process/",
"email": null,
"country": null
},
"event": "request.pending",
"status_code": 200,
}

Response Events

Some of response events are following:

EventDescription
request.pendingThis event is returned for all on-site verifications until the verification is completed or timeout.
verification.acceptedVerification accepted callback.
verification.declinedVerification declined callback.
verification.cancelledThis callback is returned when verification is cancelled midway by the end user.
request.receivedThis event states that the verification request has been received and is under processing.