Event Handling
The SDK provides three primary event handling methods that give you complete control and visibility over the document processing lifecycle:
onUpdate Handler
The onUpdate handler provides real-time status updates throughout the scanning process. It receives a status object:
VeryfiLens.onUpdate((status) => {
console.log("Current status:", status.status);
});
Status values include:
| Status | Description |
|---|---|
validation_started | Partner validation begins |
validation_completed | Partner validation successful |
validation_failed | Partner validation failed |
camera_initializing | Camera is being initialized |
camera_ready | Camera is ready for capture |
camera_failed | Camera access failed or errored. Includes error message |
camera_switching | Switching between front and back camera |
camera_switch_failed | Camera switch failed. Includes error message |
capture_started | Image capture begins |
capture_completed | Image capture successful |
capture_failed | Image capture failed |
processing_started | Document processing begins |
processing_completed | Document processing complete |
processing_failed | Document processing failed |
submission_started | Server submission begins |
submission_completed | Server submission successful |
submission_failed | Server submission failed. Includes error with details |
stitching_started | Long document stitching begins |
stitching_completed | Long document stitching complete |
autocapture_done | Automatic document capture completed (requires autoDocumentCapture: true) |
lcd_detected | LCD screen detected in captured image |
blur_detected | Blur detected in captured image |
not_a_document | No document detected in captured image |
wrong_side_detected | Wrong check side detected (e.g. back captured when front expected). Includes expectedSide and result with detection probabilities |
check_manual_capture_mode | Switched to manual capture mode for checks |
capture_back_side | Prompting user to capture back side of check (optional) |
capture_back_side_required | Requiring user to capture back side of check (enforced) |
capture_back_side_auto | Automatically proceeding to back side capture |
blueprint_selection_cancelled | Blueprint selection was cancelled (AnyDocs with blueprints) |
recording_started | Video recording started (requires lensFlavor: 'prescription_label') |
recording_stopped | Video recording stopped (requires lensFlavor: 'prescription_label') |
anydoc_page_captured | A page was captured in AnyDocs multi-page mode |
anydoc_pages_submitting | AnyDocs multi-page capture is being submitted |
field_detection_started | Crop-preview field detection started (requires documentFieldsToDetect) |
field_detection_completed | Crop-preview field detection finished. Includes field_detection result object |
field_detection_failed | Crop-preview field detection failed |
onSuccess Handler
Called when an operation completes successfully. The data structure varies based on the context:
VeryfiLens.onSuccess((result) => {
console.log("Operation successful:", result);
});
Triggered in these scenarios:
- Document processing completion
- Credit card scanning completion
- Long document stitching completion
- Server submission completion
Response format examples:
// For documents/checks
{
image: "base64_encoded_string",
field_detection: {
vendor: [{ text: "ACME STORE", box: [x1, y1, x2, y2] }],
date: [{ text: "01/15/2026", box: [x1, y1, x2, y2] }],
total: [{ text: "$42.50", box: [x1, y1, x2, y2] }],
_ocr_source: "tesseract"
},
// Additional document metadata
}
// For credit cards
{
number: "4111111111111111",
name: "JOHN DOE",
date: "12/24",
cvv: "123"
}
When documentFieldsToDetect is not configured, field_detection is omitted from document/check responses.
onFailure Handler
Called when errors occur during any stage of processing:
VeryfiLens.onFailure((error) => {
console.error("Operation failed:", error);
});
Common failure scenarios:
- Partner validation failures
- Camera initialization errors
- Image capture errors
- Document processing errors
- Server submission errors
- WASM initialization or processing errors