Skip to content

下单接口

POST /api/orders

前端表单提交,触发支付网关(JazzCash / EasyPaisa)。

请求头

必填说明
Content-Typeapplication/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"
}
字段类型必填说明
productstring产品/服务名称
amountnumber金额(分),500000 = PKR 5,000
currencystring默认 PKR
paymentMethodstringjazzcash | easypaisa | bank_transfer | JZ | EP
customer.namestring客户姓名
customer.emailstring邮箱
customer.phonestringJazzCash 必填(钱包号)
notestring备注,可放公司名

成功响应 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,
})

PK 电商站群内部台账