Feature #11531
closedFeature #11348: Integrate stripe subscription module for onboarding companies
Task 3: Automated Past-Due & Grace Period Lockout (Dunning)
Status:
Closed
Priority:
Normal
Assignee:
Target version:
Description
Goal: Protect platform access when recurring payments fail and the grace period expires.
Subtasks
Related issues
Updated by Divya Inapakurthi 7 days ago
- Due date set to 10/15/2026
- Status changed from New to Resolved
- Start date changed from 10/14/2026 to 10/15/2026
- % Done changed from 0 to 100
Automated Past-Due & Grace Period Lockout (Dunning)¶
Implemented automated dunning and access management for subscriptions with payment failures:
1. Grace Period Management
- Configured 7-day grace window (`gracePeriodDays: 7`) with automatic `graceEndsAt` calculation upon payment failure.
- Company Profile reflects remaining grace days and lockout warning (`Auto-Suspend`).
2. Background Dunning Automation
- Implemented `processPastDueGraceExpirations` in tenant billing service:
- Scans hourly for companies in `past_due` status whose `graceEndsAt <= now`.
- Automatically transitions expired accounts to `suspended`.
- Records suspension entry in `saasBillingActionHistory`.
- Dispatches account suspension email with reactivation link.
- Scans hourly for companies in `past_due` status whose `graceEndsAt <= now`.
- Automatically transitions expired accounts to `suspended`.
- Records suspension entry in `saasBillingActionHistory`.
- Dispatches account suspension email with reactivation link.
3. RBAC & Access Enforcement
- Updated `rbac.service.js`:
- Grants full operational POS access while within active grace window (`new Date() <= graceEndsAt`).
- Restricts access with HTTP 403 error once grace period has elapsed or when status is `suspended`.
- Grants full operational POS access while within active grace window (`new Date() <= graceEndsAt`).
- Restricts access with HTTP 403 error once grace period has elapsed or when status is `suspended`.
4. Verification on Tenant divya@yopmail.com
- Tested `past_due` status transition on tenant `6ad07533f1752405cfbccf1b`:
- Status confirmed `past_due`.
- Grace period calculated correctly (5 days remaining).
- Stripe action history logged in `saasBillingActionHistory`.
- Operational access preserved during grace window.
- Status confirmed `past_due`.
- Grace period calculated correctly (5 days remaining).
- Stripe action history logged in `saasBillingActionHistory`.
- Operational access preserved during grace window.
Updated by Divya Inapakurthi 3 days ago
- Target version set to sprint (10/12/2026 - 10/31/2026)
Updated by Divya Inapakurthi about 14 hours ago
- Status changed from Resolved to Closed