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
Before starting integration, contact [email protected] to bind your Mini Program App ID (小程序 App ID) to your account.
How to Use
▾
/v3/payment/online/checkoutStep 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
▾
requestPaymentDecode and parse the base64 data, then call wx.requestPayment in your mini program.
Request Parameters
▾
Checkout ID from the Hosted Payment Checkout response.
Checkout type. Set to "MINI_PROGRAM".
Payment method. Set to "WECHATPAY_CN".
WeChat user Open ID.
Response Parameters
▾
Response item
Checkout session type.
Base64-encoded data to pass to the mini program API.
"SUCCESS" if the request succeeded.
Error details
Error code.
Error message.
Debug message (sandbox only).
Frontend Integration
▾
Use base64 decode on the data parameter and pass the result to the mini program API.
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});