#ambi_best-practices

1 messages ¡ Page 1 of 1 (latest)

shell condorBOT
#

👋 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/1331316091095351440

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

tiny gyro
#
 const {
      id: stripeSubscriptionId,
      status: stripeStatus,
      cancel_at_period_end: cancelAtPeriodEnd,
      latest_invoice: latestInvoice,
    } = event.data.object

 if (subscriptionStatus == SubscriptionStatus.pastDue && cancelAtPeriodEnd && latestInvoice != null) {
      await this.stripe.invoices.voidInvoice(latestInvoice)
      await this.stripe.subscriptions.cancel(stripeSubscriptionId, { invoice_now: false })
 }
analog folio
#

Hello! If you're setting it so the Subscription cancels at the end of the period, it's not canceled. Also, the Subscription being canceled doesn't really impact any outstanding Invoices which have already been created. It sounds like when they cancel through the Portal you should void the outstanding Invoices if you no longer want to collect payment: https://docs.stripe.com/api/invoices/void

tiny gyro
#

How would I go about performing the voiding of the invoice?

analog folio
#

I linked you to the API you wold use to void the Invoice.

#

How else can I help?

tiny gyro
#

I sent a code snippet, and I am wondering if the way I implemented it is correct.
Checking on the subscription.updated event, for the following conditions in the if statement

analog folio
#

We can't perform code reviews here or tell you what your code will do when run. You can use test mode to determine if the code you have works as you expect it to or not.

tiny gyro
#

alright

#

thanks

#

its not about the code

#

I am asking I am looking at the correct information provided in the event of the subscrption.updated

#

nevermind

analog folio
#

You're referring to the latest_invoice?

#

If so, that's fine if you only want to void the latest Invoice, but there might be more outstanding Invoices than just the latest one.

tiny gyro
#

true, thanks for that heads up

#

you can close the thread