How to stop card testing attacks

Intermediate5 min readUpdated

GET /learn/ecommerce-fraud/how-to-stop-card-testing/ Accept text/html text/markdown

Short answer

To stop card testing, block payments that fail CVV or postcode checks, limit failed attempts per session, card BIN, IP address and device, and check for bots before the payment form accepts a submission. Cap attempts per cart and per account, return one generic decline message, and remove any endpoint that saves or checks a card without a logged-in customer.

If an attack is running now, act on the payment step first: stop fulfilling the suspicious orders, refund the test charges that went through so they do not become disputes, and add temporary friction such as a required login or a challenge before payment. Then add the controls below, cheapest first. A rule on one signal rarely holds, because testers rotate IP addresses through residential proxies and change cards, amounts and user agents during the attack.

Require CVV and postcode checks

Collect the card security code (CVV or CVC) and the billing postcode on every card payment, and block when the issuer reports a mismatch. A tester who guesses numbers then also needs the right code. On Stripe Radar:

txt
Block if :cvc_check: = 'fail'
Block if :address_zip_check: = 'fail'

A stricter != 'pass' also blocks payments where no check ran. Wallets such as Apple Pay send no CVC and not every issuer supports postcode checks, as Stripe's rules reference notes, so measure how many good payments a strict rule would stop first.

Limit declines per session, BIN, IP and device

Count failures by several keys at once and act when any of them crosses a limit. Starting points to tune against your own traffic:

  • 3 failed payments per session or cart in an hour
  • 5 failed payments per IP address in an hour, higher for mobile carriers and offices that share addresses
  • 3 distinct cards per device or account in a day
  • declines for one BIN (the first six to eight digits of the card number) well above its normal share

This PostgreSQL query shows which IP addresses tried the most cards in the last hour. Swap ip_address for device_id or card_bin to see the other views.

sql
SELECT ip_address,
       COUNT(*) AS attempts,
       COUNT(DISTINCT card_fingerprint) AS distinct_cards,
       SUM(CASE WHEN status = 'declined' THEN 1 ELSE 0 END) AS declines
FROM payment_attempts
WHERE created_at > NOW() - INTERVAL '1 hour'
GROUP BY ip_address
HAVING COUNT(DISTINCT card_fingerprint) >= 3
ORDER BY distinct_cards DESC;

Radar velocity rules do the same at the processor, if your Radar plan includes custom rules. Counts exclude the payment being checked.

txt
Block if :card_count_for_ip_address_hourly: > 3
Block if :declined_charges_per_ip_address_hourly: > 5
Review if :card_count_for_customer_daily: > 3

Per-IP limits miss attacks spread over thousands of addresses, which is why the other keys matter, as explained in what rate limits stop and miss.

Check for bots before the payment form

Bot detection judges the session itself: whether the browser is automated, whether the IP address belongs to a proxy or data centre, whether the visitor looked at anything before paying. Run the check when the payment page loads and again on submit, and verify the result on your server, since scripts skip any browser widget whose token the server never checks. WooCommerce found that several CAPTCHA plugins did not protect the Checkout block and Store API. Solving services pass visible puzzles, so an invisible check with a challenge only for risky sessions costs fewer real customers.

Cap attempts per cart and per account

After 3 failed payments on one cart, a starting point, lock the cart and ask the customer to log in or contact support. Limit the cards an account can add per day. Require login before a card can be saved.

Return one generic decline message

Messages such as "incorrect CVC" or "expired card" tell an enumeration script which field to change next. Log the detailed reason on the server and show one message to the customer:

js
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);

app.post('/api/checkout/pay', async (req, res, next) => {
  try {
    const intent = await stripe.paymentIntents.confirm(req.body.paymentIntentId, {
      payment_method: req.body.paymentMethodId,
    });
    return res.json({ status: intent.status });
  } catch (err) {
    if (err.type === 'StripeCardError') {
      console.warn('card declined', err.code, err.decline_code);
      return res.status(402).json({
        error: 'Payment was not approved. Check your details or try another card.',
      });
    }
    return next(err);
  }
});

This covers responses your own server sends. When the processor's library confirms the payment in the browser, the processor decides what the error contains.

Remove unauthenticated add-card endpoints

List every route that can save a card or trigger a zero-value authorisation, including account pages, subscription updates, mobile app APIs and old checkout versions. Each one should require a logged-in customer and sit behind the same limits and bot checks, or be removed if nothing uses it. Set a minimum amount on donation forms. Keep secret API keys out of client code, and rotate any that may have leaked, since a leaked key lets testers create payments directly.

Platform notes: Stripe, WooCommerce and Shopify

On Stripe, Checkout and the Payment Element include automatic card testing controls such as rate limiters and CAPTCHA. A custom integration should send the customer's IP address, email, name and billing address with each payment, because Stripe's models use them.

On WooCommerce, Store API rate limiting is built in but disabled by default. Turn it on with a filter. The toggle under WooCommerce > Settings > Advanced > Features only limits the checkout request, not the rest of the Store API:

php
add_filter( 'woocommerce_store_api_rate_limit_options', function() {
    return [
        'enabled'       => true,
        'proxy_support' => false,
        'limit'         => 25,
        'seconds'       => 10,
    ];
} );

Set proxy_support to true when the site sits behind a CDN or load balancer, or every visitor appears to share the proxy's address and real customers hit the limit together. Leave it false on a site that receives traffic directly, where a forwarded IP header could be forged. Since WooCommerce 9.8 the woocommerce_store_api_rate_limit_id filter lets you key limits on a fingerprint instead of the IP address. Kairal's WooCommerce card testing guide explains why order-level fraud plugins, CAPTCHAs and IP rules alone fall short.

On Shopify you do not control the checkout code. Shopify Payments includes card testing protection, and its fraud analysis temporarily blocks an IP address after many orders or failed payments in a short time. During an attack, cancel and refund test orders, do not fulfil them, and use manual payment capture while you investigate. Shopify's bot protection for Plus stores targets checkout bots during product drops, not payment fraud. More options are in stopping bots on Shopify.

Tools that help

StopBots is published by Kairal, which is one of the tools listed. The list is not a ranking.

  • Stripe Radar scores every Stripe payment and lets you write block and review rules on CVC results, postcode checks and card velocity; it fits stores already on Stripe.
  • Cloudflare rate limiting rules limit requests to the payment path at the edge before they reach your server; they suit sites already behind Cloudflare.
  • Cloudflare Turnstile is a free challenge you verify on the server before accepting a payment request, and with rate limits it is often enough for a small store.
  • Kairal checks device, network and behaviour signals on the session before checkout and lets you set protection per endpoint, such as payment and add-card, with a preview mode that shows decisions before anything is blocked.

Common questions

How do I stop card testing on WooCommerce?

Turn on Store API rate limiting, make sure your CAPTCHA or bot check also covers the Checkout block and the Store API, and add fraud rules that block the order pattern the attack uses, such as one cheap product. If you use WooPayments, its support team can bulk refund test orders that went through.

Does a CAPTCHA stop card testing?

It slows scripts that cannot pass it, but CAPTCHA solving services pass many puzzles for a small fee, and a CAPTCHA only checks the moment of submission. It works best as a challenge you show to sessions that already look risky, verified on the server for every payment request.

Should I refund card testing charges?

Yes, refund successful test charges quickly and do not ship anything. A refund made before the cardholder disputes the charge usually prevents the chargeback and its fee.