Found this when support kept forwarding the same complaint: "my card was declined, I tried again, now it says duplicate order."
Our checkout created one order, then sent the order id to the gateway as the merchant reference. Customer pays, issuer returns a soft decline (05 or 51). Customer fixes the card and hits Pay again. Same order, same reference, second attempt.
The gateway treated the reference as unique per transaction. The retry came back as a duplicate-reference error before it ever reached the issuer. So a recoverable decline became a dead end. About a third of those customers never came back.
We had also half-solved it the wrong way. In one path we generated a fresh reference on every click, which fixed the error but broke the other direction. Double-clicks and network retries of the same attempt produced two real charges.
The fix was to separate two ids we had collapsed into one:
- order_id: stable, one per cart
- attempt_id: new per user-initiated payment, but reused for any network-level retry of that same attempt
The gateway reference is built from attempt_id. Idempotency lives at the attempt level. Reconciliation groups attempts by order.
How do you model order vs attempt in your own systems? Do you keep them in separate tables, or a single payments table with a parent id?
Payneteasy handles this kind of payment flow for merchants and PSPs — see how it works.
Top comments (0)