为 Pending 状态的订单获取支付链接 / 二维码 / 链上扣款指令,并发起实际扣款。
不同支付方式的行为:
payment_method |
返回内容 |
用户操作 |
AliPay |
支付宝二维码 / H5 跳转 URL |
扫码或点击链接完成支付 |
WeChat |
微信扫码二维码 |
用微信扫码 |
Stripe |
Stripe Checkout Session URL |
跳转 Stripe 完成卡支付 |
Paypal |
PayPal Approve URL |
跳转 PayPal 完成支付 |
X402 / Crypto |
EIP-3009 / Solana 链上转账指令 |
钱包签名,链上确认即生效 |
ℹ️ 本接口属于 AceDataCloud 平台管理 API,统一前缀 https://platform.acedata.cloud/api/v1/。完整接口索引见获取 AceDataCloud 平台文档列表。
接口概览
| 项 |
内容 |
| 方法 |
POST |
| URL |
https://platform.acedata.cloud/api/v1/orders/{order_id}/pay/ |
| 鉴权 |
✅ 需要账户令牌 |
| Body |
application/json(多数支付方式可为空 {}) |
鉴权说明(如何获取账户令牌)
请求头:
1
|
Authorization: Bearer platform-v1-92eb****629c
|
获取账户令牌的方式见管理 AceDataCloud 平台账户令牌。
路径参数
| 参数 |
类型 |
必填 |
说明 |
order_id |
UUID |
✅ |
订单 ID |
请求体
不同支付方式所需字段不同:
AliPay / WeChat / Stripe / Paypal
通常无需 Body,直接 POST {}。
X402 / Crypto
| 字段 |
类型 |
必填 |
说明 |
signature |
string |
✅ |
钱包对授权信息的签名(EIP-712 或 Solana 签名) |
from_address |
string |
✅ |
付款方钱包地址 |
chain_id |
string |
否 |
链 ID(默认平台主链) |
token_address |
string |
否 |
代币合约地址(默认 USDC) |
请求示例
cURL — AliPay
1 2 3 4 5
|
curl -X POST 'https://platform.acedata.cloud/api/v1/orders/fa927d12-3b04-4f51-bf2e-ec3a5a7d9b2c/pay/' \ -H 'accept: application/json' \ -H 'authorization: Bearer platform-v1-92eb****629c' \ -H 'content-type: application/json' \ -d '{}'
|
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
import requests
PLATFORM_TOKEN = "platform-v1-92eb****629c" order_id = "fa927d12-3b04-4f51-bf2e-ec3a5a7d9b2c"
resp = requests.post( f"https://platform.acedata.cloud/api/v1/orders/{order_id}/pay/", headers={ "authorization": f"Bearer {PLATFORM_TOKEN}", "content-type": "application/json", }, json={}, timeout=10, ) data = resp.json() print(f"支付链接: {data.get('payment_url') or data.get('qr_code_url')}")
|
Node.js
1 2 3 4 5 6 7 8 9 10 11
|
const orderId = 'fa927d12-3b04-4f51-bf2e-ec3a5a7d9b2c' const r = await fetch(`https://platform.acedata.cloud/api/v1/orders/${orderId}/pay/`, { method: 'POST', headers: { authorization: 'Bearer platform-v1-92eb****629c', 'content-type': 'application/json', }, body: '{}', }) const data = await r.json() window.location.href = data.payment_url || data.qr_code_url
|
响应示例(HTTP 200)
AliPay / WeChat
1 2 3 4 5 6 7
|
{ "order_id": "fa927d12-3b04-4f51-bf2e-ec3a5a7d9b2c", "payment_method": "AliPay", "payment_url": "https://qr.alipay.com/bax03455azqgxxxxxxxxx", "qr_code_url": "https://qr.alipay.com/bax03455azqgxxxxxxxxx", "expires_in": 900 }
|
Stripe / Paypal
1 2 3 4 5 6
|
{ "order_id": "fa927d12-3b04-4f51-bf2e-ec3a5a7d9b2c", "payment_method": "Stripe", "payment_url": "https://checkout.stripe.com/c/pay/cs_test_xxxxx", "expires_in": 86400 }
|
X402 / Crypto
链上支付成功直接结算——返回值表示已确认上链:
1 2 3 4 5 6
|
{ "order_id": "fa927d12-3b04-4f51-bf2e-ec3a5a7d9b2c", "payment_method": "X402", "state": "Paid", "tx_hash": "0x123abc..." }
|
错误处理
| HTTP |
code |
含义 |
| 400 |
invalid_state |
订单状态不是 Pending(已支付 / 已取消 / 已过期) |
| 400 |
invalid_signature |
X402 / Crypto 签名验证失败 |
| 400 |
invalid |
其他参数错误 |
| 401 |
not_authenticated |
缺少账户令牌 |
| 403 |
permission_denied |
订单不属于你 |
| 404 |
not_found |
订单不存在 |
实用提示
- 支付链接有时效:AliPay/WeChat 一般 15 分钟过期,到期后再次调用本接口会自动重新生成新链接。
- 支付完成后自动到账:服务端会监听支付回调(异步),通常几秒内
state 变为 Paid 并增加 Application 余额。
- 不需要手动确认:第三方支付的支付状态完全由服务端 Webhook 接收,客户端只需轮询订单详情或刷新订单状态 来感知。
- X402 即付即生效:链上支付不是异步流程——本接口返回时
state 已经是 Paid。
- 重复支付保护:同一订单
state="Paid" 后调用本接口会返回 400 invalid_state,不会重复扣款。
相关接口