Skip to content
SD-32 · System design

Design a Card Payment Processing

Asked at Staff level45 minutes
Our answers stay hidden until you reveal them.

Design a card payment processor: the service that online shops call to charge a customer's credit or debit card. A shopper types their card into the shop's checkout page; the shop asks us to authorize an amount; we ask the card network and the shopper's bank (the issuer) to approve it, and answer within a second or two. Later the shop captures the money, sometimes refunds it, and every night we settle with the networks and pay the shops out, minus our fee.

We serve 2 million merchants and 100 million payments a day, with holiday peaks of 10,000 authorizations a second. The hard parts are not the request rate. A payment must never be charged twice and never lost, even when the bank times out and the shop retries. Every cent must be accounted for in a ledger that balances, card numbers must never leak, and a slow bank or a broken network link must not take the rest of the system down.

Good questions to ask first

Decide what you would assume for each before you look at ours.

  1. 1Which payment flows?
  2. 2Do we talk to card networks directly?
  3. 3How fast must an authorization be?
  4. 4Do merchants send card numbers to us?
  5. 5What if the bank does not answer?
  6. 6How do merchants learn about changes?
  7. 7Which currencies?
  8. 8How much fraud checking?

How to spend the 45 minutes

  1. 5minPart 1: Requirements: flows, what exactly-once means
  2. 5minPart 2: Estimates, including money and in-flight auths
  3. 5minPart 3: API with idempotency keys
  4. 15minPart 4: Architecture, stage by stage
  5. 15minPart 5: Timeouts and reversals, ledger, PCI, settlement
Sketch your own design: boxes, arrows and the numbers that matter. Then compare it with ours.Break it in the labVisual walkthrough