</> MAANG.io

Expert

Design landmark systems in depth, from Dynamo, GFS, Bigtable and Kafka to payments and ads pipelines.

0 of 232 solved 0%

Section 6: Paying Exactly Once - Payouts, Settlement & Seller Experience

Executive Summary: Section 5's ledger records that Lantern & Loom is owed $70.40, but a balance isn't a bank deposit. This section turns balances into transfers. Funds sit in pending until 3 days after delivery, which is why about $3.7B is pending at any moment. A daily batch then makes 500k payouts in a 2-hour window, checking eligibility against the authoritative ledger balance and never a cache. Every payout follows one ordering rule: commit the ledger debit first, then call the PSP with payout_id as the idempotency key. We follow the lamp's $70.40 into payout po_L1 on day 7, through a timeout, a lookup and a confirmation. Then we book the PSP's settlement into the platform and show how a seller statement explains every line.

The interviewer points at seller_available:lantern on the whiteboard. "There's $70.40 in there. How does it reach their bank, exactly once?" This is the step where a bug wires real money out of the building for good.

Pending, Available, and the $3.7B Float

A captured sale isn't spendable on the spot. The lamp's capture on day 1 credits seller_pending:lantern with $70.40. Delivery happens on day 4, and the release job posts a two-leg transaction on day 7, delivery plus 3 days (D12). Without a delivery scan, funds release 14 days after shipment instead.

Leg Account Debit Credit
1 seller_pending:lantern 70.40
2 seller_available:lantern 70.40

Sellers keep 88% of $600M a day, and the money waits about 7 days from capture to release, so ≈ $3.7B is pending at any moment. That float is what makes refunds cheap. Most of the 450k daily refunds land while the money is still pending, so a refund is just a debit to seller_pending, with nobody to chase.

Interviewer: "Sellers hate waiting a week. Why not pay out at capture?"

You: "Because then every refund and chargeback becomes a collection from a seller who's already spent the money. The hold is our insurance. The flip trigger is per seller: trusted sellers with a low dispute rate get a shorter hold. Risky sellers go the other way and also carry a rolling reserve in seller_reserve:{id}. Section 7 sizes that reserve."

Quick check before moving on:


Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.