#blackbearftw_subscription-cancel
1 messages ยท Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- blackbearftw_webhooks, 1 hour ago, 75 messages
๐ 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/1237898600877523037
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I just sat thinking there like okay what happens when a user cancels, won't the status go to cancelled right away?
so I looked it up and that is correct
but I want the customer to be able to still use their subscription for the remaining paid period, this isn't possible if the subscription updated event is fired right away
setting the status to cancelled
so I read the documentation
but I am using a checkout session so I cannot set that property
Why would you create a Subscription with cancel_at_period_end set to true?
That....isn't a subscription at that point
no I mean
in my application I am using the subscription status to see if the user can do the premium actions
as long as its active, they can
but when they cancel mid period
I want them to still be able to use the subscription till the end of the payed period
How are your customer canceling?
How are you configuring the Customer Portal?
You can set the features.subscription_cancel.mode to at_period_ned
just used the tutorial
okay
but to what event should I then listen?
to know that the status is cancel
after the period has ended
or does stripe refire the subscription updated event for that?
Well I would always listen to customer.subscription.updated to keep my records in sync: https://docs.stripe.com/api/events/types#event_types-customer.subscription.updated
But you can also listen for customer.subscription.deleted https://docs.stripe.com/api/events/types#event_types-customer.subscription.deleted
yeah currently I am doing this
else if (stripeEvent.Type == Events.CustomerSubscriptionUpdated)
{
var sub = stripeEvent.Data.Object as Subscription;
var tenant = dbContext.Tenants.FirstOrDefault(t => t.SubscriptionId == sub.Id);
//
if (tenant is not null)
{
tenant.SubscriptionStatus = sub.Status;
await dbContext.SaveChangesAsync();
}
then later I will just be like isSubscriptionActive which just checks that column for having the value active
so I only want to change that column to represent canceled, at the end of the period
otherwise the whole system will take that into effect instantly
so customer.subscription.deleted fires at the end of the subscription, when the period ends and the subscription was cancelled?
Yes. The easiest way to test this to make sure it behaves how you expect is to us Test Clocks: https://docs.stripe.com/billing/testing/test-clocks
That would let you simulate a customer going through this whole process and you could use the Stripe CLI and stripe listen to forward all the webhook events to your local dev machine. I would start there to examine all the events that fire, just to be certain there isn't another event that would work better for your integration
Sorry I should have mentioned, when you use Test clocks it stacks up A LOT of actions that can take a little while to process
yeah alright
Sorry about that!, will do
๐ Happy to hear it ๐