#Mr.Medi

1 messages · Page 1 of 1 (latest)

sudden cragBOT
deep schooner
#

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

cyan copper
#

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

deep schooner
#

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.

cyan copper
#

I see. If i understand correctly in stripe-cli I have to specify the webhook endpoint of my laravel app?

deep schooner
#

Depends what you mean by that. Your three main options here are:

  1. 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.
  2. Set up some external URL and use the CLI with the --forward-connect-to flag to send your events to that URL https://stripe.com/docs/cli/listen#listen-forward-connect-to
  3. 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
cyan copper
#

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
deep schooner
#

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

cyan copper
#

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?

sudden cragBOT
cyan copper
#

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

deep schooner
#

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.

cyan copper
#

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?

honest hull
#

👋 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

cyan copper
#

and the status is being updated with the webhook?

sudden cragBOT
cyan copper
#

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?

honest hull
#

Yep the customer.subscription.updated Event fires every time anything on the Subscription object changes

#

Like the status

cyan copper
#

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

honest hull
#

Well you would need to debug your local db in that case

#

I would also reccomend testing with Test Clocks here

#

They are a good way to simulate these changes over time