Create Transfer Element

createElement('payoutForm', options?)

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

Parameters

typerequired'payoutForm'

The type of element you are creating.

optionsoptionalPayoutFormElementOptions

Options for creating payoutForm Element.

Returns

PayoutFormElement | null
linkTypeScript
1import { createElement } from '@airwallex/components-sdk';
2const element = await createElement('payoutForm', {
3 defaultValues: {
4 beneficiary_id: 'replace-with-your-beneficiary-id',
5 },
6});

PayoutFormElementOptions

Options for creating the Payout 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 and appearance.

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.

PayoutFormElement

Functions and external fields can be used in your integration flow with Payout 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 PayoutFormEventCode enum
5});

submit()

Collects transfer information by submitting the form.

Returns

Promiselink<>
linkTypeScript
1const { values: transfer, errors } = await element.submit();
2if (!errors) {
3 // Submit the transfer 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();