fix: re-init subscription items when user ends his trial period (#11616)

This commit is contained in:
Etienne
2025-04-17 13:53:37 +02:00
committed by GitHub
parent 6e7956b990
commit 71dbd1d66b

View File

@ -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<BillingSubscriptionItem>,
) {}
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,