Summary

A Handler that runs whenever the user is still in the process of authentication, but has some missing kyc data to complete before they can be fully authenticated.

If information capture is enabled and has required fields or optional fields without the option to skip optional fields during onboarding turned on, the user must be updated with the required information before they’re considered authenticated.

This handler is always used when it’s set, which means the sdk will not display the modal to prompt for user information. The handler must be set when using the sdk in a headless mode or if you wish to handle onboarding on your own.

Usage

<DynamicContextProvider
  settings={{
    handlers: {
      handleUserOnboarding: async (missingFields: UserOnboardingFieldRequest[]) => {
        console.log("handleUserOnboarding was called", missingFields);
        
        /** Example
         * missingFields: [
         *  {
         *    key: 'email',
         *    required: true, 
         *    isCustom: false, // only true for custom fields
         *  },
         *  {
         *    key: 'city',
         *    required: false,
         *    isCustom: true, // only true for custom fields
         *    label: 'City',
         *  }
         * ]
        */
        
        // TODO: collect user information to return to dynamic 

        // Note: isCustom value should be the same as the one received
        return [
          { key: 'email', value: 'email@test.com', isCustom: false }, 
          { key: 'city', value: 'New York', isCustom: true }, 
        ];
      },
    },
  }}
>
  {/* ... rest of your app ... */}
</DynamicContextProvider>

Types

type HandleUserOnboarding = (
  missingFields: UserOnboardingFieldRequest[],
) => Promise<UserOnboardingFieldResponse[]>;

type UserOnboardingFieldRequest = {
  key: string;
  required: boolean;
  isCustom: boolean;
  label?: string;
};

type UserOnboardingFieldResponse = {
  key: string;
  value: string;
  isCustom: boolean;
};