Callback Methods
Socure SDK Callback Methods
Predictive DocV Web SDK Callback Methods
The Predictive Document Verification (DocV) Web SDK provides callback functions through the config object, enabling you to implement custom logic for handling progress, success, and error events during the document capture and upload process.
Additionally, the config object includes settings that allow you to modify the handoff component
The DocV Web SDK also supports webhooks events to receive notifications as a consumer progresses through each step of the document capture process.
The config object and the callback methods:
var config = {
onProgress: function(event) { ... },
onSuccess: function(response) { ... },
onError: function(error) { ... },
qrCodeNeeded: true,
disableSmsInput: false
};
config object parameters
config object parametersThe following table lists the arguments passed to the config object:
| Parameter | Type | Required | Description |
|---|---|---|---|
| onProgress | Function | Optional | Callback function triggered during the document capture process. |
| onSuccess | Function | Optional | Callback function executed when the document capture process completes successfully. |
| onError | Function | Optional | Callback function triggered when an error occurs during the document capture process. |
| qrCodeNeeded | Boolean | Optional | Determines whether a QR code is displayed on the handoff component. If true, the system generates a QR code. |
| disableSmsInput | Boolean | Optional | Disables the SMS entry option on the handoff component, showing only the QR code option. Note: Setting this to trueoverrides qrCodeNeeded: false. |
Callback event types
The following table provides additional details about the available event types of each of the three methods:
| Event Type | Message | Description |
|---|---|---|
WAITING_FOR_USER_TO_REDIRECT | Process Initiated | The process is initiated, waiting for the consumer to open the link or scan the QR code. |
WAITING_FOR_UPLOAD | Capture App Opened | The consumer opened the Capture App using a link or QR code. |
DOCUMENTS_UPLOADED | Image Upload Complete | The document and selfie images were successfully uploaded to Socure's servers. |
CONSENT_DECLINED | Consent Declined | The consumer declined the Privacy Statement and Consent agreement, causing the session to automatically expire. |
DOCUMENTS_UPLOAD_FAILED | Documents Upload Failed | An error occurred during the document and selfie upload process. |
onProgress callback
onProgress callbackThe onProgress callback returns real-time updates as the consumer progresses through the document capture and upload process.
WAITING_FOR_USER_TO_REDIRECT
Example callback event: Process Initiated
{
"docvTransactionToken": "6d454cdd-108f-46f5-8fc2-b92529940eed",
"status": "WAITING_FOR_USER_TO_REDIRECT",
"key": "6d454cdd-108f-46f5-8fc2-b92529940eed",
"customerUserId": "121212",
"mobileNumber": "+13475550100",
"deviceSessionToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJkYXRhIjp7InNlc3Npb2..."
}
WAITING_FOR_UPLOAD
If the user opens the Capture App in a new window, use the captureAppWindow object to programmatically close the Capture App window at the end of the session.
onSuccess callback
onSuccess callbackThe onSuccess callback is triggered when the document and selfie images are successfully uploaded.
Example callback event: Image Upload Complete
{
"docvTransactionToken": "6d454cdd-108f-46f5-8fc2-b92529940eed",
"status": "DOCUMENTS_UPLOADED",
"key": "6d454cdd-108f-46f5-8fc2-b92529940eed",
"customerUserId": "121212",
"mobileNumber": "+13475550100",
"deviceSessionToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJkYXRhIjp7InNlc3Npb2..."
}
onError callback
onError callbackThe onError callback is triggered when an issue occurs during the document capture or upload process.
CONSENT_DECLINED
Example callback event: Consent Declined
{
"docvTransactionToken": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
"status": "CONSENT_DECLINED",
"key": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
"customerUserId": "121212",
"mobileNumber": "+13475550100",
"deviceSessionToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJkYXRhIjp7InNlc3Npb2..."
}
DOCUMENTS_UPLOAD_FAILED
Example callback event: Documents Upload Failed
{
"docvTransactionToken": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
"status": "DOCUMENTS_UPLOAD_FAILED",
"key": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
"customerUserId": "121212",
"mobileNumber": "+13475550100",
"deviceSessionToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJkYXRhIjp7InNlc3Npb2..."
}
Callbacks in a Multiple Document Capture flow
The DocV Web SDK will receive onProgress callbacks with the "DOCUMENTS_UPLOADED" status for each document uploaded in the transaction. These callbacks will also include the total number of expected documents.
For the final document upload, the DocV Web SDK will receive both onProgressand onSuccesscallbacks with the status "DOCUMENTS_UPLOADED".
- The
onProgresscallback will contain a singledocvTransactionTokenfor the last uploaded document. - The
onSuccesscallback will return an array of alldocvTransactionTokenvalues from the transaction.
onProgress callback
onProgress callbackCurrent Document Count
onProgressfor each document upload (Multiple Document Capture only)
{
"docvTransactionToken": "78d1c86d-03a3-4e11-b837-71a31cb44142",
"status": "DOCUMENTS_UPLOADED",
"key": "78d1c86d-03a3-4e11-b837-71a31cb44142",
"mobileNumber": "+19788626926",
"deviceSessionToken": "xxSyBgzKzPNWJO3UqTFCXiOQjk1KZKtdKcQElv3f",
"multiDoc": {
"transactionGroupId": "86f4m42e-04n7-5f12-c970-32b58dc31952",
"current" : 1,
"total" : 3
}
}
Final Document Upload
onProgress for final document uploaded (Multiple Document Capture only)
{
"docvTransactionToken": "5213seac-cggn-562a-9b12-23bt3p3qra59",
"status": "DOCUMENTS_UPLOADED",
"key": "aa896ee4-b7b7-4049-92b1-0cfdd20481a5",
"mobileNumber": "+19788626926",
"deviceSessionToken": "xxSyBgzKzPNWJO3UqTFCXiOQjk1KZKtdKcQElv3f",
"multiDoc": {
"transactionGroupId": "86f4m42e-04n7-5f12-c970-32b58dc31952",
"current" : 3,
"total" : 3
}
}
onSuccess callback
onSuccess callbackonSuccessafter all document are uploaded (Multiple Document Capture only)
{
"status": "DOCUMENTS_UPLOADED",
"key": "aa896ee4-b7b7-4049-92b1-0cfdd20481a5",
"mobileNumber": "+19788626926",
"deviceSessionToken": "xxSyBgzKzPNWJO3UqTFCXiOQjk1KZKtdKcQElv3f",
"multiDoc": {
"transactionGroupId": "86f4m42e-04n7-5f12-c970-32b58dc31952",
"docvTransactionTokens": [
"78d1c86d-03a3-4e11-b837-71a31cb44142",
"891e1cac-ff1f-439d-8a22-11db6e35a607",
"5213seac-cggn-562a-9b12-23bt3p3qra59"
]
}
}Updated 21 days ago
