外观
页面跳转支付
由付款人的浏览器直接提交订单参数,Xpay 验签建单后 302 跳转到收银台。适合不方便在服务端调用下单接口的网页。对应易支付 submit.php。
请求地址
| 项目 | 值 |
|---|---|
| 地址 | https://{实例域名}/api/v1/pay/submit |
| 方法 | GET(参数放查询串)或 POST(表单提交) |
| Content-Type | POST 时为 application/x-www-form-urlencoded |
| 响应 | 成功:HTTP 302 跳转到收银台;失败:HTTP 400 HTML 提示页 |
请求参数
公共参数见 概览 · 公共参数。业务参数与 统一下单 的基础参数相同,区别如下:
| 字段 | 类型 | 必填 | 长度 / 格式 | 说明 | 示例 |
|---|---|---|---|---|---|
out_trade_no | string | 是 | 1–64 位,[a-zA-Z0-9._-|] | 商户订单号 | ORD20261130001 |
money | string | 是 | 大于 0,最多两位小数 | 订单金额(元) | 19.90 |
name / subject | string | 二选一 | ≤ 128 字 | 商品名称 | VIP月卡 |
notify_url | string | 是 | http/https,≤ 512 字节 | 异步通知地址 | https://shop.example.com/notify |
return_url | string | 是 | http/https,≤ 512 字节 | 支付完成后的跳转地址 | https://shop.example.com/return |
type | string | 否 | ^[a-z0-9]{2,16}$ | 支付方式,可用的支付方式用 支付方式列表 查询。省略时由付款人在收银台选择 | alipay |
param | string | 否 | ≤ 255 字节 | 附加参数 | uid=123 |
clientip | string | 否 | ≤ 45 字节 | 付款人 IP,缺省取浏览器来源 IP | — |
device | string | 否 | ≤ 16 字节 | 终端类型 | mobile |
channel_id | string | 否 | 整数 | 指定通道 ID | 12 |
goods | string | 否 | JSON 数组字符串 | 商品明细,同统一下单 | — |
- 本接口不支持
scene=jsapi或scene=miniapp,公众号和小程序请用 统一下单。其他scene、return_mode值不起作用,始终跳转 Xpay 收银台。 - 本接口不在下单时分配通道,由收银台完成。
请求示例
签名必须在商户服务端生成后再输出到页面,切勿把密钥放到前端。
html
<form method="post" action="https://pay.example.com/api/v1/pay/submit">
<input type="hidden" name="pid" value="10001">
<input type="hidden" name="type" value="alipay">
<input type="hidden" name="out_trade_no" value="ORD20261130001">
<input type="hidden" name="notify_url" value="https://shop.example.com/notify">
<input type="hidden" name="return_url" value="https://shop.example.com/return">
<input type="hidden" name="name" value="VIP月卡">
<input type="hidden" name="money" value="19.90">
<input type="hidden" name="timestamp" value="1764470000">
<input type="hidden" name="sign_type" value="MD5">
<input type="hidden" name="sign" value="3f0a1b6c9d2e4f5a8b7c6d5e4f3a2b1c">
</form>
<script>document.forms[0].submit();</script>text
https://pay.example.com/api/v1/pay/submit?pid=10001&type=alipay&out_trade_no=ORD20261130001¬ify_url=https%3A%2F%2Fshop.example.com%2Fnotify&return_url=https%3A%2F%2Fshop.example.com%2Freturn&name=VIP%E6%9C%88%E5%8D%A1&money=19.90×tamp=1764470000&sign_type=MD5&sign=3f0a1b6c9d2e4f5a8b7c6d5e4f3a2b1cbash
curl -i -X POST https://pay.example.com/api/v1/pay/submit \
-d pid=10001 -d type=alipay -d out_trade_no=ORD20261130001 \
-d notify_url=https://shop.example.com/notify \
-d return_url=https://shop.example.com/return \
-d name=VIP月卡 -d money=19.90 -d timestamp=1764470000 \
-d sign_type=MD5 -d sign=3f0a1b6c9d2e4f5a8b7c6d5e4f3a2b1c响应
本接口不返回 JSON,也没有响应签名。
| 情况 | HTTP 状态 | 内容 |
|---|---|---|
| 建单成功 | 302 Found | Location 为 Xpay 收银台地址 |
| 建单成功但暂无可用通道 | 302 Found | 仍跳转收银台,由收银台提示并允许重试 |
| 参数、签名或业务校验失败 | 400 Bad Request | HTML 提示页「无法发起支付」,正文为错误原因 |
成功响应示例
text
HTTP/1.1 302 Found
Location: https://pay.example.com/pay/D6XmSKI284jHKUuWHL4FvZbO4779izuN失败响应示例
text
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=utf-8
...<h1>无法发起支付</h1><p>跳转地址(return_url)不能为空</p>...常见提示:跳转地址(return_url)不能为空、公众号和小程序支付请使用 pay/create 获取拉起参数、MD5签名校验失败、订单号(out_trade_no)已存在,且金额、币种或支付方式不同,其余与 业务状态码 中的 msg 相同。
注意事项
- 幂等:与统一下单相同,同一
out_trade_no相同参数重复提交会跳转到原订单的收银台。 - 金额:单位为元;用户实付金额会在收银台展示,通知中的
money仍为下单金额。 - 签名:GET 方式的签名按解码后的原始值计算,不是按 URL 编码后的字符串。
- 结果判断:付款结果以 异步通知 或 查询订单 为准,
return_url只用于展示。