Airwallex JS
Airwallex logoAirwallex logo

Transfer Element

Copy for LLMView as Markdown
The Transfer Element renders a UI to collect transfer details such as date and amount while displaying key information like conversion rates and fees. To explore the experience, go to the Airwallex demo site.

createElement('payoutForm', options?)

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

Parameters

type

required'payoutForm'
The type of element you are creating.

options

optionalPayoutFormOptions
Options for creating payoutForm Element.

apiVersion

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

customizations

optionalPayoutFormCustomizations
Customization options for the form's behavior and appearance.

defaultValues

optionalPayoutFormDefaultValues

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.

locale

optional'en' | 'zh' | 'zh-HK' | 'de' | 'es' | 'fr' | 'it' | 'ja' | 'ko' | 'en-US' | 'es-MX' | 'tr'
The locale for the Element, applied to Element UI strings and error messages. By default, the locale configured in init() is used.

langKey

optional'en' | 'zh' | 'zh-HK' | 'de' | 'es' | 'fr' | 'it' | 'ja' | 'ko' | 'en-US' | 'es-MX' | 'tr'Deprecated
Use locale instead.

Returns

PayoutFormElement | null

createElement('payoutForm', options?)

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

destroy()

Destroys the Element instance.

destroy()

1element.destroy();

mount(domElement)

Mounts Element to your HTML DOM.

Parameters

domElement

requiredstring | HTMLElement
The container DOM element to mount the element.

mount(domElement)

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('ready', handler)

This event will be fired when the form is ready to interact with the user.

Parameters

type

required'ready'
The event name.

handler

required() => void
The callback function that will be called when the event occurs.

on('ready', handler)

1element.on('ready', () => {
2 console.log('Payout form is ready');
3 });

on('error', handler)

This event will be fired when form encounters an unexpected error.

Parameters

type

required'error'
The event name.

handler

requiredfunction

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

The handler receives an object with the following properties:

code

required'UNKNOWN_ERROR' | 'INVALID_BENEFICIARY_ID'
The unexpected error code, for example: UNKNOWN_ERROR.

message

optionalstring
The unexpected error message.

on('error', handler)

1element.on('error', (data: { code: string }) => {
2 console.error(data.code);
3 });

on('formState', handler)

This event will be fired when the form validation state or loading state is changed.

Parameters

type

required'formState'
The event name.

handler

requiredfunction

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

The handler receives an object with the following properties:

errors

requiredPayoutFormErrors
The error message if the form is invalid.

loading

requiredboolean
Whether the form is loading.

validation

requiredboolean
Whether the form is valid.

on('formState', handler)

1element.on('formState', (data: { loading: boolean; validation: boolean; errors: string }) => {
2 // validation is true if the form is valid
3 // loading is true if the form is loading
4 // errors is the error message if the form is invalid
5 });

on('change', handler)

This event will be fired when the form values change.

Parameters

type

required'change'
The event name.

handler

requiredfunction

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

The handler receives an object with the following properties:

values

requiredPayoutFormValues
The form value.

on('change', handler)

1element.on('change', (data: {values: PayoutFormValues}) => {
2 // data.values is the form value
3 });

submit()

Collects transfer information by submitting the form.

Returns

Promise<PayoutFormSubmitResponse>

PayoutFormSubmitResponse

requiredobject

additionalInfo

requiredPayoutFormAdditionalInfo
Additional information about the transfer, for example, the reason for the transfer.

values

requiredPayoutFormValues
The values submitted by the user.

errors

optionalPayoutFormErrors
The errors that occurred during the submission.

submit()

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.

unmount()

1element.unmount();
Was this page helpful?