Create Card CVC Element
createElement('cvc', options?)
Use this function to create an instance of an individual Element.
Parameters
The type of element you are creating.
Options for creating cvc Element.
Returns
CvcElement | nullcreateElement('cvc', options?)
npm
1import { init, createElement } from '@airwallex/components-sdk';23await init({4 env: 'prod',5 enabledElements: ['payments'],6});78const element = await createElement('cvc');910element.mount('cvc-container');
CvcElementOptions
Applies to split card element type integration, the interface used when createElement() called with type cvc.
The container id of the authentication form used in 3D Secure authentication.
Indicate CVC length.
Whether the CVC Element input is disabled or not. Default value is false.
Whether the CVC input is masked Default value is false.
Whether CVC Element works alone or not. If you want to use the CVC Element for a saved Payment Consent, you could set it true to improve the checkout experience.
A short hint to suggest the expected value of an input field to the shopper.
Style for the CVC Element.
CvcElement
Element functions can be used in your integration flow with Airwallex element.
confirm(data)
Call this function when the shopper is ready to make a payment as per the details in the Payment Intent.
Returns
Promiseconfirm(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
PromisecreatePaymentConsent(data)
1element.createPaymentConsent({2 client_secret: 'replace-with-your-client-secret',3});
mount(domElement)
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(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 callback function that will be called when the event occurs.
Returns
voidon(eventCode, handler)
1element.on('change', (e) => {2 const { completed, empty, error } = e.detail;3 // Handle change event4});
unmount()
1element.unmount();
update(options?, initOptions?)
Call this function to update Element options after creating the Element.
Returns
voidupdate(options?, initOptions?)
1element.update({2 placeholder: 'replace-with-your-placeholder',3});