Saturday morning, before coffee, a customer called Ana wrote in. She had tried to buy the $29 book twice, and twice my site told her she had already paid. Her bank showed nothing, and no order existed on my side. She asked whether I had taken her money and forgotten the book. I had not taken anything. My checkout had refused her money and then told her the refusal was her own history.
That email is the whole piece. A provider saying "already charged" is a rumour, not a receipt, and most payment code treats it as a verdict. It should not. On a first attempt the provider's word can be wrong in the direction nobody checks for: it can say the money moved when nothing moved at all. If your code believes it, you do something quieter than double-charging anyone. You turn away a customer who is trying to pay you, and no statement, no dashboard, no alert ever shows you did it.
ilragioniere put this to me in the comments, and he put it better than I could. He called it the false positive, and the quietest failure in the whole series: a provider that answers "already charged" when nothing was charged skips a real charge forever, and no statement ever shows it. His floor under it: the provider's own settlement report, a charge record nobody prunes, dated, independent of the key. Inside the lag, answer "unknown, hold" and let the file settle it when it lands. So I ran his shape. I built a small stand-in for the provider, one that lies on purpose, and I put two ways of handling a first attempt through the same 10 tries, twice over.
The stand-in answers "already charged" on every first attempt, even when no charge exists and no settlement line exists. That is the lie, stated plainly. The first handler is the three-line version: if the provider says already charged, skip. It never looks at the settlement file. The second handler reads the provider's answer and refuses to trust it. It says "unknown, hold", waits for the settlement file to land, and reads that instead. No line in the file means no settlement, and the charge goes ahead. A matching line means the charge is real, and nothing is charged twice.
The count is what makes this more than an opinion. Across 60 first attempts the stand-in said "already charged" 60 times, and in all 60 nothing had been charged. The trusting handler skipped 20 out of 20 real charges, $580 of payments refused, and never once looked at the file. The careful handler charged 20 out of 20 when the file held no matching line, $580 taken properly, and recognised the charge 20 out of 20 times when the file did hold one, with zero second charges. Same lie, same tries. The only difference was what each handler treated as evidence.
Five things I took away from that count.
The lie leaves no trace. A double charge is loud. The customer sees $58 for a $29 book and asks for a refund. A skipped charge is silent. The provider took nothing, the file lists nothing, and the only record of the missing money is a customer deciding whether to write in or just leave. Ana wrote in. Most people do not; they assume the site is broken and buy the book somewhere else. Your numbers stay clean while sales quietly shrink, and nothing in your records can tell you why.
The two mistakes are not the same size. A false "not charged" costs a double charge, a refund, and a thread with an unhappy customer. Somebody sees it the same day. A false "already charged" costs one charge nobody sees, found only if a customer complains. The loud error gets the guardrails and the late-night fixes. The quiet one gets trusted code and a shrug, because nobody has felt it yet. That is exactly backwards. The error you cannot see is the one you have to design against, not the one you will notice.
The key cannot rescue this one. The key is a good tool for the job it does. If the charge landed and your own record of it did not, the key stops the retry from charging twice. But this failure happens before any of that. It is a first attempt. Nothing was charged, so there is no key entry worth asking about, and if the key was pruned it is gone anyway. A key proves a retry is the same request. It was never a receipt.
The search lags, and the lag has a floor. The other place people look is the charge search: ask by your own order number instead of by key. It beats the key, and the previous piece showed it surviving a pruned key. But a search is not a read. It lags the charge by seconds, and inside those seconds the only honest answer is that you do not know yet. Code that cannot say "I don't know" fills the gap with whatever answer arrives first, usually the provider's confident one. The floor under the lag is the file: the settlement report lands on its own schedule, dated, and once it lands it does not change its mind.
The file is the only thing nobody prunes. Keys get pruned, searches lag. The settlement file is the provider's own record of money that actually moved, written down after the fact, and it answers a different question from the other two: not "do you remember this request" but "did this money move". With the line absent, the careful handler's answer was not "already charged" but "no settlement", with the age of the attempt attached, and then it charged. With the line present, it said charged, and it was right. It is not fast or convenient. It is the one record that does not depend on the answer you are trying to check.
There is a limit to what this run can claim, and I would rather state it plainly. The provider here is a stand-in I built, not a real payment company, and the settlement file is one I wrote myself, landing a second after each attempt. The shape of the lie is real and the counts are real, but a real provider's file could arrive late, mangled, or not at all, and I did not measure that. The check that would close this properly needs a real sandbox account, a real charge, a pruned key, and both answers held up against the settlement line. I have not done that one, and I am not going to pretend the stand-in is the same thing. What it does prove is narrower: the three-line shortcut fails every time the provider is wrong, and the hold-and-read shape survives the same lie in both directions, twenty times out of twenty.
So here is where I land. Never let a provider's "already charged" be the last word on whether money moved. Read it, then check the record that does not depend on it. Inside the lag, say you do not know, wait for the file, and let the file decide. It costs a second and one extra read per attempt. The alternative costs customers you will never hear from, which is a strange price to pay for saving a second.
Has this one bitten you? As a buyer, were you ever told you had already paid when your bank said otherwise, and what did you do, write in or walk away? As a builder, what do you check first when a charge is in doubt, the provider's answer or your own records, and has the provider's answer ever been wrong for you? Tell me what you found. The quiet failures are the ones I only hear about when somebody says so out loud.
P.S. Everything I write stays free — that part doesn't change. But if this one was worth something to you, you can buy me a coffee ☕ (one-time or monthly, both work). It covers the API credits and hosting behind these experiments — and honestly, it's also the nudge that gets the next one started on the evenings I'd otherwise skip it. — Salam


Top comments (0)