79111974

Date: 2024-10-21 23:04:28
Score: 1
Natty:
Report link

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.

Cashier route I added for stripe webhooks

You don't need to add this route. Cashier adds it on it's own for you.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Whitelisted phrase (-1): I had the same
  • RegEx Blacklisted phrase (2.5): please give me
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: 13garth