#jvheaney

1 messages · Page 1 of 1 (latest)

wraith boughBOT
sturdy needle
#

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

bold barn
sturdy needle
#

I do this, but that doesn't verify that the invoice has been paid

bold barn
#

Right but you could listen to both

sturdy needle
#

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

bold barn
#

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

sturdy needle
#

Where can I get more information about that?

bold barn
#

That's from the link I shared

#

At the bottom of the page

sturdy needle
#

Let me give that a shot, do you mind if I take a quick 5 minutes to test it?

bold barn
#

Go for it

wraith boughBOT
sturdy needle
#

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)?

modest grail
#

Hello! I'm taking over and catching up...

sturdy needle
#

Hey Rubeus!

modest grail
#

Yep, any changes to a Subscription object regardless of how they're made will trigger the updated Event.

sturdy needle
#

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?

modest grail
#

Not entirely. In that case you would still get a customer.subscription.updated Event telling you the Subscription has a new pending update.

sturdy needle
#

I see. So how can I verify that the user paid for the update?

modest grail
sturdy needle
#

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?

modest grail
#

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.).

sturdy needle
#

Oh I see, so there's no reason to listen for invoice paid on a subscription update then, is that correct?

modest grail
#

It really depends on your specific use case though, when it comes to which Events you listen for.

sturdy needle
#

That makes sense. I'll give it a go then. I really appreciate your help Rubeus, and the duchess's as well!