Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bheath's avatar

Stripe webhooks cannot be tested in Cashier

I was trying to test my Stripe webhooks today a was puzzled to find that it is no longer working. After some hacking away I found that a change: https://github.com/laravel/cashier/commit/ad4e8b485069b67967104b55c56a09ccb1dd059d Was made to prevent brute force attacks on the hooks. Which I get.

The problem is that Stripe only sends evt_00000000000000 when testing which is not going to pass the validation. Am I missing something here? Or should this be wrapped under a not in debug or stripe testing mode?

0 likes
3 replies
Braunson's avatar

@bheath I know this thread is old, I ran into this issue also.

Perhaps a workaround if your testing locally, is to open up the laravel/cashier under the vendors folder then the WebhookController.php and temporarily comment out the if statement for eventExistsOnStripe and test.

Editing vendor/core files is frowned upon but this seems like a workaround for now, unless I'm wrong and someone else has any other suggestions.

bheath's avatar

@Braunson That's what I was doing for awhile. Which was annoying. At some point a .env const was added that allows for testing.

CASHIER_ENV=testing

And/Or in phpunit.xml

<env name="CASHIER_ENV" value="testing"/>
1 like
Braunson's avatar

@bheath That's for 5+, I'm on a project that's still 4.2 (converting soon..)

Just got thinking, you could extend the WebhookController, override the handleWebhook() function to check for the environment which would dictate if it should run existsOnStripe or not.

Good to note for 5.x tho, thanks!

Please or to participate in this conversation.