Skip to content

Commit 3e30c89

Browse files
fix(dashboard): show paid-until-date when subscription is cancelled (#9)
Cancellation in this product is not a self-serve action — users revoke their auto-pay mandate at the bank or directly inside Razorpay. That fires subscription.cancelled to us, and our handler stores current_period_end along with the cancelled status. The cancellation email already tells the user "Paid access continues until 2026-05-24" but the in-app banner just said "Cancellation is in progress." — leaving the date as a thing they'd have to re-derive from the email. Banner now reads Paid access continues until May 24, 2026. After that you're back on the free tier. Falls back to the old generic text when current_period_end isn't populated (rare — happens if Razorpay didn't send current_end on the cancel webhook). Date formatted via toLocaleDateString in the visitor's locale. No API change, no schema change, ~10 lines.
1 parent a414e84 commit 3e30c89

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

dashboard.html

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,27 @@ <h2 id="apikey-heading">API token for CLI / agent</h2>
401401
return;
402402
}
403403

404-
// Paid-tier banner is a tight utility strip. Cancellation is intentionally
405-
// NOT self-serve — the support email lives in the footer; users who want
406-
// to cancel will find it and the operator processes the request manually.
404+
// Paid-tier banner is a tight utility strip. Cancellation is NOT a
405+
// self-serve action in this product — the user revokes their auto-pay
406+
// mandate at their bank or in Razorpay, Razorpay fires
407+
// subscription.cancelled to us, our handler stores the cancellation
408+
// along with current_period_end. We display the resulting state.
407409
var variant = status === 'halted' ? 'warn' : 'paid';
408410
var tagText = status === 'halted' ? 'PAYMENT HALTED' : (status === 'cancelled' ? 'CANCELLING' : 'ACTIVE');
411+
// For 'cancelled', show the until-date prominently when we have it —
412+
// matches what the cancellation email already says, so users see the
413+
// same guarantee in-app and don't lose track of when free-tier kicks in.
414+
var periodEndDate = '';
415+
if (plan.current_period_end) {
416+
var d = new Date(plan.current_period_end);
417+
if (!isNaN(d.getTime())) {
418+
periodEndDate = d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
419+
}
420+
}
409421
var subText = status === 'cancelled'
410-
? 'Cancellation is in progress.'
422+
? (periodEndDate
423+
? 'Paid access continues until ' + periodEndDate + '. After that you\'re back on the free tier.'
424+
: 'Cancellation is in progress.')
411425
: (status === 'halted'
412426
? 'Your card was declined. Update it and retry from the pricing page.'
413427
: 'Your plan is active. Resources are permanent.');

0 commit comments

Comments
 (0)