← All notes
Payments

Paid twice, or never, is the same bug

Escherbridge

A payment that times out is not a payment that failed. It is a payment whose outcome you do not know. Most systems treat that uncertainty as a reason to try again, which is how the same work gets paid twice, or not at all. They are the same bug, seen from opposite ends of the ledger, and nobody has to be cheating for it to happen. A timeout and a retry will do it.

Stripe is unusually plain about the problem. If your system sends a payment and never hears back, Stripe tells you to send it again with the same reference number, and it promises to return the first answer rather than charge a second time. The reference number is not a courtesy. It is how the payment processor knows the second request is the first one asking again.

A public payment rail makes the same problem visible at a shorter interval. The Federal Reserve Banks' FedNow Service uses a payment timeout clock so that a credit transfer is either settled or rejected within a defined window. The readiness guide on that clock says the clock is twenty seconds long, configurable by the Reserve Banks, and that it stops counting just before settlement. A receiving institution can reserve up to five of those seconds to answer a request for confirmation. If the clock runs out before settlement begins, the service rejects the payment and tells the sender. It does not guess.

The guide is equally plain about what happens next. If the sender resubmits a message the service has already received, it must use a new unique message identification number; otherwise the service rejects the duplicate. And because a timeout can leave the sender without an advice, an acknowledgement, or a rejection, the Reserve Banks tell institutions to ask for the payment's status — an ISO pacs.028 request — before they send the payment again. "FIs that submit request for payment status messages (pacs.028) before resending a payment message through the service are able to limit their risk of sending duplicate payments." They also recommend waiting a few seconds longer than the clock itself, twenty-five seconds in the twenty-second example, so that a late acknowledgement is not mistaken for silence.

Twenty seconds is not a long time. It is long enough to lose a reply, short enough to make a second send feel harmless, and exactly the interval in which "did it settle?" and "should I try again?" become the same question. The status request is the missing test. Without it, a timeout is treated as a failure, and a failure is treated as permission to fire the same payment twice.

The pattern is older than either system. A process starts a transfer. The network blinks. The process does not know whether the other side committed. Assume no, when the other side said yes, and someone is paid twice. Assume yes, when the other side said no, and someone is never paid. Both outcomes come from the same missing record: there was never a durable answer to "has this already been decided?"

Idempotency is not a feature you bolt on after the first double payout. It is a prior: the same intent, the same key, the same result. Timeouts, retries, and status checks are how you keep that prior when the network is unkind. A system that can start a payment and cannot later ask what became of it is not a payment system. It is a hope with a retry loop.

This is the point at which a company is tempted to announce that it has solved settlement. I will not. AZOA, the layer in the PrimusNeo stack meant to handle identity, consent, and settlement, is published as pre-launch. Its public repository calls that status "Alpha Gate." Real-value rails are off. The project's own README is clear that no provider currently implements the complete reviewed lock, mint, burn, and release path plus a production custody lifecycle, and that wallet creation is limited to a development simulation until a reviewed production custody adapter exists. Governance votes and credential revocation are listed among action types that are not enabled.

That is not a footnote. It is the same rule the FedNow guide writes for banks: do not move value until you can say, later, what happened to it. Turning the rail on before the custody review and the complete lifecycle are in place would be a way to invent the bug this essay is about. Leaving the rail off is less exciting. It is also the test, written first.

None of this requires a new philosophy of money. It requires a narrower habit. Before a system is allowed to pay anyone, it should be able to answer three questions from its own records: what was intended, whether a decision was reached, and what that decision was. A timeout is not an answer. A retry is not an answer. A dashboard that says "pending" is not an answer. The answer is a stored result that a second attempt can find.

Stripe documents that habit for card payments. The FedNow readiness guide documents it for instant settlement. AZOA is being built to keep the same kind of record for identity, consent, and settlement, and the dangerous path stays closed until that record is real. The same request should settle once, or not at all. The fix is a key, a status check, and a yes or a no you can find later. You can also trace both failure modes hands-on in our Paid-Twice interactive simulator or read the underlying specification boundary in Idempotent HTTP requests.

Sources

  1. Stripe Docs, Idempotent requests. "For API v1, Stripe saves the status code and body of the first request made with a given idempotency key after endpoint execution begins. Retries with the same key return the saved response, including 500 errors."
  2. Federal Reserve Banks, FedNow Service Readiness Guide: Understanding the Payment Timeout Clock
  3. AZOA README (JadeZaher/azoa-autonomous-zones-of-action), Status and value-rail notes

Related