KatInterview

Building a High-Throughput Payment Processing Platform

System DesignModel answer
HardModel answerSystem Designpaymentsdistributed-systemsconsistency

Last updated

Design a payment platform supporting wallet transfers, card transactions, refunds, and chargebacks with strong consistency, exactly-once semantics, and audit compliance.

You're tasked with designing a payment processing platform that handles multiple payment flows at scale. The platform must support:

  • Wallet-to-wallet transfers between users
  • Card and digital wallet payments (Apple Pay, Google Pay) for merchants
  • Full lifecycle management: authorization, capture, void, refund
  • Dispute and chargeback processing
  • Complete transaction audit trails for users and merchants
  • Integration with external payment processors, card networks, and banking systems

Your design should address:

  1. Product requirements and scale assumptions: Define the core capabilities, expected throughput (transactions per second), latency targets, and data volume projections.

  2. API contracts: Design the key endpoints for creating, authorizing, capturing, voiding, and refunding payments. Explain how you prevent duplicate charges and ensure exactly-once semantics.

  3. Ledger architecture: Describe how money moves through the system. How do you model accounts, balances, and transactions? How do authorization holds differ from captured funds?

  4. Payment flow and compliance boundaries: Walk through a card payment from end to end, including the roles of gateways, acquirers, card networks, and issuers. Where do you tokenize sensitive data, and how do you minimize your compliance scope?

  5. Fraud prevention: What controls do you implement for risk assessment, velocity checking, and regulatory compliance (KYC/AML)?

  6. Data model: Design schemas for transactions, ledger entries, settlements, and the structures needed for idempotency and auditing.

  7. Failure handling and consistency: How do you handle failures in multi-step workflows? What consistency guarantees do you provide for balances versus transaction history? How do you manage retries?

  8. Settlement and reconciliation: Explain how you match your internal records against external settlement reports, handle currency conversion, deduct fees, and schedule merchant payouts.

  9. Scale and reliability: Describe your approach to horizontal scaling, request queueing, multi-region deployment, and disaster recovery.

  10. Security and observability: Cover authentication, encryption, key management, privacy requirements, distributed tracing, and how you test integrations with external partners.

Present a high-level architecture and discuss the key trade-offs in your design.

Hints

Hint 1

Start with correctness: no money can be lost, created, or charged twice. Scale is secondary to getting the ledger right.

Hint 2

Use a double-entry accounting model where every transaction creates balanced debits and credits across accounts.

Hint 3

Idempotency keys and transactional outbox patterns are essential for exactly-once semantics in distributed payment flows.