Skip to main content

Direct Checkout — Mode: WechatPay Mini Program

Returns base64-encoded data to pass to the WeChat Pay Mini Program payment API for in-app payment within the WeChat app.

When to Use​

▾

Use this mode when:

  • Integrating payment inside a WeChat Mini Program
  • Targeting Chinese customers paying via WeChat Pay
note

Before starting integration, contact [email protected] to bind your Mini Program App ID (小程序 App ID) to your account.

How to Use​

▾
Endpoint
POST/v3/payment/online/checkout

Step 1: Create a Checkout​

▾

Call Hosted Payment Checkout to obtain checkoutId.

Step 2: Request the Mini Program Data​

▾

POST with type: "MINI_PROGRAM", method: "WECHATPAY_CN", and the user's WeChat Open ID.

Step 3: Invoke WeChat requestPayment​

▾

Decode and parse the base64 data, then call wx.requestPayment in your mini program.


Request Parameters​

▾
checkoutIdSTRINGrequired

Checkout ID from the Hosted Payment Checkout response.

typeSTRINGrequired

Checkout type. Set to "MINI_PROGRAM".

methodSTRINGrequired

Payment method. Set to "WECHATPAY_CN".

userIdSTRINGrequired

WeChat user Open ID.

Response Parameters​

▾
itemOBJECT

Response item

qrcodeOBJECT

Mini program payload

base64ImageSTRING

Base64-encoded QR image (empty for mini program mode).

dataSTRING

Base64-encoded data to pass to the mini program API.

typeSTRING

Checkout session type.

codeSTRING

"SUCCESS" if the request succeeded.

errorOBJECT

Error details

codeSTRING

Error code.

messageSTRING

Error message.

debugSTRING

Debug message (sandbox only).

Frontend Integration​

▾
note

Use base64 decode on the item.qrcode.data parameter and pass the result to the mini program API.

WeChat Mini Program
JavaScript
1var base64decoded = base64Decode(dataParameter);
2var payload = JSON.parse(base64decoded);
3wx.requestPayment({
4...payload,
5success: function (res) { console.log("success", res); },
6fail: function (res) { console.log("fail", res); },
7complete: function (res) { console.log("complete", res); }
8});