Card testing is fraudsters running stolen or generated card numbers through your checkout, usually by script, to learn which ones are live. They don't want what you sell. They want the approval, so they can use the good cards somewhere else or sell them on. Stripe lists the other names you'll see: carding, account testing, enumeration and card checking (Stripe).
A BIN attack is the generated variety. The tester takes a real issuer's bank identification number, the prefix at the start of every card, fills in the rest of the digits so the number passes the check-digit test, and fires guesses at your payment endpoint until some of them authorize. A list of stolen cards and a list of guessed ones look the same from your side: lots of attempts, mostly declines, and a few approvals you didn't earn.
It isn't free just because the charges fail. Stripe names the costs: successful test charges come back as early fraud warnings and disputes, a pile of declines tied to your business makes issuers trust your real customers less, even after the attack stops, custom pricing plans can carry authorization fees, and enough fraud can enroll you in card monitoring programs (Stripe). Each dispute that follows costs $15 on Stripe before you decide whether to fight (Stripe pricing).
What it looks like in your logs
| Signal | Where you see it |
|---|---|
| A spike in failed or blocked payments | Payments list, decline-rate graph |
A spike in 402 errors, often generic_decline | API request logs, webhook stream |
| Small amounts, nonsense names and throwaway emails | Successful payments that slipped through |
| Many cards from one IP, device, customer or session | Your own velocity counters |
| Traffic on save-card endpoints with no purchase behind it | Card setup calls, SetupIntents on Stripe |
| Lots of CVV failures in a short window | AVS and CVV results |
The save-card endpoint deserves extra paranoia. Stripe notes testers prefer card setup because a validation doesn't show on the cardholder's statement, so nobody reports it (Stripe).
The controls, in the order to add them
- Use your processor's hosted or recommended form. On Stripe, Checkout and the Payment Element come with rate limiting, models and CAPTCHA triggers that you'd otherwise build yourself.
- Put a CAPTCHA on every endpoint that charges or saves a card, and verify it on the server. A CAPTCHA the script never has to pass is decoration.
- Rate limit on more than IP. Cards per customer, customers created per IP per day, attempts per device and per card fingerprint. Testers rotate IPs; they rotate everything else less.
- Put a session in front of the form. Requiring login, or at least a CSRF-protected session, makes scripting your checkout harder than scripting the next one.
- Block failed CVV, and add velocity rules. On Stripe that's a built-in Radar rule plus custom rules if your plan has them.
- Guard your keys. A leaked secret key lets testers skip your frontend entirely.
- Don't retry the cards. After an attack, dunning the cards attached to fake customers repeats the attack under your own name.
None of these work alone. Stripe's advice is to combine them, for example letting the first attempt from an IP through and requiring a CAPTCHA for every attempt after it for the next few hours (Stripe).
When you're under attack right now
Confirm it's testing and not a real traffic spike. Refund any successful fraudulent charges before they turn into chargebacks. Switch on the controls above, starting with CAPTCHA and rate limits on the endpoint being hit. Then watch the decline rate until it's back to normal, because testers come back to check whether you meant it.
Card testing as a detection rule: a burst of small charges from one IP, next to the other payment-specific patterns a generic SIEM misses. From chapter 28.
Payment-Specific Detection Rules
Generic security monitoring misses payment-specific threats. You need rules that understand the business logic of payment systems:
class PaymentSecurityRules:
"""
Payment-specific SIEM detection rules.
These rules look for patterns that indicate payment fraud,
data theft, or system compromise - things a generic SIEM
ruleset would miss entirely.
"""
DETECTION_RULES = [
{
'name': 'Unusual Transaction Velocity',
'description': 'Single merchant processing 10x normal volume',
'query': 'transaction_count BY merchant_id | where count > baseline * 10',
'severity': 'high',
'response': 'Pause merchant payouts, investigate for compromised credentials',
},
{
'name': 'Card Testing Pattern',
'description': 'Multiple small charges ($0.50-$2.00) from same IP',
'query': 'transactions where amount < 2.00 | group by source_ip | where count > 5',
'severity': 'critical',
'response': 'Block IP, flag all associated cards, notify issuing banks',
},
{
'name': 'Off-Hours Admin Access',
'description': 'Admin panel access outside business hours',
'query': 'admin_access where hour NOT IN (8..18) AND NOT on_call_schedule',
'severity': 'medium',
'response': 'Require re-authentication, alert SOC for verification',
},
{
'name': 'Bulk Data Export',
'description': 'Large data export from payment database',
'query': 'db_queries where rows_returned > 10000 AND table IN payment_tables',
'severity': 'critical',
'response': 'Kill session, lock account, initiate incident response',
},
{
'name': 'Webhook Endpoint Probing',
'description': 'Repeated invalid webhook signatures from same source',
'query': 'webhook_failures BY source_ip | where count > 10 in 5m',
'severity': 'medium',
'response': 'Rate limit source, add to watchlist',
},
{
'name': 'Refund Anomaly',
'description': 'Refund rate exceeds 5% for a merchant in 24 hours',
'query': 'refunds / transactions BY merchant_id | where ratio > 0.05 in 24h',
'severity': 'high',
'response': 'Flag merchant, hold payouts pending review',
},
]
ML-based baselines cut false positives compared with static threshold rules. The system learns what "normal" looks like for each merchant and alerts on deviations, instead of applying one threshold to everyone.
Velocity is one of six signals in the risk score that runs on every payment. From chapter 19.
Real-Time Risk Scoring Engine
Implementation: src/examples/19-fraud/fraud_detection_engine.py
Key Components: - FraudDetectionEngine: Multi-layered fraud analysis with 6 signal types - RiskScore: Weighted scoring with explainable results (0-100 scale) - TransactionContext: Complete transaction metadata for analysis
Multi-Layered Fraud Detection Pattern (Conceptual):
# 6-layer fraud analysis (conceptual)
def analyze_transaction(context):
signals = {}
reasons = []
# Layer 1: Device fingerprinting
device_score = analyze_device(context.device_fingerprint)
signals['device'] = device_score
if device_score > 50:
reasons.append("Unknown or suspicious device")
# Layer 2: Velocity checks
velocity_score = analyze_velocity(
email=context.email,
ip=context.ip_address,
card=context.payment_method
)
signals['velocity'] = velocity_score
if velocity_score > 40:
reasons.append("High transaction velocity detected")
# Layer 3: Geolocation analysis
geo_score = analyze_geolocation(
ip_country=get_country(context.ip_address),
billing_country=context.billing_address['country']
)
signals['geolocation'] = geo_score
# Layer 4: Behavioral analysis
behavioral_score = analyze_behavior(context.user_agent)
signals['behavioral'] = behavioral_score
# Layer 5: Network analysis (VPN/proxy detection)
network_score = analyze_network(context.ip_address)
signals['network'] = network_score
# Layer 6: Card validation
card_score = analyze_card(context.payment_method)
signals['card'] = card_score
# Weighted overall score
overall_score = (
signals['device'] * 0.25 +
signals['velocity'] * 0.20 +
signals['geolocation'] * 0.20 +
signals['behavioral'] * 0.15 +
signals['network'] * 0.10 +
signals['card'] * 0.10
)
# Determine risk level and action
if overall_score >= 70:
return RiskScore(overall_score, CRITICAL, signals, reasons, "BLOCK")
elif overall_score >= 50:
return RiskScore(overall_score, HIGH, signals, reasons, "MANUAL_REVIEW")
elif overall_score >= 30:
return RiskScore(overall_score, MEDIUM, signals, reasons, "3DS_REQUIRED")
else:
return RiskScore(overall_score, LOW, signals, reasons, "APPROVE")
The complete implementation includes device reputation tracking, impossible travel detection, VPN/proxy detection, and velocity checks on email, IP, card, and amount. See src/examples/19-fraud/README.md for full code.
How the layers work together:
There's no single smoking gun in fraud detection. You're combining dozens of signals into a risk picture, airport security style: no single check catches every threat, but the combination is hard to defeat.
The analyze_transaction method orchestrates six engines: device fingerprinting (is this device trustworthy?), velocity checking (too many transactions too fast?), geolocation (does the location make sense?), behavioral analysis (does the user act like a human?), network analysis (VPN, proxy, or hosting provider IP?), and card validation (red flags on the payment method itself?). Each engine returns a numeric score plus a human-readable reason, so the system stays explainable.
Device fingerprinting builds a signature from browser characteristics, screen resolution, installed fonts, and a dozen other details. It works because fraudsters reuse devices across attacks, legitimate customers don't, and spoofing attempts leave detectable inconsistencies. The system maintains a reputation database keyed on the fingerprint and tracks fraud history over time.
Velocity analysis catches the spray-and-pray fraudsters running many transactions quickly before they get caught. It tracks email velocity (same email, multiple checkouts), IP velocity (rapid-fire from one network), card velocity (one payment method hammered repeatedly), and amount velocity (sudden spending spikes). Legitimate customers rarely trigger these. Fraudsters almost always do.
Geolocation forensics flags impossible scenarios - IP in Russia with a Texas billing address, traffic from countries with known fraud concentrations, VPN and proxy attempts to hide location, and impossible travel like New York at 2 PM followed by London at 2:05 PM. This catches both amateurs who don't hide and sophisticated operators whose hiding attempts are themselves detectable.
Behavioral pattern recognition looks for non-human signals - automated scripts that don't behave like humans, form completion times that are too fast to be real, outdated or suspicious browsers, and missing session characteristics like browsing before buying.
The combination is what makes this work. A legitimate customer might trip one flag (a VPN, say). They almost never trip several at once. Fraudsters trip multiple flags because fraud is inherently deceptive and rushed.
The Stripe end of it: Radar rules, and the session data that makes them work. From chapter 9.
Stripe Radar
Radar is Stripe's fraud ML, trained on payments across Stripe's whole network rather than just yours. It runs on every card payment without configuration.
# Enable with Payment Intents
intent = stripe.PaymentIntent.create(
amount=1000,
currency='usd',
radar_options={'session': radar_session_id} # Link to frontend session
)
The part you configure is the rules layer, and that's where the money is. Rules are one-liners in the Dashboard that block, allow, request 3D Secure, or send a payment to review:
Request 3D Secure if :card_funding: = 'prepaid'
Review if :amount_in_usd: > 1000 and :is_off_session: = false
Custom rules and the review queue come with Radar Plus, which starts at $14 a month or runs pay as you go (stripe.com/radar/pricing, checked November 2026). Stripe replaced Radar for Fraud Teams with four plans (Lite, Standard, Plus and Pro) in July 2026, and moves Fraud Teams accounts to Plus pricing in January 2027. Blocking the riskiest payments is no longer a rule either: the old Block if :risk_level: = 'highest' default is being deprecated in favour of risk settings, which you pick in the Dashboard. A payment that trips a review rule still goes through, but it lands in a queue where someone can refund it before you ship. If you want the hold to be real, pair the rule with manual capture. Two habits pay for the fee on their own. Pass a Radar session from the browser (the radar_options above) so Radar sees device signals and not just the card. And write a 3DS rule before you write a block rule, because a challenge costs you far less than a false decline. Chapter 19 covers the fraud model behind all of this.
Questions
What is card testing?
Card testing is when fraudsters run stolen or generated card numbers through a merchant's checkout, usually with a script, to find out which cards are live. They then use or sell the cards that were approved.
What is a BIN attack?
A BIN attack is card testing with generated numbers. The attacker takes a real issuer's bank identification number, fills in the remaining digits so the number passes the check-digit test, and submits guesses until some are approved.
How do I know if I'm being card tested?
Look for a spike in failed or blocked payments, a burst of 402 or generic decline errors, small successful charges with nonsense names and emails, and many cards tried from one IP address, device or customer in a short time.
How do I stop card testing on Stripe?
Use Checkout or the Payment Element, add a server-verified CAPTCHA to every endpoint that charges or saves a card, rate limit by customer, IP and device, block failed CVC checks with Radar, and keep your secret key out of reach.
Does card testing cost money if the charges are declined?
Yes. The charges that succeed turn into fraud warnings and disputes, a high decline rate makes issuers decline your real customers more often, and some pricing plans charge for each authorization attempt.