Design a payment processing system
Company: OpenAI
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Onsite
## Scenario
Design a backend payment system for an online product that supports:
- One-time charges and refunds.
- Idempotent payment APIs (clients may retry).
- Asynchronous interaction with external payment processors (e.g., card networks via a payment gateway).
- Accurate accounting/ledger and reporting.
## What to cover
- Core APIs and data model.
- Handling retries, duplicates, and failures.
- Ensuring correctness (no double charge; consistent ledger).
- Observability and reconciliation.
You can make reasonable assumptions and state them explicitly.
Quick Answer: This question evaluates system-design competency in building reliable payment workflows, covering distributed transaction handling, idempotent APIs, asynchronous external integrations, and accounting/ledger correctness.