#pro-pooja_webhooks

1 messages ¡ Page 1 of 1 (latest)

stuck shaleBOT
#

👋 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/1233397057339789394

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

formal pantherBOT
stray badge
#

hi there!

#

How to maintain the max items count updated
can you clarify what you mean by this?

formal pantherBOT
reef folio
#

Suppose User has this Subscription for 4-Apr to 4-may . 2* Product A + 3* Product B which 2+3 = 5 max total items
User downgrades and the 2* Product A + 2* Product B = 4, though for the current month its max items will be 5.
Now, for the next invoice month 5 may to 4-June , Max items should be 2* Product A + 2* Product B = 4.

acoustic quiver
#

You should be able to update this in your database each time you get an invoice.paid event for each subscription's montly invoice

reef folio
#

what if the user is not paying immediately or card is inactive

acoustic quiver
#

So you want it updated just when the next month's invoice is created?

#

You can do it on invoice.created instead if so

reef folio
#

invoice.created will be triggered when the user is charged immediately,
if total_item > max items for the month then return create_invoice_immediately proration is applied and invoice will be created

#

Is there any event triggered when the new month start for exmple, current subscription is 4 Apr to 4 May, next will start from 5 May to 5 June

acoustic quiver
#

invoice.created and customer.subscription.updated both are generated on subscription cycle

reef folio
#

This events are triggered due to multiple actions , can't identify the source of the triggere.

acoustic quiver
#

If you use customer.subscription.updated you can. You can examine the current_period_start field: https://docs.stripe.com/api/subscriptions/object#subscription_object-current_period_start. And if that's different than what's shown in the event object's previous_attributes: https://docs.stripe.com/api/events/object#event_object-data-previous_attributes you know that it's due to subscription cycle

reef folio
#

How to check this in a single request? I am not getting the idea.

acoustic quiver
#

You check it on your webhook endpoint

#

When you get customer.subscription.updated events sent to your endpoint, check the current_period_start field. If that field shows a different value in the event object's previous_attributes field, you know that the subscription has cycled and you're onto the next month

reef folio
#

For this event id - evt_1P9nElGVCe8mF8QWeKI0uES7, In event object's previous_attributes field there is no current_period_start.

acoustic quiver
#

That means the event wasn't due to subscription cycling

reef folio
#

Okay

acoustic quiver
#

Not the subscription cycling

#

That's the whole point

#

If you don't have current_period_start in previous attributes, you know it didn't change

reef folio
#

Okay, got it.