Install Airwallex.js
Alternatively with cdn installation, you can add Airwallex.js as a HTML <script> tag to the <head> element of each HTML page on your site. This installation option allows any newly created Airwallex.js objects to be globally accessible in your client side code.
1npm install @airwallex/components-sdk
Initialize Airwallex.js
The Airwallex package should only be initialized once in your application.
1// Example 1: Initialize Airwallex.js for Payment Elements2import { init } from '@airwallex/components-sdk';3const options = {4 locale: 'en',5 env: 'prod',6 enabledElements: ['payments'],7};8await init(options);910// Example 2: Initialize Airwallex.js for Onboarding, Payout, Risk, or Compliance Support Elements11import { init } from '@airwallex/components-sdk';12const options = {13 locale: 'en',14 env: 'prod',15 enabledElements: ['onboarding', 'payouts', 'risk'],16 authCode: 'replace-with-your-auth-code',17 clientId: 'replace-with-your-client-id',18 codeVerifier: 'replace-with-your-code-verifier',19};20await init(options);
InitOptions
The Airwallex environment you want to integrate your application with. Default value is 'prod'.
The locale used to globally configure localization for Airwallex.js Elements. The specified locale will be applied to both the Element UI strings and error messages unless overridden by the locale field at the Element level (except Payment Elements).
Supported locales vary by Elements type:
- Payment Elements: Supports all locales. Defaults to the browser's locale; however, if the browser's locale is not supported, it will default to 'en'.
- Payouts Elements: Supports only en, zh, zh-HK, de, es, fr, it, ja, ko with only en support available for Tax Form Element.
- Onboarding Elements: Supports only en and zh.
- Risk Elements: Supports only en and zh.
- Compliance Support Elements: Supports only en.
Fonts options to customize the font styles of Payment Elements.
An array of Element groups representing the Elements. For example, 'payments' indicates all available Elements that support collection of payments information.
Scoped auth code to exchange for scoped access token to authorize platform to make API calls. Only applicable to Onboarding, Payout, Risk and Compliance Support Elements
The ID of platform application issued by Airwallex. Only applicable to Onboarding, Payout, Risk and Compliance Support Elements
Serves as proof key for code exchange in authorization code flow. Only applicable to Onboarding, Payout, Risk and Compliance Support Elements