Get product settlement information, supporting settlement of individual or multiple product orders, including discount calculation, address information, etc.
Precautions
- This interface uses the POST method and requires data to be submitted in application/ format
- Supports ordering a single item (via goods_id, quantity, goods_sku_id parameters) or multiple items (via details parameters)
- Support using coupons (coupon code or coupon ID)
- User login verification is required
- Support setting the recipient address and order notes
Request address
{域名地址}/api/order/checkout
Description:{域名地址}Need to replace it with your domain address, such ashttps://en.anqicms.com/api/order/checkout
Request syntax
POST {域名地址}/api/order/checkout
Content-Type: application/json
Request header
This interface also involves common request headers. For more information, please seeCommon Request Headers (Common Request Headers).
Request Parameters
| Field Name | Type | Required | Description |
|---|---|---|---|
| goods_id | integer | No | Product ID, used when ordering a single item, optional with details parameter |
| quantity | integer | No | Product quantity, used when placing an order for a single item |
| goods_sku_id | integer | No | SKU ID, used when placing an order for a single item |
| details | object[] | No | Array of multiple product information, either with the goods_id parameter or not |
| remark | string | No | Order notes |
| type | string | No | Order type, such as goods (product), vip (member) |
| coupon_code | string | No | Voucher code |
| coupon_code_id | integer | No | Voucher code ID |
| coupon_id | integer | No | Coupon ID (discount coupons) |
| address | object | No | recipient address information |
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 | Result content object |
Data result parameters
| Field Name | Type | Description |
|---|---|---|
| currency_code | string | Currency Symbol |
| Currency symbol | string | Currency Name |
| details | object[] | Product Information List |
| origin_amount | integer | Total Amount Before Discount |
| amount | integer | Total Amount After Discount |
| Discount amount | integer | Total Discount Amount |
| coupon_id | integer | Coupon ID |
| coupon_code | string | Voucher code |
| coupon_code_id | integer | Voucher code ID |
| address_id | integer | Recipient Address ID |
| remark | string | Order notes |
Details Product Information Parameters
Each product object includes the following fields (specific fields depend on system design):
| Field Name | Type | Description |
|---|---|---|
| id | integer | Product Details ID |
| goods_id | integer | Product ID |
| goods_sku_id | integer | SKU ID |
| quantity | integer | quantity of goods |
| Price | integer | Product Unit Price |
| total_price | integer | 商品小计 |
Example Usage
请求示例(单个商品下单)
POST /api/order/checkout HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"goods_id": 1,
"quantity": 2,
"goods_sku_id": 1,
"remark": "请尽快发货",
"type": "goods",
"coupon_code": "SAVE100",
"address": {
"name": "张三",
"phone": "13800138000",
"province": "广东省",
"city": "深圳市",
"district": "南山区",
"address": "科技园南区1号",
"zipcode": "518000"
}
}
请求示例(多个商品下单)
POST /api/order/checkout HTTP/1.1
Host: www.anqicms.com
Content-Type: application/json
{
"details": [
{
"goods_id": 1,
"quantity": 2,
"goods_sku_id": 1
},
{
"goods_id": 2,
"quantity": 1,
"goods_sku_id": 3
}
],
"remark": "多个商品订单",
"type": "goods",
"coupon_id": 5,
"address": {
"name": "李四",
"phone": "13900139000",
"province": "北京市",
"city": "北京市",
"district": "朝阳区",
"address": "建国路1号",
"zipcode": "100000"
}
}
Response Example
{
"code": 0,
"msg": "获取成功",
"data": {
"currency_code": "CNY",
"currency_symbol": "¥",
"details": [
{
"id": 1,
"goods_id": 1,
"goods_sku_id": 1,
"quantity": 2,
"price": 10000,
"total_price": 20000
}
],
"origin_amount": 20000,
"amount": 18000,
"discount_amount": 2000,
"coupon_id": 0,
"coupon_code": "SAVE100",
"coupon_code_id": 1,
"address_id": 123,
"remark": "请尽快发货"
}
}
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 |