From 71dbd1d66bfe2333f66eb7a19b61fc3a016b87ef Mon Sep 17 00:00:00 2001 From: Etienne <45695613+etiennejouan@users.noreply.github.com> Date: Thu, 17 Apr 2025 13:53:37 +0200 Subject: [PATCH] fix: re-init subscription items when user ends his trial period (#11616) --- .../billing/services/billing-subscription.service.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/twenty-server/src/engine/core-modules/billing/services/billing-subscription.service.ts b/packages/twenty-server/src/engine/core-modules/billing/services/billing-subscription.service.ts index 5e320a269..c5ba4378e 100644 --- a/packages/twenty-server/src/engine/core-modules/billing/services/billing-subscription.service.ts +++ b/packages/twenty-server/src/engine/core-modules/billing/services/billing-subscription.service.ts @@ -45,6 +45,8 @@ export class BillingSubscriptionService { private readonly stripeCustomerService: StripeCustomerService, private readonly twentyConfigService: TwentyConfigService, private readonly stripeSubscriptionItemService: StripeSubscriptionItemService, + @InjectRepository(BillingSubscriptionItem, 'core') + private readonly billingSubscriptionItemRepository: Repository, ) {} async getCurrentBillingSubscriptionOrThrow(criteria: { @@ -240,6 +242,11 @@ export class BillingSubscriptionService { }, ); + await this.billingSubscriptionItemRepository.update( + { stripeSubscriptionId: updatedSubscription.id }, + { hasReachedCurrentPeriodCap: false }, + ); + return { status: getSubscriptionStatus(updatedSubscription.status), hasPaymentMethod: true,