Create payment for pending orders, supporting multiple payment methods including WeChat, WeChat Mini Program, Alipay, PayPal, and Stripe.
Precautions
- This interface uses the POST method and requires data to be submitted in application/ format
- Need to provide 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 the corresponding payment information (QR code, jump link, or mini-program payment parameters) based on different payment methods
Request address
{ๅๅๅฐๅ}/api/order/payment
Description:{ๅๅๅฐๅ}Need to replace it with your domain address, such ashttps://en.anqicms.com/api/order/payment
Request syntax
POST {ๅๅๅฐๅ}/api/order/payment
Content-Type: application/json
Request header
This interface requires user login authentication, please refer toCommon Request Headers (Common Request Headers).
Request Parameters
| Field Name | Type | Required | Description |
|---|---|---|---|
| order_id | string | Yes | Order ID |
| pay_way | string | Yes | Payment methods: Optional values include: wechat, weapp, alipay, paypal, stripe |
Response Headers
This interface only involves public response headers. More information, please refer toCommon Request Headers (Common Request Headers).
Return parameters
| Field Name | Type | Description |
|---|---|---|
| code | integer | Error code |
| message | string | Error Description |
| data | object | Payment related information |
Description of the data field
| 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 | integer | Timestamp (WeChat Mini Program Payment) |
| package | string | package (WeChat Mini Program Payment) |
| nonceStr | string | nonceStr (WeChat Mini Program Payment) |
| signType | string | Sign method (WeChat Mini Program Payment) |
According to different payment methods, the payment information fields corresponding to the payment method will be included in the data.
Example Usage
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 | Unauthorized |
| 200 | API request OK |
| 4001 | Order does not exist |
| 4002 | Order status does not allow payment |
| 4003 | Payment method is not supported |
| 4004 | Order amount is 0, no payment needed |