准备支付 (Prepare Payment)
授权并生成执行支付所需的区块链交易数据 (calldata)。
POST /payment/prepare
EIP-712 授权
此接口需要 purpose 为 prepare_payment 的 EIP-712 签名。此签名作为用户执行交易的最终确认。
请求参数
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
message | Object | ✅ | 用户签署的 EIP-712 消息对象。 |
message.purpose | String | ✅ | 必须是 prepare_payment。 |
message.sessionId | String | ✅ | 会话 ID。 |
message.merchantId | String | ✅ | 商户 ID。 |
message.payer | Address | ✅ | 支付者地址。 |
message.payerEmail | String | ✅ | 支付者邮箱。 |
message.paymentChainId | String | ✅ | 支付链 ID。 |
message.paymentToken | Address | ✅ | 支付代币地址。 |
message.authorizationNonce | Bytes32 | ✅ | 唯一 Nonce。 |
message.authorizationExpiresAt | Timestamp | ✅ | 过期时间。 |
signature | Bytes | ✅ | EIP-712 签名。 |
请求示例
{
"message": {
"purpose": "prepare_payment",
"sessionId": "sess_example_payment_03",
"merchantId": "f7d65b193454db46fb2d6277e2f5e593bffcf6adde5064a2bb5dee6fd9b0fb7a",
"paymentChainId": "137",
"paymentToken": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
"payer": "0x1234567890123456789012345678901234567890",
"payerEmail": "test@example.com",
"authorizationNonce": "0x3132...",
"authorizationExpiresAt": "1769488108"
},
"signature": "0x48a654a..."
}
响应结构
响应包含区块链交易的 calldata 和 aiView 中的 paymentExecutionGuide。
响应示例
{
"calldata": "0xa9059cbb000000000000000000000000f7d65b193454db46fb2d6277e2f5e593bffcf6ad00000000000000000000000000000000000000000000000000000000002de6b0",
"aiView": {
"pricingModel": { "type": "fixed" },
"paymentExecutionGuide": {
"authorizationRequired": false,
"executionRequest": {
"purpose": "execute_payment_guide",
"sessionId": "sess_example_payment_03",
"txRequest": {
"chainId": "137",
"to": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
"data": "0xa9059cbb...",
"value": "0"
},
"userReview": {
"description": "This transaction will execute the prepared payment on-chain.",
"irreversible": true
}
}
},
"workflow": {
"stage": "payment_prepared",
"nextAction": {
"action": "execute_payment_client_side",
"description": "Client must execute the on-chain transaction."
}
}
}
}
错误处理
此接口遵循 统一错误处理 标准。业务错误返回 HTTP 200 及非零 code。