Upgrade to Airwallex.js
Refer to this guide if your integration uses Airwallex Payment Elements SDK
The Airwallex Payment Elements JavaScript library has been deprecated. The Drop-in Element, Card Element, Split Card Element, Apple Pay Element, Google Pay Element, and Hosted Payment Page are now available via Airwallex.js JS. This guide covers the changes made and instructions for migrating to Airwallex.js.
Update JavaScript client library
npm/yarn/pnpm installation
Install the new package.
- Before: airwallex-payment-elements
- After: @airwallex/components-sdk
cdn installation
Update the URL in the <script>
tag.
- Before:
<script src="https://checkout.airwallex.com/assets/elements.bundle.min.js"></script>
- After:
<script src="https://static.airwallex.com/components/sdk/v1/index.js"></script>
After installation, you will need to initialize the SDK by calling the init()
method.
Update SDK functions
init()
New parameters
enabledElements
: An array of Element groups representing the Elements. For example, to use Payments elements, setenabledElements
topayments
.
Deprecated parameters
origin
BEFORE
AFTER
createElement()
No changes to the function other than the import source.
BEFORE
AFTER
redirectToCheckout()
Replace redirectToCheckout()
with payments.redirectToCheckout()
.
BEFORE
AFTER
getPaymentIntent()
This function has been deprecated.
getDeviceFingerprint()
This function has been deprecated.
getGatewayUrl()
This function has been deprecated.
Element functions
For the following functions, replace the global object Airwallex
with the instance object element
where element
is the object returned from createElement()
.
createPaymentConsent()
Replace Airwallex.createPaymentConsent()
with element.createPaymentConsent()
.
BEFORE
AFTER
createPaymentMethod()
Replace Airwallex.createPaymentMethod()
with element.createPaymentMethod()
.
BEFORE
AFTER
confirmPaymentIntent()
Replace Airwallex.confirmPaymentIntent()
with element.confirm()
.
BEFORE
AFTER
confirmPaymentIntentWithSavedCard()
Replace Airwallex.confirmPaymentIntentWithSavedCard()
with element.confirm
.
BEFORE
AFTER
destroyElement()
Replace Airwallex.destroyElement()
with element.destroy()
.
BEFORE
AFTER
Event listeners
Replace domElement.addEventListener('onEventName', ...)
with element.on('eventName', ...)
where element
is the object returned from createElement()
.
BEFORE
AFTER