From e532c6eea79d41a976155f1ad2a9e943526746e9 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Sun, 26 Oct 2025 18:06:24 +0530 Subject: [PATCH 1/4] fix: correct payment method expiration notification logic --- src/lib/stores/billing.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index d23fa3346..21238936d 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -503,7 +503,11 @@ export async function paymentExpired(org: Organization) { } ] }); - } else if (!expiringNotification && payment.expiryYear <= year && payment.expiryMonth < month) { + } else if ( + !expiringNotification && + payment.expiryYear === year && + payment.expiryMonth === month + 1 + ) { addNotification({ type: 'warning', isHtml: true, @@ -517,6 +521,26 @@ export async function paymentExpired(org: Organization) { } ] }); + } else if ( + !expiredNotification && + !payment.expired && + payment.expiryYear <= year && + payment.expiryMonth < month + ) { + addNotification({ + type: 'error', + isHtml: true, + timeout: 0, + message: expiredMessage, + buttons: [ + { + name: 'Update payment details', + method: () => { + goto(`${base}/account/payments`); + } + } + ] + }); } sessionStorage.setItem('expiredPaymentNotification', 'true'); } From 608bcad8019651443222421cfed6ac7f5dc17d7a Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Sun, 26 Oct 2025 18:11:20 +0530 Subject: [PATCH 2/4] fix: removed redundant notifcation --- src/lib/stores/billing.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 21238936d..84aee8f00 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -521,26 +521,6 @@ export async function paymentExpired(org: Organization) { } ] }); - } else if ( - !expiredNotification && - !payment.expired && - payment.expiryYear <= year && - payment.expiryMonth < month - ) { - addNotification({ - type: 'error', - isHtml: true, - timeout: 0, - message: expiredMessage, - buttons: [ - { - name: 'Update payment details', - method: () => { - goto(`${base}/account/payments`); - } - } - ] - }); } sessionStorage.setItem('expiredPaymentNotification', 'true'); } From 2176587646420c6cc1c66209b139278442899035 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Sun, 26 Oct 2025 18:17:42 +0530 Subject: [PATCH 3/4] fix: code rabbit suggestion --- src/lib/stores/billing.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 84aee8f00..fbbd83072 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -505,8 +505,12 @@ export async function paymentExpired(org: Organization) { }); } else if ( !expiringNotification && - payment.expiryYear === year && - payment.expiryMonth === month + 1 + !payment.expired && + (() => { + const cardExpiry = new Date(payment.expiryYear, payment.expiryMonth, 1); + const nextMonth = new Date(year, month + 1, 1); + return cardExpiry.getTime() === nextMonth.getTime(); + })() ) { addNotification({ type: 'warning', From ea1c3ea8c792a452ab11b110b0bf88fadd9ff7c2 Mon Sep 17 00:00:00 2001 From: Harsh Mahajan <127186841+HarshMN2345@users.noreply.github.com> Date: Sun, 26 Oct 2025 18:35:41 +0530 Subject: [PATCH 4/4] extracted to local variable instead of iife --- src/lib/stores/billing.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index fbbd83072..46134dde3 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -488,6 +488,9 @@ export async function paymentExpired(org: Organization) { const nots = get(notifications); const expiredNotification = nots.some((n) => n.message === expiredMessage); const expiringNotification = nots.some((n) => n.message === expiringMessage); + const cardExpiry = new Date(payment.expiryYear, payment.expiryMonth, 1); + const nextMonth = new Date(year, month + 1, 1); + const isExpiringNextMonth = cardExpiry.getTime() === nextMonth.getTime(); if (payment.expired && !expiredNotification) { addNotification({ type: 'error', @@ -503,15 +506,7 @@ export async function paymentExpired(org: Organization) { } ] }); - } else if ( - !expiringNotification && - !payment.expired && - (() => { - const cardExpiry = new Date(payment.expiryYear, payment.expiryMonth, 1); - const nextMonth = new Date(year, month + 1, 1); - return cardExpiry.getTime() === nextMonth.getTime(); - })() - ) { + } else if (!expiringNotification && !payment.expired && isExpiringNextMonth) { addNotification({ type: 'warning', isHtml: true,