Bank Account Linking Elements

Secure bank account linking

Element_Updated Specific Messages

type ElementResult = {
  status: initial | success| review | failed;
};

Complete React, TypeScript Code Sample

import React, { useEffect, useState, useMemo } from 'react';

const EJS = window.FortressElementsJS;

function generateElementSessionJWT(identityId) {
    return axios.get(
      `/api/trust/v1/identity-elements/{identityId}/jwt?element="addBankAccount"`,
    );
  }

function Main() {
  const ElementBankAccount = useMemo(() => EJS.createElementClient({
    elementName: EJS.ElementNames['BANK-ACCOUNT'],
    onMessage: (message) => {
      if (message.type === EJS.ElementEvenTypes.ELEMENT_STARTED) {
        // handle action element started
      }
    },
    theme: ThemeConfig // link on ThemeConfig section
  }), []);

  const identityId = '9a443475-5159-4f51-bf21-002e6609091e';
  const { data: { jwt } } = await generateElementSessionJWT(identityId);

  useEffect(() => {
    ElementBankAccount.done(({ status }) => {
      if (status !== EJS.ElementResultStatus.Success) {
        /// Show notification...
      }
      console.log(`Element result status: ${status}`);
    });
    return () => {
      ElementBankAccount.destroy();
    };
  }, [ElementBankAccount]);

  return (
    <button
      type="button"
      onClick={() => ElementBankAccount.run(jwt)}
    >
      Open add bank account
    </button>
  );
}

export default Main;