Direct Checkout — Mode: Alipay Mini Program
Returns base64-encoded data to pass to the Alipay Mini Program payment API for in-app payment within the Alipay app.
When to Use
▾
Use this mode when:
- Integrating payment inside an Alipay Mini Program
- Targeting Chinese customers paying via Alipay
How to Use
▾
Endpoint
POST
/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" and method: "ALIPAY_CN".
Step 3: Invoke Alipay tradePay
▾
tradePayDecode the base64 data and pass it to my.tradePay in your mini program.
Request Parameters
▾
Checkout ID from the Hosted Payment Checkout response.
Checkout type. Set to "MINI_PROGRAM".
Payment method. Set to "ALIPAY_CN".
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
▾
note
Use base64 decode on the data parameter and pass the result to the mini program API.
Alipay Mini Program
JavaScript
1my.tradePay({2orderStr: base64Decode(dataParameter),3success: (res) => { console.log("success", res); },4fail: (res) => { console.log("error", res); }5});