Design a scalable payment system
OpenAISoftware Engineer · Technical ScreenLast updated
Design a scalable payment system evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Question
Design a scalable payment system. The system must support both peer-to-peer money movement between users and merchant payments (accepting card and digital-wallet payments), with refunds, chargebacks, and full transaction history. Assume it may integrate with external payment rails/providers (card networks, bank transfers).
Cover the following:
- Core product requirements: user-to-user (wallet-to-wallet) transfers, merchant card/digital-wallet payments, refunds, chargebacks/disputes, payment status tracking, and per-user/merchant transaction history.
- API design: key endpoints (authorize, capture, refund, void, create-payment, get-payment), request/response fields, idempotency keys, and exactly-once charge semantics (no double-spend).
- Money-movement model: a double-entry ledger; authorization vs capture, holds/reservations, settlement, and reconciliation; how you represent accounts, balances, and transactions.
- End-to-end flow & PCI scope: the flow across gateway, acquirer, card networks, and issuers; tokenization and the PCI scope boundary; how digital wallets (Apple Pay / Google Pay) are handled.
- Risk & fraud controls: 3DS/SCA, risk scoring, velocity limits, sanctions/AML/KYC hooks, and optional ML integration.
- Data model & storage: transactions, ledger entries, settlements, chargebacks, idempotency keys, and immutable audit logs.
- Consistency & failure handling: consistency model, deduplication, retries, exactly-once vs at-least-once processing, and orchestration patterns (outbox / SAGA) for multi-step workflows.
- Settlement & reconciliation: matching the internal ledger against acquirer/provider settlement files, currency conversion, fees, and scheduled payouts.
- Scalability & resilience: throughput targets (e.g., thousands of TPS, p99 latency < 200 ms), backpressure/queueing, high availability, and disaster recovery (multi-region, RPO/RTO).
- Security, privacy & observability: authentication/authorization, encryption, key management, PII/GDPR handling, metrics/tracing/log correlation, and a testing strategy with simulators for external partners.
Explain the key trade-offs and provide a high-level architecture (in words).
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.