Create Drop-in Element

createElement('dropIn', options?)

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

Parameters

typerequired'dropIn'

The type of element you are creating.

optionsoptionalDropInElementOptions

Options for creating dropIn Element.

Returns

DropInElement | null
linkTypeScript
1import { createElement } from '@airwallex/components-sdk';
2const element = createElement('dropIn', {
3 intent_id: 'replace-with-your-intent-id',
4 client_secret: 'replace-with-your-client-secret',
5 currency: 'replace-with-your-intent-currency',
6});

DropInElementOptions

Apply to dropIn element type integration, interface used when createElement called with type dropIn

client_secretrequiredstring

The client_secret of the Payment Intent when Payment Intent is provided. Otherwise, this should be the client_secret of the Customer object.

currencyrequiredstring

The three-letter ISO currency code representing the currency of the Payment Intent or Payment Consent.

allowedCardNetworksoptional[]

One or more card networks that you support.

The layout of each element stays consistent, but you can modify confirm button, inputs, and more.

Checkout configuration options for Apple Pay.

authFormContaineroptionalstring

The container of the authentication form used in 3D Secure authentication.

The authorization type for the card payment. Set it to pre_auth if you want to place a hold on your customer’s card for more than 7 days, i.e., extend the authorization time window. Currently pre_auth is only available when the card brand is Visa or Mastercard. autoCapture will be automatically set to false if you enable pre_auth. Default value is 'final_auth'.

autoCaptureoptionalboolean

Whether the amount should be captured automatically upon successful payment authorization. Set it to false if you want to place a hold on the payment method and capture the funds sometime later. Default value is true.

Billing information provided by the merchant. This option overrides the billing information from the shopper as provided in the input billing fields. Do not set withBilling and requiredBillingContactFields when you use this option.

country_codeoptionalstring

The two-letter ISO country code of the shopper's country. This is required for bank_transfer, online_banking, skrill or seven_eleven payment methods.

cvcRequiredoptionalboolean

Whether you require the shopper to provide CVC when they checkout with a network tokenized card.

Checkout configuration options for Google Pay.

intent_idoptionalstring

The ID of the Payment Intent you would like to checkout. Required when mode is 'payment'.

The payment methods your website would like to integrate with.

modeoptional

The checkout mode for the shopper, 'payment' or 'recurring'. Default value is 'payment'.

When using Payments for Platforms, specify the ID of the connected account associated with the payment if you want to use its information to process the payment. For example, the statement descriptor displayed on the shopper's credit card or bank statement and the payment methods activated by the connected account.

Options for recurring flow.

The billing information that you require from the user in order to process the transaction.

shopper_emailoptionalstring

The shopper's email address.

shopper_nameoptionalstring

The shopper's full name.

shopper_phoneoptionalstring

The shopper's phone number.

Box style for the dropIn element.

Customize DropIn Element style.

The options for Wechat Pay.

componentsdeprecated[]

The payment methods your website would like to integrate with

withBillingdeprecatedboolean

Indicate to improve 3DS experience, indicate if the payment form will collect billing info from shopper

DropInElement

Element functions can be used in your integration flow with Airwallex element.

destroy()

Destroys the Element instance.

Returns

void
linkTypeScript
1element.destroy();

mount(domElement)

Mounts Element to your HTML DOM.

Parameters

domElementrequiredstring | HTMLElement

Returns

null | HTMLElement
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(event, handler)

Listen to element event.

Parameters

handlerrequiredEventListener

Returns

void
linkTypeScript
1element.on('success', () => {
2 // Handle success event
3});

unmount()

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

Returns

void
linkTypeScript
1element.unmount();

update(options?, initOptions?)

Using this function to update the element option after create the element.

Returns

void
linkTypeScript
1element.update({
2 methods: ['card'],
3}, {
4 locale: 'en',
5});