Airwallex logo
Airwallex logo

Native UI Integration

We provide native screens to facilitate the integration of payment functions. You can integrate edit shipping info flow to manage shipping info of the order and use our prebuilt payment flow to present payment flow to your shopper.

  1. Initialize an Airwallex object, it’s the entry-point of the Airwallex SDK
Java
1val airwallex = Airwallex(this)
  1. Set up a ClientSecretProvider

Set up an ClientSecretProvider in your app, make your API client class implement the ClientSecretProvider interface, which defines a single method, provideClientSecret. When implementing this method, pass the customerId parameter along to your generate_client_secret endpoint. Consult our Example App to see this in practice.

Java
1Airwallex.initialize(
2 AirwallexConfiguration.Builder()
3 .enableLogging(true) // Enable log in sdk, and don’t forogt to set to false when it is ready to release
4 .setEnvironment(Environment.DEMO) // You can change the environment to STAGING, DEMO or PRODUCTION. It must be set to PRODUCTION when it is ready to release.
5 .setSupportComponentProviders(
6 listOf(
7 CardComponent.PROVIDER,
8 WeChatComponent.PROVIDER,
9 RedirectComponent.PROVIDER
10 )
11 )
12 .build(),
13 ExampleClientSecretProvider() // If you need to support recurring, you must to support your custom ClientSecretProvider
14 )
15
16class ExampleClientSecretProvider : ClientSecretProvider {
17
18 private val api: Api
19 get() {
20 if (TextUtils.isEmpty(AirwallexPlugins.environment.baseUrl())) {
21 throw IllegalArgumentException("Base url should not be null or empty")
22 }
23 return ApiFactory(AirwallexPlugins.environment.baseUrl()).buildRetrofit()
24 .create(Api::class.java)
25 }
26
27 override fun provideClientSecret(customerId: String): ClientSecret {
28 val authResponse = api.authenticationSynchronous(
29 apiKey = Settings.apiKey,
30 clientId = Settings.clientId
31 ).execute().body()
32 Settings.token = JSONObject(authResponse!!.string())["token"].toString()
33 val clientSecretResponse = api.createClientSecretSynchronous(customerId).execute().body()
34 return ClientSecretParser().parse(JSONObject(clientSecretResponse!!.string()))
35 }
36}

Edit shipping info flow

Use presentShippingFlow method to allow users to provide a shipping address as well as select a shipping method. The shipping parameter is optional. After successfully saving, it will return a shipping object.

Java
1AirwallexStarter.presentShippingFlow(
2 fragment,
3 shipping,
4 override fun onCompleted(status: AirwallexShippingStatus) {
5
6 }
7)

Payment flow

General steps for initiating a one-off payment (guest user checkout) and retrieving the payment result are as follows:

  1. (Optional) Create a Customer API if you want to save your customer's details and attach payment information to them (This step is compulsory when you process recurring payment for a new customer)
  2. Create a Payment Intent API on your server and pass it to your client
  3. Create a payment session with corresponding payment type and order information
  4. Present payment flow by passing payment session to Airwallex SDK
  5. Query and present payment result in callback functions

Integration steps for Redirect module and Card module are the same, they only differ in actions performed by the SDK.

However, when incorporating WeChat Pay module, you need to implement another callback function onResp declared by WeChat SDK to check the payment result which will be invoked when the shopper completes payment in WeChat app and gets redirected back to your app. For recurring payments, see Android recurring payments integration guide.

Custom Theme

You can overwrite these color values in your app.

Java
1<color name="airwallex_tint_color">@color/airwallex_color_red</color>

See Android developer guide for: Styles and Themes | Android Developers

Was this page helpful?