diff --git a/.env.example b/.env.example
index 86056bc..3f9948f 100644
--- a/.env.example
+++ b/.env.example
@@ -1,5 +1,6 @@
VITE_API_URL=https://demo-api.incodesmile.com/0
-VITE_SDK_URL=https://sdk.incode.com/sdk/onBoarding-1.71.1.js
+VITE_SDK_URL=https://sdk.incode.com/sdk/onBoarding-1.73.1.js
+VITE_CONSENT_ID=
# HERE ONLY FOR DEMO PURPOSES, THE APIKEY AND THE FLOW_ID SHOULD NEVER BE IN THE FRONTEND.
VITE_FAKE_BACKEND_APIURL=https://demo-api.incodesmile.com
diff --git a/fake_backend.js b/fake_backend.js
index 6749523..bb7ec7c 100644
--- a/fake_backend.js
+++ b/fake_backend.js
@@ -14,6 +14,8 @@ const fakeBackendStart = async function() {
const url = `${apiurl}/omni/start`;
const params = {
configurationId: flowid,
+ // language: "pt-BR",
+ // language: "es-ES",
// language: "en-US",
// redirectionUrl: "https://example.com?custom_parameter=some+value",
// externalCustomerId: "the id of the customer in your system",
diff --git a/main.js b/main.js
index bc6c56f..f019b38 100644
--- a/main.js
+++ b/main.js
@@ -2,36 +2,51 @@ import { fakeBackendStart, fakeBackendFinish } from './fake_backend'
let incode;
let incodeSession;
-const container = document.getElementById("camera-container");
+let showTutorialsFlag=true;
+const cameraContainer = document.getElementById("camera-container");
function showError(e=null) {
- container.innerHTML = "
There was an error
";
- console.log(e.message)
+ const finishContainer = document.getElementById("finish-container");
+ if (e?.message) {
+ finishContainer.innerHTML = `Error: ${e.message}
`;
+ } else {
+ finishContainer.innerHTML = "There was an error
";
+ console.log(e);
+ }
}
function saveDeviceData() {
incode.sendGeolocation({ token: incodeSession.token });
incode.sendFingerprint({ token: incodeSession.token });
- captureIdFrontSide();
+ getCombinedConsent();
+}
+
+function getCombinedConsent() {
+ const consentId = import.meta.env.VITE_CONSENT_ID;
+ incode.renderCombinedConsent(cameraContainer, {
+ onSuccess: captureIdFrontSide,
+ token: incodeSession,
+ consentId: consentId
+ });
}
function captureIdFrontSide() {
- incode.renderCamera("front", container, {
+ incode.renderCamera("front", cameraContainer, {
onSuccess: captureIdBackSide,
onError: showError,
token: incodeSession,
numberOfTries: 3,
- showTutorial: true
+ showTutorial: showTutorialsFlag
});
}
function captureIdBackSide(response) {
- incode.renderCamera("back", container, {
+ incode.renderCamera("back", cameraContainer, {
onSuccess: processId,
onError: showError,
token: incodeSession,
numberOfTries: 3,
- showTutorial: true
+ showTutorial: showTutorialsFlag
});
}
@@ -44,12 +59,12 @@ async function processId() {
}
function captureSelfie() {
- incode.renderCamera("selfie", container, {
+ incode.renderCamera("selfie", cameraContainer, {
onSuccess: finishOnboarding,
onError: showError,
token: incodeSession,
numberOfTries: 3,
- showTutorial: true
+ showTutorial: showTutorialsFlag
});
}
@@ -57,39 +72,32 @@ function finishOnboarding() {
// Finishing the session works along with the configuration in the flow
// webhooks and business rules are ran here.
fakeBackendFinish(incodeSession.token)
- .then((response) => {
- console.log(response);
- const container = document.getElementById("finish-container");
- container.innerHTML = "Onboarding Finished.
";
- })
- .catch((error) => {
- showError(error);
- });
+ .then((response) => {
+ console.log(response);
+ const container = document.getElementById("finish-container");
+ container.innerHTML = "Onboarding Finished.
";
+ })
+ .catch((e) => {
+ showError(e);
+ });
}
async function app() {
try {
const apiURL = import.meta.env.VITE_API_URL;
incode = window.OnBoarding.create({
- apiURL: apiURL
+ apiURL: apiURL,
+ lang: "en"
});
// Create the single session
- container.innerHTML = "Creating session...
";
- try {
- incodeSession = await fakeBackendStart();
- } catch(e) {
- showError(e);
- return;
- }
-
+ cameraContainer.innerHTML = "Creating session...
";
+ incodeSession = await fakeBackendStart();
// Empty the container and start the flow
- container.innerHTML = "";
+ cameraContainer.innerHTML = "";
saveDeviceData();
} catch (e) {
- console.dir(e);
- container.innerHTML = "Something Went Wrong
";
- throw e;
+ showError(e);
}
}