Effective WooCommerce fraud prevention against bot transactions and card attacks

Card testing bots use stolen card lists to place small orders straight through the WooCommerce REST API, so CAPTCHAs and fraud plugins on your checkout page never stop them. Check your access logs for hits to /wp-json/wc/store/checkout, then block that endpoint with a code snippet or a Cloudflare custom rule, and add reCAPTCHA to guest checkout.

WooCommerce Fraud Prevention against Bots

WooCommerce fraud prevention is the set of checks that stop fake orders, card testing bots and stolen-card payments before they cost your store money. Plugins and CAPTCHAs are the usual advice, but card testing bots often skip your checkout page entirely and place orders through the WooCommerce REST API. Below is how I found and blocked one of these attacks on a client’s store, and the signs to look for on yours.

WooCommerce store hit by fraudulent bot orders

One of our clients asked for urgent help after a sudden surge of fraudulent orders, mostly for low-value items. When I checked her WooCommerce orders, I found lots of random orders with a failed status. Strangely, they all had valid names and addresses, random but proper Gmail addresses, and came from different IP addresses.

Solutions I tried to tackle bot transactions

I first tried the usual WooCommerce fraud prevention steps: adding reCAPTCHA, turning off guest checkout and installing a fraud prevention plugin. None of them stopped the bot orders. My client’s audience wasn’t very tech-savvy, so she had enabled “Guest Checkout” to keep ordering simple, and at first that looked like the obvious weak spot.

To combat this, I installed the Wordfence security plugin, which offers seamless reCAPTCHA integration for WooCommerce login and registration pages.

After installing and activating Wordfence, I set up Google reCAPTCHA and enabled the WooCommerce integration feature. To further secure the process, I disabled the Guest Checkout option, requiring users to create accounts or log in before placing an order as a fraud prevention measure.

Surprisingly, this didn’t help. Bot orders kept coming and coming.

So, I searched for fraud prevention plugins that can help with bot transactions and found the Fraud Prevention For WooCommerce and EDD WordPress plugin.

After a straightforward setup, I decided to monitor the situation for a few hours to see if any new fraudulent bot orders would be submitted. Unfortunately, the free version of this plugin had almost no configuration options and didn’t stop any bot orders from getting through.

Continue reading to find out what was the source of the issue and how I fixed it.

How I detected and prevented the fraudulent bot transactions

I found the cause in the raw web server access logs: the bots were placing orders through the WooCommerce REST API instead of the checkout page. That’s why none of the plugins or CAPTCHA solutions helped, since they only protect the pages a human visitor sees. Blocking REST API access for visitors who aren’t logged in stopped the attack.

The WordPress REST API is primarily designed for software integration, allowing GET and POST requests. WooCommerce extends WordPress’ REST API with additional functionality, which bots have been exploiting.

Marked lines starting with /wp-json/ in the web server access log show how a bot can browse items in the online shop, programmatically add products to the cart, and complete the checkout.

To disable the WP REST API for non-logged-in users, I added the following code using the popular Code Snippets plugin.

add_filter( 'rest_authentication_errors', function( $result ) {
    if ( true === $result || is_wp_error( $result ) ) {
        return $result;
    }
    if ( ! is_user_logged_in() ) {
        return new WP_Error(
            'rest_not_logged_in',
            __( 'You are not currently logged in.' ),
            array( 'status' => 401 )
        );
    }
    return $result;
});

Alternatively, you can also add this code to your child theme’s functions.php file using File Manager of your hosting provider, or through FTP.

I kept monitoring the site for 24 hours as well as raw web access logs. The issue was resolved. My customer didn’t receive any other orders submitted by bots and was super happy with the result!

NOTICE: Some websites might need WordPress REST API for integration purposes. In that case try to disable only the WooCommerce API endpoints or consult your WordPress developer for additional security measures.

What is a card attack?

A card attack, or card testing attack, is a type of fraud where bots use lists of stolen card numbers to place small orders and find out which cards still work. On WooCommerce, they often hit the REST API directly and skip your checkout page, which is how they got past the reCAPTCHA and every other measure I tried at first.

Card testing is widespread: at the peak of a 2022 wave, Stripe’s Radar blocked more than 20 million card testing attempts per day.

If you are also seeing weird activity in your store lately, you might be under the same kind of attack.

3 signs your WooCommerce site is facing a card attack

Card testing attacks leave a clear pattern in three places: your orders, your customer data and your server logs. If you see several of the signs below at the same time, especially lots of small failed orders around the clock, treat it as a card attack and check your access logs before trying another plugin.

Sign #1: Dozens of small-value orders

  • Orders for the cheapest products in your catalog
  • Always single items, never bulk purchases
  • Failed payments but orders still show up in your system
  • Happening 24/7, even at 3am

Sign #2: Suspicious customer patterns

  • Email addresses like firstname.lastname.randomnumber@gmail.com
  • Different credit cards but similar billing details
  • Orders marked as “unknown” origin in WooCommerce
  • Customer accounts created seconds before ordering

Sign #3: Your server logs tell the story

  • Direct API calls to /wp-json/wc/store/checkout
  • No referrer data (shows as “-” in logs)
  • Requests bypass your actual checkout pages
  • VPN IP addresses from around the world

The hidden cost of card attacks

Card attacks cost more than a few fake orders. Depending on your payment gateway, failed authorizations can carry processing fees, and every fraudulent charge the real cardholder disputes adds a dispute fee on top of the lost sale ($15 per dispute at Stripe in the US). If fraud and disputes keep piling up, card networks can put your store into a fraud monitoring program with higher processing fees, as Stripe explains.

