Before you start
The Airwallex Android SDK is open source and available through Maven Central.
Follow these steps to set up Airwallex Android SDK.
Requirements
- Compatible with apps supporting Android API level 21 (Lollipop) and above
- Available through Maven Central
Step 1: Set up SDK
Airwallex Android SDK is available through Maven Central. Add the following dependencies to your app-level build.gradle file:
1dependencies {2 // Core module (required)3 implementation 'io.github.airwallex:payment:6.6.1'45 // Payment method modules - select the ones you want to support6 implementation 'io.github.airwallex:payment-card:6.6.1'7 implementation 'io.github.airwallex:payment-redirect:6.6.1'8 implementation 'io.github.airwallex:payment-wechat:6.6.1'9 implementation 'io.github.airwallex:payment-googlepay:6.6.1'10}
Replace 6.6.1 with the latest version shown in the badge above.
You can choose one or more individual payment method modules depending on the payment methods available to you.
If you are integrating WeChat Pay
Please register your app at WeChat Pay to get a WeChat app ID and configure it in your Airwallex account. We will need your WeChat app ID to initiate WeChat payments. For more details on how Airwallex SDK interacts with WeChat Pay, see WeChat In-App Pay Development Guide .
Step 2: Set up your server to access Airwallex API
Generate API keys from Settings > Developer > API keys tab in the web app. Authenticate from your server using your Client ID and API key to generate an access token before calling Payments APIs. For more information, see Manage API keys.
Before processing a payment, your server must create a PaymentIntent API and pass it to the client. After the payment is completed, your server needs to retrieve the PaymentIntent API to check the payment result.
Step 3: Configure SDK
After installing the SDK, initialize it in your Application class with the required configuration:
1import com.airwallex.android.Airwallex2import com.airwallex.android.core.AirwallexConfiguration3import com.airwallex.android.core.Environment45class YourApplication : Application() {6 override fun onCreate() {7 super.onCreate()89 Airwallex.initialize(10 AirwallexConfiguration.Builder()11 .enableLogging(true) // Set to false for production12 .setEnvironment(Environment.DEMO) // Use Environment.PRODUCTION for production13 .setSupportComponentProviders(14 listOf(15 CardComponent.PROVIDER,16 WeChatComponent.PROVIDER,17 RedirectComponent.PROVIDER,18 GooglePayComponent.PROVIDER19 )20 )21 .build()22 )23 }24}
Make sure to register your Application class in AndroidManifest.xml:
1<application2 android:name=".YourApplication"3 ...>4</application>
SDK initialization classes
The Airwallex Android SDK provides two initialization classes depending on your integration type: Airwallex for Embedded Payment Elements and Low-level API integration, and AirwallexStarter for Hosted Payment Page. Both use the same AirwallexConfiguration.Builder() for SDK configuration.
Optional: Configure redirect mode
For payment methods that require browser redirects (for example, Alipay, PayPal), you can configure how redirects are handled:
1import com.airwallex.android.core.RedirectMode23Airwallex.initialize(4 AirwallexConfiguration.Builder()5 .enableLogging(true)6 .setEnvironment(Environment.DEMO)7 .setRedirectMode(RedirectMode.CUSTOM_TAB) // or .CUSTOM_TAB_BOTTOM_SHEET, .EXTERNAL_BROWSER8 .setSupportComponentProviders(9 listOf(10 CardComponent.PROVIDER,11 WeChatComponent.PROVIDER,12 RedirectComponent.PROVIDER,13 GooglePayComponent.PROVIDER14 )15 )16 .build()17)
Redirect mode options:
| Option | Description |
|---|---|
RedirectMode.CUSTOM_TAB (default) | Opens redirect URLs in a Chrome Custom Tab for a seamless in-app experience |
RedirectMode.CUSTOM_TAB_BOTTOM_SHEET | Opens redirect URLs in a Chrome Custom Tab presented as a bottom sheet |
RedirectMode.EXTERNAL_BROWSER | Opens redirect URLs in the device's default browser |