Sample integration
This page provides a step-by-step integration guide for the fictitious platform SaaSOS that enables customers to collect payments from end users across the world. The platform will own each payment and will be responsible for payments fees, disputes and subsequent transactions such as captures and refunds. The customers will be onboarded as connected accounts and will be the Merchant-Of-Record for the payment.
The integration involves onboarding customers through KYC and KYB screening, collecting payments from end users into the connected account Wallet after deducting platform and Airwallex fees, and then processing payouts to customers’ external bank accounts.
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 should 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.
- Initiate KYB onboarding.
- Verify successful KYB onboarding and payment method activation.
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 transfer funds from the connected account’s Wallet to their external bank account.
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 KYC 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 Embedded Components solution, see Embedded Components.
- To explore the other KYC onboarding options, see KYC and onboarding.
- Read more about connected account status simulation.
Initiate KYB onboarding
When connected accounts are onboarded as Merchant-Of-Record, you will need to complete the KYB (Know Your Business) onboarding process to start receiving funds via the Airwallex payment acceptance solution. The Embedded KYB component is a pre-built UI element that delivers a conversion-optimized flow, including STP (Straight Through Processing) after submission.
The integration steps for the KYB Embedded component are similar to the KYC component. You will need to initialize the KYB web SDK and add the KYB component to your page. For detailed information, see Embedded KYB Component.
Ensure that you have already completed KYC onboarding else you will receive errors when accessing the KYB component. Before you begin, you must provide your Account Manager with a list of payment methods you want to make available to your connected accounts.
Verify successful KYB onboarding and payment method activation
After the connected account is active, Airwallex will begin the KYB review for the requested payment methods.
Call Retrieve Account Capability API to verify the status of the payment method.
The status transitions to ENABLED
when the payment method is enabled for the account. This means KYB onboarding has been successful.
You can subscribe to webhook events for a seamless integration. Note that it might take time for the account capability to transition from ENABLED
to ACTIVE
. To confirm that the payment method capability has been activated and ready for use, check that the status of the payment method is ACTIVE
using Retrieve available payment methods types API with query parameter ?active=true
.
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: Collect payments from end users
With this model, the platform account owns each payment and is responsible for payments fees, disputes and subsequent transactions such as captures and refunds. The funds collected via payments acceptance will be routed to Airwallex and collected into Airwallex’s funds pool in buyer’s local currency, for currencies where like-for-like settlement is supported. Airwallex offers multiple integration options to accept payments. This guide describes payments acceptance integration via Embedded Elements but you can choose from Hosted Payment Page/Native API/Drop-in/Mobile Integration.
After creating the Payment Intent, you will need to display the Embedded Element on the UI to collect payment details and process payment. To do so, you will need to initialize the Airwallex Payments Elements SDK and add the desired element to the checkout page. For detailed information, see Embedded Elements.
If you want to save payment details of the buyer and trigger subsequent payments using saved payment details, you must create a Payment Consent by using the createPaymentconsent(props)
method within the Airwallex Payments SDK.
For detailed information on merchant-initiated transactions, see Registered user checkout guide.
Split funds into the Platform Account and Connected Account
Call Create a Payment Intent API and specify the connected account ID (connected_account_id
field) you want to associate the transaction with.
Provide funds_split_data
object directly in the request and specify values for the amount and destination fields. The funds will be automatically split after the Payment Intent has been captured.
In the case where funds need to be split into multiple connected accounts, the platform needs to create multiple funds splits to each connected account as a destination.
Funds will be settled to all customer’s Wallets based on the split portion, where the platform receives the platform fee and the connected account receives the final disbursement amount after deducting the Airwallex fee.
Alternatively, you can split funds using Create a FundsSplit API request. Specify source_id
and destination
as the payment_intent_id
and the connected_account_id
respectively. Provide the final disbursement amount to the customer in the amount
field after deducting the platform fee and the Airwallex fee.
Please note that a funds split can only be created after the Payment Intent has succeeded and before funds settlement in Airwallex. For most payment methods, the SLA for settlement is 2-3 days after successful payment capture. Subscribe to payment_intent.succeeded
webhook to confirm if the payment was successful.
See Funds Split Reversal if you want to reverse an existing funds split made to a connected account, either entirely or partially.
Funds Split Reversal
If a funds split has been created incorrectly or the platform would like to retrieve money back from the connected account, a Funds Split Reversal API can be created. The platform can partially reverse a funds split as many times until the entire amount is reversed. A fund split reversal can also happen if there’s a refund request on the original Payment Intent.
Step 3: Process payouts
In this integration model where funds are collected into the customer’s Connected Account Wallet, funds will move from each customer's Wallet to their external bank accounts, over Airwallex’s payout rails.
Prepare required beneficiary information
Before creating a payout, you will need to prepare the required beneficiary information, which can vary depending on the payout country/currency, payment method, local clearing system, beneficiary type.
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.
Embedded Beneficiary Component
In this sample integration, we will use the Embedded Beneficiary component, which is a pre-built UI element for you to integrate into your own flow for beneficiary (recipient) information collection. It renders the user interface to help you collect required beneficiary information, such as bank account details, business/personal information.
Please note that the Embedded Beneficiary component uses the same API version that you integrate with. As you upgrade API versions, the information rendered in the component will follow suit. This allows you to benefit from the continuous coverage expansion and product enhancements that Airwallex makes over time.
To view and interact with the Embedded Beneficiary component, go to the Embedded Components demo site .
Similar to the Embedded KYC component, you will need to initialize the beneficiary web SDK and add the beneficiary component to your page. For detailed information, see Embedded Beneficiary Component.
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
Once the beneficiary payload is retrieved, you can Create a new beneficiary API in Airwallex. You can also use the beneficiary payload to Update a beneficiary API that you have already saved with Airwallex.
Create a payout
With the beneficiary created, you can use the Embedded transfer component to render the user interface to collect required transfer information, such as country/region, beneficiary (recipient) type, transfer method, amount, date etc., while displaying other important information, such as currency conversion rates and fees. To view and interact with the Embedded transfer component, go to the Embedded Components demo site . Similar to the Embedded Beneficiary component, you will need to initialize the payout web SDK and add the transfer component to your page. For detailed information, see Embedded transfer component.
Note that the payout component does not support Strong Customer Authentication (SCA). You still need to build SCA on top of the component (e.g. two-factor authentications) to comply with regulations such as the second Payment Services Directive (PSD2), if applicable.
After you retrieve the final transfer payload from the Embedded transfer component, you can call Create a new transfer API. Please make sure that the required beneficiary payload generated using the Embedded beneficiary component has been aggregated into the transfer payload. 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 payout API to get the status of the payout.
The payout status should transition from SCHEDULED
to PROCESSING
. Listen to the payment.funding.funded
webhook to confirm that the payout has been successfully processed.
For detailed information on creating and validating a payout, see create a payout and validate a payout.
See also
Fees and pricing
Payments fees
FX and Payout fees
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, Payments, Payouts products, you can simulate connected account status transition, payments acceptance, payouts, and also test webhooks in the demo environment before going live in the production environment.
Next steps
- Explore LockFX API if you would like to fix the conversion rate of the payout.