Communication
Upload a document and get instant results. Gain a deeper understanding of how Veryfi Lens interacts with your application.
- iOS
- Android
- Capacitor
- React Native
- Flutter
- .NET
- Set your delegate:
VeryfiLens.shared().delegate = self
- Implement the delegate methods:
extension ViewController: VeryfiLensDelegate {
func veryfiLensClose(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensClose: " + jsonString!)) // do something with the JSON here
}
func veryfiLensUpdate(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensUpdate: " + jsonString!)) // do something with the JSON here
}
func veryfiLensSuccess(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensSuccess: " + jsonString!)) // do something with the JSON here
}
func veryfiLensError(_ json: [String : Any]) {
let jsonData = try? JSONSerialization.data(withJSONObject: json as Any, options: .prettyPrinted)
let jsonString = String(data: jsonData!, encoding: .utf8)
print(String("veryfiLensError: " + jsonString!)) // do something with the error JSON here
}
}
Delegate Definitions
- veryfiLensClose - the Veryfi Lens camera has been closed, either as a result of submitting an image for processing, or the user closed the camera without submitting an image.
{
"status": "close",
"queue_count": 1,
"framework-version": "1.4.0",
"session_scan_count": 1,
"framework-build": "1"
}
NOTE: In the object above, queue_count refers to the number of submitted documents that are currently in the processing queue. session_scan_count refers to the number of documents that were submitted in the most recent Lens camera session - if this is equal to 0 (zero) then the camera session was canceled without submitting anything.
- veryfiLensUpdate - during the processing of a document, this delegate will be fired multiple times. One time it will contain the thumbnail path for the submitted document and one time it will contain a full-size image path. In addition, multiple instances of this delegate will be fired containing the current upload progress percentage.
Sample package created notification:
{
"status": "start",
"package_id": "edc8653e4c2b4ef1"
}
Thumbnail shared example:
{
"status": "inprogress",
"msg": "img_thumbnail_path",
"data": "/path/to/thumbnail.jpg",
"package_id": "edc8653e4c2b4ef1"
}
Full-size image shared example:
{
"status": "inprogress",
"msg": "img_original_path",
"data": "/path/to/image.jpg",
"package_id": "edc8653e4c2b4ef1",
"document_type": "receipt"
}
Stitched PDF shared example:
{
"status": "inprogress",
"msg": "img_stitched_pdf_path",
"data": "/path/to/images.pdf",
"package_id": "edc8653e4c2b4ef1"
}
Upload progress example:
{
"status": "inprogress",
"msg": "progress",
"data": 68,
"package_id": "edc8653e4c2b4ef1"
}
Package removed example:
{
"status": "removed",
"msg": "clear_package",
"package_id": "edc8653e4c2b4ef1"
}
- veryfiLensError - if an error occurs during uploading or processing a submitted or a general exception or crash is caught in Veryfi Lens, this notification contains the error details.
Sample error data:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"error": "[Wombat].Reachability.noInternetConnection"
}
- veryfiLensSuccess - this delegate fires once a document has finished processing, whether it was submitted via the camera, the gallery, or it was dictated or entered/typed manually. This delegate provides the response from the Veryfi API.
Example:
{
"status": "done",
"data": { "advance_eic_payment":null,"allocated_tips":null,"control_number":null,"dependent_care_benefits":null,"ein":"46-1234567","employee_address":"80 WORKHOURS WAY\nSLEEPLESS HOLLOW NY 11222","employee_name":"DOCTORED B. MONEY","employee_ssn":"123-45-6879","employer_address":"123 PAYNE LANE\nPOSTCALL, NY 11111","employer_name":"BESTEST HOSPITAL EVER INC.","employer_state_id":null,"federal_income_tax":4000,"field_12a_col1":null,"field_12a_col2":45.5,"field_12b_col1":null,"field_12b_col2":5000,"field_12c_col1":null,"field_12c_col2":9800.57,"field_12d_col1":null,"field_12d_col2":null,"field_14_other":[{"column_1":"NY SDI","column_2":31.2}],"id":74511,"is_13a":false,"is_13b":false,"is_13c":false,"local_income_tax":500,"local_wages_tips":60000,"locality_name":"NYC","medicare_tax":870,"medicare_wages":60000,"non_qualified_plans":null,"pdf_url":"https:\/\/cdn.veryfi.com\/w2s\/partner-receipts\/14dfc62c-2713-4559-985a-073b4e33390d\/0394d9c5-49ff-464e-b50b-195f3058f770.pdf?Expires=1695936052&Signature=dmIlk369lsneef0jPZTH5DgG0cT36T1z~uTve7grasoMuCgjtiO8iRVVx6L8jxISygBBT1LDCrQlW1YJ6ODO7dPvAwUBApbwvDVLjDJ9OLc~XIeQ2G6Oi5ubrb9yRk6pvYeY-98DTzcGbfqThRzJOrUrYt34ngnMOspL40MYFj1ZIA7D8iqasHi0ql9Rdj6WCh4kXIbsFnvCNjKnQS3KZfWCDo8TtQJqwlisJPJJg3mmF3AEDAulaF2i1cUWGw7Hv82PBVEilgyPHtNzSXOZPyy-kVwNcHbnaoffsKkQer88wU5lLsnMdfY6skOKM7bfQuY9jEHJZOyAA8AHI2YenQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ","ss_tax":3720,"ss_tips":null,"ss_wages":60000,"state":"NY","state_income_tax":1500,"state_wages_tips":60000,"states":[{"state":"NY","employer_state_id":null,"state_wages_tips":60000,"state_income_tax":1500,"local_wages_tips":60000,"local_income_tax":500,"locality_name":"NYC"}],"wages_other_comps":55000 },
"package_id": "855d7fdf6ddf4939"
}
Use the VeryfiLens.setDelegate function to define your delegate functions that will be responsible for handling events triggered by Veryfi Lens:
VeryfiLens.setDelegate(object : VeryfiLensDelegate {
override fun veryfiLensClose(json: JSONObject) {
Log.d(TAG, json.toString(2)) // do something with the JSON response here
}
override fun veryfiLensError(json: JSONObject) {
Log.d(TAG, json.toString(2)) // do something with the JSON response here
}
override fun veryfiLensSuccess(json: JSONObject) {
Log.d(TAG, json.toString(2)) // do something with the JSON response here
}
override fun veryfiLensUpdate(json: JSONObject) {
Log.d(TAG, json.toString(2)) // do something with the JSON response here
}
})
Delegate Definitions:
veryfiLensClose
Veryfi Lens camera has been closed, either as a result of submitting an image for processing, or the user closed the camera without submitting an image.
Example:
{
"status": "close",
"queue_count": 1,
"session_scan_count": 1,
"framework-version": "1.4.0",
"framework-build": "1"
}
In the object above, queue_count refers to the number of submitted documents that are currently in the processing queue. session_scan_count refers to the number of documents that were submitted in the most recent Lens camera session - if this is equal to 0 (zero) then the camera session was canceled without submitting anything.
veryfiLensUpdate
During the processing of a document, this delegate will be fired multiple times. One time it will contain the thumbnail path for the submitted document and one time it will contain a full-size image path. In addition, multiple instances of this delegate will be fired containing status updates and the current upload progress percentage.
Sample package created notification:
{
"status": "start",
"package_id": "edc8653e4c2b4ef1"
}
Thumbnail shared example:
{
"status": "inprogress",
"msg": "img_thumbnail_path",
"data": "/path/to/thumbnail.jpg",
"package_id": "edc8653e4c2b4ef1"
}
Full-size image shared example:
{
"status": "inprogress",
"msg": "img_original_path",
"data": "/path/to/image.jpg",
"package_id": "edc8653e4c2b4ef1",
"document_type": "receipt"
}
Stitched PDF shared example:
{
"status": "inprogress",
"msg": "img_stitched_pdf_path",
"data": "/path/to/images.pdf",
"package_id": "edc8653e4c2b4ef1"
}
Upload progress example:
{
"status": "inprogress",
"msg": "progress",
"data": 68,
"package_id": "edc8653e4c2b4ef1"
}
Package removed example:
{
"status": "removed",
"msg": "clear_package",
"package_id": "edc8653e4c2b4ef1"
}
veryfiLensSuccess
This delegate fires once a document has finished processing, whether it was submitted via the camera, the gallery, or it was dictated or entered/typed manually. This delegate provides the response from the Veryfi API.
Example:
{
"status": "done",
"data": { "advance_eic_payment":null,"allocated_tips":null,"control_number":null,"dependent_care_benefits":null,"ein":"46-1234567","employee_address":"80 WORKHOURS WAY\nSLEEPLESS HOLLOW NY 11222","employee_name":"DOCTORED B. MONEY","employee_ssn":"123-45-6879","employer_address":"123 PAYNE LANE\nPOSTCALL, NY 11111","employer_name":"BESTEST HOSPITAL EVER INC.","employer_state_id":null,"federal_income_tax":4000,"field_12a_col1":null,"field_12a_col2":45.5,"field_12b_col1":null,"field_12b_col2":5000,"field_12c_col1":null,"field_12c_col2":9800.57,"field_12d_col1":null,"field_12d_col2":null,"field_14_other":[{"column_1":"NY SDI","column_2":31.2}],"id":74511,"is_13a":false,"is_13b":false,"is_13c":false,"local_income_tax":500,"local_wages_tips":60000,"locality_name":"NYC","medicare_tax":870,"medicare_wages":60000,"non_qualified_plans":null,"pdf_url":"https:\/\/cdn.veryfi.com\/w2s\/partner-receipts\/14dfc62c-2713-4559-985a-073b4e33390d\/0394d9c5-49ff-464e-b50b-195f3058f770.pdf?Expires=1695936052&Signature=dmIlk369lsneef0jPZTH5DgG0cT36T1z~uTve7grasoMuCgjtiO8iRVVx6L8jxISygBBT1LDCrQlW1YJ6ODO7dPvAwUBApbwvDVLjDJ9OLc~XIeQ2G6Oi5ubrb9yRk6pvYeY-98DTzcGbfqThRzJOrUrYt34ngnMOspL40MYFj1ZIA7D8iqasHi0ql9Rdj6WCh4kXIbsFnvCNjKnQS3KZfWCDo8TtQJqwlisJPJJg3mmF3AEDAulaF2i1cUWGw7Hv82PBVEilgyPHtNzSXOZPyy-kVwNcHbnaoffsKkQer88wU5lLsnMdfY6skOKM7bfQuY9jEHJZOyAA8AHI2YenQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ","ss_tax":3720,"ss_tips":null,"ss_wages":60000,"state":"NY","state_income_tax":1500,"state_wages_tips":60000,"states":[{"state":"NY","employer_state_id":null,"state_wages_tips":60000,"state_income_tax":1500,"local_wages_tips":60000,"local_income_tax":500,"locality_name":"NYC"}],"wages_other_comps":55000 },
"package_id": "855d7fdf6ddf4939"
}
veryfiLensError
If an error occurs during uploading or processing a submitted document, an error object is sent. If a general exception or crash is caught in Veryfi Lens, an exception object is sent instead.
Error:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"error": "{\"status\":\"error\",\"message\":\"Failed to initialize AWS\",\"uploadId\":\"0921a75550504d2e\",\"code\":\"301\"}"
}
Exception:
{
"status": "exception",
"package_id": "edc8653e4c2b4ef1",
"exception": "java.lang.IllegalArgumentException: Cannot create enum from value!\n\tat com.amazonaws.regions.Regions.fromName(Regions.java:126)\n\tat com.veryfi.lens.helpers.RegionHelper.getRegion(RegionHelper.kt:28)\n\tat com.veryfi.lens.service.UploadDocumentsService.setAccelerateModeEnable(UploadDocumentsService.kt:94)\n\tat com.veryfi.lens.service.UploadDocumentsService.onUploadType(UploadDocumentsService.kt:186)\n\tat com.veryfi.lens.service.UploadDocumentsService.onStartCommand(UploadDocumentsService.kt:161)\n\tat android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4236)\n\tat android.app.ActivityThread.access$1800(ActivityThread.java:231)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)\n\tat android.os.Handler.dispatchMessage(Handler.java:106)\n\tat android.os.Looper.loop(Looper.java:223)\n\tat android.app.ActivityThread.main(ActivityThread.java:7478)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)\n"
}
Veryfi Lens provides a camera experience that allows users to capture and submit documents for data extraction and enrichment. Lens communicates the activities performed by the user, the various progress stages and status updates and also the final results of the data extraction process asynchronously, with the help of events.
The following example simply logs all data received from all Lens events. This implementation will need to be adapted to do something that is more meaningful to your app's users.
Implementation:
//Set the events delegate.
VeryfiLensCapacitor.setLensEventDelegate();
//Do something with the response and event types.
VeryfiLensCapacitor.addListener("veryfiLensClose", (data: Object) => {
console.log("veryfiLensClose");
console.log(data);
});
VeryfiLensCapacitor.addListener("veryfiLensError", (data: Object) => {
console.log("veryfiLensError");
console.log(data);
});
VeryfiLensCapacitor.addListener("veryfiLensSuccess", (data: Object) => {
console.log("veryfiLensSuccess");
console.log(data);
});
VeryfiLensCapacitor.addListener("veryfiLensUpdate", (data: Object) => {
console.log("veryfiLensUpdate");
console.log(data);
});
Events
onVeryfiLensClose
Fired when the Veryfi Lens camera has been closed, either as a result of submitting an image for processing, or the user closed the camera without submitting an image.
Example:
{
"status": "close",
"queue_count": 1,
"framework-version": "1.4.0",
"session_scan_count": 1,
"framework-build": "1"
}
In the object above, queue_count refers to the number of submitted documents that are currently in the processing queue. session_scan_count refers to the number of documents that were submitted in the most recent Lens camera session - if this is equal to 0 (zero) then the camera session was canceled without submitting anything.
onVeryfiLensUpdate
During the processing of a document, this event will be raised multiple times. One time it will contain the thumbnail path for the submitted document, one time it will contain the original (submitted) image path and optionally, one time it will contain the stitched PDF path, if the user submitted more than one image for a document. In addition, multiple instances of this event will be fired containing the current upload progress percentage and other status updates.
Sample package created notification:
{
"status": "start",
"package_id": "edc8653e4c2b4ef1"
}
Thumbnail shared example:
{
"status": "inprogress",
"msg": "img_thumbnail_path",
"data": "/path/to/thumbnail.jpg",
"package_id": "edc8653e4c2b4ef1"
}
Full-size image shared example:
{
"status": "inprogress",
"msg": "img_original_path",
"data": "/path/to/image.jpg",
"package_id": "edc8653e4c2b4ef1",
"document_type": "receipt"
}
Stitched PDF shared example:
{
"status": "inprogress",
"msg": "img_stitched_pdf_path",
"data": "/path/to/images.pdf",
"package_id": "edc8653e4c2b4ef1"
}
Upload progress example:
{
"status": "inprogress",
"msg": "progress",
"data": 68,
"package_id": "edc8653e4c2b4ef1"
}
Package removed example:
{
"status": "removed",
"msg": "clear_package",
"package_id": "edc8653e4c2b4ef1"
}
onVeryfiLensSuccess
Fired once a document has finished processing, whether it was submitted via the camera, the gallery, or it was dictated or entered/typed manually. This delegate provides the response from the Veryfi API.
Example:
{
"status": "done",
"data": { "advance_eic_payment":null,"allocated_tips":null,"control_number":null,"dependent_care_benefits":null,"ein":"46-1234567","employee_address":"80 WORKHOURS WAY\nSLEEPLESS HOLLOW NY 11222","employee_name":"DOCTORED B. MONEY","employee_ssn":"123-45-6879","employer_address":"123 PAYNE LANE\nPOSTCALL, NY 11111","employer_name":"BESTEST HOSPITAL EVER INC.","employer_state_id":null,"federal_income_tax":4000,"field_12a_col1":null,"field_12a_col2":45.5,"field_12b_col1":null,"field_12b_col2":5000,"field_12c_col1":null,"field_12c_col2":9800.57,"field_12d_col1":null,"field_12d_col2":null,"field_14_other":[{"column_1":"NY SDI","column_2":31.2}],"id":74511,"is_13a":false,"is_13b":false,"is_13c":false,"local_income_tax":500,"local_wages_tips":60000,"locality_name":"NYC","medicare_tax":870,"medicare_wages":60000,"non_qualified_plans":null,"pdf_url":"https:\/\/cdn.veryfi.com\/w2s\/partner-receipts\/14dfc62c-2713-4559-985a-073b4e33390d\/0394d9c5-49ff-464e-b50b-195f3058f770.pdf?Expires=1695936052&Signature=dmIlk369lsneef0jPZTH5DgG0cT36T1z~uTve7grasoMuCgjtiO8iRVVx6L8jxISygBBT1LDCrQlW1YJ6ODO7dPvAwUBApbwvDVLjDJ9OLc~XIeQ2G6Oi5ubrb9yRk6pvYeY-98DTzcGbfqThRzJOrUrYt34ngnMOspL40MYFj1ZIA7D8iqasHi0ql9Rdj6WCh4kXIbsFnvCNjKnQS3KZfWCDo8TtQJqwlisJPJJg3mmF3AEDAulaF2i1cUWGw7Hv82PBVEilgyPHtNzSXOZPyy-kVwNcHbnaoffsKkQer88wU5lLsnMdfY6skOKM7bfQuY9jEHJZOyAA8AHI2YenQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ","ss_tax":3720,"ss_tips":null,"ss_wages":60000,"state":"NY","state_income_tax":1500,"state_wages_tips":60000,"states":[{"state":"NY","employer_state_id":null,"state_wages_tips":60000,"state_income_tax":1500,"local_wages_tips":60000,"local_income_tax":500,"locality_name":"NYC"}],"wages_other_comps":55000 },
"package_id": "855d7fdf6ddf4939"
}
onVeryfiLensError
If an error occurs during uploading or processing a submitted document, an error object is sent. If a general exception or crash is caught in Veryfi Lens, an exception object is sent instead.
Error:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"error": "{\"status\":\"error\",\"message\":\"Failed to initialize AWS\",\"uploadId\":\"0921a75550504d2e\",\"code\":\"301\"}"
}
Exception:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"exception": "java.lang.IllegalArgumentException: Cannot create enum from value!\n\tat com.amazonaws.regions.Regions.fromName(Regions.java:126)\n\tat com.veryfi.lens.helpers.RegionHelper.getRegion(RegionHelper.kt:28)\n\tat com.veryfi.lens.service.UploadDocumentsService.setAccelerateModeEnable(UploadDocumentsService.kt:94)\n\tat com.veryfi.lens.service.UploadDocumentsService.onUploadType(UploadDocumentsService.kt:186)\n\tat com.veryfi.lens.service.UploadDocumentsService.onStartCommand(UploadDocumentsService.kt:161)\n\tat android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4236)\n\tat android.app.ActivityThread.access$1800(ActivityThread.java:231)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)\n\tat android.os.Handler.dispatchMessage(Handler.java:106)\n\tat android.os.Looper.loop(Looper.java:223)\n\tat android.app.ActivityThread.main(ActivityThread.java:7478)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)\n"
}
Veryfi Lens provides a camera experience that allows users to capture and submit documents for data extraction and enrichment. Lens communicates the activities performed by the user, the various progress stages and status updates and also the final results of the data extraction process asynchronously, with the help of events.
The following example simply logs all data received from all Lens events. This implementation will need to be adapted to do something that is more meaningful to your app's users.
Implementation:
const lensEventCallback = (event) => {
console.log(JSON.stringify(event, null, ' '))
}
const VeryfiLensEmitter = new NativeEventEmitter(VeryfiLens)
VeryfiLensEmitter.addListener(
VeryfiLens.getConstants().onVeryfiLensClose,
lensEventCallback
)
VeryfiLensEmitter.addListener(
VeryfiLens.getConstants().onVeryfiLensUpdate,
lensEventCallback
)
VeryfiLensEmitter.addListener(
VeryfiLens.getConstants().onVeryfiLensError,
lensEventCallback
)
VeryfiLensEmitter.addListener(
VeryfiLens.getConstants().onVeryfiLensSuccess,
lensEventCallback
)
Events
onVeryfiLensClose
Fired when the Veryfi Lens camera has been closed, either as a result of submitting an image for processing, or the user closed the camera without submitting an image.
Example:
{
"status": "close",
"queue_count": 1,
"framework-version": "1.4.0",
"session_scan_count": 1,
"framework-build": "1"
}
In the object above, queue_count refers to the number of submitted documents that are currently in the processing queue. session_scan_count refers to the number of documents that were submitted in the most recent Lens camera session - if this is equal to 0 (zero) then the camera session was canceled without submitting anything.
onVeryfiLensUpdate
During the processing of a document, this event will be raised multiple times. One time it will contain the thumbnail path for the submitted document, one time it will contain the original (submitted) image path and optionally, one time it will contain the stitched PDF path, if the user submitted more than one image for a document. In addition, multiple instances of this event will be fired containing the current upload progress percentage and other status updates.
Sample package created notification:
{
"status": "start",
"package_id": "edc8653e4c2b4ef1"
}
Thumbnail shared example:
{
"status": "inprogress",
"msg": "img_thumbnail_path",
"data": "/path/to/thumbnail.jpg",
"package_id": "edc8653e4c2b4ef1"
}
Full-size image shared example:
{
"status": "inprogress",
"msg": "img_original_path",
"data": "/path/to/image.jpg",
"package_id": "edc8653e4c2b4ef1",
"document_type": "receipt"
}
Stitched PDF shared example:
{
"status": "inprogress",
"msg": "img_stitched_pdf_path",
"data": "/path/to/images.pdf",
"package_id": "edc8653e4c2b4ef1"
}
Upload progress example:
{
"status": "inprogress",
"msg": "progress",
"data": 68,
"package_id": "edc8653e4c2b4ef1"
}
Package removed example:
{
"status": "removed",
"msg": "clear_package",
"package_id": "edc8653e4c2b4ef1"
}
onVeryfiLensSuccess
Fired once a document has finished processing, whether it was submitted via the camera, the gallery, or it was dictated or entered/typed manually. This delegate provides the response from the Veryfi API.
Example:
{
"status": "done",
"data": { "advance_eic_payment":null,"allocated_tips":null,"control_number":null,"dependent_care_benefits":null,"ein":"46-1234567","employee_address":"80 WORKHOURS WAY\nSLEEPLESS HOLLOW NY 11222","employee_name":"DOCTORED B. MONEY","employee_ssn":"123-45-6879","employer_address":"123 PAYNE LANE\nPOSTCALL, NY 11111","employer_name":"BESTEST HOSPITAL EVER INC.","employer_state_id":null,"federal_income_tax":4000,"field_12a_col1":null,"field_12a_col2":45.5,"field_12b_col1":null,"field_12b_col2":5000,"field_12c_col1":null,"field_12c_col2":9800.57,"field_12d_col1":null,"field_12d_col2":null,"field_14_other":[{"column_1":"NY SDI","column_2":31.2}],"id":74511,"is_13a":false,"is_13b":false,"is_13c":false,"local_income_tax":500,"local_wages_tips":60000,"locality_name":"NYC","medicare_tax":870,"medicare_wages":60000,"non_qualified_plans":null,"pdf_url":"https:\/\/cdn.veryfi.com\/w2s\/partner-receipts\/14dfc62c-2713-4559-985a-073b4e33390d\/0394d9c5-49ff-464e-b50b-195f3058f770.pdf?Expires=1695936052&Signature=dmIlk369lsneef0jPZTH5DgG0cT36T1z~uTve7grasoMuCgjtiO8iRVVx6L8jxISygBBT1LDCrQlW1YJ6ODO7dPvAwUBApbwvDVLjDJ9OLc~XIeQ2G6Oi5ubrb9yRk6pvYeY-98DTzcGbfqThRzJOrUrYt34ngnMOspL40MYFj1ZIA7D8iqasHi0ql9Rdj6WCh4kXIbsFnvCNjKnQS3KZfWCDo8TtQJqwlisJPJJg3mmF3AEDAulaF2i1cUWGw7Hv82PBVEilgyPHtNzSXOZPyy-kVwNcHbnaoffsKkQer88wU5lLsnMdfY6skOKM7bfQuY9jEHJZOyAA8AHI2YenQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ","ss_tax":3720,"ss_tips":null,"ss_wages":60000,"state":"NY","state_income_tax":1500,"state_wages_tips":60000,"states":[{"state":"NY","employer_state_id":null,"state_wages_tips":60000,"state_income_tax":1500,"local_wages_tips":60000,"local_income_tax":500,"locality_name":"NYC"}],"wages_other_comps":55000 },
"package_id": "855d7fdf6ddf4939"
}
onVeryfiLensError
If an error occurs during uploading or processing a submitted document, an error object is sent. If a general exception or crash is caught in Veryfi Lens, an exception object is sent instead.
Error:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"error": "{\"status\":\"error\",\"message\":\"Failed to initialize AWS\",\"uploadId\":\"0921a75550504d2e\",\"code\":\"301\"}"
}
Exception:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"exception": "java.lang.IllegalArgumentException: Cannot create enum from value!\n\tat com.amazonaws.regions.Regions.fromName(Regions.java:126)\n\tat com.veryfi.lens.helpers.RegionHelper.getRegion(RegionHelper.kt:28)\n\tat com.veryfi.lens.service.UploadDocumentsService.setAccelerateModeEnable(UploadDocumentsService.kt:94)\n\tat com.veryfi.lens.service.UploadDocumentsService.onUploadType(UploadDocumentsService.kt:186)\n\tat com.veryfi.lens.service.UploadDocumentsService.onStartCommand(UploadDocumentsService.kt:161)\n\tat android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4236)\n\tat android.app.ActivityThread.access$1800(ActivityThread.java:231)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)\n\tat android.os.Handler.dispatchMessage(Handler.java:106)\n\tat android.os.Looper.loop(Looper.java:223)\n\tat android.app.ActivityThread.main(ActivityThread.java:7478)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)\n"
}
Veryfi Lens provides a camera experience that allows users to capture and submit documents for data extraction and enrichment. Lens communicates the activities performed by the user, the various progress stages and status updates and also the final results of the data extraction process asynchronously, with the help of events.
The following example simply logs all data received from all Lens events. This implementation will need to be adapted to do something that is more meaningful to your app's users. Define your event handler. Refer to the full list of events available in the event handler later in this section.
Implementation:
void handleVeryfiEvent(LensEvent eventType, Map<String, dynamic> response) {
if (eventType == LensEvent.close) {
debugPrint("[close] data: ${response}");
}
if (eventType == LensEvent.error) {
debugPrint("[error] data: ${response}");
}
if (eventType == LensEvent.success) {
debugPrint("[success] data: ${response}");
}
if (eventType == LensEvent.update) {
debugPrint("[update] data: ${response}");
}
}
Events
LensEvent.close
Fired when the Veryfi Lens camera has been closed, either as a result of submitting an image for processing, or the user closed the camera without submitting an image.
Example:
{
"status": "close",
"queue_count": 1,
"framework-version": "1.4.0",
"session_scan_count": 1,
"framework-build": "1"
}
In the object above, queue_count refers to the number of submitted documents that are currently in the processing queue. session_scan_count refers to the number of documents that were submitted in the most recent Lens camera session - if this is equal to 0 (zero) then the camera session was canceled without submitting anything.
LensEvent.update
During the processing of a document, this event will be raised multiple times. One time it will contain the thumbnail path for the submitted document, one time it will contain the original (submitted) image path and optionally, one time it will contain the stitched PDF path, if the user submitted more than one image for a document. In addition, multiple instances of this event will be fired containing the current upload progress percentage and other status updates.
Sample package created notification:
{
"status": "start",
"package_id": "edc8653e4c2b4ef1"
}
Thumbnail shared example:
{
"status": "inprogress",
"msg": "img_thumbnail_path",
"data": "/path/to/thumbnail.jpg",
"package_id": "edc8653e4c2b4ef1"
}
Full-size image shared example:
{
"status": "inprogress",
"msg": "img_original_path",
"data": "/path/to/image.jpg",
"package_id": "edc8653e4c2b4ef1",
"document_type": "receipt"
}
Stitched PDF shared example:
{
"status": "inprogress",
"msg": "img_stitched_pdf_path",
"data": "/path/to/images.pdf",
"package_id": "edc8653e4c2b4ef1"
}
Upload progress example:
{
"status": "inprogress",
"msg": "progress",
"data": 68,
"package_id": "edc8653e4c2b4ef1"
}
Package removed example:
{
"status": "removed",
"msg": "clear_package",
"package_id": "edc8653e4c2b4ef1"
}
LensEvent.success
Fired once a document has finished processing, whether it was submitted via the camera, the gallery, or it was dictated or entered/typed manually. This delegate provides the response from the Veryfi API.
Example:
{
"status": "done",
"data": { "advance_eic_payment":null,"allocated_tips":null,"control_number":null,"dependent_care_benefits":null,"ein":"46-1234567","employee_address":"80 WORKHOURS WAY\nSLEEPLESS HOLLOW NY 11222","employee_name":"DOCTORED B. MONEY","employee_ssn":"123-45-6879","employer_address":"123 PAYNE LANE\nPOSTCALL, NY 11111","employer_name":"BESTEST HOSPITAL EVER INC.","employer_state_id":null,"federal_income_tax":4000,"field_12a_col1":null,"field_12a_col2":45.5,"field_12b_col1":null,"field_12b_col2":5000,"field_12c_col1":null,"field_12c_col2":9800.57,"field_12d_col1":null,"field_12d_col2":null,"field_14_other":[{"column_1":"NY SDI","column_2":31.2}],"id":74511,"is_13a":false,"is_13b":false,"is_13c":false,"local_income_tax":500,"local_wages_tips":60000,"locality_name":"NYC","medicare_tax":870,"medicare_wages":60000,"non_qualified_plans":null,"pdf_url":"https:\/\/cdn.veryfi.com\/w2s\/partner-receipts\/14dfc62c-2713-4559-985a-073b4e33390d\/0394d9c5-49ff-464e-b50b-195f3058f770.pdf?Expires=1695936052&Signature=dmIlk369lsneef0jPZTH5DgG0cT36T1z~uTve7grasoMuCgjtiO8iRVVx6L8jxISygBBT1LDCrQlW1YJ6ODO7dPvAwUBApbwvDVLjDJ9OLc~XIeQ2G6Oi5ubrb9yRk6pvYeY-98DTzcGbfqThRzJOrUrYt34ngnMOspL40MYFj1ZIA7D8iqasHi0ql9Rdj6WCh4kXIbsFnvCNjKnQS3KZfWCDo8TtQJqwlisJPJJg3mmF3AEDAulaF2i1cUWGw7Hv82PBVEilgyPHtNzSXOZPyy-kVwNcHbnaoffsKkQer88wU5lLsnMdfY6skOKM7bfQuY9jEHJZOyAA8AHI2YenQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ","ss_tax":3720,"ss_tips":null,"ss_wages":60000,"state":"NY","state_income_tax":1500,"state_wages_tips":60000,"states":[{"state":"NY","employer_state_id":null,"state_wages_tips":60000,"state_income_tax":1500,"local_wages_tips":60000,"local_income_tax":500,"locality_name":"NYC"}],"wages_other_comps":55000 },
"package_id": "855d7fdf6ddf4939"
}
LensEvent.error
If an error occurs during uploading or processing a submitted document, an error object is sent. If a general exception or crash is caught in Veryfi Lens, an exception object is sent instead.
Error:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"error": "{\"status\":\"error\",\"message\":\"Failed to initialize AWS\",\"uploadId\":\"0921a75550504d2e\",\"code\":\"301\"}"
}
Exception:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"exception": "java.lang.IllegalArgumentException: Cannot create enum from value!\n\tat com.amazonaws.regions.Regions.fromName(Regions.java:126)\n\tat com.veryfi.lens.helpers.RegionHelper.getRegion(RegionHelper.kt:28)\n\tat com.veryfi.lens.service.UploadDocumentsService.setAccelerateModeEnable(UploadDocumentsService.kt:94)\n\tat com.veryfi.lens.service.UploadDocumentsService.onUploadType(UploadDocumentsService.kt:186)\n\tat com.veryfi.lens.service.UploadDocumentsService.onStartCommand(UploadDocumentsService.kt:161)\n\tat android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4236)\n\tat android.app.ActivityThread.access$1800(ActivityThread.java:231)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)\n\tat android.os.Handler.dispatchMessage(Handler.java:106)\n\tat android.os.Looper.loop(Looper.java:223)\n\tat android.app.ActivityThread.main(ActivityThread.java:7478)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)\n"
}
Veryfi Lens provides a camera experience that allows users to capture and submit documents for data extraction and enrichment. Lens communicates the activities performed by the user, the various progress stages and status updates and also the final results of the data extraction process asynchronously, with the help of events.
The following example simply logs all data received from all Lens events. This implementation will need to be adapted to do something that is more meaningful to your app's users. Define your event handler. Refer to the full list of events available in the event handler later in this section.
Implementation:
1. Define your event handler. Refer to the full list of events available in the event handler later in this section.
- iOS
private class VeryfiLensDelegateListener : VeryfiLensDelegate
{
public override void VeryfiLensClose(NSDictionary<NSString, NSObject> json)
{
System.Console.WriteLine("VeryfiLensClose: " + json.ToString());
}
public override void VeryfiLensError(NSDictionary<NSString, NSObject> json)
{
System.Console.WriteLine("VeryfiLensError: " + json.ToString());
}
public override void VeryfiLensSuccess(NSDictionary<NSString, NSObject> json)
{
System.Console.WriteLine("VeryfiLensSuccess: " + json.ToString());
}
public override void VeryfiLensUpdate(NSDictionary<NSString, NSObject> json)
{
System.Console.WriteLine("VeryfiLensUpdate: " + json.ToString());
}
}
- Android
private class VeryfiLensDelegateListener : Java.Lang.Object, IVeryfiLensDelegate
{
void IVeryfiLensDelegate.VeryfiLensClose(JSONObject json)
{
System.Console.WriteLine("VeryfiLensClose: " + json.ToString());
}
void IVeryfiLensDelegate.VeryfiLensError(JSONObject json)
{
System.Console.WriteLine("VeryfiLensError: " + json.ToString());
}
void IVeryfiLensDelegate.VeryfiLensSuccess(JSONObject json)
{
System.Console.WriteLine("VeryfiLensSuccess: " + json.ToString());
}
void IVeryfiLensDelegate.VeryfiLensUpdate(JSONObject json)
{
System.Console.WriteLine("VeryfiLensUpdate: " + json.ToString());
}
}
2. Assign your event handler in Veryfi Lens:
- iOS:
VeryfiLens.Shared().Delegate = new VeryfiLensDelegateListener()
- Android:
VeryfiLens.SetDelegate(new VeryfiLensDelegateListener())
Events
VeryfiLensClose
Fired when the Veryfi Lens camera has been closed, either as a result of submitting an image for processing, or the user closed the camera without submitting an image.
Example:
{
"status": "close",
"queue_count": 1,
"framework-version": "1.4.0",
"session_scan_count": 1,
"framework-build": "1"
}
In the object above, queue_count refers to the number of submitted documents that are currently in the processing queue. session_scan_count refers to the number of documents that were submitted in the most recent Lens camera session - if this is equal to 0 (zero) then the camera session was canceled without submitting anything.
VeryfiLensUpdate
During the processing of a document, this event will be raised multiple times. One time it will contain the thumbnail path for the submitted document, one time it will contain the original (submitted) image path and optionally, one time it will contain the stitched PDF path, if the user submitted more than one image for a document. In addition, multiple instances of this event will be fired containing the current upload progress percentage and other status updates.
Sample package created notification:
{
"status": "start",
"package_id": "edc8653e4c2b4ef1"
}
Thumbnail shared example:
{
"status": "inprogress",
"msg": "img_thumbnail_path",
"data": "/path/to/thumbnail.jpg",
"package_id": "edc8653e4c2b4ef1"
}
Full-size image shared example:
{
"status": "inprogress",
"msg": "img_original_path",
"data": "/path/to/image.jpg",
"package_id": "edc8653e4c2b4ef1",
"document_type": "receipt"
}
Stitched PDF shared example:
{
"status": "inprogress",
"msg": "img_stitched_pdf_path",
"data": "/path/to/images.pdf",
"package_id": "edc8653e4c2b4ef1"
}
Upload progress example:
{
"status": "inprogress",
"msg": "progress",
"data": 68,
"package_id": "edc8653e4c2b4ef1"
}
Package removed example:
{
"status": "removed",
"msg": "clear_package",
"package_id": "edc8653e4c2b4ef1"
}
VeryfiLensSuccess
Fired once a document has finished processing, whether it was submitted via the camera, the gallery, or it was dictated or entered/typed manually. This delegate provides the response from the Veryfi API.
Example:
{
"status": "done",
"data": { "advance_eic_payment":null,"allocated_tips":null,"control_number":null,"dependent_care_benefits":null,"ein":"46-1234567","employee_address":"80 WORKHOURS WAY\nSLEEPLESS HOLLOW NY 11222","employee_name":"DOCTORED B. MONEY","employee_ssn":"123-45-6879","employer_address":"123 PAYNE LANE\nPOSTCALL, NY 11111","employer_name":"BESTEST HOSPITAL EVER INC.","employer_state_id":null,"federal_income_tax":4000,"field_12a_col1":null,"field_12a_col2":45.5,"field_12b_col1":null,"field_12b_col2":5000,"field_12c_col1":null,"field_12c_col2":9800.57,"field_12d_col1":null,"field_12d_col2":null,"field_14_other":[{"column_1":"NY SDI","column_2":31.2}],"id":74511,"is_13a":false,"is_13b":false,"is_13c":false,"local_income_tax":500,"local_wages_tips":60000,"locality_name":"NYC","medicare_tax":870,"medicare_wages":60000,"non_qualified_plans":null,"pdf_url":"https:\/\/cdn.veryfi.com\/w2s\/partner-receipts\/14dfc62c-2713-4559-985a-073b4e33390d\/0394d9c5-49ff-464e-b50b-195f3058f770.pdf?Expires=1695936052&Signature=dmIlk369lsneef0jPZTH5DgG0cT36T1z~uTve7grasoMuCgjtiO8iRVVx6L8jxISygBBT1LDCrQlW1YJ6ODO7dPvAwUBApbwvDVLjDJ9OLc~XIeQ2G6Oi5ubrb9yRk6pvYeY-98DTzcGbfqThRzJOrUrYt34ngnMOspL40MYFj1ZIA7D8iqasHi0ql9Rdj6WCh4kXIbsFnvCNjKnQS3KZfWCDo8TtQJqwlisJPJJg3mmF3AEDAulaF2i1cUWGw7Hv82PBVEilgyPHtNzSXOZPyy-kVwNcHbnaoffsKkQer88wU5lLsnMdfY6skOKM7bfQuY9jEHJZOyAA8AHI2YenQ__&Key-Pair-Id=APKAJCILBXEJFZF4DCHQ","ss_tax":3720,"ss_tips":null,"ss_wages":60000,"state":"NY","state_income_tax":1500,"state_wages_tips":60000,"states":[{"state":"NY","employer_state_id":null,"state_wages_tips":60000,"state_income_tax":1500,"local_wages_tips":60000,"local_income_tax":500,"locality_name":"NYC"}],"wages_other_comps":55000 },
"package_id": "855d7fdf6ddf4939"
}
VeryfiLensError
If an error occurs during uploading or processing a submitted document, an error object is sent. If a general exception or crash is caught in Veryfi Lens, an exception object is sent instead.
Error:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"error": "{\"status\":\"error\",\"message\":\"Failed to initialize AWS\",\"uploadId\":\"0921a75550504d2e\",\"code\":\"301\"}"
}
Exception:
{
"status": "error",
"package_id": "edc8653e4c2b4ef1",
"exception": "java.lang.IllegalArgumentException: Cannot create enum from value!\n\tat com.amazonaws.regions.Regions.fromName(Regions.java:126)\n\tat com.veryfi.lens.helpers.RegionHelper.getRegion(RegionHelper.kt:28)\n\tat com.veryfi.lens.service.UploadDocumentsService.setAccelerateModeEnable(UploadDocumentsService.kt:94)\n\tat com.veryfi.lens.service.UploadDocumentsService.onUploadType(UploadDocumentsService.kt:186)\n\tat com.veryfi.lens.service.UploadDocumentsService.onStartCommand(UploadDocumentsService.kt:161)\n\tat android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4236)\n\tat android.app.ActivityThread.access$1800(ActivityThread.java:231)\n\tat android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)\n\tat android.os.Handler.dispatchMessage(Handler.java:106)\n\tat android.os.Looper.loop(Looper.java:223)\n\tat android.app.ActivityThread.main(ActivityThread.java:7478)\n\tat java.lang.reflect.Method.invoke(Native Method)\n\tat com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)\n\tat com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)\n"
}