#Samwise-subscriptions
1 messages · Page 1 of 1 (latest)
sure - I have a subscriptions that renew, and I want to show when the exact next billing date / time is to the client of the subscription after a renewal.
E.g Your plan renews on 30th March at 9pm
But I don't want to do this lookup on the fly
I want to store this value after the subscription renews, just not sure when is the earliest I can fetch the new billing date / time
as I will be replacing the old value in my subscription db row
Got it! Please give me a few minutes to run some tests.
ta
Actually this is covered in our documentation: https://stripe.com/docs/billing/subscriptions/webhooks#tracking
So we recommend listening to the webhook event invoice.paid to udpate the current_period_end.
Note that the invoice.paid event will contain an invoice object that has a subscription field with the corresponding Subscription ID.
So if I am hearing you right - btw (I am currently using 'invoice.payment_succeeded' event )
As soon as I receive that webhook, if I lookup the subscription ( based on the subscription field in that object ) it will have already renewed and the current_period_end will be the next billing date / time ?
Yes, exactly!
kk cool, will test it locally. That guide is a little ambiguous
Your webhook endpoint updates the customer’s current_period_end timestamp in your database to the appropriate date in the future (plus a day or two for leeway).
By appropriate day in the future, you would still need to look up this 'current_period_end' field on the subscription ( since months like feb are short etc )
Thanks for your help.