Design Buy Now, Pay Later
Understanding the Problem
🧾 What is buy now, pay later? Buy now, pay later (BNPL) lets a shopper split a purchase into installments at checkout. Affirm, Klarna and Afterpay are the familiar names. The classic product is Pay in 4: 25% today and three more payments every two weeks, interest-free. Longer plans (6, 12 or 24 monthly payments) usually charge interest. The BNPL provider pays the merchant up front (minus a fee), takes on the credit risk, and collects from the shopper over time.
So a BNPL company is really three things: a checkout integration that merchants embed, a lender that decides in a couple of seconds whether to extend credit, and a servicer that tracks each loan for weeks or months and collects every payment. The scale is modest compared to a social network. What makes the question interesting is money that moves over time: schedules that must add up to the cent, charges that must happen exactly once on the right day, and refunds that arrive halfway through a loan.
Functional Requirements
Core Requirements
- Shoppers should be able to choose BNPL at a merchant's checkout and get an instant credit decision with the plans they're approved for.
- Shoppers should be able to accept a plan, which creates a loan with a repayment schedule; the merchant gets confirmation and is paid.
- The system should collect each installment automatically on its due date, retry failed payments and apply late fees per the loan terms.
- Shoppers should be able to view their loans, pay early, and get refunds applied when they return items.
Below the line (out of scope)
- Merchant onboarding and the merchant dashboard.
- Debt collection agencies and credit bureau reporting in detail.
- How the company funds its loans (credit facilities, selling loans to investors).
- Virtual cards for merchants without a direct integration.
Non-Functional Requirements
Ask about scale and about risk. A reasonable set: 20 million active shoppers, 1 million checkouts per day (with 10x peaks on Black Friday), and about 30 million active loans at any time.
Core Requirements
- The credit decision should return within about 2 seconds, because the shopper is waiting at checkout and every second of delay costs the merchant conversions.
- Money must be exactly right. Every installment is charged exactly once, every schedule sums exactly to the amount owed, and every cent is recorded in a ledger.
- Collection must be reliable. Missing a due date is lost revenue; charging twice is a regulatory and trust problem.
- Credit decisions must be auditable and explainable. Lenders must be able to tell a declined applicant the main reasons, and regulators can ask why any decision was made.
- The checkout path should be highly available (99.95%+). When it's down, merchants lose sales.
Below the line (out of scope)
- Multi-region active-active writes. One primary region with a standby is enough.
Let's size it. One million checkouts per day is about 12 per second on average and maybe 150 per second at a Black Friday peak. That's small. The decision path is expensive per request (bureau calls, models), but the request rate isn't a challenge.
Collection is where volume shows up. With 30 million active loans and Pay in 4 installments every two weeks, roughly 30M / 14 ≈ 2 million installments come due on a typical day. They're all due "today," and we'd like to charge them in the morning, so a few hours of processing means a few hundred charges per second to card and bank processors, which enforce their own rate limits. Retries add more. That's a classic batch-with-deadlines problem, not a real-time one.
Storage is tiny: 30 million loans with a handful of installments each is well under a billion rows, comfortably in a sharded relational database.
Name the shape of this problem early: low-volume, high-stakes writes and long-lived state. Relational databases, transactions, a double-entry ledger and idempotent scheduled jobs are the right tools. You don't need a streaming platform; you need correctness.