Laravel Cashier Events Laravel Cashier Events php php

Laravel Cashier Events


Just build an API endpoint in your routes/api.php and then add them to your stripe account. Stripe will treat those APIs as webhooks. Once someone subscribes to one of your services then Stripe will call the supplied webhook on your server to let it knows about the new subscription event.

In your routes/api.php or (better) in a separate API controller, add whatever event you need to fire there.

in Laravel, make sure to:

1- remove middleware('auth:api') on these webhooks.

2- then analyze the payload that sent by stripe to verify the payment

you can refer to Stripe documentation here for more details.


The guys over at Spatie have created a beautiful package for this exact purpose.

I've just implemented it within my own subscription management app for Stripe webhook handling and its, well - a breeze!

Their blog post on it is here: https://murze.be/handling-stripe-webhooks-in-a-laravel-application

And the GitHub repo is here: https://github.com/spatie/laravel-stripe-webhooks

Took about 5 minutes to get up and running and creating my own handling of the inbound webhooks, including reading it!