From deed08ba259f0edefe543c8c981dbc96a24b9354 Mon Sep 17 00:00:00 2001 From: Antoine Moreaux Date: Fri, 19 Sep 2025 15:16:57 +0200 Subject: [PATCH] fix(billing): reenable trial (#14616) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …reation --- .../billing/services/billing-portal.workspace-service.ts | 2 ++ .../billing/stripe/services/stripe-checkout.service.ts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts b/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts index d899763e7ec..acfbdee7eb2 100644 --- a/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts +++ b/packages/twenty-server/src/engine/core-modules/billing/services/billing-portal.workspace-service.ts @@ -101,6 +101,8 @@ export class BillingPortalWorkspaceService { stripeCustomerId: customer?.stripeCustomerId, plan, requirePaymentMethod, + withTrialPeriod: + !isDefined(customer) || customer.billingSubscriptions.length === 0, }); const createdBillingSubscription = diff --git a/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-checkout.service.ts b/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-checkout.service.ts index bce91a6ae91..41066f39cd8 100644 --- a/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-checkout.service.ts +++ b/packages/twenty-server/src/engine/core-modules/billing/stripe/services/stripe-checkout.service.ts @@ -95,6 +95,7 @@ export class StripeCheckoutService { stripeCustomerId, plan = BillingPlanKey.PRO, requirePaymentMethod = false, + withTrialPeriod, }: { user: User; workspace: Pick; @@ -102,6 +103,7 @@ export class StripeCheckoutService { stripeCustomerId?: string; plan?: BillingPlanKey; requirePaymentMethod?: boolean; + withTrialPeriod: boolean; }): Promise { if (!isDefined(stripeCustomerId)) { const stripeCustomer = @@ -128,6 +130,10 @@ export class StripeCheckoutService { workspaceId: workspace.id, plan, }, + ...this.getStripeSubscriptionTrialPeriodConfig( + withTrialPeriod, + requirePaymentMethod, + ), automatic_tax: { enabled: !!requirePaymentMethod }, };