#pro-pooja_webhooks
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/1233397057339789394
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
hi there!
How to maintain the max items count updated
can you clarify what you mean by this?
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.
You should be able to update this in your database each time you get an invoice.paid event for each subscription's montly invoice
what if the user is not paying immediately or card is inactive
So you want it updated just when the next month's invoice is created?
You can do it on invoice.created instead if so
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
invoice.created and customer.subscription.updated both are generated on subscription cycle
This events are triggered due to multiple actions , can't identify the source of the triggere.
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
How to check this in a single request? I am not getting the idea.
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
For this event id - evt_1P9nElGVCe8mF8QWeKI0uES7, In event object's previous_attributes field there is no current_period_start.
That means the event wasn't due to subscription cycling
That event was created as a result of this request: https://dashboard.stripe.com/test/logs/req_o0ESvMfhmrwcz5
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Okay
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
Okay, got it.