Who this lesson is for: the people who decide which orders to trust
If you work in e-commerce operations, payments, risk, customer service or finance at an online shop, you have probably seen it happen: a large order goes out, the money comes in, and weeks later a chargeback arrives because the card was stolen. The goods are gone, the payment is reversed and a fee is added on top. The fraud team's job is to catch those orders before they ship, without blocking the honest customers who make up the vast majority of checkouts.
Large payment platforms use machine learning for this, but almost every fraud program, from a small shop to a big retailer, still relies on rules: clear, explainable conditions such as "decline if the amount is more than five times the card's usual basket and the device is new". Rules are easy to explain to colleagues, easy to change on a sale day and easy to test in a spreadsheet. And every rule is built from features, the numbers and flags that describe one checkout.
This free first lesson follows the lab above. You are on the fraud team of Brightwater Gear, a fictional online outdoor store, looking at 14 card-not-present checkout attempts from one morning. All data are synthetic. You build the three classic features, amount relative to the card's history, a new-device flag and a country mismatch, and then count the attempts where all three red flags appear together. The course is defensive training for people who protect a business, not legal or compliance advice.
The core idea: compare each checkout with its own history
In a card-not-present (CNP) payment there is no chip and no PIN. The shop only sees data: the card number, the amount, the device and browser, the IP address and the billing and shipping details. A fraud feature turns that raw data into a number that means something. The single most important trick is to compare a value with the card's own normal behaviour instead of with a fixed limit.
Take amount. $699 is an ordinary basket for a customer who buys tents and jackets every few months, and a wild outlier for someone who usually buys socks and energy bars. A fixed rule such as "review every order over $500" would flag the first customer for nothing and miss a $450 fraud on the second. Dividing the amount by the card's 90-day average fixes that: amount ÷ average says how many times the usual basket this checkout is. T-1007, $699 on a card that averages $88.60, scores 7.89, almost eight times the usual.
The second feature is the device. Most customers shop from a small number of phones and computers, so a device the card has never been used with is a meaningful signal. The key detail is that only the pair of card and device counts. In the lab, device D-C33 is a regular for card C-203, but card C-206 has never been seen on it. Looking up the device alone would say "known", looking up card and device together correctly says "new for this card". That is why the lab uses COUNTIFS with two conditions.
The third feature is the country mismatch: the billing country of the card differs from the country of the IP address. On its own this is a weak signal. Travellers, people on VPNs or corporate networks and shoppers near a border trigger it every day. But weak signals become strong in combination. A large basket, a new device and a foreign IP address on the same checkout is a very different picture from any one of them alone.
| Feature | Why it can signal fraud | Innocent explanations |
|---|---|---|
| Amount ÷ card average | A stolen card is often used for a large basket before the owner notices. | Gifts, holidays, a planned big purchase, a new tent before a trip. |
| New device for this card | The fraudster rarely has the cardholder's phone or laptop. | A new phone, a work computer, a browser that cleared its cookies. |
| Billing ≠ IP country | Card data bought online is often used from another country. | Travel, VPNs, corporate networks, cross-border shoppers, border regions. |
Worked example: 14 checkout attempts at Brightwater Gear
Here is the lab sheet after the four tasks. The limit for the ratio is 3 (cell B30): an attempt counts as a large-amount flag when it is at least three times the card's usual basket. Rows with all three flags are shown in bold.
| Txn | Card | Amount ($) | Card avg 90d ($) | Amount ÷ avg (E)=C2/D2 | Device | New device (G)=IF(COUNTIFS($A$18:$A$28,B2,$B$18:$B$28,F2)=0,1,0) | Billing / IP | Mismatch (J)=IF(H2<>I2,1,0) |
|---|---|---|---|---|---|---|---|---|
| T-1001 | C-201 | 64.90 | 58.20 | 1.12 | D-A11 | 0 | US / US | 0 |
| T-1002 | C-202 | 312.00 | 74.50 | 4.19 | D-B07 | 1 | US / CA | 1 |
| T-1003 | C-203 | 89.50 | 95.10 | 0.94 | D-C33 | 0 | GB / GB | 0 |
| T-1004 | C-204 | 1,249.00 | 110.40 | 11.31 | D-X91 | 1 | DE / NL | 1 |
| T-1005 | C-201 | 47.20 | 58.20 | 0.81 | D-A12 | 0 | US / US | 0 |
| T-1006 | C-205 | 158.00 | 142.30 | 1.11 | D-E52 | 0 | CA / CA | 0 |
| T-1007 | C-206 | 699.00 | 88.60 | 7.89 | D-C33 | 1 | US / BR | 1 |
| T-1008 | C-207 | 35.90 | 41.00 | 0.88 | D-G18 | 0 | FR / FR | 0 |
| T-1009 | C-202 | 289.00 | 74.50 | 3.88 | D-B07 | 1 | US / US | 0 |
| T-1010 | C-208 | 420.00 | 395.00 | 1.06 | D-H64 | 0 | GB / ES | 1 |
| T-1011 | C-209 | 290.00 | 120.00 | 2.42 | D-K02 | 1 | US / US | 0 |
| T-1012 | C-204 | 1,190.00 | 110.40 | 10.78 | D-X91 | 1 | DE / NL | 1 |
| T-1013 | C-210 | 72.40 | 66.80 | 1.08 | D-M21 | 0 | NL / NL | 0 |
| T-1014 | C-205 | 610.00 | 142.30 | 4.29 | D-E52 | 0 | CA / US | 1 |
Six attempts reach the ratio limit, 6 come from a device that is new for the card and 6 have a country mismatch. Only four attempts carry all three flags: T-1002, T-1004, T-1007 and T-1012. That is the number the Coach checks in B31, calculated with =COUNTIFS(E2:E15,">="&B30,G2:G15,1,J2:J15,1).
The first chart shows the ratio feature. Most attempts sit close to 1, which is what normal shopping looks like: people tend to buy similar amounts each time. The peach bars stand out. Card C-204 appears twice, at 11.31 and 10.78 times its usual basket, with the same new device and the same DE/NL country pair. Two near-identical large attempts on one card within a morning is exactly the pattern the velocity checks of lesson 2 are built to catch.
The second chart puts all three features side by side. Each row is an attempt, each coloured square is a red flag. It shows why combinations matter. T-1009 has a large amount and a new device, but the IP country matches the billing country. T-1014 has a large amount and a mismatch, but the device is the one card C-205 always uses. T-1010 is a mismatch only, a British card used from Spain on a known device, which looks like a customer on holiday. Only the yellow rows stack all three.
What would the team do with these four? Not necessarily decline them. A typical next step is a manual review or a step-up check, such as 3-D Secure authentication, which asks the cardholder's bank to confirm the payment. Lesson 3 turns flags like these into a weighted score with three outcomes, approve, review or decline, and lessons 4 to 6 show how to choose the cut-off using labelled fraud, analyst capacity and costs.
How to build the features in Excel, step by step
- Lay out one checkout attempt per row: transaction ID, card, amount, the card's 90-day average, device, billing country and IP country. Keep the list of known card-device pairs in a separate block (A18:B28 in the lab) or on its own sheet.
- Put the ratio limit in its own labelled cell: B30 = 3. Every rule threshold you might tune later belongs in a cell, not inside a formula.
- In E2, enter
=C2/D2and format it with two decimals (Home > Number > Increase Decimal). Double-click the fill handle to copy it down to E15. Check E8 by hand: 699 ÷ 88.6 = 7.89. - In G2, enter
=IF(COUNTIFS($A$18:$A$28,B2,$B$18:$B$28,F2)=0,1,0). Select each of the two list ranges inside the formula and press F4 to lock them, so they stay in place when you copy down. - Check G8: card C-206 with device D-C33 should give 1 (new for this card), while G4, card C-203 with the same device, should give 0.
- In J2, enter
=IF(H2<>I2,1,0)and copy it down. The <> operator means "not equal". - In B31, count the attempts with all three flags:
=COUNTIFS(E2:E15,">="&B30,G2:G15,1,J2:J15,1). The criterion">="&B30builds the text ">=3" from the limit cell, so changing B30 updates the count. - Optional: in K2, count the flags per attempt with
=(E2>=$B$30)+G2+J2. Comparisons return TRUE or FALSE, and inside a sum TRUE counts as 1. - Optional: highlight the risky rows. Select A2:J15, choose Home > Conditional Formatting > New Rule > Use a formula, enter
=($E2>=$B$30)+$G2+$J2=3and pick a fill colour. The $ before the column letters keeps every cell of the row looking at the same columns. - Optional: press Ctrl+Shift+L to turn on filters and show only the rows with three flags for the review queue.
Beyond the three features
The three features in this lab are the foundation, and real fraud programs add many more built the same way. A few examples: the number of different cards seen on one device in a day (a device that suddenly serves several cards is a well-known sign of someone testing stolen card numbers); the distance between billing and shipping address; whether the email address is new; the time since the account was created; and the number of failed payment attempts before a success.
The lab data already contain a hint of the first one. D-C33 is a known device for C-203 and appears again with C-206. A formula such as =COUNTIFS($A$18:$A$28,"<>"&B8,$B$18:$B$28,F8) counts how many other cards are known on the same device, and returns 1 for T-1007. On its own that could be a household sharing a laptop. Combined with a basket almost eight times the usual and a foreign IP, it is worth a closer look.
Whatever features you add, the same two rules apply. First, compare with the right baseline: the card, the customer or the device, not the shop as a whole. Second, keep each feature as a separate, explainable column. When a customer complains that an order was blocked, the team must be able to say which conditions were met, and a column of 0/1 flags makes that easy.

