#Mr.Medi
1 messages · Page 1 of 1 (latest)
Hello, what kind of best practices are you looking for here? We don't know much about laravel specifically but are happy to advise on webhooks from the Stripe side
Also dropping a link to this doc in case you have not seen it yet https://stripe.com/docs/webhooks/best-practices
I will like to know the project structure regarding creating the webhook and how to test it locally with real data in my local db without exposing my private ip
We have this doc on testing locally with the Stripe CLI https://stripe.com/docs/webhooks/test
You can listen to live events with the --live flag https://stripe.com/docs/cli/listen#listen-live
Unfortunately we can't consult on laravel project structure and hooking things up to your DB. Those are more general questions that you will want to check laravel docs and your DB's docs for.
I see. If i understand correctly in stripe-cli I have to specify the webhook endpoint of my laravel app?
Depends what you mean by that. Your three main options here are:
- Use stripe listen and direct events to some localhost port on your machine. The CLI will automatically create an endpoint and direct events when you do.
- Set up some external URL and use the CLI with the
--forward-connect-toflag to send your events to that URL https://stripe.com/docs/cli/listen#listen-forward-connect-to - Set up an external URL and register it as an endpoint in your dashboard (this does not require the CLI) https://dashboard.stripe.com/test/webhooks
Yes, Im using the option 1 with this command in stripe cli ```bash
stripe listen --forward-to https://localhost:8001/stripe/webhook --skip-verify
but im having issues in laravel cashier when running ```php artisan cashier:webhook --url "https://localhost:8001/stripe/webhook"
Invalid URL: URL must be publicly accessible. Consider using a tool like the Stripe CLI to test webhooks locally when im using already it
For forward to I think the proper syntax is --forward-to localhost:8001/stripe/webhook
I think the https:// may be throwing the CLI off
if you dont specify the protocol it will use http by default
I will try that again
To test that stripe endpoint i have to trigger the stripe events from stripe right?
but how do I use it use it with real customer
My goal is to check if the status of one suscription is active or not with the webhook
In livemode you will want to set up your endpoints via the dashboard https://dashboard.stripe.com/webhooks, the CLI is only meant to be used for testing
If you have an existing customer with a subscription you can use the cli resend command to send that exact event to the endpoint that you want to test on https://stripe.com/docs/cli/events/resend
That being said, it may be easier to set up a subscription in test mode and test with test mode webhook events before doing things with your live users and subscriptions.
Yes, I meant to test it with a test customer that I have
I will try that command with my test customer
Sorry if I ask a lot of questions, Its just my first time implementing a payment gateway. I get the point of resending events and it works locally, but how do i check if a suscription of the current user is active or not?
As far as i understand, a suscription can be cancelled but the user have paid and still may have access to the content, do i control that?
👋 stepping in here as Pompey needs to step away
You control when you provision access to your product. Usually you want to mirror the status of the Subscription for when you provision
and the status is being updated with the webhook?
because I meant. Imagine an user that suscribes to my yearly plan and after that he cancels that. The user have to access the content because he paid but the suscription is not active. Whats the best way to check it and does the webhook update those fields?
Yep the customer.subscription.updated Event fires every time anything on the Subscription object changes
Like the status
Perfect! Is it supposed to test it with stripe trigger customer.subscription.updated ?
I dont see changes in my db
I see, that command creates a customer with a suscription in my dashboard but not in my local db, despite it catch the requests