下单接口
POST /api/orders
前端表单提交,触发支付网关(JazzCash / EasyPaisa)。
请求头
| 头 | 必填 | 说明 |
|---|---|---|
Content-Type | ✅ | application/json |
x-domain | ✅ | 站点域名,如 techconsult.site |
请求体
json
{
"product": "Gateway Integration",
"amount": 4500000,
"currency": "PKR",
"paymentMethod": "jazzcash",
"customer": {
"name": "Ali Khan",
"email": "ali@example.com",
"phone": "03001234567"
},
"note": "Company: Acme Corp"
}| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
product | string | ✅ | 产品/服务名称 |
amount | number | ✅ | 金额(分),500000 = PKR 5,000 |
currency | string | ❌ | 默认 PKR |
paymentMethod | string | ❌ | jazzcash | easypaisa | bank_transfer | JZ | EP |
customer.name | string | ✅ | 客户姓名 |
customer.email | string | ✅ | 邮箱 |
customer.phone | string | ❌ | JazzCash 必填(钱包号) |
note | string | ❌ | 备注,可放公司名 |
成功响应 201
json
{
"success": true,
"data": {
"id": "69e2096fb89a14295f5964fa",
"orderNo": "MO2RC2QC-V2G",
"domain": "techconsult.site",
"status": "paid",
"product": "Gateway Integration",
"amount": 4500000,
"currency": "PKR",
"paymentMethod": "jazzcash",
"customer": { "name": "Ali Khan", "email": "ali@example.com", "phone": "03001234567" },
"createdAt": "2026-04-17T10:20:31.572Z",
"updatedAt": "2026-04-17T10:20:43.028Z"
},
"payment": {
"provider": "jazzcash",
"status": "completed",
"responseCode": "000",
"responseMessage": "Thank you for using JazzCash...",
"gatewayStatus": "Completed",
"txnRefNo": "T202604171520310IVN5"
}
}失败响应 422(支付失败)
json
{
"success": false,
"message": "JazzCash transaction failed",
"payment": {
"status": "failed",
"responseCode": "157",
"responseMessage": "Transaction failed due to..."
}
}前端调用示例
js
// src/utils/orderApi.js(已封装,直接用)
import { createOrder } from '@/utils/orderApi'
const result = await createOrder({
domain: 'techconsult.site',
product: 'Basic Plan',
amount: 500000,
currency: 'PKR',
paymentMethod: 'jazzcash',
customer: { name, email, phone },
note: company,
})