Card testing attacks show up as many rapid charge attempts with small amounts (NGN 100–500) across different email addresses from the same IP. Defend by: (1) rate limiting your checkout endpoint per IP (max 5 transactions per minute), (2) blocking transactions with amounts below a threshold (e.g., NGN 500) unless explicitly supporting small amounts, (3) checking for multiple failed charges from the same IP within 10 minutes, and (4) requiring CAPTCHA after 2 failed charges from the same session.
A card testing attack in your transaction logs looks like:
The attacker finds which cards succeed, then uses those for larger fraudulent transactions elsewhere.
// Middleware: rate limit checkout by IP
var redis = require('redis');
var client = redis.createClient();
async function velocityCheck(req, res, next) {
var ip = req.ip;
var key = 'checkout:' + ip;
var windowSeconds = 60;
var maxAttempts = 5;
var count = await client.incr(key);
if (count === 1) {
await client.expire(key, windowSeconds);
}
if (count > maxAttempts) {
return res.status(429).json({
error: 'Too many payment attempts. Please try again later.',
});
}
next();
}
// Track failed charges by IP
async function trackFailedCharge(ip) {
var key = 'failed:' + ip;
var count = await client.incr(key);
if (count === 1) {
await client.expire(key, 600); // 10-minute window
}
if (count >= 3) {
// Block this IP for 1 hour
await client.setex('blocked:' + ip, 3600, '1');
// Alert your team
console.error('Card testing suspected from IP:', ip, 'Failed attempts:', count);
}
}
// Check webhook for failed charges
if (event.event === 'charge.failed') {
var ip = event.data.ip_address;
if (ip) await trackFailedCharge(ip);
}
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
This guide is part of the Paystack security guide.
KES 2,999
The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.
Start Paystack Course