Designing a Payment System
A full chapter from the newly released book System Design Interview: Volume 2.
My friend Alex Xu released Systems Design Interview: An Insider’s Guide: Volume 2 two days ago. As of writing, the book is the best-selling computer science book on Amazon in the US, and for good reason.
The book contains 13 original and in-depth systems design challenges not covered anywhere else. These include building a proximity service, a nearby friends feature, Google Maps, distributed messaging queue, metrics monitoring and alerting, a hotel reservation system, real-time gaming leaderboard, digital wallet, stock exchange and more.
I had the opportunity to read the book before it was released and I’m impressed by both the depth, and the attention to detail.
I connected with Alex after reading and reviewing the original Systems Design Interview book, and he had just started working on the second edition. Alex worked at Zynga, Apple and Twitter, before leaving his full-time job behind to go all-in writing the first edition of the book. For this second edition, he pulled in co-author Sahn Lam who previously worked at Discord, Zynga and NetApp. The two of them wrote the book for 1.5 years and got feedback and reviews from experienced engineers at Amazon, Google, eBay, Instacart, Tencent, Twitter, Microsoft, Airbnb, TikTok and others.
The book follows a four-step process for each chapter:
Understand the problem and establish the design scope.
Propose high-level design and get buy-in.
Design deep-dive.
Wrap-up.
Alex has kindly agreed to share a full chapter from the book with newsletter readers. I chose the Payments System chapter, as I worked on payments systems for years at Uber, and building payments systems requires understanding some terms like payment service, payment executor, PSP (Payment Service Provider), ledger or wallet.
I also reviewed the Payments chapter as Alex was writing it. The reality is that a book can’t cover all real-life scenarios when building a payments system. However, this summary does an excellent job, of balancing conciseness and going deep enough. I had to learn most of what Alex covers the hard way: through working on a payments system, asking around, and trial-and-error.
This issue covers the following topics - straight from the book:
Step 1: understand the problem
Functional requirements
Non-functional requirements
Back-of-the-envelope estimations
Step 2: high-level design
Payment service
Payment executor
Payment service provider
Card schemes
Ledger
Wallet
Double-entry ledger system
Step 3: design deep dive
PSP integration
Reconciliation
Handling processing delays
Handling failed payments
Exactly-once delivery
Consistency
Payment security
Step 4: wrap up
If you find this chapter useful, get System Design Interview: Volume 2.
As usual, I aim to stay independent with my recommendations: I have no financial association with this book, nor have I been paid to mention it, and there are no affiliate links in this email.