idempotency-demo · sequence diagram

Scenario C · Same key, different body

The same Idempotency-Key arrives with another amount. Reusing a key for a different payment is a client bug, so it is rejected. Answer: 422.

alt · hash differs Clientcurl / test PaymentControllerPOST /payments PaymentFacadecreatePayment() IdempotencyReserverREQUIRES_NEW H2idempotency_record PaymentServicesimulated provider pago-001 exists with amount 150.00 POST /payments · same key, amount 999.00 createPayment(key, request) requestHash = SHA-256(new body) findByKey(pago-001) record with the hash of 150.00 stored hash ≠ new hash not called 422 Unprocessable Entity 422 Unprocessable Entity Result: rejected; a key can only ever mean one payment
Solid arrows: calls. Dashed: replies. Red: errors. Amber: conflicts. Dashed blue boxes: database transactions (each IdempotencyReserver method opens its own); amber boxes: alternative branches.

What to look for