7
Back to Problem Dungeon

Payment System

hard

Step 1: Requirements

Requirements

Questions to Ask the Interviewer

  1. Which payment gateways do we support? (Start with Stripe, Razorpay, PayPal — must be extensible)
  2. Do we need to support refunds? (Yes — full and partial)
  3. What payment methods? (Credit card, debit card, UPI, net banking, wallets)
  4. Do we handle webhooks from gateways? (Yes — async payment confirmations)
  5. Currency support? (Single currency for now, multi-currency later)
  6. Retry policy on failures? (Yes — with idempotency keys)
  7. Do we store card details? (No — tokenized via gateway, PCI compliance out of scope)

Functional Requirements

  • Process payments through multiple gateways
  • Support payment lifecycle: created → processing → completed / failed
  • Handle refunds (full and partial)
  • Receive and process webhook notifications from gateways
  • Generate payment receipts
  • Idempotent payment processing (retry-safe)

Non-Functional Requirements

  • Idempotency on all payment operations
  • Audit trail for every state transition
  • Gateway timeout handling (30s max)
  • Eventual consistency for webhook-driven updates

Constraints

  • No direct card storage (PCI)
  • Gateway APIs are external and unreliable
  • Webhooks may arrive before or after the synchronous response
  • Refund can only happen on completed payments

1 / 7 — Requirements