System Design Interview

Wrap Up

Wrap up 2 min readLesson 4 of 4

In this chapter, we investigated the pay-in flow and pay-out flow. We went into great depth about retry, idempotency, and consistency. Payment error handling and security are also covered at the end of the chapter.

A payment system is extremely complex. Even though we have covered many topics, there are still more worth mentioning. The following is a representative but not an exhaustive list of relevant topics.

  • Monitoring. Monitoring key metrics is a critical part of any modern application. With extensive monitoring, we can answer questions like “What is the average acceptance rate for a specific payment method?”, “What is the CPU usage of our servers?”, etc. We can create and display those metrics on a dashboard.

  • Alerting. When something abnormal occurs, it is important to alert on-call developers so they respond promptly.

  • Debugging tools. “Why does a payment fail?” is a common question. To make debugging easier for engineers and for customer support, it is important to develop tools that allow staff to review the transaction status, processing server history, PSP records, etc. of a payment transaction.

  • Currency exchange. Currency exchange is an important consideration when designing a payment system for an international user base.

  • Geography. Different regions might have completely different sets of payment methods.

  • Cash payment. Cash payment is very common in India, Brazil, and some other countries. Uber 28 and Airbnb 29 wrote detailed engineering blogs about how they handled cash-based payment.

  • Google/Apple pay integration. Please read 30 if interested.

Congratulations on getting this far! Now give yourself a pat on the back. Good job!

Chapter Summary

Figure — this diagram isn't included in the course export.

Reference Materials

  1. Payment system: https://en.wikipedia.org/wiki/Payment_system
  2. AML/CFT: https://en.wikipedia.org/wiki/Money_laundering
  3. Card scheme: https://en.wikipedia.org/wiki/Card_scheme
  4. ISO 4217: https://en.wikipedia.org/wiki/ISO_4217
  5. Stripe API Reference: https://stripe.com/docs/api
  6. Double-entry bookkeeping: https://en.wikipedia.org/wiki/Double-entry_bookkeeping
  7. Books, an immutable double-entry accounting database service: https://developer.squareup.com/blog/books-an-immutable-double-entry-accounting-database-service/
  8. Payment Card Industry Data Security Standard: https://en.wikipedia.org/wiki/Payment_Card_Industry_Data_Security_Standard
  9. Tipalti: https://tipalti.com/
  10. Nonce: https://en.wikipedia.org/wiki/Cryptographic_nonce
  11. Webhooks: https://stripe.com/docs/webhooks
  12. Customize your success page: https://stripe.com/docs/payments/checkout/custom-success-page
  13. 3D Secure: https://en.wikipedia.org/wiki/3-D_Secure
  14. Kafka Connect Deep Dive – Error Handling and Dead Letter Queues: https://www.confluent.io/blog/kafka-connect-deep-dive-error-handling-dead-letter-queues/
  15. Reliable Processing in a Streaming Payment System: https://www.youtube.com/watch?v=5TD8m7w1xE0&list=PLLEUtp5eGr7Dz3fWGUpiSiG3d_WgJe-KJ
  16. Chain Services with Exactly-Once Guarantees: https://www.confluent.io/blog/chain-services-exactly-guarantees/
  17. Exponential backoff: https://en.wikipedia.org/wiki/Exponential_backoff
  18. Idempotence: https://en.wikipedia.org/wiki/Idempotence
  19. Stripe idempotent requests: https://stripe.com/docs/api/idempotent_requests
  20. Idempotency: https://developer.paypal.com/docs/platforms/develop/idempotency/
  21. Paxos: https://en.wikipedia.org/wiki/Paxos_(computer_science)
  22. Raft: https://raft.github.io/
  23. YugabyteDB: https://www.yugabyte.com/
  24. Cockroachdb:https://www.cockroachlabs.com/
  25. What is DDoS attack: https://www.cloudflare.com/learning/ddos/what-is-a-ddos-attack/
  26. How Payment Gateways Can Detect and Prevent Online Fraud: https://www.chargebee.com/blog/optimize-online-billing-stop-online-fraud/
  27. Advanced Technologies for Detecting and Preventing Fraud at Uber: https://www.uber.com/en-PK/blog/project-radar-intelligent-early-fraud-detection/
  28. Re-Architecting Cash and Digital Wallet Payments for India with Uber Engineering: https://eng.uber.com/india-payments/
  29. Scaling Airbnb’s Payment Platform: https://medium.com/airbnb-engineering/scaling-airbnbs-payment-platform-43ebfc99b324
  30. Payments Integration at Uber: A Case Study: https://www.youtube.com/watch?v=yooCE5B0SRA

Finished reading?

Mark it complete to track your progress.