创建订单
curl --request POST \
--url https://openplatform.gateapi.io/v1/pay/order \
--header 'Content-Type: application/json' \
--header 'X-GatePay-Certificate-ClientId: <x-gatepay-certificate-clientid>' \
--header 'X-GatePay-Nonce: <x-gatepay-nonce>' \
--header 'X-GatePay-Signature: <x-gatepay-signature>' \
--header 'X-GatePay-Timestamp: <x-gatepay-timestamp>' \
--data '
{
"merchantTradeNo": "22212345678555",
"env": {
"terminalType": "APP"
},
"currency": "GT",
"orderAmount": "1.21",
"goods": {
"goodsName": "NF2T",
"goodsDetail": "123444"
}
}
'import requests
url = "https://openplatform.gateapi.io/v1/pay/order"
payload = {
"merchantTradeNo": "22212345678555",
"env": { "terminalType": "APP" },
"currency": "GT",
"orderAmount": "1.21",
"goods": {
"goodsName": "NF2T",
"goodsDetail": "123444"
}
}
headers = {
"X-GatePay-Certificate-ClientId": "<x-gatepay-certificate-clientid>",
"X-GatePay-Signature": "<x-gatepay-signature>",
"X-GatePay-Timestamp": "<x-gatepay-timestamp>",
"X-GatePay-Nonce": "<x-gatepay-nonce>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-GatePay-Certificate-ClientId': '<x-gatepay-certificate-clientid>',
'X-GatePay-Signature': '<x-gatepay-signature>',
'X-GatePay-Timestamp': '<x-gatepay-timestamp>',
'X-GatePay-Nonce': '<x-gatepay-nonce>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
merchantTradeNo: '22212345678555',
env: {terminalType: 'APP'},
currency: 'GT',
orderAmount: '1.21',
goods: {goodsName: 'NF2T', goodsDetail: '123444'}
})
};
fetch('https://openplatform.gateapi.io/v1/pay/order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://openplatform.gateapi.io/v1/pay/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'merchantTradeNo' => '22212345678555',
'env' => [
'terminalType' => 'APP'
],
'currency' => 'GT',
'orderAmount' => '1.21',
'goods' => [
'goodsName' => 'NF2T',
'goodsDetail' => '123444'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-GatePay-Certificate-ClientId: <x-gatepay-certificate-clientid>",
"X-GatePay-Nonce: <x-gatepay-nonce>",
"X-GatePay-Signature: <x-gatepay-signature>",
"X-GatePay-Timestamp: <x-gatepay-timestamp>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://openplatform.gateapi.io/v1/pay/order")
.header("X-GatePay-Certificate-ClientId", "<x-gatepay-certificate-clientid>")
.header("X-GatePay-Signature", "<x-gatepay-signature>")
.header("X-GatePay-Timestamp", "<x-gatepay-timestamp>")
.header("X-GatePay-Nonce", "<x-gatepay-nonce>")
.header("Content-Type", "application/json")
.body("{\n \"merchantTradeNo\": \"22212345678555\",\n \"env\": {\n \"terminalType\": \"APP\"\n },\n \"currency\": \"GT\",\n \"orderAmount\": \"1.21\",\n \"goods\": {\n \"goodsName\": \"NF2T\",\n \"goodsDetail\": \"123444\"\n }\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://openplatform.gateapi.io/v1/pay/order"
payload := strings.NewReader("{\n \"merchantTradeNo\": \"22212345678555\",\n \"env\": {\n \"terminalType\": \"APP\"\n },\n \"currency\": \"GT\",\n \"orderAmount\": \"1.21\",\n \"goods\": {\n \"goodsName\": \"NF2T\",\n \"goodsDetail\": \"123444\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-GatePay-Certificate-ClientId", "<x-gatepay-certificate-clientid>")
req.Header.Add("X-GatePay-Signature", "<x-gatepay-signature>")
req.Header.Add("X-GatePay-Timestamp", "<x-gatepay-timestamp>")
req.Header.Add("X-GatePay-Nonce", "<x-gatepay-nonce>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://openplatform.gateapi.io/v1/pay/order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-GatePay-Certificate-ClientId"] = '<x-gatepay-certificate-clientid>'
request["X-GatePay-Signature"] = '<x-gatepay-signature>'
request["X-GatePay-Timestamp"] = '<x-gatepay-timestamp>'
request["X-GatePay-Nonce"] = '<x-gatepay-nonce>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"merchantTradeNo\": \"22212345678555\",\n \"env\": {\n \"terminalType\": \"APP\"\n },\n \"currency\": \"GT\",\n \"orderAmount\": \"1.21\",\n \"goods\": {\n \"goodsName\": \"NF2T\",\n \"goodsDetail\": \"123444\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": "SUCCESS",
"message": "订单创建成功",
"data": {
"prepayId": "GATE202400001",
"terminalType": "APP",
"expireTime": 1672909255498
}
}订单
创建订单
在 GatePay 支付平台创建一个新的支付订单。成功创建后,系统会返回支付相关信息,可用于跳转到支付页面或生成支付二维码。
POST
/
v1
/
pay
/
order
创建订单
curl --request POST \
--url https://openplatform.gateapi.io/v1/pay/order \
--header 'Content-Type: application/json' \
--header 'X-GatePay-Certificate-ClientId: <x-gatepay-certificate-clientid>' \
--header 'X-GatePay-Nonce: <x-gatepay-nonce>' \
--header 'X-GatePay-Signature: <x-gatepay-signature>' \
--header 'X-GatePay-Timestamp: <x-gatepay-timestamp>' \
--data '
{
"merchantTradeNo": "22212345678555",
"env": {
"terminalType": "APP"
},
"currency": "GT",
"orderAmount": "1.21",
"goods": {
"goodsName": "NF2T",
"goodsDetail": "123444"
}
}
'import requests
url = "https://openplatform.gateapi.io/v1/pay/order"
payload = {
"merchantTradeNo": "22212345678555",
"env": { "terminalType": "APP" },
"currency": "GT",
"orderAmount": "1.21",
"goods": {
"goodsName": "NF2T",
"goodsDetail": "123444"
}
}
headers = {
"X-GatePay-Certificate-ClientId": "<x-gatepay-certificate-clientid>",
"X-GatePay-Signature": "<x-gatepay-signature>",
"X-GatePay-Timestamp": "<x-gatepay-timestamp>",
"X-GatePay-Nonce": "<x-gatepay-nonce>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-GatePay-Certificate-ClientId': '<x-gatepay-certificate-clientid>',
'X-GatePay-Signature': '<x-gatepay-signature>',
'X-GatePay-Timestamp': '<x-gatepay-timestamp>',
'X-GatePay-Nonce': '<x-gatepay-nonce>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
merchantTradeNo: '22212345678555',
env: {terminalType: 'APP'},
currency: 'GT',
orderAmount: '1.21',
goods: {goodsName: 'NF2T', goodsDetail: '123444'}
})
};
fetch('https://openplatform.gateapi.io/v1/pay/order', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://openplatform.gateapi.io/v1/pay/order",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'merchantTradeNo' => '22212345678555',
'env' => [
'terminalType' => 'APP'
],
'currency' => 'GT',
'orderAmount' => '1.21',
'goods' => [
'goodsName' => 'NF2T',
'goodsDetail' => '123444'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-GatePay-Certificate-ClientId: <x-gatepay-certificate-clientid>",
"X-GatePay-Nonce: <x-gatepay-nonce>",
"X-GatePay-Signature: <x-gatepay-signature>",
"X-GatePay-Timestamp: <x-gatepay-timestamp>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://openplatform.gateapi.io/v1/pay/order")
.header("X-GatePay-Certificate-ClientId", "<x-gatepay-certificate-clientid>")
.header("X-GatePay-Signature", "<x-gatepay-signature>")
.header("X-GatePay-Timestamp", "<x-gatepay-timestamp>")
.header("X-GatePay-Nonce", "<x-gatepay-nonce>")
.header("Content-Type", "application/json")
.body("{\n \"merchantTradeNo\": \"22212345678555\",\n \"env\": {\n \"terminalType\": \"APP\"\n },\n \"currency\": \"GT\",\n \"orderAmount\": \"1.21\",\n \"goods\": {\n \"goodsName\": \"NF2T\",\n \"goodsDetail\": \"123444\"\n }\n}")
.asString();package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://openplatform.gateapi.io/v1/pay/order"
payload := strings.NewReader("{\n \"merchantTradeNo\": \"22212345678555\",\n \"env\": {\n \"terminalType\": \"APP\"\n },\n \"currency\": \"GT\",\n \"orderAmount\": \"1.21\",\n \"goods\": {\n \"goodsName\": \"NF2T\",\n \"goodsDetail\": \"123444\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-GatePay-Certificate-ClientId", "<x-gatepay-certificate-clientid>")
req.Header.Add("X-GatePay-Signature", "<x-gatepay-signature>")
req.Header.Add("X-GatePay-Timestamp", "<x-gatepay-timestamp>")
req.Header.Add("X-GatePay-Nonce", "<x-gatepay-nonce>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://openplatform.gateapi.io/v1/pay/order")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-GatePay-Certificate-ClientId"] = '<x-gatepay-certificate-clientid>'
request["X-GatePay-Signature"] = '<x-gatepay-signature>'
request["X-GatePay-Timestamp"] = '<x-gatepay-timestamp>'
request["X-GatePay-Nonce"] = '<x-gatepay-nonce>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"merchantTradeNo\": \"22212345678555\",\n \"env\": {\n \"terminalType\": \"APP\"\n },\n \"currency\": \"GT\",\n \"orderAmount\": \"1.21\",\n \"goods\": {\n \"goodsName\": \"NF2T\",\n \"goodsDetail\": \"123444\"\n }\n}"
response = http.request(request)
puts response.read_body{
"code": "SUCCESS",
"message": "订单创建成功",
"data": {
"prepayId": "GATE202400001",
"terminalType": "APP",
"expireTime": 1672909255498
}
}概述
本页说明/v1/pay/order 接口。完整的请求参数、响应结构与示例由上方关联的 OpenAPI 定义渲染。
说明
- 认证方式使用 GatePay 标准签名请求头。
- 本页展示普通商户接口。
- 通用签名规则请参见 /api-reference/version/100/cn/common/securityAndSignature。
请求头
商户客户端ID,在 GatePay 平台申请获得
示例:
"4186d0c6-6a35-55a9-8dc6-5312769dbff8"
HMAC-SHA256签名,用于验证请求合法性
示例:
"672d5650dcc9bb22ebf25fa16c28d03c0e159d742a9176d4340a5da326d75dc8a2ec24c97fa6fc5d1533dd6e968863747e1d86a45e562cbe899f9ed7e9ca7f77"
毫秒级时间戳,与服务端时间偏差不得超过30秒
示例:
"1672905655498"
随机数,用于防止重放攻击
示例:
"9578"
请求体
application/json
支付订单创建参数
商户订单号,必须唯一
Required string length:
5 - 32示例:
"22212345678555"
Show child attributes
Show child attributes
订单币种。请参考上方“支持的网络币种”确认当前可用范围。
示例:
"GT"
订单金额,必须为正数,支持小数
Pattern:
^\d+(\.\d{1,2})?$示例:
"1.21"
Show child attributes
Show child attributes
订单过期时间,UTC时间戳,millisecond。不设置时默认为1小时,最大过期时间为1小时
示例:
1770789143000
订单支付成功后返回跳转地址,最长256字符。仅在独立页面支付完成后会跳转到该Url
Maximum string length:
512示例:
"http://47.99.158.63:8205/payment/redirect"
订单支付取消后返回跳转地址
Maximum string length:
512示例:
"http://47.99.158.63:8205/payment/redirect"
客户渠道名称
Maximum string length:
32示例:
"123456"
法币币种
法币金额
用户承担的手续费金额
支付币种
支付金额
链网络
链地址
订单来源类型
支持的支付方式列表
⌘I

