#Chhay-webhooks
1 messages ยท Page 1 of 1 (latest)
but this event will trigger as well when we switching from one plan to another, or changing the status from trial to active, right?
so Is it safe to listen this event?
I have checked some tutorial
and saw this notice
Yes that is true... it really just depends on what you are looking to do exactly. I assumed you would only be updating when the Sub changed status.
So you would ignore the events if the status was the same
You want StartAt & EndAt of the Subscription, not each individual billing period, correct?
what I am looking for is to update the startAt & endAt in the DB whenever User has been paid successfully.
Oh okay so you want the billing period itself
That is a bit different
You can listen for invoice.paid in that case to only update on successful payment.
but when I looking at the fields in Invoice Object, there is no "current_period_end" & "current_period_start".
It has only fields "period_start" & "period_end" where the value are the same.
Upon an invoice.paid event you would retrieve the Subscription and look at the current_period_end and current_period_start which will be the new period at that point.
Do you mean we need to look at
object.lines.data[0].period.start
object.lines.data[0].period.end
right?
here is the invoice.paid object
or we need to get the subscription ID from "invoice.paid" and call Stripe API to get Subscription Detail by ID?
Hello. Taking over for bismarck as they have to step out. Give me a moment to catch up
Is he got headache? ๐
Ah no we all rotate ๐
Oh thanks God!
So I believe you can use the end and start values on that line item as well
I recommend retrieving the subscription to check the values there as well to make sure they match, but they should just be the same
when you talk about "retrieving the subscription"
does it mean we need to call Stripe API to get Subscription Detail by ID?
Yeah because that's where current_period_end and current_period_start are located
They should match what's on that line item above
If so, it would be increase the waiting time at the server.
Yeah I don't beleive you have to do it
Just suggesting you do it to verify the details match
As I remember, we need to return the response as soon as possible after we received the webhook.
When you are recommend me to double check, I feel like that the value in the Line Item is not so accurate.
Just saying that because I don't know the answer off the top of my head
You should be able to trust it as long as there aren't multiple line items
Yep! Go for it
what is the different between
payment_intent.succeeded
invoice.payment_succeeded
invoice.paid
```?
when recurring happen does these 3 events trigger?
and when the customer subscription expired, which event should we listen in order to update some data (like user subscription status, update the user roles...etc) in DB?
Those 3 events get triggered on successful subscription payment. Subscriptions generate both invoices and paymentintent objects, that's why
What do you mean by subscription expired?
Like if a user cancels the subscription?
Or if a payment failed?
yes
Which one?
both of them
user cancels the subscription
and payment failed
Gotcha. Take a look at this link that has a complete list of events you should consider listening to with subscriptions: https://stripe.com/docs/billing/subscriptions/webhooks#events
thank you boss
No problem!
have a lovely day
Same to you!