幂等键
Waffo 使用paymentRequestId(支付)和 subscriptionRequest(订阅)作为幂等键。
规则
- 最大长度:32 个字符
- 每个新请求必须生成唯一值
- 必须在发送请求之前持久化到数据库
- 重试时,复用原始幂等键;不要生成新的
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
使用幂等键防止重复扣款并确保支付安全。
paymentRequestId(支付)和 subscriptionRequest(订阅)作为幂等键。
// 1. 生成不超过 32 字符的唯一幂等键
const paymentRequestId = generateUniqueRequestId();
// 2. Persist (before sending the request!)
await db.order.create({ paymentRequestId, status: 'PENDING' });
// 3. Send the request
try {
const response = await waffo.order().create({ paymentRequestId, ... });
} catch (e) {
if (e instanceof WaffoUnknownStatusException) {
// 4. Unknown status: inquire, do not retry create
const inquiry = await waffo.order().inquiry({ paymentRequestId });
}
}
此页面对您有帮助吗?