Create payment for the pending order, supporting various payment methods including WeChat, WeChat Mini Program, Alipay, PayPal, and Stripe.
Points to note
- The API uses the POST method and requires data to be submitted in application/ format
- Provide the order ID and payment method
- Only logged-in users can call this interface
- The order must be in the 'pending payment' status to create payment
- Return payment information corresponding to different payment methods (QR code, jump link, or mini-program payment parameters)
Request address
{域名地址}/api/order/payment
Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/order/payment
Request Syntax
POST {域名地址}/api/order/payment
Content-Type: application/json
Request Headers
This interface requires user login authentication, please refer toCommon Request Headers (Common Request Headers).
Request parameters
| Field name | Type | Required | Description |
|---|---|---|---|
| order_id | string | Is | Order ID |
| pay_way | string | Is | Payment method: Optional values include wechat, weapp, alipay, paypal, stripe |
Response header
This interface only involves public response headers. For more information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field name | Type | Description |
|---|---|---|
| code | int | Error code |
| msg | string | Error description |
| data | object | Payment related information |
Data field description
| Field name | Type | Description |
|---|---|---|
| pay_way | string | Payment method |
| code_url | string | QR code image link (WeChat payment) |
| jump_url | string | Redirect link (Alipay, PayPal payment) |
| paySign | string | Signature (WeChat Mini Program Payment) |
| timeStamp | int | Timestamp (WeChat Mini Program Payment) |
| package | string | package (WeChat Mini Program Payment) |
| nonceStr | string | nonceStr (WeChat Mini Program Payment) |
| signType | string | Signature method (WeChat Mini Program Payment) |
Payment methods differ, corresponding payment information fields will be included in the data.
Usage Example
Request example
POST /api/order/payment HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"order_id": "202211232209080046",
"pay_way": "alipay"
}
Response Example
Alipay payment response
{
"code": 0,
"msg": "",
"data": {
"pay_way": "alipay",
"jump_url": "https://openapi.alipay.com/gateway.do?..."
}
}
WeChat payment response
{
"code": 0,
"msg": "",
"data": {
"pay_way": "wechat",
"code_url": "weixin://wxpay/bizpayurl?pr=..."
}
}
WeChat Mini Program payment response
{
"code": 0,
"msg": "",
"data": {
"pay_way": "weapp",
"paySign": "A8E3A1C5F7...",
"timeStamp": 1672531200,
"package": "prepay_id=wx2023010123456789",
"nonceStr": "abc123def456",
"signType": "MD5"
}
}
error code
| Error code | Description |
|---|---|
| 0 | OK |
| -1 | Error, the reason is indicated in msg |
| 1001 | Not logged in |
| 1002 | Not authorized |
| 200 | API request OK |
| 4001 | Order does not exist |
| 4002 | The order status does not allow payment |
| 4003 | The payment method is not supported |
| 4004 | The order amount is 0, no payment is required |