#eleanor
1 messages · Page 1 of 1 (latest)
Hey there
Hmm let's back up a second
So your actual question here is: "how do I distinguish what plan a customer changed to on an upgrade/downgrade"?
I guess it's two questions — the first is making sure I understand when we'll receive the type invoiceitem (which I think is just when proration happens?)
Yes that's correct
And then if I am right in my understanding of that, the follow-up question is distinguishing plans; I'm a little worried to do it based on the description since it's described as an "arbitrary string" in the docs so wanted to confirm
ok awesome!! that's great
Or if you add your own invoice item
That wasn't generated by the Subscription's regular renewal
Yes definitely would not use the description to determine plans
You want to use the customer.subscription.updated webhook in this case.
Which will contain previous_attributes
And you can easily compare the plan that is now on the Sub versus what it was before
Ah, nice — yes, that's a much better way of doing things!! Woo!! 🥳
Thanks so much, this is super useful (scrambling to release new billing haha so I really appreciate the fast response)
Happy to help!
One more question here, sorry — will the customer.subscription.updated hook be fired only if billing actually succeeds? We don't want to give people access to features on plan B unless their payment works
Nope
It fires every time anything on the Subscription object changes
So every time a new billing period is reached it will fire
Regardless of whether their payment is successful or not
Then you can check the status of the Subscription to determine whether payment was successful
Or you can listen for the invoice.payment* event
Ah, awesome. So status being active would be the thing to look for there, then (we don't do trials)? that's what I'm seeing in the docs https://stripe.com/docs/api/subscriptions/object#subscription_object-status
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and yeah, we want the niceness of checking for previous plan vs current plan that the customer.subscription.updated hook would give us (I think, based on your earlier message), thus the preference to handle fulfillment for prorations there