Airwallex JS
Airwallex logoAirwallex logo

Getting started

Copy for LLMView as Markdown

Airwallex.js is a browser-side JavaScript library that lets you seamlessly embed pre-built UI elements into your web pages. With Airwallex.js, you can enable payment acceptance, customer onboarding (KYC/KYB), payouts, risk management, and more—all with minimal effort.

This reference provides detailed documentation on every available element, object, and method in Airwallex.js.

For step-by-step integration guidance on using Airwallex.js UI components, visit our Product Docs.

If you're currently using Airwallex legacy libraries (Payment Elements, Payouts SDK) for embedding UI elements, check out our upgrade guides for migration details.

Install Airwallex.js

Install Airwallex.js using your preferred package manager, for example, npm, yarn, or pnpm.

Alternatively with the 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 the SDK object to be globally accessible in your client-side code as window.AirwallexComponentsSDK.

Install Airwallex.js

1npm install @airwallex/components-sdk

init(options?)

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.

Parameters

options

optionalInitOptions

env

optional'demo' | 'prod'
The Airwallex environment you want to integrate your application with.
Default: 'prod'

locale

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

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.
  • Payouts Elements supports only en, zh, zh-HK, de, es, fr, it, ja, ko.
  • Onboarding Elements supports only en, fr, zh.
  • Risk Elements supports only en, fr, zh.
  • Compliance Support Elements supports only en.

fonts

optionalFontOptions[]
Fonts options to customize the font styles of Payment Elements.

enabledElements

optional('payments' | 'payouts' | 'onboarding' | 'risk')[]
An array of Element groups representing the Elements. For example, 'payments' indicates all available Elements that support collection of payments information.

authCode

optionalstring
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

clientId

optionalstring
The ID of platform application issued by Airwallex. Only applicable to Onboarding, Payout, Risk and Compliance Support Elements

codeVerifier

optionalstring
Serves as proof key for code exchange in authorization code flow. Only applicable to Onboarding, Payout, Risk and Compliance Support Elements

Returns

Promise<InitResult>

InitResult

requiredobject
The result of the initialization of Airwallex.js

payments

optionalPayments
Object implementing the Payments interface. It will be present in the result when payments is one of the enabled elements.

sca

optionalSCA
Object implementing the SCA interface. It will be present in the result when risk is one of the enabled elements.

init(options?)

1// Example 1: Initialize Airwallex.js for Payment Elements
2import { init } from '@airwallex/components-sdk';
3const options = {
4 locale: 'en',
5 env: 'prod',
6 enabledElements: ['payments'],
7};
8await init(options);
9
10// Example 2: Initialize Airwallex.js for Onboarding, Payout, Risk, or Compliance Support Elements
11import { 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);
Was this page helpful?