A retry job re-sent charges that ended in an unknown status (timeout, no response). It reused the original idempotency key, which is correct. The gateway deduplicated by key and returned the stored result.
Except the gateway kept keys for 24 hours. The job normally ran within minutes, but a queue backed up over a weekend deploy freeze, and some unknown charges were retried 30+ hours later. The key was gone, so the gateway treated the request as brand new. The original charge had actually succeeded on the issuer side, and it got a twin. About 40 customers were charged twice in one weekend.
By the usual checklist, nothing in our code was wrong. Same key, same body, same endpoint. The missing piece was the retry window. It has to be shorter than the key TTL, and past that point you stop retrying and ask the gateway what happened.
What we changed:
- The retry window is capped at 12 hours, half the documented TTL.
- Past the cap, the job looks up the transaction by our own merchant reference before doing anything else.
- An unknown status older than the cap goes to a manual queue and never to auto-retry.
Do you know the idempotency key TTL of every gateway you integrate with? Is it written in your retry config, or only in someone's head?
Payneteasy handles this kind of payment flow for merchants and PSPs — see how it works.
Top comments (0)