#Marroco-webhooks

1 messages ยท Page 1 of 1 (latest)

spring ore
#

Hi there ๐Ÿ‘‹ I've created a thread for this, feel free to ask your question here.

steel ledge
#

Hey Toby

#

I have a question Im using webhook right now in my localhost

#

So I use ngrok to simulate that is online, I make the stripe listen --forward-to ...

#

and it works perfectly with ther events

#

my question is, in order to make this work in my production enviroment

#

I need to instal CLI stripe on my server or I just run that command on my local host

#

and how do I know that stripe knows whitch is my webhook route and always use that for sending updates

spring ore
#

No, for production you should not be using the CLI to listen for events. You should have an endpoint that you build that is expecting these events and is specifically built to handle them. The CLI is just an option provided to help make testing faster and easier.

steel ledge
#

Go it, so if my CLI is working I can change the keys

#

push to production and follow this

#

to add my endpoint

spring ore
#

If the events are working as expected, and you move your event handling code to an endpoint, then yes you're exactly right. You'll register your endpoint, and then update your event handling code so it uses the signing secret for that endpoint.

steel ledge
#

One Question if a payment intent of a customer didnt pass, the subscription status change?

spring ore
steel ledge
#

thanks that works, what is the event for tracking the subscription status

#

here I need to select the events but I dont see subscription

spring ore
#

They're nested under customer, I think you're looking for customer.subscription.updated

steel ledge
#

thanks! with that and the previous configuration of subs I can handle if is cancel or not

#

and what event I should check if I want to know witch payment intent was refused of witch customer

spring ore
#

payment_intent.payment_failed is a good event to listen for if you want to be notified of payment failures.

#

Subscriptions use our Invoice objects as well, so invoice.payment_failed is also an option. It has a bit more narrow scope than the previous one I mentioned since it only applies to Invoices.

steel ledge
#

but the only problem of the payment intent is that the payment intent object doesnt have the customer ID

#

so I cannot know witch customer has the card problem

proven tartan
#

Hey, Toby had to step out but I am catching up on this thread and can help in a minute

#

If the payment intent is from a subscription, and doesn't have customer populated on it, you can probably get that info via the invoice that the payment intent is from

#

The paymentintent will have an invoice field with and ID like in_123, if you retrieve that invoice you should be able to get any related subscription info

steel ledge
#

Hey Pompey so in order to know with customer his card got refuse or somwthing like that

#

I will need to go Paymentintent->Invoice->Customer ?

#

or there is another way to do it faster

proven tartan
#

Can you tell me more about what info you are looking for on these failures?

steel ledge
#

I just want to have make an alert in my backoffice so if a payment for a subscription fails it will automatically alert us

#

to call our customer before it will automatically cancell the sub

proven tartan
#

Gotcha, invoice.payment_failed should be the event to listen to then. It will have info on the payment and the subscription that you can use

steel ledge
#

got it

#

in this case Im looking at invoice object and is givin me the customer

#

perfect with that I can track my customer