#romaten1_webhooks

1 messages ยท Page 1 of 1 (latest)

stuck patioBOT
#

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

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

dry schooner
#

Hey! Question about subscription cancellation in case of non-payment of invoice. We use two types of subscriptions - monthly paid and annual paid (one-time payment is added via add_invoice_items when creating the subscription). A user can use more than the monthly paid package, in this case usage_records are added to the subscription and when billing_threshold is reached, Stripe creates a new invoice and tries to pay it. In the Billing->Subscriptions->Manage Failed Payments settings, set the "Retry Schedule" value to "Retry up to 4 times within 1 week". And for "Subscription Status" set it to "If all retries for a payment fail, cancel the subscription". This works fine for monthly subscriptions. But for annual subscriptions, we don't want it to cancel the whole subscription - our script often checks unpaid invoices for annual subscriptions, and in 6 days after the invoice is created, if payment fails - it deletes the invoice and stores it in our database. The problem is that Stripe can delete unpaid subscriptions earlier than 7 days after the invoice was created. For example - sub_1QhXAuCYIYr4SWC9NVhFLfkX. Question- how to better control this case through events, or maybe to change the settings of annual subscriptions so that only for this type of subscriptions it will not be deleted in case of non-payment of the invoice

short bloom
#

Why do you delete the invoice?

#

It does sound like you'll likely want to change the dashboard behavior away from "If all retries for a payment fail, cancel the subscription" and handle cancelling the monthly ones once they're out of attempts, so that the annual one can be handled the way you want.

Does that make sense?

dry schooner
#

We set void for invoice for a one-year subscription because we don't want it to be automatically deleted when the invoice is not paid

#

We need for monthly subscriptions current setting "If all retries for a payment fail, cancel the subscription" , but for annual subscription - do nothing

short bloom
#

I didn't realize you could set different behaviour for different terms.

#

Ya, you can't.

#

So the setting is Account-wide.

#

So in your case, where one of your types (annual) need it to not be cancelled automatically by Stripe, you'll need to disable that altogether, and handle the (monthly) cancellations in your app, likely based on events.

dry schooner
#

How can I check than invoice will get payment_failed before 7 days from account settings?

short bloom
#

I don't understand the question?

#

You will be informed when any Invoice payment attempt succeeds or fails via webhook events, and you can use that to decide, right?

dry schooner
#

For example - here was two attempts and may be I can check after first attempt than next will be the last

dry schooner
short bloom
#

It would, yes. But based on the behaviour you want, that doesn't matter - you have to do this yourself.

You can look at next_payment_attempt on an invoice.payment_failed event, and if it's null (or in the past) it won't be re-attempted, so you can cancel it at that point.

dry schooner
#

Okay, great. But is there any way I can set the time between invoice.payment_failed event and subscription deletion?

short bloom
#

Yes, by having your app do it. ๐Ÿ™‚

That's the only way.

dry schooner
#

ok, thanks for help!

short bloom
#

You're welcome. Does the way forward make sense?

dry schooner
#

I will check this ideas, thanks!

short bloom
#

Sounds great - if you have further questions, we're here! ๐Ÿ™‚

stuck patioBOT