My AI Agent Charged a Customer Twice in 11 Seconds
Описание и применение
Повторная обработка вебхука платежа привела к двойному списанию средств. Решение: сделать обработчик идемпотентным, используя уникальный ID события, сохранять его до выполнения действий и игнорировать повторные события.
Задача
Duplicate payment charges were created because the webhook handler did not dedupe repeated events, leading to a customer being charged twice.
Результат
Prevented double charges by making the webhook handler idempotent; added duplicate‑event tests and nightly reconciliation to catch similar issues early.
Рабочий процесс
- Receive payment.succeeded webhook
- Extract event_id from payload
- Check if event_id already processed in durable store
- If processed, return success and skip
- If not, record event_id
- Charge customer
- Provision account
- Send receipt email
- Return success
Доказательства
The provider had sent the payment.succeeded event three times.
The fix is small enough to be almost insulting, which is the point.
- Дата записи: 2026-09-07T23:23:12.637Z