Skip to content
Tutorials Center
My learning

Topics

Lesson 28 of 40 ยท Trust, Security and Compliance

Fraud and Risk Management

Understand card testing, stolen cards, account takeover and friendly fraud, then build risk signals, velocity limits, manual review and a rule-based scorer that balances losses and lost sales.

Every shop that takes cards attracts fraud. Criminals buy goods with stolen cards, test lists of card numbers on small purchases, take over customer accounts, and sometimes honest customers dispute a purchase they actually made. The cost is more than the lost goods: you also pay the dispute fee, you lose the shipping cost, and a high dispute rate can get your payment account restricted or closed.

Fraud prevention is a balancing act. If you decline too little, you lose money. If you decline too much, you turn away good customers, which is called a false positive, and these are often more expensive than the fraud itself. This lesson explains the common attacks, the signals that reveal them, and how to turn signals into a decision with a small scoring engine you can run below. Your payment provider and any fraud service add their own models; the ideas here are what you need to configure and question them.

The main kinds of fraud

Type What happens Who loses
Card testing Bots try many stolen card numbers on small orders or a donation form to find the working ones You: fees per attempt, a damaged reputation with the card networks
Stolen card use A criminal buys goods with a real card they stole, often for resale items You: the goods plus a chargeback
Account takeover (ATO) Reused passwords from other breaches unlock a customer's account, which holds saved addresses and payment methods The customer, then you
Refund and return abuse Returning a different item, claiming non-delivery, or "wardrobing" You
Promotion abuse Creating many accounts to reuse a first-order coupon You
Friendly fraud The real cardholder disputes a legitimate purchase ("I didn't order this", or they forgot, or a family member did) You

Card testing has a distinct pattern: many tiny orders, many different cards, a high decline rate, often through the same IP range or user agent. It matters even though the amounts are small, because each attempt costs you a processing fee and a spike of declines can lead the card networks to penalize your account.

Signals

A single fact rarely proves fraud, but a combination is strong. Signals come from several places:

  • Payment: the AVS (address verification) and CVV check results, whether 3-D Secure authentication passed (PCI DSS Scope and 3-D Secure), the card country versus the billing country, a prepaid or virtual card.
  • Customer: new account versus a long history, a past chargeback, a disposable email domain, many orders in a short time.
  • Order: a large amount, high-resale items such as gift cards and electronics, a rush shipping choice, an unusual quantity.
  • Address: billing and shipping differ, the shipping address is a known freight forwarder, or the same address is linked to several accounts.
  • Device and network: a proxy or VPN, an IP country far from the shipping country, one device used with many accounts or many cards.
  • Behavior: a very fast checkout with pasted data, repeated failed attempts, or logins from new devices just before an order.

Remember two cautions. Some signals hurt honest people: a customer buying a gift for someone in another country will have different billing and shipping addresses. And some signals relate to protected characteristics or unfair proxies; avoid rules that discriminate. Use signals about behavior and payment facts, not about who a person seems to be.

From signals to a decision

Most systems work in three tiers:

flowchart TD
    O["Order submitted"] --> S["Compute risk score<br/>from rules and signals"]
    S -->|"low"| A["Approve and capture"]
    S -->|"medium"| R["Hold for manual review<br/>(authorize only)"]
    S -->|"high"| D["Decline or cancel"]
    R -->|"reviewer approves"| A
    R -->|"reviewer rejects"| D

A middle tier keeps the people in the loop where the model is unsure.

Holding an order uses the authorize-then-capture split from Authorization, Capture, Refunds and Chargebacks: you authorize the card, do not ship, and capture or void after the review. Authorization holds expire, so review needs a deadline.

A rule-based score is easy to explain, which matters when support must tell a customer why an order was held. Each rule adds points and records a reason. Thresholds decide the outcome. This is also how many fraud tools are configured, and a record of the reasons helps you tune them later.

