Create Card Element

createElement('card', options?)

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

Parameters

typerequired'card'

The type of element you are creating.

optionsoptionalCardElementOptions

Options for creating card Element.

Returns

CardElement | null
linkTypeScript
1import { createElement } from '@airwallex/components-sdk';
2const element = createElement('card');

CardElementOptions

Applies to card element type integration, the interface used when createElement() is called with type card.

allowedCardNetworksoptional[]

One or more card networks that you support.

authFormContaineroptionalstring

The container id 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 it's 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.

disabledoptionalboolean

Whether the Element input is disabled or not. Default value is false.

Style for the card element.

CardElement

Functions and external fields can be used in your integration flow with Airwallex Payment Elements.

blur()

Using this function to blur the HTML Input element

Returns

void
linkTypeScript
1element.blur();

clear()

Using this function to clear the HTML Input element

Returns

void
linkTypeScript
1element.clear();

confirm(data)

Using this function to confirm payment intent Confirms the Payment Intent. Call this function when the shopper is ready to make a payment as per the details in the Payment Intent.

Parameters

Payment method request payload

Returns

Promiselink<>
linkTypeScript
1element.confirm({
2 client_secret: 'replace-with-your-client-secret',
3});

createPaymentConsent(data)

Creates a Payment Consent, which represents the consent between you and the shopper to use the shopper’s saved card details for future payments.

Parameters

Payment consent request payload

Returns

Promiselink<>
linkTypeScript
1element.createPaymentConsent({
2 client_secret: 'replace-with-your-client-secret',
3});

destroy()

Destroys the Element instance.

Returns

void
linkTypeScript
1element.destroy();

focus()

Using this function to focus the HTML Input element

Returns

void
linkTypeScript
1element.focus();

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 events.

Parameters

The event name

handlerrequiredEventListener

The event handler

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({autoCapture: true});

verifyConsent(data)

Using this function to verify consent

Parameters

Verify consent request payload

Returns

Promiselink<boolean | >
linkTypeScript
1element.verifyConsent({
2 consent_id: 'replace-with-your-consent-id',
3 client_secret: 'replace-with-your-client-secret',
4 currency: 'replace-with-your-currency',
5});