#ajivrajani_code

1 messages ¡ Page 1 of 1 (latest)

harsh parrotBOT
#

👋 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.

acoustic kettleBOT
#

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.

proper cipher
hallow sky
proper cipher
#

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?

hallow sky
#

The invoice.created event is probably better then. It fires an hour before the Subscription renews

proper cipher
#

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.

hallow sky
#

True, yes

proper cipher
#

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?

hallow sky
#

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

proper cipher
#

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?

hallow sky
#

For subscription.updated yes

proper cipher
#

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 ^

hallow sky
proper cipher
#

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?
hallow sky
#

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

proper cipher
#

Yes, we (our product team) do create subscriptions dated in the future directly on the Stripe console sometimes.

hallow sky
#

Gotcha, yeah so you would just need to account for that in your webhook handler

proper cipher
#

Okay thanks

harsh parrotBOT
proper cipher
#

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.

dusky sage
#

Sure, I'll share your feedback.