Loading video player...
Become a senior software engineer with a job guarantee: https://go.hayksimonyan.com/165-payment-system A complete system design blueprint for building a reliable payment backend that prioritizes correctness under failure and achieves 99.999% availability. ⏱️ Timestamps: 0:00 Introduction to payment systems 0:50 3 approaches to accepting payments 0:59 Approach 1: No-code checkout (Stripe Checkout links) 2:21 Approach 2: Build your own payment processor 3:26 Approach 3: Integrate a PSP (the right choice for most companies) 5:18 Functional requirements 6:41 Non-functional requirements and scale estimates 8:41 How money actually moves through the card network 9:29 Phase 1: Authorization 11:18 Phase 2: Capture (immediate vs. delayed) 12:25 Phase 3: Clearing and settlement 13:00 High-level architecture overview 13:43 Synchronous path: Payment API and Stripe Integration Layer 15:26 Async path: Webhook Receiver and Message Queue 18:22 Database schema design 18:56 Payments table and idempotency keys 21:40 Payment events (immutable audit log) and refunds 23:43 How idempotency works at all three layers 25:00 Recovery points and the atomic phases pattern 27:28 Exactly-once processing: optimistic locking and CAS 28:46 Payment state machine and valid transitions 29:40 Designing for high availability