Skip to main content

Initialization

  1. Create index.js next to your index.html
  2. Import it to your index.html <script src="index.js" type="module"></script>
  3. Import SDK to your index.js import VeryfiLens from "./veryfi-lens-wasm/veryfi-lens.js"
  4. Set process url and your credentials from Authentification
const PROCESS_DOCUMENT_URL = "https://lens.veryfi.com/rest/process" or "https://lens-dev.veryfi.com/rest/process";
const CLIENT_ID = "YOUR_CLIENT_ID";
const API_KEY = "YOUR_API_KEY";
const USERNAME = "your.username";
  1. Add function to validate client and receive session token (it is necessary to initialize Lens)
async function validatePartner(clientId) {
const validateUrl = "https://lens.veryfi.com/rest/validate_partner";
try {
const requestOptions = {
method: "POST",
headers: { "CLIENT-ID": clientId },
};
const response = await fetch(validateUrl, requestOptions);
const data = await response.json();
return data.session;
} catch (error) {
console.error("Error validating partner:", error);
return null;
}
}
  1. Call it const sessionToken = validatePartner(CLIENT_ID)

  2. Call const deviceData = await VeryfiLens.getDeviceData() (Is reqiured to send an image to our backend)

  1. Add following div to your index.html (Stitching preview will be rendered to it)
  • <div id="preview-container"></div>
  1. Call await VeryfiLens.initWasmLong(sessionToken, CLIENT_ID)

Long receipt capturing consists of 2 stages

  1. await VeryfiLens.startStitching() - Starts sending frames to WASM and stitches long document together
  2. await VeryfiLens.captureLong() - Stops stitching and returns result