#jvheaney
1 messages · Page 1 of 1 (latest)
So I did this, but when the invoice paid webhook is called it still has the old price ID in the object
So they don't end up actually being upgraded on my end
Recommend listening for https://stripe.com/docs/api/events/types#event_types-customer.subscription.updated to tell when the sub's price has changed
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I do this, but that doesn't verify that the invoice has been paid
Right but you could listen to both
I do, and the invoice paid (which should be more important since it verifies payment) overwrites it...
Here is what I see on my end:
Webhook: Customer subscription updated
CUSTOMER: cus_ODhvnXwCuQnylz
Subscription: sub_1NRGViIMivMon7GPC6TbW4I6
Product/price id: price_1NBjnGIMivMon7GPiDDOGO78
Webhook: Invoice PAID
CUSTOMER: cus_ODhvnXwCuQnylz
Product/price id: price_1NBN2uIMivMon7GPidotrPbA
PaymentIntentId: null
Which happens back to back
price_1NBjnGIMivMon7GPiDDOGO78 is what the user wants to upgrade to, and price_1NBN2uIMivMon7GPidotrPbA is the old priceId they are upgrading from
You can combine this behavior with pending updates so that the subscription is only updated if payment succeeds on the new invoice. is an option then
That way you know payment succeeded if the subscription update occurred
Where can I get more information about that?
Let me give that a shot, do you mind if I take a quick 5 minutes to test it?
Go for it
That seems to work, can I rely on it only calling my subscription update webhook if the payment is successful (so I don't need to listen to invoice paid in this case)?
Hello! I'm taking over and catching up...
Hey Rubeus!
Yep, any changes to a Subscription object regardless of how they're made will trigger the updated Event.
If I add this line to my upgrade endpoint, .setPaymentBehavior(SubscriptionUpdateParams.PaymentBehavior.PENDING_IF_INCOMPLETE), then only payments that were successful will call my update webhook
Is that correct?
Not entirely. In that case you would still get a customer.subscription.updated Event telling you the Subscription has a new pending update.
I see. So how can I verify that the user paid for the update?
You can check the status of the Subscription, or you can check the details of pending_update: https://stripe.com/docs/api/subscriptions/object#subscription_object-pending_update
I see the update subscription webhook only gets called once after someone upgrades, so if I listened for status of the subscription object and the payment did not yet go thru, it would have a status of incomplete_expired or something of the like (not active)
So I would still have to wait for an invoice paid webhook call?
In the case of a failed payment that's not true, the update webhook would fire multiple times (once for the failed payment changes, again for a later successful payment, etc.).
Oh I see, so there's no reason to listen for invoice paid on a subscription update then, is that correct?
For the specific use case you mentioned no, you can just listen for Subscription updates. That said, it's typical for a Subscriptions integration to listen for both of those Events and several others: https://stripe.com/docs/billing/subscriptions/overview#subscription-events
It really depends on your specific use case though, when it comes to which Events you listen for.
That makes sense. I'll give it a go then. I really appreciate your help Rubeus, and the duchess's as well!