Before you start
You need your Public Merchant Key. You can find it in the API / Webhook section of your Youverify dashboard. It is safe to use in client-side code.Document Capture on web is initialized with your Public Merchant Key. You don’t need to generate a session ID on your server for this flow. Keep your secret API key on your server and never put it in a web page.
Installation
- npm
- yarn
Integration steps
1
Create the Document Capture module
Pass your options to
YouverifySDK.documentCapture:2
Initialize the module
Call
initialize() once. It throws if the options are invalid, so wrap it in a try block.3
Start the capture flow
Call
start() when your user is ready, for example on a button click. This opens the modal.Options
string
required
Your Public Merchant Key from the API / Webhook section of your dashboard.
boolean
default:"false"
Set to
true to run in sandbox mode while you develop and test. Set to false for production.boolean
default:"false"
Set to
true to hide the option to capture the document with a secondary device.object
User attributes used to personalize the experience.
object
Customize the greeting text, button text and colours. All fields are optional.
array
Limit the capture to specific countries and document types. Each item is an object. All fields are optional.
object
Any other information you want sent to your webhook URL. Use your own keys.
(data) => void
Called when document capture has a result. See Success result.
(error) => void
Called when the result could not be retrieved. Receives an error object.
() => void
Called when the modal is closed.
Success result
When capture succeeds,onSuccess receives an object like this:
string
Base64 image of the front of the document.
string
Base64 image of the back of the document.
string
Base64 image of the front of the document. Present when the document has no back to capture.
onSuccess callback, nothing happens when capture succeeds.
Close the modal from code
You can close the SDK modal from your own code withsetShowModal. It takes a Boolean and returns nothing.