Tax Form Element
The Tax Form Element renders a UI to collect your beneficiary’s tax information for US 1099-NEC filing, including TIN/SSN, name, and address.
createElement('taxForm', options?)
Use this function to create an instance of an individual Element.
Parameters
type
required'taxForm'The type of element you are creating.
options
optionalTaxFormElementOptionsOptions for creating
taxForm Element.enabledForms
optional('Form8233' | 'W8ben' | 'W8bene' | 'W8eci' | 'W8exp' | 'W8imy' | 'W9')[]Optional allowlist of IRS form types to show. If omitted, show all forms.
locale
optional'en'The locale for the Element, applied to Element UI strings and error messages. By default, the locale configured in
init() is used.prefillData
optionalPrefillDataOptionsPrefilled data to populate the form fields.
W9
optionalW9PrefillDataOptionsPrefilled data to populate the W9 form
businessName
optionalstringThe business name or disregarded entity name if different from the legal name.
isElectronicDelivery
optionalobjectOption that makes the electronic delivery field read-only.
readonly
optionalbooleanname
optionalstringThe legal name of the individual or entity.
Returns
TaxFormElement | null
1import { createElement } from '@airwallex/components-sdk';23const taxFormElement = await createElement('taxForm');
destroy()
Destroys the Element instance.
1element.destroy();
mount(domElement)
Mounts Element to your HTML DOM.
Parameters
domElement
requiredstring | HTMLElementThe container DOM element to mount the element.
1// type2element.mount: (domElement: string | HTMLElement) => void34// There are two ways to mount element:5// 1. call with container dom id6element.mount('container-dom-id');78// 2.find the created DOM in existing HTML and call with container DOM element9const containerElement = document.getElementById("container-dom-id");10element.mount(containerElement);
on('ready', handler)
This event will be fired when the tax form page is ready.
Parameters
type
required'ready'The event name.
handler
requiredfunctionThe callback function that will be called when the event occurs.
The handler receives an object with the following properties:
elementType
required'taxForm'1element.on('ready', (data) => {2 console.log('Tax form ready:', data.elementType);3});
on('success', handler)
This event fires when the tax form is completed successfully.
Parameters
type
required'success'The event name.
handler
requiredfunctionThe callback function that will be called when the event occurs.
1element.on('success', (data) => {2 console.log('Tax form submitted successfully', data);3});
on('save', handler)
This event fires when the tax form is saved and exited.
Parameters
type
required'save'The event name.
handler
requiredfunctionThe callback function that will be called when the event occurs.
1element.on('save', (data) => {2 console.log('Tax form saved', data);3});
on('cancel', handler)
This event fires when the element is exited by cancellation.
Parameters
type
required'cancel'The event name.
handler
required() => voidThe callback function that will be called when the event occurs.
1element.on('cancel', () => {2 console.log('Tax form cancelled');3});
on('error', handler)
This event fires when an error occurs within the element.
Parameters
type
required'error'The event name.
handler
requiredfunctionThe callback function that will be called when the event occurs.
The handler receives an object with the following properties:
code
requiredstringThe error code identifying the type of error.
message
optionalstringA human-readable error message.
1element.on('error', (data) => {2 console.error('Tax form error:', data.code, data.message);3});
on('download', handler)
This event fires when the tax form is downloaded.
Parameters
type
required'download'The event name.
handler
requiredfunctionThe callback function that will be called when the event occurs.
The handler receives an object with the following properties:
name
requiredstringThe filename of the downloaded file.
uri
requiredstringThe URI of the downloaded file.
1element.on('download', (data) => {2 console.log('Downloaded:', data.name, data.uri);3});
unmount()
Unmounts the Element. Note that the Element instance will remain.
1element.unmount();
Was this page helpful?