// 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 });
}
}