#gabor-period-end-sub
1 messages ยท Page 1 of 1 (latest)
Hello ๐
So your end goal is to check when the current period ends?
Hi @onyx bobcat ๐ , yes, I want to update my db with the new end of the period when plan has changed and successful payment happened.
For example when a user switches from monthly to yearly payment.
Shouldn't you rather use current_period_end property on the subscription itself than looking at the line-items?
https://stripe.com/docs/api/subscriptions/object#subscription_object-current_period_end
gabor-period-end-sub
Well, I experimented with watching for customer.subscription.updated events so that I can rely on the subscription object. But I am not sure how I could make the db update only on successful payment.
On the invoice.paid event, you'd want to retrieve the subscription again and check the current_period_end timestamp
Ah, okay, thank you.
NP! ๐ Happy to help
Do you recommend to do this also when a user just signs up, and when a new cycle happens?
Is this solution more reliable than using the line items?
I am asking because of the double request.
I mean one more request.
So you can certainly just use customer.subscription.updated event as it is sent when the subscription is successfully started, after the payment is confirmed. Also sent whenever a subscription is changed. but in that case you'd need to check if the latest invoice was paid or not
NP! ๐ Good luck
Thanks ๐