Card Element
createElement('card', options?)
Parameters
type
required'card'options
optionalCardElementOptionscard Element.allowedCardNetworks
optional('visa' | 'mastercard' | 'maestro' | 'unionpay' | 'amex' | 'jcb' | 'diners' | 'discover')[]authFormContainer
optionalstringThe 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'.
'final_auth'autoCapture
optionalbooleanWhether 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.
truedisabled
optionalbooleanfalsestyle
optionalInputStylebase
optionalPseudoClassStyle & CSSPropertiesinvalid
optionalCSSPropertiespopupHeight
optionalnumberpopupWidth
optionalnumbervalid
optionalCSSPropertiesReturns
CardElement | null
1import { init, createElement } from '@airwallex/components-sdk';23await init({4 env: 'prod',5 enabledElements: ['payments'],6});78const element = await createElement('card', {9 autoCapture: true, // Optional: Enable automatic capture10});1112element.mount('card-container');
blur()
1element.blur();
clear()
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
data
requiredPaymentMethodRequestDataclient_secret
requiredstringclient_secret of the Payment Intent when Payment Intent is provided. Otherwise, this should be the client_secret of the Customer object.customer_id
optionalstringThe ID of the Customer used in registered user checkout. Refer to Airwallex Client API
This field is required when mode is 'recurring'.
error
optionalobjectcode
optionalstringmessage
optionalstringintent_id
optionalstringThe ID of the Payment Intent you would like to checkout. Required when mode is 'payment'.
Refer to Airwallex Client API
payment_consent
optionalPaymentConsentOptionsnext_triggered_by
required'merchant' | 'customer'merchant_trigger_reason
optional'scheduled' | 'unscheduled' | 'installments''unscheduled'terms_of_use
optionalTermsOfUsepayment_amount_type
required'FIXED' | 'VARIABLE'payment_currency
requiredstringstart_date
requiredstringbilling_cycle_charge_day
optionalnumberThe granularity per billing cycle. Required when payment_schedule.period_unit is WEEK, MONTH, or YEAR.
end_date
optionalstringfirst_payment_amount
optionalnumberThe first payment. It could include the costs associated with the first debited amount. Optional if payment_amount_type is VARIABLE.
fixed_payment_amount
optionalnumberThe fixed payment amount that can be charged for a single payment. Required if payment_amount_type is FIXED.
max_payment_amount
optionalnumberThe maximum payment amount that can be charged for a single payment. Optional if payment_amount_type is VARIABLE.
payment_schedule
optionalobjectperiod
requirednumberThe number of period units between billing cycles. For example, the payment cycle is one month if period=1 and period_unit=MONTH. Required when merchant_trigger_reason = scheduled.
period_unit
required'DAY' | 'WEEK' | 'MONTH' | 'YEAR'Specifies billing frequency. One of DAY, WEEK, MONTH, and YEAR. Required when merchant_trigger_reason = scheduled.
total_billing_cycles
optionalnumberThe total number of billing cycles of the payment schedule. If null, the mandate will continue indefinitely.
payment_method
optionalPaymentMethodObjTypecard
requiredobjectname
optionalstringbilling
optionalBillingaddress
requiredAddresscity
requiredstringcountry_code
requiredstringThe two-letter ISO country code of the shopper's country. https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
postcode
requiredstringstate
requiredstringstreet
requiredstringfirst_name
requiredstringlast_name
requiredstringdate_of_birth
optionalstringphone_number
optionalstringpayment_method_id
optionalstringpayment_method_options
optionalPaymentMethodOptionsTypecard
optionalobjectThe 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.
'final_auth'auto_capture
optionalbooleanWhether 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.
truetriggered_by
optional'customer'This field is used to indicate whether the current payment is initiated by the cardholder. This field must be used only in combination with payment_method_id field and is applicable only for Cvc element. FYI : next_triggered_by is used to indicate the driver for subsequent payments in the series.
'customer': The payment is initiated by the customer using the stored payment method details.
id
optionalstringDeprecatedThe payment intent you would like to checkout Refer to Airwallex Client API
methodId
optionalstringDeprecatedReturns
Promise<Intent>
Intent
requiredobjectid
requiredstringamount
optionalnumberclient_secret
optionalstringclient_secret of the Payment Intent when Payment Intent is provided. Otherwise, this should be the client_secret of the Customer object.created_at
optionalstringcurrency
optionalstringcustomer_id
optionalstringcustomer_payment_consents
optionalobjectid
requiredstringnext_triggered_by
required'merchant' | 'customer'payment_method
requiredobjecttype
required'card' | 'ach_direct_debit' | 'becs_direct_debit'ach_direct_debit
optionalobjectaba_routing_number
requiredstringaccount_number
requiredstringowner_email
requiredstringowner_name
requiredstringbecs_direct_debit
optionalobjectaccount_number
requiredstringbsb_number
requiredstringowner_email
requiredstringowner_name
requiredstringcard
optionalobjectbin
requiredstringbrand
requiredstringfingerprint
requiredstringlast4
requiredstringnumber_type
required'AIRWALLEX_NETWORK_TOKEN' | 'EXTERNAL_NETWORK_TOKEN' | 'PAN'id
optionalstringstatus
required'PENDING_VERIFICATION' | 'VERIFIED' | 'DISABLED'customer_payment_methods
optionalobjectid
requiredstringcard
optionalobjectbin
requiredstringbrand
requiredstringfingerprint
requiredstringlast4
requiredstringnumber_type
required'AIRWALLEX_NETWORK_TOKEN' | 'EXTERNAL_NETWORK_TOKEN' | 'PAN'merchant_order_id
optionalstringpayment_consent_id
optionalstringrequest_id
optionalstringstatus
optionalstringupdated_at
optionalstring1element.confirm({2 client_secret: 'replace-with-your-client-secret',3});
createPaymentConsent(data)
Parameters
data
requiredPaymentConsentRequestDataclient_secret
requiredstringclient_secret of the Payment Intent when Payment Intent is provided. Otherwise, this should be the client_secret of the Customer object.billing
optionalBillingaddress
requiredAddresscity
requiredstringcountry_code
requiredstringThe two-letter ISO country code of the shopper's country. https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
postcode
requiredstringstate
requiredstringstreet
requiredstringfirst_name
requiredstringlast_name
requiredstringdate_of_birth
optionalstringphone_number
optionalstringcardname
optionalstringconnected_account_id
optionalstringThe ID of the connected account linked to the platform. The platform should indicate the connected entity in the transaction only when platform is the owner of the transaction.
currency
optionalstringcustomer_id
optionalstringintent_id
optionalstringmerchant_trigger_reason
optional'scheduled' | 'unscheduled''scheduled' or 'unscheduled'. Only applicable when next_triggered_by is 'merchant'.'unscheduled'metadata
optionalRecord<string, unknown>next_triggered_by
optional'merchant' | 'customer''customer'payment_method_id
optionalstringthree_ds_action
optional'SKIP_3DS' | 'FORCE_3DS'Set it to SKIP_3DS if you want to skip 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
Set it to FORCE_3DS if you want to force 3DS regardless of the risk score and Strong Customer Authentication (SCA) regulation. Only applicable when it's a card recurring flow.
Returns
Promise<PaymentConsentResponse>
PaymentConsentResponse
requiredobjectcustomer_id
requiredstringpayment_consent_id
requiredstringcurrency
optionalstringintent_id
optionalstringintent_id if merchant provides intent_id in createPaymentConsent(). Otherwise, Airwallex creates an initial Payment Intent and returns the intent_id.payment_method
optionalobjectid
requiredstringbin
optionalstringbrand
optionalstringlast4
optionalstring1element.createPaymentConsent({2 client_secret: 'replace-with-your-client-secret',3});
destroy()
1element.destroy();
focus()
1element.focus();
mount(domElement)
Parameters
domElement
requiredstring | HTMLElementReturns
HTMLElement | null
1// There are two ways to mount the element:2// 1. Call with the container DOM id3element.mount('container-dom-id');45// 2. Find the created DOM in the existing HTML and call with the container DOM element6const containerElement = document.getElementById('container-dom-id');7element.mount(containerElement);
on('ready', handler)
Parameters
type
required'ready'handler
required() => void1element.on('ready', () => {2 console.log('Element is ready');3 });
on('change', handler)
Parameters
type
required'change'handler
requiredfunctionThe event handler
The handler receives an object with the following properties:
detail
requiredobjectcompleted
requiredbooleanempty
requiredbooleanerror
requiredobjectcode
requiredstringmessage
requiredstring1element.on('change', (e) => {2 const { completed, empty, error } = e.detail;3 console.log('Form changed', { completed, empty, error });4 });
on('focus', handler)
Parameters
type
required'focus'handler
requiredfunctionThe event handler
The handler receives an object with the following properties:
detail
requiredobjectcompleted
requiredbooleanempty
requiredbooleanerror
requiredobjectcode
requiredstringmessage
requiredstring1element.on('focus', (e) => {2 const { completed, empty, error } = e.detail;3 console.log('Form focused', { completed, empty, error });4 });
on('blur', handler)
Parameters
type
required'blur'handler
requiredfunctionThe event handler
The handler receives an object with the following properties:
detail
requiredobjectcompleted
requiredbooleanempty
requiredbooleanerror
requiredobjectcode
requiredstringmessage
requiredstring1element.on('blur', (e) => {2 const { completed, empty, error } = e.detail;3 console.log('Form blurred', { completed, empty, error });4 });
on('submit', handler)
Parameters
type
required'submit'handler
required() => void1element.on('submit', () => {2 console.log('Form submitted');3 });
unmount()
1element.unmount();
update(options?, initOptions?)
Parameters
options
optionalCardElementOptionsallowedCardNetworks
optional('visa' | 'mastercard' | 'maestro' | 'unionpay' | 'amex' | 'jcb' | 'diners' | 'discover')[]authFormContainer
optionalstringThe 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'.
'final_auth'autoCapture
optionalbooleanWhether 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.
truedisabled
optionalbooleanfalsestyle
optionalInputStylebase
optionalPseudoClassStyle & CSSPropertiesinvalid
optionalCSSPropertiespopupHeight
optionalnumberpopupWidth
optionalnumbervalid
optionalCSSPropertiesinitOptions
optionalInitOptionsenv
optional'demo' | 'prod''prod'fonts
optionalFontOptions[]family
optionalstringThe font-family property, for example, AxLLCircular.
https://developer.mozilla.org/en-US/docs/Web/CSS/font-family
src
optionalstringThe font-source property, for example, https://checkout.airwallex.com/fonts/CircularXXWeb/CircularXXWeb-Regular.woff2.
https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face
weight
optionalstring | numberThe font-weight property. Supported font weights include: regular (400) and bold (700). https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
locale
optionalenumar
da
de
en
es
fi
fr
he
id
it
ja
ko
ms
nl
pl
pt
ro
ru
si
sv
tr
vi
ur
zh
zh-HK
origin
optionalstringDeprecated1element.update({autoCapture: true});
verifyConsent(data)
Parameters
data
requiredVerifyConsentRequestclient_secret
requiredstringcurrency
requiredstringReturns
Promise<boolean | PaymentConsentResponse>
PaymentConsentResponse
requiredobjectcustomer_id
requiredstringpayment_consent_id
requiredstringcurrency
optionalstringintent_id
optionalstringintent_id if merchant provides intent_id in createPaymentConsent(). Otherwise, Airwallex creates an initial Payment Intent and returns the intent_id.payment_method
optionalobjectid
requiredstringbin
optionalstringbrand
optionalstringlast4
optionalstring1element.verifyConsent({2 client_secret: 'replace-with-your-client-secret',3 currency: 'replace-with-your-currency',4});