Airwallex LogoAirwallex Logo
Airwallex LogoAirwallex Logo

Create Card Number Element

createElement('cardNumber', options?)

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

Parameters

typerequired'cardNumber'

The type of element you are creating.

optionsoptionalCardNumberElementOptions

Options for creating cardNumber Element.

Returns

CardNumberElement | null

createElement('cardNumber', options?)

npm

1import { init, createElement } from '@airwallex/components-sdk';
2
3await init({
4 env: 'prod',
5 enabledElements: ['payments'],
6});
7
8const element = await createElement('cardNumber', {
9 showIcon: true, // Optional: Show card brand icon
10});
11
12element.mount('card-number-container');

CardNumberElementOptions

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

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 cardNumber Element input is disabled or not. Default value is false.

intentoptional

The Payment Intent you would like to checkout. Refer to Airwallex Client APIAPI

placeholderoptionalstring

A short hint to suggest the expected value of an input field to the shopper.

Style for the cardNumber Element.

CardNumberElement

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

blur()

1element.blur();

clear()

Using this function to clear the HTML Input element.

Returns

void

clear()

1element.clear();

confirm(data)

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

Returns

Promiselink<>

confirm(data)

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

createPaymentConsent(data)

Call this function to create a Payment Consent, which represents the agreement between the merchant and shopper of making subsequent payments using the provided payment method.

Returns

Promiselink<>

createPaymentConsent(data)

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

createPaymentMethod(data)

Using this function to create a payment method for future payments. The created payment method can be saved in your system.

Parameters

Payment method request payload

Returns

Promiselink<>

createPaymentMethod(data)

1element.createPaymentMethod({
2 client_secret: 'replace-with-your-client-secret',
3 customer_id: 'replace-with-your-customer-id',
4 payment_method: {
5 card: {
6 name: 'John Doe',
7 },
8 },
9});

destroy()

Destroys the Element instance.

Returns

void

destroy()

1element.destroy();

focus()

Using this function to focus the HTML Input element

Returns

void

focus()

1element.focus();

getBinInfo(client_secret)

Using this function to get BIN (Bank Identification Number) information for the card.

Returns

Promiselink<>

getBinInfo(client_secret)

1element.getBinInfo('replace-with-your-client-secret');

getPaymentIntent(id, client_secret)

Parameters

idrequiredstring

The ID of the Payment Intent.

client_secretrequiredstring

The client secret of the Payment Intent.

Returns

Promiselink<>

getPaymentIntent(id, client_secret)

1element.getPaymentIntent('replace-with-your-intent-id', 'replace-with-your-client-secret');

mount(domElement)

Mounts Element to your HTML DOM.

Parameters

domElementrequiredstring | HTMLElement

Returns

null | HTMLElement

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

Listen to Element events.

Type Parameters

A generic type for event codes. Ideally, you don't need to specify this explicitly as it can be inferred automatically.

Parameters

The event code to listen for.

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

Returns

void

on(eventCode, handler)

1element.on('change', (e) => {
2 const { completed, empty, error } = e.detail;
3 // Handle change event
4});

unmount()

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

Returns

void

unmount()

1element.unmount();

update(options?, initOptions?)

Call this function to update Element options after creating the Element.

Returns

void

update(options?, initOptions?)

1element.update({
2 autoCapture: false,
3});

verifyConsent(data)

Using this function to verify payment consent.

Returns

Promiselink<boolean | >

verifyConsent(data)

1element.verifyConsent({
2 client_secret: 'replace-with-your-client-secret',
3 currency: 'replace-with-your-currency',
4});

Was this page helpful?