Search code examples
c#asp.net-core.net-corestripe-payments

How to detect how long since a user's payment failed?


I'm using Stripe to bill monthly for the use of our website.

I figured out how to retrieve the customer's Subscription object. And I can check the Status property for active or trialing to see if it's currently active.

My question is about when it isn't currently active. I don't want to lock the user out immediately. I want to give them time to try and resolve the payment issue.

So, say I want to give them 10 days to resolve it before I lock the user out. Can someone tell me how I could do this? Is there a date somewhere in the Subscription object that tells me how much time has passed since their billing failed, and I could test whether 10 days has passed?


Solution

  • There's no date on the Subscription itself to indicate how many days have passed since the first failed payment attempt on the latest Invoice. I think you probably want to use the smart retries feature to retry failed payments and mark a Subscription as unpaid after all retries fail. This way, you can continue to allow access to your service if a Subscription is in past_due state but block access once it transitions to unpaid.