1. Enable users to pay merchants safely, reliably, and idempotently — handling multiple payment methods (credit card, wallet, bank transfer).
  2. Credit card payment will be processed by Payment Service Providers (PSP) → Stripe, Braintree, Square
  3. Credit card information will not be saved in the system. → The system will not save the credit card information info, if it does, it needs to deal with regulations such as Payment Card Industry Data Security Standard (PCI DSS) in the US.
  4. The system will handle 1 million transactions per day

High Level Design

Source: https://blog.bytebytego.com/p/payment-system

Source: https://blog.bytebytego.com/p/payment-system

Pay-in Flow

Payment system receives money from customers on behalf of receivers, the payment will be transfered to system’s bank account, instead of receivers. The payment will be saved in the system, allowing receivers to withdraw (Pay-out Flow) in certain condition. If the payment system is Amazon’s, a seller can withdraw the payment when buyer has received the merchandise.

Payment Service

It accepts payment events from users and coordinates payment process. It will also proceed risk-check, assessing if user comply regulations such as AML/CFT.

Payment Executor

It executes a single payment order. A payment event may contain several payment orders.

Payment Service Provider (PSP)

The PSP moves the money out of the buyer’s credit card account. The payment will be transfered to system’s bank account, instead of sellers.

Ledger

When a user pays the seller $1, it records debit $1 from a user and credit $1 to the seller. It keeps a financial record.

Wallet

It keeps the account balance of the seller, allowing receivers to withdraw (Pay-out Flow) in certain condition.

Pay-out Flow (Withdraw)

The flow is similar to Pay-in Flow, but instead of using PSP to handle credit card payment, it uses other 3rd pay-out provider (e.g., Tipalti) to move the money from company’s bank account to seller’s.