Stripe is a terrific company for developers wanting to integrate paytments into their application. Their API's and developer facilities are top-notch. One of the awesome tools Stripe offers is the Stripe CLI, a command-line tool for testing and simulating webhooks easily on your local device. This is pretty useful when you want to use laravel cashier to develop your saas product locally.
However, the Stripe CLI doesn't immediately work with Laravel Herd, a blazing fast, native Laravel and PHP development environment for macOS, which includes PHP, nginx, dnsmasq, and Node.js. This trick also applies for laravel valet, or local site configured with nginx.
Ensure stripe cli installed in your local. Stripe CLI Installation guide
To make the Stripe CLI work with Laravel Valet, make a change to your hosts file (/etc/hosts). You can edit it with Nano-editor using:
sudo nano /etc/hosts
Add the following rule to your /etc/hosts file, replacing `mysite.test` with your domain:
127.0.0.1 mysite
Save the file.
Flush the DNS cache to ensure the changes take effect:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
You might also need to clear your browser cache/cookies.
Now you can use the Stripe CLI with Laravel Valet. For example, if you're using Laravel Cashier with Stripe, you can forward webhooks to your local application with:
stripe listen --forward-to https://mysite.test/stripe/webhook
Give it a try and let me know how it goes!
Comments (1)
6 months ago
Hello Rezaul, you are a live saver!!! Works like a charm. Thank You!