The simple fix

The simplest fix for card testing bots on WooCommerce is to block the Store API checkout endpoint they use. If you’re not running headless WooCommerce or using checkout blocks, you can add the code snippet below to your child theme’s functions.php file or through the Code Snippets plugin to disable checkout via the REST API.

function disable_wc_endpoint() {
    $current_url = $_SERVER['REQUEST_URI'];
    if (strpos($current_url, '/wp-json/wc/store/checkout') !== false) {
        wp_redirect(home_url('/404.php'));
        exit;
    }
}
add_action('rest_api_init', 'disable_wc_endpoint');

Make sure you compare your logs to check which API endpoint the bots are hitting. Some WooCommerce installations have “v1” in the URI path. So, it might look like wp-json/wc/store/v1/checkout in your case.

Alternatively, if you are using Cloudflare, you can add a custom security rule to block or initiate a Managed Challenge in case the request path contains /wp-json/wc/store/checkout or /wp-json/wc/store/cart. If you’re new to Cloudflare, see how to set up Cloudflare for your WordPress site.

Implement reCAPTCHA for the WooCommerce checkout page

Adding reCAPTCHA to the WooCommerce checkout page stops bots that do go through your real checkout form. I set it up after blocking the REST API checkout, because the client asked to re-enable “Guest Checkout” and guest orders need their own protection. It’s a second layer, not a replacement for blocking the endpoint.

There is a fantastic free plugin that provides this functionality, built by Elliot Sowersby. The reCAPTCHA for WooCommerce WordPress plugin is very easy to set up. You just need to generate a reCAPTCHA v2 site key and secret key at Google reCAPTCHA, and the whole setup takes only a few minutes.

You can protect both Guest Checkout as well as WooCommerce login and register forms. In my case, I only enabled Guest Checkout, as login and registration pages were protected by Wordfence.

Additional strategies for WooCommerce fraud prevention

Blocking the checkout endpoint and adding reCAPTCHA handle card testing bots, but long-term WooCommerce fraud prevention takes a few more layers. The practices below cover your payment gateway, how you score and review risky orders, and keeping your store updated. If most fraudulent orders come from countries you don’t sell to, you can also block those countries for free.

Secure payment processing

A secure payment gateway is your first line of defense, because it can decline fraudulent transactions before they ever become orders in your store. Choose one with built-in fraud detection and real-time monitoring, such as Stripe Radar, so suspicious payments are flagged or blocked automatically based on the card, the device and the customer’s history.

Opt for gateways with two-factor authentication and IP blocking to add security layers. Two-factor authentication requires users to verify their identity with a second method, while IP blocking prevents access from known malicious IP addresses.

Select gateways offering PayPal email verification to avoid fake account creation, ensuring emails are legitimate and verified. Some gateways provide detailed transaction reports and analytics, helping you spot transaction patterns and potential fraud risks.

Risk scores and mitigation policies

Utilize risk scores to evaluate the potential for fraudulent activity. These scores, based on factors like IP address, billing address, and transaction history, help identify suspicious transactions quickly. By analyzing these scores, you can prioritize which transactions need further scrutiny.

Implement mitigation policies to handle high-risk transactions effectively. These are predefined actions your WooCommerce store can take, such as automatically canceling suspicious orders or requiring additional verification. Clear policies help manage fraud efficiently and reduce its impact on your business.

Customizable risk scores and mitigation policies allow you to tailor fraud prevention to your store’s needs. Adjust risk factors and policies to match your store’s characteristics and risk tolerance, ensuring effective protection against fraudulent transactions while minimizing false positives.

Monitor and analyze transactions

Monitor and analyze transactions regularly to spot suspicious activity early. Reviewing recent orders can reveal fraud patterns, such as repeated attempts from the same IP address, many failed payments in a row or billing details that don’t match the card’s country. Staying vigilant lets you respond before a small attack turns into chargebacks.

Your payment gateway’s dashboard (for example Stripe Radar or WooPayments) shows risk scores, fraud alerts and disputes, and the WooCommerce Orders screen lets you filter failed and on-hold orders so you can review them in one place.

Utilize fraud prevention tools that provide real-time alerts and risk assessments. These tools help identify fraudulent transactions, enabling you to block orders from specific countries or high-risk IP addresses.

Keep software and plugins up to date

Keeping WooCommerce, WordPress and your plugins up to date closes the security vulnerabilities that fraudsters and malware rely on. Outdated plugins are also the most common way malware gets into a site, so update regularly and remove plugins you no longer use. If you suspect an infection, see how to scan and remove malware from WordPress.

Key takeaways

The key takeaway is that card testing bots often bypass WooCommerce checkout protections by using the REST API, so check your access logs before adding more plugins. Block the checkout endpoint they hit, add reCAPTCHA to guest checkout, and back it up with a fraud-aware payment gateway and regular updates. In short:

  • WooCommerce fraud prevention is an essential part of running a successful online store.
  • Use a combination of tools and strategies to detect and prevent fraudulent activities.
  • Consider using WooCommerce anti-fraud plugins and secure payment gateways to enhance your fraud prevention efforts.
  • Use Cloudflare’s Bot Fight Mode and custom security rules to block and challenge malicious bots automatically, helping to reduce fraudulent bot transactions and protect your WooCommerce store from fake orders and suspicious activities.

About the author

Ozgur Sar Avatar