#gagan.suie
1 messages · Page 1 of 1 (latest)
Hi, at a glance, cancellting a subscription at end of period should not trigger invoice.payment_failed event. That event, https://stripe.com/docs/api/events/types#event_types-invoice.payment_failed is sent only when the payment attempt fails.
so how do i change the subscription status of a user in our internal database at the end of a period if they canceled?
You would listen to customer.subscription.deleted event. This event, https://stripe.com/docs/api/events/types#event_types-customer.subscription.deleted will be triggered when the subscirption ends.
will invoice.payment_failed ever trigger before a period ends?
If the payment fails, sure
when does payment retrieval typically occur?
im using the following events for our webhook flow.
invoice.paid: to trigger paid events
customer.subscription.updated: if user changes from paid to free plan, update with cancel_at_period_end.
invoice.payment_failed: if payment fails
customer.subscription.deleted: triggers at the end of a period to change subscription on our end.
What do you mean by 'when does payment retrieval typically occur?'?
when does payment occur for a user that has a subscription
on the 30th of each month?
It depends on the billing cycle anchor, https://stripe.com/docs/api/subscriptions/object#subscription_object-billing_cycle_anchor. I recommend that you test this in test mode using Test Clocks, https://stripe.com/docs/billing/testing/test-clocks
fantastic! thank you
Sure, you can also listen to an event that is sent based on the settings, https://dashboard.stripe.com/settings/billing/automatic for Upcoming renewal events. 'invoice.upcoming', https://stripe.com/docs/api/events/types#event_types-invoice.upcoming can be sent a few days prior to the renewal of the subscription.
I also think this document might be helpful, https://stripe.com/docs/billing/subscriptions/webhooks to learn all the events that could be useful for your use case.
'invoice.upcoming', https://stripe.com/docs/api/events/types#event_types-invoice.upcoming can be sent a few days prior to the renewal of the subscription.
is this even useful if the payment is retrieved before the next period starts?
and if it fails, we cancel their subscription
You can see what upcoming invoices are coming in advance to prepare for keeping payment details up to date. On that same page, you can set Stripe to send remind emails to your customers for upcoming payments as well. If the payment fails, we also have a few settings, under 'Manage failed payments' and can even cancel the subscription programmatically if all reties fails on that invoice. Or as you mentioned, you can cancel it manually.
If you do not have any questions on this, I'm archiving this thread
by default, how many times does a request for payment trigger before canceling, and can i change this setting??
👋 hello! hopping in here since pgskc had to head out
The # of automatic retries for invoices is something that would be managed under the "manage failed payments" section here (https://dashboard.stripe.com/settings/billing/automatic).
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
awesome! last question:
if a user is on paid plan, and switches to free plan at $0. and they remove their card. will that trigger payment failed events?
No, if the user is on a free plan then removing their card would still allow payment to succeed
when a retry payment fails, it triggers the invoice.payment_failed event correct?
Correct