Install Airwallex.js

Install Airwallex.js using your preferred package manager, for example, npm, yarn, or pnpm.
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.
npm
yarn
pnpm
cdn
1npm install @airwallex/components-sdk

Initialize Airwallex.js

Load Airwallex.js and specify the initialization settings and elements you want to fetch using the init() function. The modular approach of fetching only the resources specified in init() ensures optimized performance and customization tailored to your needs.

The Airwallex package should only be initialized once in your application.

init(options?)

Parameters

optionsoptionalInitOptions

Returns

void
linkTypeScript
1import { init } from '@airwallex/components-sdk';
2const options = {
3 locale: 'en',
4 env: 'prod',
5 enabledElements: ['payments'],
6};
7await init(options);

InitOptions

envoptional'demo' | 'prod'

The Airwallex environment you want to integrate your application with. Default value is 'prod'.

localeoptional'en' | 'zh' | 'ja' | 'ko' | 'ar' | 'fr' | 'es' | 'nl' | 'de' | 'it' | 'zh-HK' | 'pl' | 'fi' | 'ru' | 'da' | 'id' | 'ms' | 'sv' | 'ro' | 'pt'

The locale for your website. Only applicable to Payment Elements. Default value is browser’s language; however, if it's not a supported language then defaults to 'en'.

fontsoptional[]

Fonts options to customize the font styles of Payment Elements. Supports regular (400) and bold (700) weights.

enabledElementsoptionalstring[]

An array of Element groups representing the Elements. For example, 'payments' indicates all available Elements that support collection of payments information. Currently allowed values include: 'payments'.