Airwallex logo

Mobile Browser (H5)

Accept WeChat Pay on your mobile website by redirecting shoppers to WeChat App. See checkout experience as below. WeChat H5 payment flow

  1. The shopper chooses to pay with WeChat Pay and the shopper will be redirected to WeChat Pay App
  2. The shopper completes payment in WeChat Pay App
  3. Payment succeeds and the shopper is redirected back to the mobile browser page you designated
Note

To use WeChat H5 payment, extra offline review process is required, please contact your account manager for detailed information

Step 1. Initialize a payment Intent

Create a PaymentIntent object with a request_id, amount, currencyand a merchant_order_id from your backend server. Provide return_url to specify where shoppers will be redirected to both for cancelled payment and succeeded payment scenarios . Please note that the first level domain name of the return_url and the url you use to pull up the WeChat Pay shall both be aligned with the one you submitted to WeChat in the offline review process.

POST /payment_intents/create
https://pci-api.airwallex.com/api/v1/pa/payment_intents/create \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer your_bearer_token \
  -d '{
    "request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89",
    "amount": 100,
    "currency": "CNY",
    "merchant_order_id": "85d7b0e0-7235-11ea-862e-9f6aa1adfca6"
    "return_url": "https://www.airwallex.com"
  }'

Step 2. Redirect to WeChat App to complete payment

When a shopper selects to pay with WeChat Pay on their mobile browser, call the following API endpoints to get a e-wallet cashier URL (next_action.url in API response), which you can redirect the shopper to WeChat App to complete payment.

  1. Obtain URL from Airwallex and redirect shopper to WeChat App

Request:

POST /payment_intents/{id}/confirm
https://pci-api.airwallex.com/api/v1/pa/payment_intents/{id}/confirm \
      -H 'Content-Type: application/json' \
      -H 'client-secret: Ss3thJHPE6TyI4r-8BJFlqNz1mA7DblVuN0c8GOthnchp7Sf-_JuQnuX3sqzv7_0EiTMOs2kcGopFrMoFC0w7IzPCErJ1a0P7sFnpwB6uz-H2h_6rDhhSd2tKJF-l2myVOXQV4Zou3s_OsX6thLiUKI=" \
      -d '{"request_id": "ed11e38a-7234-11ea-aa94-7fd44ffd1b89", 
   "payment_method": {
       "type": "wechatpay",
       "wechatpay": {
           "flow": "mweb"
       }
   }
}

Response:

"next_action": {
       "type": "redirect",
       "method": "GET",
       "url": "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx……"
   }
}
  1. Wait for notification from Airwallex

Airwallex will notify you on the payment result asynchronously via the webhook API. Please refer to webhook documentation to set up your webhook accordingly. Although subscribing to different events is optional, it is recommended to at least subscribe to the ‘payment_intent.succeeded’ which indicates that the shopper has successfully paid for the order via WeChat Pay.

  1. Query the PaymentIntent status

You may also query the status of a payment anytime via the PaymentIntents API

GET /payment_intents/{id}
Note

WeChat Pay also supports using H5 flow in your App, to realize the scheme redirect, extra offline sheet needs to be filled and you need to wait for WeChat for configuration.