A payout reconciler on AWS for a few dollars a month
A homeware retailer with one shop, a website and a marketplace listing booked £451,168 of sales last year. It sold £486,213. Nobody had taken anything and nobody had mistyped anything. Every payout that reached the bank had been entered as a sale, and a payout is not a sale.

Key takeaways
- A payout is a net figure: sales less refunds, disputes, fees and whatever the provider held back.
- Booking payouts as sales understates revenue and hides every cost the provider deducted.
- One clearing account per provider, whose balance is what that provider owes you.
- That balance can be checked against the provider’s own figure, which is the point.
- Designed on AWS for about $2 a month.
The whole system on one page
Before any code, here is the shape of what we are designing.
- Machine learning
- Networking
- Management
- Analytics
Why this is hard for a business that is otherwise well run
Because the bank statement looks like the answer. A deposit arrives from the card terminal provider every working day, the amount is roughly what the till said, and the obvious bookkeeping entry is a sale of that amount. Doing anything else means opening a report nobody asked for, in a format that differs for every provider, and splitting one bank line into dozens.
It also works well enough to go unnoticed for years. The bank reconciles, because the entries were copied from the bank. The VAT return goes in. The only symptom is that the sales figure in the accounts is a little lower than the sales figure in the till and the website, and every business has a story for why those two never quite agree.
What runs (the inside)
- Settlement lines. Every provider’s report broken into individual sales, refunds, disputes, fees and holds, in one shape. Part 2.
- Clearing accounts. One per provider, whose balance is what that provider owes you, checked against the provider’s own figure. Part 3.
- The unexplained lines. Adjustments with a sentence where a type code should be, and how they get a type. Part 4.
- Match and close. Bank lines matched to payouts, the month cut off on the date of the sale, and a journal posted gross. Part 5.
One retailer, one financial year
In plain words
Each provider publishes a report of what it did with your money: every payment it took, every refund it sent back, every dispute it lost on your behalf, every fee, and every amount it decided to hold for a while. It then pays out whatever is left, in a lump, on its own schedule. The report is the ledger; the payout is only its last line.
The system reads those reports as they appear and turns each one into settlement lines of a single shape, whichever provider it came from. A card terminal provider’s daily file, an online checkout’s balance report, a PayPal activity download and a marketplace’s fortnightly statement all become the same thing: a dated line with a type, an amount and the payout it belongs to.
Those lines post to a clearing account, one for each provider. Sales push the balance up; refunds, fees and disputes pull it down; a payout moves money from the clearing account to the bank. What is left at any moment is what the provider owes you, and the provider publishes its own version of that figure, so the two can be compared.
Then the bank lines are matched to the payouts, the month is cut off on the date each sale happened rather than the date it was paid out, and the accounts receive a journal with sales, refunds, disputes and fees on their own lines. The sales figure in the books becomes the figure the till and the website already knew.
Design rules that shaped every decision
- A payout is never a sale. It is a transfer from a clearing account to the bank.
- Every provider gets its own clearing account, and its balance must be explainable.
- The lines inside a payout must sum to the payout to the penny, or nothing posts.
- Reports are parsed. The model only sees what no rule can type.
- Cut-off follows the date of the sale, not the date of the money.
- History is appended. Provider reports only go back so far, and this store is the record.
What it does not do
It does not judge whether the fees are reasonable. A fee line here is an expense with a date and an amount, and whether it is the right amount is a different question with its own system elsewhere in this series. Mixing the two produces a reconciliation that stops every month to argue about pricing.
It does not fight disputes either. A dispute appears here as money leaving the clearing account and, if it is later won, as money coming back. Gathering the evidence to win it happens somewhere else; the reconciler only needs the outcome.
And it does not post to the accounts on its own. It writes a journal and a reconciliation pack for each month, and a person imports the journal after reading the pack. A month-end entry that changes reported sales is the kind of entry somebody should have looked at.
The next four posts walk through each piece: what is actually inside a payout, the clearing account that makes it checkable, the adjustment lines nobody can explain, and matching the bank before closing the month. One diagram per post, a cost breakdown, and an engineering reference at the end.
All posts