Stop card testing attacks on WooCommerce checkout
Published Updated 3 min read
Card testing is simple: a bot submits card numbers, one after another, until a payment goes through. The attacker does not want anything from your store. They want a live card to sell or use elsewhere, and your checkout is a convenient validator.
The first response is not a plugin at all. It is your payment gateway: AVS mismatch rejection, CVV failure handling, and velocity filters that throttle repeated attempts from one IP. If your gateway has those controls and they are off, turn them on. For most stores that ends the attack.
A plugin earns its place in the gap between the gateway and WordPress. Some gateway integrations do not expose those controls, and some attacks rotate cards faster than velocity filters react. A WooCommerce-level lockout counts failed orders per IP and keeps that IP out of checkout. It is a second layer, not a replacement.
What an attack looks like from the orders screen
The bot submits a checkout with stolen card data. WooCommerce creates an order, the gateway declines, the order is marked failed, and the bot tries the next card. Every attempt leaves a failed order behind, and a busy attack can leave hundreds before anyone notices.
Because each attempt is a real, complete checkout submission, usually from one list of cards with the same billing details, rate limiting on page views does nothing. What does slow it down: gateway controls that reject the pattern before WooCommerce marks an order failed, Cloudflare or another WAF that recognises the submissions, a CAPTCHA at checkout, or a lockout that counts failures per IP.
Where the gateway controls live
AVS (Address Verification Service) rejects a transaction when the billing address does not match the card's address on file. CVV rejection declines a payment with the wrong security code. Velocity filters block an IP that submits more than a set number of transactions in a short window. Between them they stop card testing better than anything in WordPress.
Stripe keeps its fraud settings under Radar in the Dashboard. Authorize.Net has Velocity Filters and AFDS under Account > Security Settings. Square and PayPal both have fraud prevention settings in their dashboards, PayPal's under Fraud Management Filters.
If your gateway plugin does not show these in the WordPress admin, log in to the gateway itself. Some older WooCommerce integrations pass transactions through without surfacing the account's security settings at all.
Counting failures per IP
Each time an order moves to failed, the plugin reads the customer's IP from the order and increments a counter for it in a transient. At the threshold (by default five failures in sixty minutes) the IP goes onto a blocked list in wp_options and the counter is cleared.
At the start of checkout processing, the visitor's IP is checked against that list. A blocked IP inside its lockout period (24 hours by default) gets an error notice and cannot reach payment. Once the period has passed, the IP drops off the list on its next checkout attempt.
Settings has a page listing each blocked IP with the time it was blocked and an Unblock button, alongside the threshold, the tracking window and the lockout length.
Rotating IPs, shared networks and the orders left behind
A per-IP lockout assumes the attacker has one IP. Coordinated attacks rotate through hundreds, and against those the lockout only raises the cost slightly. Gateway velocity filters or a network-level tool like Cloudflare are what stop volume attacks.
Shared addresses cause false positives: a hotel, a university network, a corporate proxy where many people leave through one IP. If real customers start getting blocked, raise the threshold or release them from the blocked list.
The plugin does not touch the failed orders. WooCommerce keeps an order for every checkout attempt, failed ones included, and never deletes them on its own, so after an attack you will want a database query or a cleanup plugin that removes orders stuck in failed status beyond a set age.
What you get
Included
- Tracking failed WooCommerce payment attempts per IP address using WordPress transients
- Locking out IPs that exceed the failure threshold, with a checkout error notice
- An admin page listing blocked IPs with blocked-at timestamps and one-click unblock
- Configurable failure threshold, tracking window in minutes, and lockout duration in hours
Not included
- AVS, CVV, or velocity filtering at the payment processor level, which are the primary defense
- Bot detection, browser fingerprinting, or CAPTCHA at checkout
- IP reputation lookups, geolocation blocking, or Cloudflare integration
- Blocking by email address, phone number, or billing address patterns
- Removing failed orders from the WooCommerce database
Questions
A real customer says they cannot check out. What do I do?
Open Settings > Blocked IPs, find their IP in the table and click Unblock. They can check out straight away. If it keeps happening, raise the failure threshold in Settings > Card Testing Lockout Settings.
Which payment gateways does it work with?
It watches WooCommerce's order status rather than any gateway, so it works with any gateway that marks an order failed when a payment is declined. That includes Stripe, Authorize.Net, PayPal and Square.
Build it in Steem
The button opens the builder with this guide's prompt filled in, so you can change anything before it runs. Nothing is built, and nothing is charged, until you send it.
Read the prompt (386 words)
Build a WordPress plugin called WooCommerce Card Testing Lockout. Plugin Name: WooCommerce Card Testing Lockout. Description: Locks out IP addresses that make repeated failed payment attempts at WooCommerce checkout. Requires WooCommerce. Single PHP file. No JavaScript. No external requests. Track failures: hook woocommerce_order_status_changed at priority 10 with 4 arguments. When $new_status equals 'failed': get $ip via $order->get_customer_ip_address(). Build transient key $key = 'wc_ctlk_' . md5($ip). Read $data = get_transient($key). If $data is false, set $data = ['n' => 0, 'since' => time()]. Get $window = (int) get_option('wc_ctlk_window', 3600). If time() minus $data['since'] exceeds $window, reset $data to ['n' => 0, 'since' => time()]. Increment $data['n']. set_transient($key, $data, 86400). Get $threshold = (int) get_option('wc_ctlk_threshold', 5). If $data['n'] >= $threshold: get $blocked = get_option('wc_ctlk_blocked', []); $blocked[$ip] = time(); update_option('wc_ctlk_blocked', $blocked, false); delete_transient($key). Block at checkout: hook woocommerce_checkout_process at priority 1. Get $ip = WC_Geolocation::get_ip_address(). Get $blocked = get_option('wc_ctlk_blocked', []). If $ip is a key in $blocked: get $duration = (int) get_option('wc_ctlk_duration', 86400). If time() minus $blocked[$ip] < $duration: wc_add_notice('Too many failed payment attempts from your connection. Please try again later or contact us for help.', 'error'). Else: unset($blocked[$ip]); update_option('wc_ctlk_blocked', $blocked, false). Settings: register_setting for wc_ctlk_threshold (sanitize_callback intval), wc_ctlk_window (sanitize intval, stores seconds), wc_ctlk_duration (sanitize intval, stores seconds). Add options page via add_options_page: page title 'Card Testing Lockout Settings', menu title 'Card Testing Lockout', capability 'manage_woocommerce', menu_slug 'wc-ctlk'. Page callback renders a form posting to options.php with settings_fields and three number inputs: wc_ctlk_threshold (label 'Failure threshold', default 5, min 1, description 'Failed payments before lockout'), wc_ctlk_window_min (label 'Tracking window (minutes)', display value = get_option(wc_ctlk_window,3600)/60, save via sanitize_callback that multiplies by 60 and calls update_option('wc_ctlk_window',...) then returns null to skip auto-save), wc_ctlk_duration_hrs (label 'Lockout duration (hours)', display value = get_option(wc_ctlk_duration,86400)/3600, save via sanitize_callback multiplying by 3600 into wc_ctlk_duration). Blocked IPs page: add_submenu_page under wc-ctlk, page title 'Blocked IPs', menu_slug 'wc-ctlk-blocked'. Page callback: get blocked list; if empty show a paragraph 'No IPs are currently blocked.'; else show a table with class widefat and columns IP Address, Blocked At, Action. Each row shows the IP, date_i18n('Y-m-d H:i:s', $blocked[$ip]), and a form posting to admin-post.php with action wc_ctlk_unblock, hidden field ip_address set to $ip, wp_nonce_field('wc_ctlk_unblock'), submit button 'Unblock'. Show an admin-notice if GET unblocked=1. Register admin_post_wc_ctlk_unblock: check_admin_referer('wc_ctlk_unblock'); get $ip = sanitize_text_field($_POST['ip_address']); get $blocked = get_option('wc_ctlk_blocked', []); unset($blocked[$ip]); update_option('wc_ctlk_blocked', $blocked, false); wp_redirect(admin_url('options-general.php?page=wc-ctlk-blocked&unblocked=1')); exit.
Steem