The Predictive Document Verification (DocV) Web SDK provides a set of callback methods that let you monitor and respond to key events in the document capture and upload flow. These callbacks are configured through the `config` object passed to the `SocureDocVSDK.launch()` method and can be used to implement custom logic based on user progress, success, or error conditions.

The `config` object also supports behavioral flags to customize the handoff experience—for example, enabling a QR code, skipping SMS input, auto-closing the Capture App tab, or streamlining mobile flow by skipping the **Continue on New Tab** screen.

### The config object and the callback methods

```javascript
var config = {
  onProgress: function(event) { /* Called during capture */ },
  onSuccess: function(response) { /* Called on success */ },
  onError: function(error) { /* Called on error */ },
  qrCodeNeeded: true, // Show QR code option
  disableSmsInput: false, // Enable SMS input
  closeCaptureWindowOnComplete: true, // Auto-close tab after document upload confirmation
  autoOpenTabOnMobile: true // Skip "Continue on New Tab" screen on mobile and launch Capture App in a new tab
};
```

## `config` object parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `onProgress` | Function | Yes | Callback function triggered during the document capture process. |
| `onSuccess` | Function | Yes | Callback function executed when the document capture process completes successfully. |
| `onError` | Function | Yes | Callback function triggered when an error occurs during the document capture process. |
| `qrCodeNeeded` | Boolean | No | Determines whether a QR code is displayed on the handoff component. If `true`, the system generates a QR code. |
| `disableSmsInput` | Boolean | No | Disables the SMS entry option on the handoff component, showing only the QR code option. |
| `closeCaptureWindowOnComplete` | Boolean | No | Automatically closes the Capture App browser tab 2 seconds after the consumer reaches the **Confirmation** screen. |
| `autoOpenTabOnMobile` | Boolean | No | Automatically opens the Capture App in a new browser tab on mobile devices, bypassing the intermediate **Continue on New Tab** screen |

## Callback event types

| Event Type | Status | Callback | Description |
| --- | --- | --- | --- |
| `WAITING_FOR_REDIRECT_METHOD` | Awaiting Consumer Action | `onProgress` | The consumer is directed to the Web SDK handoff screen, providing the option to send an SMS or scan a QR code. |
| `WAITING_FOR_USER_TO_REDIRECT` | SMS Sent – Awaiting Consumer | `onProgress` | The Web SDK has sent an SMS containing the document request URL and is awaiting the consumer to open the link. |
| `WAITING_FOR_UPLOAD` | Capture App Opened | `onProgress` | The consumer has been redirected to the Capture App and is ready to begin the flow. |
| `DOCUMENTS_UPLOADED` | Image Upload Complete | `onSuccess` | The consumer has successfully completed the Capture App flow, with all images uploaded. |
| `CONSENT_DECLINED` | Consent Declined | `onError` | The consumer declined the Privacy Statement and Consent agreement, terminating the session. |
| `DOCUMENTS_UPLOAD_FAILED` | Documents Upload Failed | `onError` | An error occurred while uploading one or more document images or the selfie, preventing completion. |

## Callback Details

The `onProgress` callback returns real-time updates as the consumer progresses through the document capture and upload process.

### `onProgress`

Example callback event: Awaiting Consumer Action

```json
{
  "docvTransactionToken": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "status": "WAITING_FOR_REDIRECT_METHOD",
  "key": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "customerUserId": "121212",
  "mobileNumber": "+13475550100",
  "deviceSessionToken": "..."
}
```

Example callback event: SMS Sent – Awaiting Consumer

```json
{
  "docvTransactionToken": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "status": "WAITING_FOR_USER_TO_REDIRECT",
  "key": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "customerUserId": "121212",
  "mobileNumber": "+13475550100",
  "deviceSessionToken": "..."
}
```

Example callback event: Capture App Opened

```json
{
  "captureAppWindow": "Window {...}",
  "docvTransactionToken": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "status": "WAITING_FOR_UPLOAD",
  "key": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "customerUserId": "121212",
  "mobileNumber": "+13475550100",
  "deviceSessionToken": "..."
}
```

### `onSuccess`

The `onSuccess` callback is triggered when the document and selfie images are successfully uploaded.

Example callback event: Image Upload Complete

```json
{
  "docvTransactionToken": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "status": "DOCUMENTS_UPLOADED",
  "key": "6d454cdd-108f-46f5-8fc2-b92529940eed",
  "customerUserId": "121212",
  "mobileNumber": "+13475550100",
  "deviceSessionToken": "..."
}
```

### `onError`

The `onError` callback is triggered when an issue occurs during the document capture or upload process.

Example callback event: Consent Declined

```json
{
  "docvTransactionToken": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
  "status": "CONSENT_DECLINED",
  "key": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
  "customerUserId": "121212",
  "mobileNumber": "+13475550100",
  "deviceSessionToken": "..."
}
```

Example callback event: Documents Upload Failed

```json
{
  "docvTransactionToken": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
  "status": "DOCUMENTS_UPLOAD_FAILED",
  "key": "c1c4223f-ce22-4c72-9fdf-90480ccefc77",
  "customerUserId": "121212",
  "mobileNumber": "+13475550100",
  "deviceSessionToken": "..."
}
```
