A guide on creating a customized electronic Know Your Customer (eKYC) flow with form handling and validation.

Instead of building your own flow, it’s highly recommended to fork an existing flow from the public sample codes found here

1

Initialize OneSDK

1const oneSDKInstance = await OneSDK({
2 session: sessionObjectFromBackend,
3 mode: "production",
4 recipe: {
5 form: {
6 provider: {
7 name: "react",
8 googleApiKey: '<YOUR GOOGLE MAPS API KEY>'
9 },
10 },
11 },
12});

Replace <YOUR GOOGLE MAPS API KEY> with your actual Google Maps API key for the address feature.

2

Set Up Individual Profile

1const oneSdkIndividual = oneSDKInstance.individual();
2oneSdkIndividual.setProfileType("auto");
3

Configure Form Components

Event Handling

1welcome.on("form:welcome:ready", () => {
2 consent.mount(appContainer);
3});
4
5consent.on("form:consent:ready", async () => {
6 personal.mount(appContainer);
7});
8
9personal.on("form:personal:ready", async () => {
10 document.mount(appContainer);
11});
12
13document.on("form:document:ready", async () => {
14 review.mount(appContainer);
15});

Retry Logic Implementation

The implementation includes a retry mechanism that allows users up to 2 attempts before showing the failure screen.

1// Define the retry form
2const retry = oneSDKInstance.component("form", {
3 name: "RETRY",
4 type: "manual",
5});
6
7// Define the retry count
8let retryCount = 0;
9
10// Add partial result event listener to the review form
11review.on("form:result:partial", async () => {
12 if (retryCount < 2) {
13 retry.mount(appContainer);
14 } else {
15 result_fail.mount(appContainer);
16 }
17});

Best Practices

Error Handling

Always implement proper error handling and validation for each form step to ensure data quality.

User Experience

Provide clear feedback and instructions in the user’s preferred language, especially for country-specific forms.

Was this page helpful?
Built with