Sample integration
This page provides a step-by-step integration guide for the fictitious platform ReimbursementOS to streamline its global payout processes to employees. The integration involves onboarding ReimbursementOS's customers (depicted by BizCo and MarCo) as connected accounts in Airwallex, ReimbursementOS pulling funds from the customers’ external bank accounts into their connected account Wallets, and then transferring these funds to the external bank accounts of the employees.
Before you begin
- You must have a pre-configured demo Airwallex platform account with API access. If you don't already have one, contact your Account Manager to get access.
- You must have demo account credentials (username and password).
- You must have your access token to make API calls. Obtain your access token API using your unique Client ID and API key.
Step 1: Onboard customers onto your platform
Airwallex offers multiple options to onboard connected accounts and submit them for KYC.
- Embedded KYC component (Airwallex-hosted iFrame)
- Hosted flow (Airwallex-hosted full-page redirect)
- Connected Accounts API
In this sample integration, we will be using the Embedded KYC Component (Airwallex-hosted iFrame) integration to onboard your customers.
For each of your customers, you will need to:
- Create a connected account.
- Submit a KYC application.
- Verify successful KYC onboarding.
Create a connected account
As a platform, you can create Airwallex connected accounts for your customers underneath your platform account. You can then transact on behalf of connected accounts such as debiting funds from the connected account’s Wallet to pay out to external customers.
Submit a KYC application
Initialize the web SDK
Once a connected account is created, you will need to onboard your customers through a KYC process to finish activating their account. The Embedded Component option allows you to use an Airwallex-hosted iFrame to deliver a conversion-optimized, frictionless onboarding experience. The customer submits their documentation, and Airwallex will handle the verification process, any requests for additional information, as well as the approval or rejection of the request.
Before initializing the SDK, you must install the package using either of the following methods.
- Yarn or NPM
yarn add @airwallex/components-sdk
npm install @airwallex/components-sdk
- CDN
<script src="https://static.airwallex.com/components/sdk/v1/index.js"></script>
For more information, see Airwallex Components SDK .
Set up the server for authentication
When the customer, i.e. the connected account holder begins the onboarding process, you will need to get an authorization code to authorize them into the Embedded onboarding workflow. Always get authorization code on the server side, a trusted environment. This prevents malicious users from being able to alter the scope.
When the onboarding page loads, on your server, call Authorize a connected account API by providing your Airwallex connected account ID in the x-on-behalf-of
header, and the following payload.
The authorization_code
is returned in the response, which you should then return to the client side as authCode in order to initialize the Embedded onboarding component.
Generate code challenge
To generate a value for the code_challenge field, generate a challenge token together with the code_verifier
using the S256 generation method RFC 7636 Section 4.
code_challenge
= BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))
. Use a third-party package to generate code_verifier
and code_challenge
or use the following code example in Javascript.
Add the onboarding component to your page
To embed the onboarding flow into your page, you will need to define an empty container, create the onboarding component (call createElement(type, options)
and specify the type
as kyc
) and then mount the element to the container. For detailed information on how to add the component and handle the response, see Embedded KYC component.
Verify successful customer onboarding
After your customer finishes onboarding, the status of the connected account will transition to SUBMITTED
. Confirm the account status by calling Retrieve a Connected Account API.
For a smoother onboarding experience, use account status webhooks to respond to customer account validation in real-time and seamlessly integrate them into your system. By relying on these webhooks, you can eliminate the need for polling and automatically initiate customer onboarding upon validation.
As you build your integration, you might want to conduct unit and end-to-end testing of your integration. In the demo environment, you can simulate the KYC process and programmatically transition the account status from SUBMITTED
to ACTIVE
using the connected account simulation API. Simulation APIs are not available in the production environment.
The sample code below shows how to simulate the status transition for the connected account to ACTIVE
.
At this point, your connected account is activated!
See also
- Understanding the difference between Platform Account vs. Connected Account.
- For more information on the hosted flow solution, see Hosted onboarding.
- To explore the other KYC onboarding options, see KYC and onboarding.
Handle KYC Request for Information (RFI)
In some cases, Airwallex may request additional information from your customers if the information initially provided during KYC is deemed insufficient to approve the application. To handle any requests for information (RFI), we recommend integrating our Embedded KYC RFI solution, which has a similar integration setup as Embedded Components.
Step 2: Fund the customer's Wallet
While you can choose from multiple options to fund the Wallet, BizCo wants to add a US bank account (Linked Account) and pull funds using ACH direct debit. ReimbursementOS can complete a one-time linkage of BizCo’s external bank account to their connected account with Airwallex. This allows funds to be pulled in over direct debit, avoiding the need for BizCo to ‘push’ funds from their bank account to Airwallex. Please note that applicable limits are in place to mitigate the risk of direct debit recalls.
A Linked Account is a verified external financial account (such as a bank account, credit/debit card, or e-wallet account) that is bound to an Airwallex account. In this sample integration, we will create a Linked Account for BizCo’s US bank account.
Before you can create a Linked Account and add funds via direct debit, you must obtain a direct debit agreement from the external bank account owners. In the demo environment, we can bypass this mandate. For production, see Direct Debit mandate requirements.
Create a Linked Account using micro-deposits verification
As a platform, you can call Linked Accounts API endpoints on behalf of your connected accounts by specifying the connected account's open ID (in the format acct_xxxxxxxx) in the x-on-behalf-of
header of your API requests.
Note that currently Airwallex only supports linking bank accounts owned by the business that signed up for the Airwallex account, or by one of its Ultimate Beneficial Owners (UBOs).
To successfully link an external bank account, Airwallex must first verify its ownership. Airwallex offers two options to verify the external bank account: Micro-deposits or Open Banking.
In this sample integration, we'll use the micro-deposits verification to verify that the Linked Account and mandate have been successfully created.
After verification, you will see that the Linked Account status has transitioned to SUCCEEDED
. Review status codes to track status transitions when Linked Accounts are created and verified.
Similar to the account status webhook, you can listen to Linked Account webhook events to notify your system that the Linked Account verification is successful.
You can retrieve details of your Linked Account by calling Retrieve a Linked Account API.
Fund BizCo's Wallet via Direct Debit
After successfully linking BizCo’s Linked Account to its connected account with Airwallex, you can proceed to pull funds from the Linked Account into BizCo’s connected account Wallet using the steps outlined below.
Before you proceed, check funding limits for your platform using Get funding limits API. Platform funding limits determine the maximum amount of direct debit deposits that may be created, and are shared across all Airwallex accounts under your platform account. For more information, see direct debit flight times and funding limits. Contact your Account Manager to increase either the direct debit limit or the Faster Direct Debit limit, and understand our fee schedule for the Faster Direct Debit product.
Call Create a deposit via Direct Debit API to add funds into BizCo’s Wallet by providing BizCo’s Linked Account ID.
Make sure the amount you deposit does not exceed the funding limit.
You can also listen to the deposit.settled
webhook to confirm that the deposit is successfully settled into the connected account’s Wallet.
See also
- For detailed instructions on depositing funds into Wallets via direct debits from Linked Accounts, see Add funds via direct debit from Linked Accounts.
- Learn more about Direct Debit funding limits.
- Explore Linked Account using Open Banking verification.
Step 3: Process payouts
ReimbursementOS can enable customers to trigger payouts to employees on a one time or recurring basis. In this integration guide, we will demonstrate the flow of a one-time payment where funds will move from each of customers’ connected accounts to the external bank accounts of the employees who are receiving the payout, over Airwallex’s payout rails.
Airwallex offers multiple options to collect beneficiary bank account information:
- Native API: Programmatically create payouts with our Payout API endpoints with full control of the beneficiary bank account information collection experience.
- Using API and Form Schema: Programmatically retrieve beneficiary bank account information schema for payout scenarios and render on your user interface.
- Embedded Components: Low-code option to render your beneficiary bank account information collection experience using pre-built UI elements.
Prepare required beneficiary information
Before creating a transfer, you will need to prepare the required beneficiary information, which can vary depending on the payout country/currency, transfer method, local clearing system, beneficiary type.
Retrieve the form schema
In this sample integration, we will use Get the form schema API endpoint to programmatically obtain the required beneficiary fields for a given country, currency, transfer method, clearing system and entity type. The response also includes validation rules and recommended UI components in JSON format for each field to be rendered on the form.
Validate a beneficiary
Call Validate a beneficiary API to check for errors before creating a beneficiary:
- If validation errors are found, a list of all errors will be returned as a 400 response.
- If all parameters provided for the payout are valid, the endpoint will return a 200 (OK) response.
Create a beneficiary
Proceed to create a beneficiary using the validated beneficiary payload.
In the production environment, you will need to build a generic response handler to parse the validation rules and recommended UI component definitions in the response and adopt them in your application. However, as all schema and field validation rules are maintained by Airwallex, once integrated there will be no further code changes needed on your end when there are updates to the schema.
Create a payout transfer
Call Create a new transfer API with the required beneficiary and transaction information (currency, amount, date, reference) to create a transfer.
If the source currency is different from the transfer currency, an underlying currency conversion will be booked. By default, the prevailing market rate at the point of conversion will be applied to the underlying currency conversion.
Retrieve a payout
Call Retrieve a transfer API to get the status of the transfer.
The transfer status should transition from SCHEDULED
to PROCESSING
. Listen to the payout.transfer.funding.funded
webhook to confirm that the transfer has been successfully processed.
For detailed information on creating and validating a transfer, see create a transfer and validate a transfer.
Fees and pricing
When a payout involves currency conversion (FX), there are two types of fees applied to the connected account:
- FX fees: These cover the cost of converting the payout amount from one currency to another.
- Payout fees: These are separate fees associated with sending the payout itself.
Airwallex allows you to mark up both FX and payout fees. This markup becomes your platform's revenue when your customers make transactions.
Your Account Manager can help you decide how to configure these fees. Options include:
- You can have Airwallex charge the connected accounts directly for FX and payout fees.
- You can cover the FX and payout fees yourself and create a customized pricing model for your product, such as a flat monthly subscription fee via your system.
Reporting and reconciliation
Call Get balance history API and Get list of financial transactions API anytime to retrieve balances and generate financial statements/reports for the purposes of reconciliation, proof of funds, and data analysis. For non-real-time data analysis and reporting requirements, you can also use Platform Reports API to get the data async in a file format and ingest into your data source.
Test and go live
After integrating with Airwallex’s Connected Accounts, Treasury, Payouts products, you can simulate connected account status transition, deposits, payouts, and also test webhooks in the demo environment before going live in the production environment. For more information, see Integration checklist.
Make sure you handle failed transfers before you go live.
Next steps
- Explore Quotes API if you would like to fix the conversion rate of the payout.