All projects
Backend engineering and reliability, 2026
Idempotency Gateway for Safe Payment Retries
A FastAPI gateway that prevents duplicate payment processing by binding each request body to an idempotency key and replaying completed responses safely.
Challenge
Network retries are normal, but a repeated payment request must never become a second charge.
Approach
The gateway hashes request bodies, tracks processing and completed states, coordinates concurrent requests, detects key conflicts, replays safe responses, and expires stale records with a TTL.
Result
The implementation turns retry safety into an explicit protocol with clear 201, replay, in-flight, and 409 conflict behaviour.
Core capabilities
- Request-body hashing and key conflict detection
- Thread-safe in-flight request coordination
- Completed response replay with cache signalling
- TTL-based record expiration
Discuss this work