Common mistakes and how to spot them
- Looking up the device alone.
COUNTIF($B$18:$B$28,F2)asks whether anyone has used the device, not this card. It marks T-1007 as known because C-203 uses D-C33. Spot it when a device shared between cards never shows as new. - Forgetting the $ on the lookup ranges. Copied down, A18:A28 slides to A19:A29, A20:A30 and so on, and known pairs drop out of the list one by one. Rows further down then show false "new device" flags.
- Typing the limit into the formula.
">=3"works until someone tunes the rule and forgets one of five formulas. Reference the cell with">="&B30. - Writing the criterion as ">=B30". Inside quotes, B30 is just text. COUNTIFS then compares with the letters "B30" and returns 0. The operator must be joined to the cell with &.
- Using a fixed amount instead of a ratio. A rule like "amount > $500" flags loyal big spenders and misses fraud on small-basket cards. Check the ratio column next to the amount column and you see the difference immediately.
- A missing or zero average. A brand-new card has no 90-day history, so the ratio returns #DIV/0!. Decide what happens in that case, for example
=IF(D2=0,"no history",C2/D2), and treat "no history" as a separate signal. - Treating one flag as proof. A country mismatch alone is common for honest customers. Judge rules by how often they are right, which is exactly what lessons 4 and 7 measure.
Quick reference: functions and shortcuts used
| Function, operator or shortcut | What it does in this lesson |
|---|---|
=C2/D2 | Amount relative to the card's own 90-day average. |
COUNTIFS(r1,c1,r2,c2) | Counts rows where card and device match: 0 means the pair is new. |
IF(test,1,0) | Turns a test into a 0/1 flag that can be added and counted. |
<> | The "not equal" operator, used for billing country vs IP country. |
COUNTIFS(E2:E15,">="&B30,…) | Counts attempts that meet several conditions. The & joins the operator text to the limit cell. |
=(E2>=$B$30)+G2+J2 | Number of red flags per attempt. TRUE counts as 1 inside a calculation. |
SUMPRODUCT | Counts combinations directly from raw columns, without helper columns. |
| F4 | Locks references such as $A$18:$A$28 before you copy down. |
| Ctrl+Shift+L | Turns on AutoFilter, e.g. to filter all rows with three flags. |
| Home > Conditional Formatting > New Rule | Highlights the whole row when a formula such as =$E2>=$B$30 is true. |
Real-world uses
- Building a manual review queue. A small shop without a fraud platform exports yesterday's orders, adds the three features and reviews the orders with two or three flags before shipping.
- Writing rules for a payment provider's rule engine. Many payment and fraud tools let merchants write their own rules. Prototyping the features in Excel shows how many orders a rule would have caught on last month's data.
- Investigating a chargeback wave. When chargebacks rise, the features of the disputed orders often share a pattern, such as the same device or the same country pair.
- Explaining a declined order. Customer service can see which flags fired and decide whether to approve the customer manually.
- Preparing for a sale day. Testing the flag counts on last year's sale data shows how many reviews the team should expect and whether a threshold needs to move.
What you will build in the rest of this course
Lesson 1 is free. The next 19 lessons are part of the full course, a one-time purchase of $9.90. Each one is a hands-on lab with Brightwater Gear's synthetic data, checked by the Coach, and together they take you from single features to a tested, tuned rule set.
Velocity Checks: Attempts and Amounts per Card in Rolling 24-Hour and 1-Hour Windows. You build rolling time windows with COUNTIFS and SUMIFS, count attempts and dollars per card in the last 24 hours and the last hour, and flag cards that break a velocity limit, the check that would catch C-204's repeated attempts.
Rule Hits & a Weighted Risk Score: Approve, Review or Decline. You turn five fraud rules into a 0/1 hit matrix, weight the hits into one risk score with SUMPRODUCT and route each attempt to Approve, Review or Decline.
Choosing the Alert Threshold: Precision, Recall and Dollar Recall against Labelled Fraud. You back-test the risk score against chargeback labels: alerts, true positives, precision and recall per threshold, then dollar recall and the highest threshold that still catches 90% of the fraud dollars.
Alert Volume vs Analyst Capacity: Staffing, the Lowest Workable Threshold and a Sale-Day Backlog. You convert analyst hours into a daily review capacity, turn alert rates into alerts and head-count, pick the lowest threshold the team can handle and watch a sale day build a backlog.
False-Positive Cost vs Fraud Loss Prevented: the Net-Benefit Threshold (with a Chart). You price every threshold, fraud dollars and chargeback fees saved against review costs and the friction false alarms cause, find the threshold with the highest net benefit and chart the curve.
Rule Performance Table: Hit Rate, Precision and Fraud Share per Rule (with a Chart). You read an alert log where each attempt lists the rules it fired, count hits and fraud hits per rule with wildcard COUNTIFS, compare precision and coverage, and chart which rules earn their place.
Champion vs Challenger: Shadow-Testing a New Rule Set Before It Goes Live. You compare the live rule set with a challenger that ran in shadow mode on the same four weeks: precision, net benefit, a two-proportion z-test and a clear promote-or-keep decision.
Summary
Good fraud rules are built from good features. Compare the amount with the card's own average (amount ÷ average), check whether the card and device pair is known with a two-condition COUNTIFS, and flag a billing-vs-IP country mismatch with <>. Each feature on its own catches honest customers too, but together they narrow the field: at Brightwater Gear, 14 attempts become 4 with all three flags. Keep every threshold in a cell, lock the lookup ranges and keep each flag in its own column so every decision can be explained.
Now scroll up and build it yourself in the free lab: the ratio, the new-device flag, the country mismatch and the COUNTIFS that finds the four high-risk attempts. The Coach checks each step and points out the typical mistakes as you go.
Frequently asked questions
What are the most common fraud detection features for online payments?
Typical features compare a checkout with normal behaviour: amount relative to the card's average, new device for the card, billing country versus IP country, the number of attempts in a short time and new email or shipping addresses.
How do I check in Excel whether a card and device pair is new?
Use COUNTIFS with both columns of a known-pairs list: =IF(COUNTIFS($A$18:$A$28,B2,$B$18:$B$28,F2)=0,1,0). A result of 1 means this card has never been seen on this device.
Why compare the amount with the card average instead of a fixed limit?
A fixed limit treats all customers the same. The ratio amount ÷ average shows how unusual a purchase is for that particular card, so big regular spenders are not flagged and small-basket cards are not ignored.
Is a billing and IP country mismatch a sign of fraud?
On its own it is a weak signal, because travellers, VPN users and cross-border shoppers trigger it often. It becomes useful when combined with other flags such as a new device and an unusual amount.
How do I count rows that meet several fraud conditions in Excel?
Use COUNTIFS with one range and criterion per condition, for example =COUNTIFS(E2:E15,">="&B30,G2:G15,1,J2:J15,1). Join operators to cell references with & so the threshold stays in one cell.
What is card-not-present fraud?
Card-not-present (CNP) fraud is the use of stolen card details for payments where the card is not physically shown, such as online or phone orders. Merchants often bear the loss through chargebacks.
Keep going: Fraud Detection Rules: Velocity Checks, Rule Scoring & Alert Tuning
This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time €9.90.
- Velocity Checks: Attempts and Amounts per Card in Rolling 24-Hour and 1-Hour Windows
- Rule Hits & a Weighted Risk Score: Approve, Review or Decline
- Choosing the Alert Threshold: Precision, Recall and Dollar Recall against Labelled Fraud
- Alert Volume vs Analyst Capacity: Staffing, the Lowest Workable Threshold and a Sale-Day Backlog
- False-Positive Cost vs Fraud Loss Prevented: the Net-Benefit Threshold (with a Chart)
- Rule Performance Table: Hit Rate, Precision and Fraud Share per Rule (with a Chart)
- Champion vs Challenger: Shadow-Testing a New Rule Set Before It Goes Live
- Rule Overlap: Which Rule Catches Fraud That No Other Rule Catches?
- Chargeback Lag: Label Maturity and the Fraud That Has Not Been Reported Yet
- Fraud Rate in Basis Points and a Dispute-Ratio Early Warning (with a Chart)
- Card-Testing Bursts: Volume Spikes, Tiny Amounts and Decline Rates per Card Range
- Trusted-Customer Allow-List: Suppressed Alerts, Saved Reviews and the Fraud That Slips Through
- Linked Entities: Distinct Cards per Device and per Shipping Address
- Reason Codes: Explaining Each Decline by Its Biggest Score Contributor (with a Chart)
- Step-Up Instead of Decline: Approve, Challenge or Decline per Score Band
- One Threshold or Two? Segment Thresholds for Gift Cards and Physical Goods (with a Chart)
- Prioritising the Review Queue: Expected Loss First, Not Highest Score First
- Rule Sensitivity Grid: Ratio Limit × Minimum Amount, Hits, Fraud Caught and Precision
- Final Project: Weekly Fraud Rules Dashboard for the Risk Meeting (Chart & Highlights)