Update logic for setting active subscription status
Broaden the conditions for active subscriptions in the lemon-squeezy-webhook-handler.service. Now, subscriptions that are cancelled but still within their valid period (cancelAtPeriodEnd) are considered active. This helps prevent users from losing access to services until their current subscription period strictly ends.
This commit is contained in:
@@ -331,7 +331,13 @@ export class LemonSqueezyWebhookHandlerService
|
||||
trialStartsAt: number | null;
|
||||
trialEndsAt: number | null;
|
||||
}): UpsertSubscriptionParams {
|
||||
const active = params.status === 'active' || params.status === 'trialing';
|
||||
const canceledAtPeriodEnd =
|
||||
params.status === 'cancelled' && params.cancelAtPeriodEnd;
|
||||
|
||||
const active =
|
||||
params.status === 'active' ||
|
||||
params.status === 'trialing' ||
|
||||
canceledAtPeriodEnd;
|
||||
|
||||
const lineItems = params.lineItems.map((item) => {
|
||||
const quantity = item.quantity ?? 1;
|
||||
|
||||
Reference in New Issue
Block a user