In this episode, we're diving into how to actually handle Stripe webhooks in a Laravel app, now that we have our checkout flow working. The main focus is on setting up your local app so Stripe can notify it when an event happens—like when a payment succeeds. For this, you’ll need to expose your local development server to the outside (we use Expose here, but ngrok or others work too).
We start by walking through how to set up a webhook endpoint in the Stripe dashboard, making sure to select events specifically on connected accounts (because that’s how the money flows in our app). Then we pick the important event types, like checkout.session.completed
and asynchronous payment events.
Next, we set up a new route and a controller in Laravel to receive these webhook notifications, making sure to exclude the endpoint from CSRF protection since Stripe will be posting directly to it. We test that everything’s wired up by logging webhook payloads to the Laravel log, then make a sample purchase and confirm everything works as expected.
The episode wraps up by showing how to cleanly organize your webhook handler, automatically routing incoming events like checkout.session.completed
to distinctly named methods in your controller using Laravel’s string helpers. This makes it really easy to manage many webhook event types as your app grows. Finally, we highlight the difference between instant and asynchronous payments, and discuss how you might handle those less immediate events in the future.
TL;DR: By the end of this video, you'll have a Stripe webhook controller that organizes event processing nicely, and you’ll see real webhooks being received, logged, and ready for you to code up whatever app logic you need!