#luke_webhooks

1 messages ยท Page 1 of 1 (latest)

subtle atlasBOT
#

๐Ÿ‘‹ 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/1309087137987170325

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

jaunty kindle
#

๐Ÿ‘‹ happy to help

scarlet light
#

Here's the sequence of events.

  1. User's subscription was cancelled due to failed payments
  2. User added a new payment method
  3. User gets charged

I would have expected a new subscription to be created but it hasn't. How are we meant to handle this?

jaunty kindle
#

yes this is basically related to your dashboard settings

#

you marked the invoice as uncollectible instead of voiding the invoice

scarlet light
#

Oh ok. Is that in revenue recovery?

jaunty kindle
#

please give me a second I'm double checking something

scarlet light
#

Ok

jaunty kindle
#

this is not technically related to your webhooks

#

ok so let me explain what happened here

#

based on your settings, if the payment fails past all retries the subscription will be canceled and the invoice will be marked as uncollectible.
Uncollectible is a payable state though, so your customer would still be able to pay the invoice at that stage even if the subscription is canceled
https://docs.stripe.com/invoicing/overview#invoice-statuses

Learn about the stages of the invoice lifecycle.

#

you have 2 options here and depending on your business model you can choose either one

#

the first option: once you receive customer.subscription.deleted event you can void all non-paid invoices of that subscription, which avoids you dealing with this situation again

#

the second option: you don't change the current behavior, but when you receive a invoice.paid event on a subscription that is already deleted you can create a new subscription and backdate the start_date to the period start of the invoice

#

as for the payment part, you can either credit the customer balance to pay the newly generated invoice or you can add discount or trial period

scarlet light
#

Would it be easier if I leave invoices as past-due rather than marking them as uncollectible?

jaunty kindle
#

same issue if the subscription is cancelled

scarlet light
#

Ok so maybe I can leave the subscription as past-due as well?

jaunty kindle
#

yes that's a 3rd option

#

but this means you want to handle the service fulfillment on your end (when to pause/stop and when to reactivate)

#

in all cases there are cases that you should take into conisderation in your webhooks that you haven't accounted for yet

scarlet light
#

Ok I think I understand. In the first option, if I void all unpaid invoices, the user would be creating a new subscription after updating their payment method then?

#

will I receive a checkout.session.completed because that's what I'm expecting to set the subscription id for the user

jaunty kindle
#

the user would be creating a new subscription after updating their payment method then?
the subscription won't exist anymore and the invoice won't be "payable" anymore

scarlet light
#

Right so they have to go through checkout again. Would they then be treated as a new customer?

jaunty kindle
#

will I receive a checkout.session.completed because that's what I'm expecting to set the subscription id for the user
if they create a new subscription using your Checkout Sessions flow then yes

#

but in all cases I advise you to use invoice.paid instead of checkout.session.completed

#

for everything related to your service providing/fulfillment

scarlet light
#

Ok interesting. I'm not sure how to get the userId from that I cause right now I pass it in the checkout metadata or the subscription metadata. I guess I can get the subscription from the invoice?

#

Have a call right now so might be slow to respond but thanks for your help!

jaunty kindle
#

I guess I can get the subscription from the invoice?
correct