# 创建 GMPay 订单 

**POST**`https://pay.example.com/payments/gmpay/v1/order/create-transaction`

[请求示例 ↓](https://epusdt.com/zh/api/endpoints/create-order#request-example)

在商户服务器上签名，创建订单后引导买家打开 `payment_url`。`token` 和 `network` 必须同时传入，也可以同时省略，让买家在收银台选择。

## 请求参数 

| 字段            | 类型     | 必填   | 说明                                                                                                                            |
| ------------- | ------ | ---- | ----------------------------------------------------------------------------------------------------------------------------- |
| pid           | string | 是    | 商户 PID，用于查找 API Key，并参与签名。                                                                                                    |
| order\_id     | string | 是    | 商户订单号，最长 32 字符，不能重复。                                                                                                          |
| currency      | string | 是    | 法币币种，如 cny、usd。                                                                                                               |
| token         | string | 条件必填 | 收款币种，如 usdt、trx、usdc、sol。GMPay 可与 network 同时省略以创建状态 4 占位订单。                                                                   |
| network       | string | 条件必填 | 收款网络，如 tron、solana、ethereum、binance、polygon、plasma。GMPay 可与 token 同时省略以创建状态 4 占位订单。                                           |
| amount        | number | 是    | 法币金额，必须大于 0.01。                                                                                                               |
| notify\_url   | string | 是    | 支付成功异步回调地址。                                                                                                                   |
| redirect\_url | string | 否    | 支付完成后的同步跳转地址。                                                                                                                 |
| name          | string | 否    | 商品/订单名称。                                                                                                                      |
| payment\_type | string | 否    | GMPay 兼容字段，不要求必须传；如果传了非空值，必须参与 GMPay signature 计算。普通 GMPay 不传时后台会存为 Gmpay；传 Epay（大小写不敏感）会统一存为 Epay 并使用 EPay 回调格式，且 PID 必须是数字。 |
| signature     | string | 是    | 64 位小写十六进制 GMPay HMAC-SHA256 签名。                                                                                              |

示例使用演示密钥 `epusdt_secret_key` 签名。更改参数或商户密钥后，请在商户服务端重新签名。

## 相关文档 

* [打开收银台](https://epusdt.com/zh/api/endpoints/open-checkout)
* [签名规则](https://epusdt.com/zh/api/payment#signing)

## 响应

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` object  
接口返回的数据，失败时为 null。

  * `trade_id` string
  * `order_id` string
  * `status` integer
  * `expiration_time` integer
  * `payment_url` string
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

application/json响应字段
* `status_code` integer  
业务结果码，商户可据此判断具体原因。
* `message` string  
便于阅读的结果说明。
* `data` null  
接口返回的数据，失败时为 null。
* `request_id` string  
请求标识，可用于排查日志。

[error-codes.json ↓](https://epusdt.com/agent-setup/error-codes.json)

**请求示例**

网关地址 

```
curl -i -X POST \
  'https://pay.example.com/payments/gmpay/v1/order/create-transaction' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "pid": "1000",
  "order_id": "ORD202605230001",
  "currency": "cny",
  "token": "usdt",
  "network": "tron",
  "amount": 100,
  "notify_url": "https://merchant.example/notify",
  "redirect_url": "https://merchant.example/return",
  "name": "VIP",
  "signature": "6f874b1919d95081835e2809b620e354a5866f5a6dbb2e432d1627f1eb10059d"
}'
```

**响应示例**200 · 成功401 · 签名认证错误400 · 10009 · 无法解析参数400 · 10041 · 通知地址无效400 · 10002 · 支付交易已存在，请勿重复创建400 · 10004 · 支付金额有误，无法满足最小支付单位400 · 10014 · 链未启用400 · 10016 · 支持的资产不存在400 · 10003 · 无可用钱包地址，无法发起支付400 · 10005 · 无可用金额通道

application/json · 响应字段节选

```
{
  "status_code": 200,
  "message": "success",
  "data": {
    "trade_id": "20260523171652123456001",
    "order_id": "ORD202605230001",
    "status": 1,
    "expiration_time": 1779530812,
    "payment_url": "https://pay.example.com/pay/checkout-counter/20260523171652123456001"
  },
  "request_id": "b1344d70-ff19-4543-b601-37abfb3b3686"
}
```
