DEV Community

anuj kumar
anuj kumar

Posted on

The Payment Succeeded. The Response Never Arrived.

A customer clicks Pay £100.

The payment succeeds — but the response is lost.
The customer retries.
Without idempotency:
Retry → second charge ❌
With an idempotency key:
Same logical payment → same key → same result ✅

A robust design should:

  • Generate the key once at the caller
  • Reuse it for every retry
  • Protect it with a DB unique constraint
  • Store a request hash
  • Persist the final response
  • Pass the same key to the payment provider when supported

The key lesson:

A retry should repeat the request for the result — not repeat the business side effect.

Payments #SpringBoot #SoftwareArchitecture

Top comments (0)