Airwallex logo
Airwallex logo

WeChat Pay

Integration flow for WeChat Pay module

Android WeChat one-off

  1. (Optional) Create a Customer

Create a customer object and pass it to your server 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)

From your server, access Airwallex API to Create a Customer API

  1. Create a PaymentIntent

Your client app will need a PaymentIntent to form a payment session for Airwallex SDK to present payment flow.

From your server, access Airwallex API to Create a Payment Intent API and pass the PaymentIntent returned to client app.

  1. Call AirwallexStarter.presentPaymentFlow with an AirwallexSession and a PaymentResultListener to present payment flow to the shopper.
Java
1val session = AirwallexPaymentSession.Builder(
2 paymentIntent = paymentIntent,
3 countryCode = Settings.countryCode
4 )
5 .setReturnUrl(Settings.returnUrl)
6 .build()
7 AirwallexStarter.presentPaymentFlow(this, session,
8 object : Airwallex.PaymentResultListener {
9
10 override fun onCompleted(status: AirwallexPaymentStatus) {
11
12 }
13 }
14 )
15
  1. Query WeChat payment result with callback function onResp

Implement the callback function onResp which will be invoked when the shopper is redirected from WeChat back to your app. onResp knows the payment result when it's called and you can render the payment result page from here, or you can confirm the payment result by retrieving the PaymentIntent from your server.

Java
1public void onResp(BaseResp resp) {
2if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
3Log.d(TAG, "onPayFinish, errCode = " + resp.errCode);
4 ...
5}
6}
7

Your server can retrieve the Payment Intent API, get the payment result within it and return it to client app if you need to confirm the payment result again.

Was this page helpful?