This was a tricky one!
So please give me a thumbs up for sharing if this helps you. Thanks!
I had the same issue of Laravel Cashier saving fine to stripe but not to my database.
However, I was experiencing this on my local development environment.
Running stripe listen command fixed the issue.
Here are the details :
Understanding Why the Records Save Only When Running stripe listen.
The reason your subscription records are saved to your database only when you run:
stripe listen --forward-to http://localhost-url/stripe/webhook
is because your local development environment (http://localhost-url) is not accessible from the internet. Therefore, Stripe cannot send webhook events directly to your local server. The stripe listen command provided by the Stripe CLI acts as a proxy between Stripe's servers and your local machine, forwarding the webhook events to your local webhook endpoint.
In summary:
Without stripe listen: Stripe's servers cannot reach your local webhook endpoint (http://localhost-url/stripe/webhook) because it's not publicly accessible. With stripe listen: The Stripe CLI listens for events on Stripe's servers and forwards them to your local endpoint, allowing your application to process the webhooks.
Also, I had added this route to my web.php file.
You don't need to add this route. Cashier adds it on it's own for you.