Skip to main content

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/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" and method: "ALIPAY_CN".

Step 3: Invoke Alipay tradePay

Decode the base64 data and pass it to my.tradePay 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 "ALIPAY_CN".

Response Parameters

itemOBJECT

Response item

typeSTRING

Checkout session type.

dataSTRING

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

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 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});