The short version

A payment request that was sent and never answered is not a failure. It is a third outcome, and the client cannot tell it from either of the other two. Treat it as failure and you tell a debited customer their money did not move; treat it as success and you ship a lie. The two pieces that resolve it are an idempotency key created once when the user commits and reused on every attempt, and a status query rather than a blind retry — because asking what happened is always safe, and re-sending is safe only if you built it to be.

Every payment screen handles two outcomes well. It went through, or it did not. Both have a design, a message and a colour.

The third one has none of that, and it is the one that generates the support calls: the request left the device and no answer came back. A lift, a tunnel, a handover between cells, a slow downstream system, a load balancer that gave up at thirty seconds. The customer is looking at a spinner and the app knows exactly as much as they do.

Why it is genuinely a third state

The temptation is to fold it into failure, because that is what it looks like from the client. The request did not complete, so nothing happened.

But the request may well have arrived. The payment may be processed, the ledger written, the counterparty credited, with only the response lost on the way back. From the device those two situations are identical, and any message you show is a guess.

Guessing failure is the worse direction. The customer has been debited and told it did not work, so they pay again — often through a different route, which guarantees the two attempts share nothing your systems can match up. Now you have a duplicate, an unhappy customer, and a refund process. Guessing success is rarer and worse in a different way: you have told someone a payment is done when it may not be.

So the honest answer is to say what is true. Something was sent, the outcome is not yet known, here is a reference, please do not pay again.

THREE OUTCOMES, NOT TWO Request sent key made once, at commit Answered: succeeded show done Answered: declined show failed No answer at all it knows only what it sent no design for this RESOLVING THE THIRD BRANCH Ask, do not re-send query the status of that key The server knows it stored the key first One payment, either way replayed, or safe re-send QUERYING IS ALWAYS SAFE — RE-SENDING IS SAFE ONLY IF YOU BUILT IT TO BE and the key has to survive the app being closed, or the retry arrives without one
The client cannot distinguish the third branch from the second. The server always can, if it was asked to remember.

The idempotency key, and the detail everyone gets wrong

The mechanism is well known. The client generates a unique value for one intended payment and sends it with the request. The server records that key before doing any work, and if the same key turns up again it returns the stored result rather than moving money a second time.

The part that gets implemented wrong is when the key is created. It must be generated once, at the moment the user commits to the payment, and reused unchanged on every subsequent attempt at that same payment. A key generated freshly inside the request function is not an idempotency key — each retry carries a new one, every attempt looks like a different payment, and the system behaves exactly as if the mechanism were absent. This is a common and entirely invisible bug: it passes every test where nothing goes wrong.

Two further details earn their keep. The key has to survive the app being closed, so it belongs in persistent storage next to the pending payment rather than in memory; otherwise the customer who force-quits and reopens sends a retry with nothing to match on. And the server should store a fingerprint of the request alongside the key: if the same key arrives with a different amount or beneficiary, that is a bug or a tampered request, and it should fail loudly rather than quietly replaying or quietly double-charging.

Query before you retry

Given an unknown outcome, the instinct is to re-send. The better instinct is to ask.

A status endpoint that takes the idempotency key and reports what happened to it is safe by construction — a query moves no money, so it can be called as often as needed, on a backoff, when the app returns to the foreground, or when the customer taps refresh. A retry is safe only if idempotency is genuinely enforced all the way down, including at whatever downstream system actually moves the funds, and that last part is frequently where the guarantee quietly stops. Your service may be idempotent while the gateway behind it is not.

Which is worth checking explicitly rather than assuming, in the same way that every integration should be called before it is relied on. The question for the provider is simple: if I send this twice with the same key, what happens?

The ledger is the truth

The key store answers “did I already process this request”. It is not the record of what the customer's money did.

That record is the ledger, and it needs to be reconcilable against the provider's own view independently of anything the app believes. A daily comparison that lists payments the provider has and you do not, and the reverse, is the control that catches the cases the retry logic missed — and there will be some, because this is a distributed systems problem and not one you close entirely. Finding them in a scheduled report is ordinary operations; finding them because a customer called is an incident.

The same discipline applies when the payment has to land in a core banking system, where the write path and the reconciliation path are usually two different integrations with different failure characteristics.

What the customer should see

Three rules, and they are mostly about resisting a tidy interface.

Never show a terminal failure on a timeout. Show a pending state that names what is happening, gives a reference, and says plainly not to pay again. It is less satisfying than a red cross and it is the difference between one payment and two.

Resolve it without being asked. The app should keep querying in the background and update the screen when the answer arrives, rather than leaving the customer to work it out. Most unknowns resolve within seconds.

Make the pending payment visible. It belongs in the transaction list in its pending state, not hidden until it settles. A customer who closed the app mid-payment will go looking there, and an empty list is what sends them to pay again.

A checklist worth running

  1. Generate the key at commit, once, and persist it with the pending payment.
  2. Store the key server-side before doing the work, not after.
  3. Fingerprint the request and reject a reused key with different parameters.
  4. Build a status endpoint keyed on the idempotency key and query it instead of retrying.
  5. Confirm idempotency downstream, at the gateway or core, rather than assuming it.
  6. Reconcile against the provider daily, both directions.
  7. Test with the network cut after the request leaves, which is the one test that exercises all of this and the one nobody writes.

That last point is most of the value. The third outcome is rare enough to miss in testing and common enough to be a weekly occurrence at any volume, and the only way to see it before your customers do is to cause it deliberately.

Questions we get asked

Why is a payment timeout not just a failure?

Because the request may have arrived and been processed, with only the response lost on the way back. The client knows what it sent and nothing about what happened. Showing failed is a guess that is wrong a meaningful share of the time, and when it is wrong the customer has been debited and told otherwise, which is the single worst outcome a payment screen can produce.

What is an idempotency key and where should it come from?

A unique value the client generates for one intended payment and sends with every attempt at it. The server records the key before doing any work and, if the same key arrives again, returns the stored result instead of moving money a second time. The critical detail is when it is generated: once, at the moment the user commits to the payment, and reused across retries. A key created per attempt is not an idempotency key and protects nothing.

Should the app retry automatically after a timeout?

It should ask, not retry. A retry re-sends an instruction whose outcome is unknown, which is safe only if idempotency is enforced end to end, including at whatever downstream system actually moves the money. The better first move is a status query: ask the server what happened to that key. Querying is always safe; retrying is safe only under conditions you have to have built deliberately.

What should the screen say while the outcome is unknown?

Something true, which means neither failed nor done. A pending state that says the payment is being confirmed, with a reference the customer can quote and a clear statement that they should not pay again, is accurate and calms the situation. The costly pattern is a terminal error message that prompts a second attempt through a different route, because now there are two payments and no connection between them.

Does the same key with a different amount matter?

Yes, and it should be rejected rather than replayed. If a key arrives again with different parameters, something is wrong — a reused key, a bug, or an altered request — and quietly returning the first result would hide it while quietly processing it would double-charge. Store a fingerprint of the request alongside the key and fail loudly on a mismatch.

How long should idempotency keys be kept?

Long enough to cover every path by which a retry can reach you, which is longer than the request timeout suggests. A customer may reopen the app hours later, and a queued or offline attempt can surface much later still. Keeping keys for at least as long as the longest plausible retry window, and reconciling against the ledger rather than the key store for anything older, is the usual arrangement.

Related service Fintech app development Payment products built for the bad network

If your payment flow has a red failure screen and no pending state, the cheapest test available is cutting the network after the request leaves the device. It is a standard part of how we build fintech and payment apps, because the alternative is finding out in production.