Prompt
Do I need exactly-once processing for payment webhooks?
Latest observation
Usually, you do not need true exactly-once processing for payment webhooks, and in practice it’s often not achievable anyway because most webhook delivery systems are at-least-once and may retry.
What you do need is:
- Idempotent handling
- Deduplication
- A reliable source of truth for payment state
Why not exactly-once?
Webhooks can be:
- delivered more than once,
- delivered out of order,
- retried after timeouts,
- duplicated by the provider.
So if you design for exactly-once, you’ll still need safeguards.
What to do instead
For payment webhooks, the standard approach is:
-
Verify the signature
Ensure the webhook really came from the provider. -
Store event IDs / transaction IDs
Keep a record of processed webhook event IDs. -
Make processing idempotent
If the same webhook arrives twice, the second attempt should not double-charge, double-fulfill, or double-update. -
Use your database as the authority
Update order/payment state in a way that can be safely repeated. -
Handle out-of-order events
For example, don’t assume “paid” arrives before “pending.”
Example
If a webhook says “payment succeeded”:
- check whether the order is already marked paid,
- if yes, ignore it,
- if no, mark it paid and fulfill once.
Bottom line
No, you don’t need exactly-once processing.
You need idempotent, deduplicated, and state-safe processing that achieves the same business result.
If you want, I can show a simple webhook design pattern for Stripe/PayPal-style payment events.