Design a USD donation service for US users with tokenized card collection, server-side validation, idempotent payments, reconciliation, and layered anti-abuse.
Design a donation service where users choose a charity and make a payment. Only US users are eligible, only USD is accepted, and sensitive card details must not be exposed to the application backend. Explain the payment flow, duplicate-payment prevention, and controls against spam or bots.
Evaluate whether frontend-only currency validation and an allowlist of device-type identifiers are sufficient controls.
### Clarifying Questions to Ask
- What evidence establishes US eligibility, and which cases require further verification?
- Does the payment provider offer hosted card collection/tokenization and idempotent payment creation?
- What should the user see when payment confirmation is delayed?
```hint Separate user experience from enforcement
A browser can help users enter valid data, but a caller can bypass its validation entirely.
```
### What a Strong Answer Covers
- Provider-hosted card collection and opaque payment references.
- Server-side eligibility, currency, charity, and amount validation.
- Idempotency, asynchronous confirmation, and auditable donation state.
- Layered anti-abuse controls without treating device identity as proof.
### Follow-up Questions
- How would you reconcile a payment succeeded at the provider when the client saw a timeout?
- What risks arise if a payment webhook is replayed?
Overview: Design a USD donation service for US users with tokenized card collection, server-side validation, idempotent payments, reconciliation, and layered anti-abuse.
Design a donation service where users choose a charity and make a payment. Only US users are eligible, only USD is accepted, and sensitive card details must not be exposed to the application backend. Explain the payment flow, duplicate-payment prevention, and controls against spam or bots.
Evaluate whether frontend-only currency validation and an allowlist of device-type identifiers are sufficient controls.
Clarifying Questions to Ask Guidance
What evidence establishes US eligibility, and which cases require further verification?
Does the payment provider offer hosted card collection/tokenization and idempotent payment creation?
What should the user see when payment confirmation is delayed?
What a Strong Answer Covers Guidance
Provider-hosted card collection and opaque payment references.
Server-side eligibility, currency, charity, and amount validation.
Idempotency, asynchronous confirmation, and auditable donation state.
Layered anti-abuse controls without treating device identity as proof.
Follow-up Questions Guidance
How would you reconcile a payment succeeded at the provider when the client saw a timeout?
What risks arise if a payment webhook is replayed?