# How to design payment fraud detection

Source: https://systemdesignsim.com/system-design/payment-fraud-detection

System design · Risk scoring, delayed labels and payment review

Separate risk scoring from payment state transitions. Keep decision inputs and versions auditable, account for delayed labels, and make review capacity part of the design.

Updated October 28, 2026 · 4 min read

[Take the UPI payments challenge](https://systemdesignsim.com/challenges/upi-payments)

![Payment Fraud Detection System architecture diagram](https://systemdesignsim.com/diagrams/payment-fraud-detection-system-design-diagram.svg)

A payment API reads features, scores risk, applies policy and records a decision.

## The short version

* Fraud detection is a risk decision around a payment, not a classifier returning a score. The score is one policy input.
* Spend the latency budget deliberately: features, rules and model can use 80 ms of a 100 ms budget before network.
* Every decision is immutable and versioned, so you can explain it later. Retries return the original decision.
* Review capacity is finite: 20 cases a second at 30 seconds each needs 600 reviewers.
* Labels arrive days later. Train point-in-time correct, and never treat a missing label as legitimate.

## Clarifying questions to ask first

* Before authorisation, after, or both? (The payment state machine handles issuer outcomes either way.)
* What latency budget, and which dependencies share it? (Assume 100 ms as an example, not a payment standard.)
* What does a false decline cost against a missed fraud attempt? (It decides fail-open versus fail-closed.)
* Which features exist at decision time, how fresh, and how long can a human review wait?

## Numbers that shape the design

Assumptions. At a peak of 2,000 decisions/s with 40 ms feature lookups, Little's Law gives about 80 lookups in flight. API 10 ms, rules 5 ms, model 25 ms and features 40 ms use 80 ms before network and processing. Parallelise independent reads only if stores can take the fan-out, with per-dependency deadlines and measured p95/p99.

With an illustrative fraud rate of one in 1,000 and a policy flagging 1% of traffic, that's 20 reviews/s. If only 10% of flagged cases are fraud, 90% are false positives. Set thresholds from mature labels.

## API

```
POST /risk/decisions
{ paymentId, idempotencyKey, amount, currency, merchantId }
200 { decisionId, decision, policyVersion, reasonCodes, reviewCaseId? }

GET /risk/decisions/{decisionId}
```

A replay with the same key returns the earlier decision, so a retry can't create a second authorisation or review case. A changed request needs a new key. Review differs from decline: it may trigger a step-up check or human action.

## Data model

A risk decision is immutable: policy, model and feature versions, outcome, reason codes and timestamp. A review case holds queue status, assignment, reviewer action and timestamps. A dispute or confirmed label links to the original payment and decision instead of overwriting them. Correlate risk and issuer outcomes without logging card secrets.

Training data must be point-in-time correct. A feature that arrived after the decision leaks the future into evaluation, and a missing label is unresolved, not negative.

## High-level design

The payment API loads idempotent state and asks a feature service for bounded-latency signals such as recent velocity and account history. Rules enforce explicit policy, a model scores the features, and a policy combiner picks approve, review or decline. The decision is recorded with its versions. An event stream updates velocity aggregates, review queues, monitoring and offline training; enrichment that can wait stays off the synchronous path. Stripe's public Radar guide discusses real-time versus historical training features, without describing its full internal system.

## Online features and model lifecycle

A recent transaction count is updated from events and read from a low-latency store. Define its window: does a retry count again, does a declined payment stay in? Read the feature's timestamp so policy can tell zero from unavailable, and give missing or stale values an explicit fallback. Protect features from poisoned events and stop old consumers overwriting newer values.

Train on held-out time ranges with mature labels. Compare calibration, fraud loss, false declines and review volume, not one accuracy score; lower fraud loss isn't better if legitimate users get blocked. Roll out by shadow or canary with fast rollback, and watch drift and decision rates. Chargebacks arrive late, so track decision, settlement and label times separately.

## Human review

Review is a separate, capacity-limited service. At 20 cases/s with one reviewer closing a case every 30 seconds, matching arrivals needs 600 reviewers before breaks. So uncertain payments shouldn't automatically go to people. Watch queue age as well as depth. A payment held for review and a post-payment investigation have different targets and expiry rules. Record reviewer outcomes as labels without overwriting the decision.

## Common traps

* Treating a score as a calibrated fraud probability without measuring it.
* Training on post-decision data and leaking future information, or treating missing labels as legitimate.
* Retrying without idempotency and duplicating payment work.
* Sending every uncertain case to a human without capacity planning.
* Picking fail-open or fail-closed globally. Fail open permits fraud and fail closed rejects good customers; choose by context and keep a measured rules fallback.

## Follow-up questions interviewers ask

* "An attacker spreads attempts across accounts." Apply per-entity limits.
* "How do you measure harm from false declines?" Track legitimate conversion and friction outcomes.
* "Can operators explain and reverse a decision?" Preserve versions, reasons and recovery procedures. For payment correctness see [UPI payments](https://systemdesignsim.com/system-design/upi-payments); for monitoring, [metrics monitoring](https://systemdesignsim.com/system-design/metrics-monitoring).

## Frequently asked questions

### What happens if the model is unavailable?+

Use a documented fallback such as rules over available signals and measure its error trade-offs. Policy depends on payment context.

### Why not decline every high-risk score?+

Scores can be uncertain or miscalibrated. Review or step-up may reduce risk without rejecting a legitimate customer.

### How does delayed feedback affect training?+

Keep decision time separate from label time, use only features available then, and account for labels that have not matured.

### How do you prevent duplicate fraud decisions?+

Tie an idempotency key to the payment request and return the original decision when retried.

## More system design guides

[All 76 guides](https://systemdesignsim.com/system-design)

* [Design a UPI Payment App like PhonePe or Google PayIdempotency, pending payments, no double debits](https://systemdesignsim.com/system-design/upi-payments)
* [Design a Metrics and Monitoring System](https://systemdesignsim.com/system-design/metrics-monitoring)
* [CQRS and Event Sourcing explainedRead models, event logs, projections and replay](https://systemdesignsim.com/system-design/cqrs-event-sourcing)
* [Design a Collaborative Document Editor like Google Docs](https://systemdesignsim.com/system-design/google-docs)
* [Observability explainedMetrics, logs, traces and alerting](https://systemdesignsim.com/system-design/observability)
* [Design an IRCTC Tatkal Booking System10:00 rush, waiting room, no double booking](https://systemdesignsim.com/system-design/irctc-tatkal)

## Now fix it yourself.

Run the design under real traffic and see what breaks first. No signup.

[Take the UPI payments challenge](https://systemdesignsim.com/challenges/upi-payments)
