The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(billing) - Suspend workspace at trial period end if cancelation is planned (#21363)
Etienne7530775dc1e9
diff --git a/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-subscription.service.ts b/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-subscription.service.tsindex a78c98c0edd..e3d9f904c6f 100644--- a/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-subscription.service.ts+++ b/packages/twenty-server/src/engine/core-modules/billing-webhook/services/billing-webhook-subscription.service.ts@@ -197,7 +197,6 @@ export class BillingWebhookSubscriptionService {const suspendedStatuses = [SubscriptionStatus.Canceled,SubscriptionStatus.Unpaid,- SubscriptionStatus.Paused, // TODO: remove this once paused subscriptions are deprecated];if (suspendedStatuses.includes(status)) {@@ -208,7 +207,16 @@ export class BillingWebhookSubscriptionService {const hasTrialJustEnded =timeSinceTrialEnd > 0 && timeSinceTrialEnd < 60 * 60 * 24;- return hasTrialJustEnded && status === SubscriptionStatus.PastDue;+ const canceledDuringTrial =+ data.object.cancel_at_period_end &&+ isDefined(data.object.canceled_at) &&+ isDefined(data.object.trial_end) &&+ data.object.canceled_at <= data.object.trial_end;++ return (+ hasTrialJustEnded &&+ (status === SubscriptionStatus.PastDue || canceledDuringTrial)+ );}async updateBillingSubscriptionItems(