I’m in the process of testing how our plugin Reserved Stock Pro behaves when payments via Stripe fail. Turns out there’s not a clear way to “fail” payments via the Stripe API and WooCommerce. So, I found another solution.
Firstly, I’m using a WooCommerce store in my local development enviroment. Therefore, I’ll be using the Stripe test API keys.
Once your WooCommerce store is ready and accepting test payments, we’ll want to block the next payment. We do using the Stripe Radar (also in test mode).
Setting up new Stripe Radar Rules
I want my payment to fail, so I poked around the Stripe Radar Rules to find an easy way to block my payment. I settled for an easy rule that will block my payment if the customer email matches mine. See the screenshots below.
As you can see in the screenshot, my test email is
firstname.lastname@example.org and I’ve created a new rule which looks like this:
Block if :email: = 'email@example.com‘
To save the new rule, we have to click the “Test Rule” button. All that does is run the rule against your previous Stripe payments to give you an indication of what would have been blocked if this rule was active. It’s a nice feature that will show you if your rule is too aggressive. You don’t want to accidentally block all future payments.
One of my previous test payments were made by the same email, which was me testing. This looks good to me. Go ahead and save the rule.
Now to checkout in WooCommerce
We’ll need to confirm that the rule is working and blocking our payment. I’ll checkout any product and use the customer email specified in the Stripe Radar Rule.
Next up, I’ll fill out the checkout form with test data and test credit card information. Bang! Success – WooCommerce lets us know that the card was declined.
WooCommerce did indeed create a new order and mark it as “Failed”. I’m now ready to move on to test failed payment with stock reservations.
I hope this helps other people who need to test failed/declined payments with Stripe. Let me know in the comments below!