KatInterview

Fundraising Payments Backend: No Lost or Double Gifts

System DesignModel answer
HardModel answerSystem Designsystem-designpaymentsidempotency

Last updated

Design a charity fundraising service that takes one-time and recurring gifts through a third-party payment processor, with exact amounts, no duplicate charges, and survival of traffic surges.

Problem

Design the backend for a fundraising site where people find charity campaigns and give money to them. Card processing is done by a third-party payment provider (you never touch the card network), but your platform must still make sure that no gift is lost, charged twice, or recorded with the wrong amount.

Assume:

  • Millions of registered users.
  • Traffic can jump by one to two orders of magnitude during disasters or high-profile fundraising events.
  • Money movement and the ledger must be correct and auditable. Notifications and analytics may lag.

What to cover

  1. Functional and non-functional requirements (correctness, durability, availability, auditability, burst handling), with rough capacity numbers.
  2. The main APIs for donors, nonprofits and internal admins.
  3. A data model for campaigns, donations, ledger, recurring gifts and payouts, with money stored as integer minor units (cents).
  4. A high-level architecture and its components.
  5. The end-to-end payment flow, including how the provider is called.
  6. How you guarantee idempotency: double clicks, client and server retries, and a crash that happens after the provider charged the card but before your database was updated.
  7. Failure handling: provider timeouts, duplicate or out-of-order webhooks, queue or notification outages, and reconciliation.
  8. One-time and recurring gifts, receipts, donor history, nonprofit payouts and reporting.
  9. Admin workflows to create, approve, pause and audit campaigns.
  10. Which data needs strong consistency and which can be eventually consistent.
  11. Scaling for read-heavy campaign browsing and write-heavy donation surges.
  12. Security and compliance: no raw card data, tokenization, webhook authentication, RBAC, audit logs, fraud controls.
  13. Observability and the main trade-offs you made.

Hints

Hint 1

Write the gift record to your own database before you call the provider, and pass a stable idempotency key to the provider. Then a charge can never exist without a local record.

Hint 2

Treat the provider as the source of truth for whether money moved. Model the gift as a forward-only state machine and heal stuck rows with both webhooks and a periodic sweeper that polls the provider.

Hint 3

Separate the money path (strongly consistent, append-only double-entry ledger, transactional outbox) from the display path (cached totals, search, notifications, analytics), which can be eventually consistent.