Python A rule-based risk scorer

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Change the thresholds and watch which orders move between tiers. Scores like these are starting points: you tune them with real outcomes (confirmed fraud, false declines) rather than guessing.

Velocity limits

A velocity limit caps how often something can happen in a time window: attempts per IP per hour, cards per device per day, accounts per address, orders per customer per hour. Velocity rules are the best defense against card testing because they cost little and do not need to understand the content of an order. Typical responses escalate from a CAPTCHA or a short delay to a temporary block. Count failed payments separately from successful ones, and put the limits at the point where the card is attempted, not only on the final order page. See Securing an Online Shop for rate limiting in practice.

Python A sliding-window velocity limiter

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The first five attempts pass, the rest are blocked, and normal shoppers are not affected. Because blocked attempts are not recorded, the window slides forward as time passes.

Other defenses for card testing: require 3-D Secure on suspicious traffic, never allow unlimited retries on one cart, avoid public endpoints that confirm a card without an order, and hide the specific decline reason from the client ("could not process the payment" rather than "incorrect CVV").

Account takeover

Because many people reuse passwords, attackers try leaked credentials on your login form (credential stuffing). Defenses: rate limits and lockouts per account and per IP, breached-password checks, notifications for new-device logins, and a re-authentication step before changing the email address, password or saved payment details. Do not display full saved addresses or card details even to a logged-in session; show only the last four digits. Offering two-factor authentication and passkeys reduces the problem.

Chargebacks and the ratios

A chargeback happens when the cardholder asks their bank to reverse a payment. You lose the amount, pay a fee, and have a chance to submit evidence (order details, delivery proof, the customer's IP and device, communication). Card networks watch your chargeback ratio: disputes divided by transactions. Many networks start warning programs around one percent, and a higher ratio can lead to fines or loss of the ability to process cards, though the exact thresholds and counting rules vary by network and change over time, so read your provider's current terms.

Keep your ratio low by recognizing your name on statements (a clear statement descriptor), responding quickly to customers, making refunds easy, and keeping delivery proof for expensive items. A fast, painless refund is cheaper than a dispute.

Friendly fraud is hard to prevent by blocking, because the buyer is real. Good evidence, clear descriptors, delivery confirmation and a visible support route reduce it. Some shops also track repeat disputers.

Measuring your system

Track at least: approval rate, fraud rate by value, chargeback ratio, manual review volume and review accuracy, and the false-positive rate, estimated by sampling declined orders. If you only watch fraud losses, you will keep tightening rules until you strangle sales. Treat every rule like code: version it, log which rule fired, and review it regularly. Keep customers' data protected too; fraud data is personal data (GDPR, Consumer Law and Accessibility).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which pattern most strongly suggests card testing?

    Card testers try lists of stolen numbers cheaply and quickly, which produces many small attempts, many different cards and many declines.
  2. 2. Why is a middle tier of manual review useful?

    Uncertain orders are held by authorizing without capturing, and a person decides before the hold expires. This avoids declining good customers or shipping risky orders blindly.
  3. 3. What is a false positive in fraud screening?

    False positives are legitimate customers wrongly blocked. They cost sales and trust, so they must be measured, not just fraud losses.
  4. 4. Why show the customer a generic message like "could not process the payment" instead of the exact decline reason?

    Specific errors confirm to an attacker which field to adjust. Log the detail on your side and keep the public message general.

Summary

  • Common attacks are card testing, stolen cards, account takeover, abuse of refunds and promotions, and friendly fraud.
  • Combine many signals from payment, customer, order, address, device and behavior; no single signal proves fraud.
  • Use three outcomes: approve, hold for review (authorize only), decline. Record the reasons for each score.
  • Velocity limits are cheap and effective, especially against card testing and credential stuffing.
  • Keep the chargeback ratio low with clear descriptors, fast support and good evidence.
  • Measure false positives and approval rate as well as fraud losses.

Next, the technical side of protecting the shop itself: Securing an Online Shop.