Episode 1 of 9 · Stripe
Stripe, end to end: how a company proves where every dollar is
Vertical version.
Chapters
Narration
You buy a forty dollar coffee machine online. You tap pay. A second later, forty dollars has left your bank account, and a shop's account has forty dollars more. Nobody carried it. One request, two banks that have never met, and not one cent may be lost on the way. Here is the strange part. The company behind this, Stripe, is not mainly a payments company. Under the payment sits a book. And that book can answer a question most apps cannot. Where is every dollar, right now? Why should you care? Because money is the one thing a program may never get approximately right. A feed can drop a like. A payment cannot drop a cent, and it cannot invent one either. So here is our one question for the next few minutes. How do we prove where every dollar is, at any moment? Here is the plan. First, the obvious way, one number per account. Second, the book, the way merchants have kept money for five hundred years. Third, the catch, a payment that arrives twice. And fourth, the real world, where money takes days to move. Stop one, the obvious way. Give every account one number, its balance. A payment takes from one number and adds to another. It is simple, and it is fast. Now the cost. A number is only an assertion. It says, this is what you have, and gives you nothing to check it against. Suppose a bug adds one dollar to the wrong account. That balance now reads one dollar higher, and it looks exactly as correct as before. Nothing about a single number can be wrong, because nothing about it can be tested. Stop two, the book. The idea is old. In fourteen ninety four, in Venice, a friar printed a how to for a method merchants there had used for two centuries. Never write one number for a movement of money. Write two. One line where the money leaves. One line where the same money arrives. The line where it leaves is called a debit. The line where it arrives is called a credit. Together, a pair, and the pair must always match. A mistake can no longer hide in a single number. It shows up as a pair that does not match. Run an example. A shopper pays a shop one hundred dollars, and Stripe keeps a three percent fee. The cash coming in is one hundred. Ninety seven is owed to the shop. Three is Stripe's fee. Write it as lines. Plus one hundred, minus ninety seven, minus three. One hundred, minus ninety seven, minus three, is zero. Zero, every time. If any line is wrong, the sum is not zero, and the book fails loudly instead of quietly. And nobody ever erases a line. A mistake gets a new pair that undoes it. A refund is a new pair moving the money back. Stop three, the catch. The book is only as honest as the number of times a payment is written into it. Picture the shopper on a slow connection. They tap pay. The network drops for two seconds, and no answer comes back. So they tap again. Now two requests arrive for one coffee machine. Write both, and you charged someone twice. Refuse both, and a shopper whose first tap worked thinks the shop lost their money. As an example, a million charges a day, and one in a hundred times out. One million times one percent is ten thousand charges a day where nobody knows what happened. The fix is a habit from paper forms. Every attempt carries a ticket number, chosen by whoever is paying. The first time a ticket arrives, run the charge, and staple the receipt to that number. The second time the same ticket arrives, run nothing. Hand back the same receipt. One ticket, one receipt, one entry in the book. The timeout did not change. The ticket turned an unknown into a lookup. Stripe calls it an idempotency key, and it is its own episode. Stop four, the real world. Where is the money while the card is being charged? Three moments. At time zero, about a second after you tap, your bank approves. That is only a hold. It sets the amount aside and promises to send it. The next day, the banks agree on the amounts, in a batch. Then a day or two after you saw success, the money actually moves, bank to bank. So approved is a hold, not a transfer. The book gets a row at every hop, so money is never in flight without a record. Even a perfect book can drift from reality. A message gets lost between two systems. A bug nobody caught. So every night, Stripe adds up what its ledger says, and compares it with what the banks say they hold, in every currency. The two must agree to the penny. Stripe's own rule of thumb is about one disagreement for every ten million dollars moved. Small enough that a person can look at each one. Frequent enough that the check has to run every night. That check is called reconciliation. Three things to keep. One. A single balance cannot be checked, so a ledger writes every movement of money as a matching pair that sums to zero. Two. Pairs are only ever added, never edited, and a ticket number makes sure each payment is written once. Three. Approved is only a hold, and every night the book is checked against the bank, to the penny. So that is the map. Stripe is a ledger, with an API in front. A fast plane that moves money, a slow plane that tells everyone about it, and underneath both, a book that is never allowed to lie.
Based on the board The Map.
Saved in this browser, and to your account when you sign in.