Create Beneficiary Element

createElement('beneficiaryForm', options?)

Use this function to create an instance of an individual Element.

Parameters

typerequired'beneficiaryForm'

The type of element you are creating.

optionsoptionalBeneficiaryFormElementOptions

Options for creating beneficiaryForm Element.

Returns

BeneficiaryFormElement | null
linkTypeScript
1import { createElement } from '@airwallex/components-sdk';
2const element = await createElement('beneficiaryForm', {
3 defaultValues: {
4 beneficiary: {
5 entity_type: 'COMPANY',
6 bank_details: {
7 account_currency: 'AUD',
8 bank_country_code: 'AU',
9 local_clearing_system: 'BANK_TRANSFER',
10 },
11 },
12 transfer_methods: ['LOCAL'],
13 },
14});

BeneficiaryFormElementOptions

Options for creating the Beneficiary Form Element.

apiVersionoptionalstring

The Airwallex API version to use for the form. Only support for api version after 2023-04-15.

customizationsoptional

Customization options for the form's behavior.

Pre-filled values for the form fields. Note: Pre-filled values only take effect for fields that can be rendered on initial load. Fields that are dynamically generated through user interactions will not be affected by default values.

The locale for the Element, applied to Element UI strings and error messages. By default, the locale configured in init() is used.

langKeydeprecated

Use locale instead.

BeneficiaryFormElement

Functions and external fields can be used in your integration flow with Beneficiary Form element.

destroy()

Destroys the Element instance.

Returns

void
linkTypeScript
1element.destroy();

mount(domElement)

Mounts Element to your HTML DOM.

Parameters

domElementrequiredstring | HTMLElement

The container DOM element to mount the element.

Returns

void
linkTypeScript
1// There are two ways to mount the element:
2// 1. Call with the container DOM id
3element.mount('container-dom-id');
4
5// 2. Find the created DOM in the existing HTML and call with the container DOM element
6const containerElement = document.getElementById('container-dom-id');
7element.mount(containerElement);

on(eventCode, handler)

Listen to the Element events.

Parameters

The event code to listen for.

The callback function that will be called when the event occurs.

Returns

void
linkTypeScript
1element.on('ready', () => {
2 // The 'ready' event indicates that the form is ready for user interaction
3 // This event can be used to hide loading indicators
4 // For a complete list of event codes, please refer to the BeneficiaryFormEventCode enum
5});

submit()

Collects beneficiary information by submitting the form.

Returns

Promiselink<>
linkTypeScript
1const { values: beneficiary, errors } = await element.submit();
2if (!errors) {
3 // Submit the beneficiary information to the backend for processing
4} else {
5 // Handle errors using the error code
6}

unmount()

Unmounts the Element. Note that the Element instance will remain.

Returns

void
linkTypeScript
1element.unmount();