跳到主要内容

准备支付 (Prepare Payment)

授权并生成执行支付所需的区块链交易数据 (calldata)。

POST /payment/prepare

EIP-712 授权

此接口需要 purposeprepare_payment 的 EIP-712 签名。此签名作为用户执行交易的最终确认。

请求参数

字段类型必填描述
messageObject用户签署的 EIP-712 消息对象。
message.purposeString必须是 prepare_payment
message.sessionIdString会话 ID。
message.merchantIdString商户 ID。
message.payerAddress支付者地址。
message.payerEmailString支付者邮箱。
message.paymentChainIdString支付链 ID。
message.paymentTokenAddress支付代币地址。
message.authorizationNonceBytes32唯一 Nonce。
message.authorizationExpiresAtTimestamp过期时间。
signatureBytesEIP-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..."
}

响应结构

响应包含区块链交易的 calldataaiView 中的 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