#ajivrajani_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1267544930926985267
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- ajivrajani_code, 4 days ago, 32 messages
- ajivrajani_code, 5 days ago, 43 messages
Unrelated to my previous queries.
If you ctrl+f for renew on this page, it should get you the info you're looking for: https://docs.stripe.com/billing/subscriptions/webhooks#events
Right. This doc pointed me to the subscription.updated event. However, that event is generated in multiple cases not just renewal. I don't want to rely on the upcoming invoice event since that is not at the time of renewal.
Do you have a recommendation on specific attributes that I should be looking for in the subscription.updated event?
The invoice.created event is probably better then. It fires an hour before the Subscription renews
Hmm true. That event is created when we create one-off invoices too though, right? It is not necessarily related to the renewal invoices.
I was wondering if I could look for current_period_start in the previous attributes of the subscription updated event.
True, yes
But I don't have the full breadth of knowledge around when this field would actually be updated. Would it be updated in non-subscription renewal cases?
If there's a Subscription update that results in a new invoice being created (i.e. any update that creates prorations) then obviously those events will also fire, so you mostly just need to look at each subscription.updated Event's previous_attributes hash
That specific attribute will tell you what changed and if there's a new latest_invoice on the Subscription
Ah okay, I didn't think of looking at the latest_invoice field.
So then look for the previous_attributes[latest_invoice] in the subscription event? No need to look for the current_period_start date in that hash?
For subscription.updated yes
Or maybe I can look for reason field on the invoice.created field and see if the invoice is created for subscription_cycle?
ignore please ^
Ah, okay. I mean, there's billing_reason which would work similarly; https://docs.stripe.com/api/invoices/object#invoice_object-billing_reason
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I thought about this but I see this comment on SO:
```If the subscription was created with a billing_cycle_anchor in the future then even if it is the first invoice/payment for the subscription, the billing cycle comes through as subscription_cycle
Can you confirm if the above is true?
That sounds feasible, yes. Though that's kind of an edge-case so it only really applies if you're creating a subscription with a future billing cycle
Yes, we (our product team) do create subscriptions dated in the future directly on the Stripe console sometimes.
Gotcha, yeah so you would just need to account for that in your webhook handler
Okay thanks
Could you take some feedback back to the product team please? I would be nice to have an explicit event/attribute that says "subscription has renewed". I see a LOT of folks on SO/Reddit wanting this behavior as well.
Sure, I'll share your feedback.