#mayank_sharma.
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- mayank_sharma., 21 minutes ago, 9 messages
You'd write in to support as my colleague mentioned
No, I mentione I will get back with the detailed issue here itself...
Then you can explain your issue without the PDF/files
If you want to share attachements, support is the way to go
Ok sharing here only
Problem Statement: Let's take a scenario where in my platform I have two time intervals which is Monthly and Yearly under both of which we have the Free Plan and Classic Plan (paid). Let's say a customer signs up on our platform and subscribes to the Free Plan First. These are the set of Webhook events triggered by Stripe and sent to us (only the relevant ones are shared here):
customer.created
invoice.created
invoice.finalized
invoice.paid
customer.subscription.created
After this the customer is sucessfully subscribed to the free plan. Now the customer is trying to upgrade the paid plain. These are the series of webhook events that we got from Stripe for the same (only sharing the event names)
invoice.createdinvoice.finalizedcustomer.subscription.updated(Event ID:evt_1O9nQuSEyw5Of2ovGfKmhH9H)- with the new cycle and status as
activewith the attributepending_updateas
- with the new cycle and status as
invoice.has_changedinvoice.paidcustomer.subscription.updated(withpending_updatesasnull, status asactive)
After this the customer is successfully subscribed to our paid plan.
Now comes, the scenario for recurriing renewal of subcriptions. These are the set of events recieved for the same:
invoice.upcoming(1 week before the renewal date)customer.subscription.updated(with status asactive, pending_updates asnull)- When we process this event on our side, we are doing some actions like sending the user emails for succesful renewal as the status coming to us is active and there are no pending updates.
invoice.payment_failedinvoice.updated(with status asopen)invoice.finalizedcustomer.subscription.updatedwith the status aspast_due.
This flow is causing problems in how we process renewals at our end. So our question is why are we getting the customer.subsctiption.updated event with status as active and pending_updates as null before processing the payent/invoice at Stripe's end? Shouldn't it be something like this:
invoice.upcominginvoice.payment_failedinvoice.updatedcustomer.subscription.updatedwithstatusaspast_due.
Well we don't guarantee event ordering: https://stripe.com/docs/webhooks#event-ordering
So your integration can't rely on the order of events recieved
No that's fine, but why are we getting customer.subscription.updated with status as active it should be past_due in the case where even the event ordering is not guaranteed right?
No, we'll always send an initial customer.subscription.updated even at the start of a new billing cycle that reflects the new timestamps and triggers Invoice creation (status will remains the same value here). Only after that do we attempt payment of the invoice and related events that follow (i.e. failure/success)
So then, how do we differentiate these kind of events?
You could look at the previous_attributes hash in the payload, for example