fix: make Stripe subscription events monotonic
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
237899745
2026-07-26 02:04:17 +08:00
parent 57892f6509
commit fd9a828225
3 changed files with 620 additions and 76 deletions

View File

@@ -137,7 +137,8 @@ RETURNING used_units;
要求:
- **验签**:使用 `STRIPE_WEBHOOK_SECRET` 校验 `Stripe-Signature`
- **事件幂等**:按 `provider_event_id` 去重(落库 `webhook_events`)。
- **乱序容忍**以 Stripe 事件时间 + 当前 DB 状态做“只前进不回退”更新
- **乱序容忍**订阅对象按 `(event.created, 事件优先级, event.id)` 保存独立水位;`deleted` 即使先到也会保留 tombstone`created/updated` 不得恢复已取消订阅
- **并发一致性**`subscriptions(provider, provider_subscription_id)` 唯一,订阅业务写入与 `webhook_events=processed` 在同一事务提交。
- **可重放**:保存原始 payload脱敏用于排查。
建议首期处理的事件(示例):