fix: re-init subscription items when user ends his trial period (#11616)
This commit is contained in:
@ -45,6 +45,8 @@ export class BillingSubscriptionService {
|
|||||||
private readonly stripeCustomerService: StripeCustomerService,
|
private readonly stripeCustomerService: StripeCustomerService,
|
||||||
private readonly twentyConfigService: TwentyConfigService,
|
private readonly twentyConfigService: TwentyConfigService,
|
||||||
private readonly stripeSubscriptionItemService: StripeSubscriptionItemService,
|
private readonly stripeSubscriptionItemService: StripeSubscriptionItemService,
|
||||||
|
@InjectRepository(BillingSubscriptionItem, 'core')
|
||||||
|
private readonly billingSubscriptionItemRepository: Repository<BillingSubscriptionItem>,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getCurrentBillingSubscriptionOrThrow(criteria: {
|
async getCurrentBillingSubscriptionOrThrow(criteria: {
|
||||||
@ -240,6 +242,11 @@ export class BillingSubscriptionService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await this.billingSubscriptionItemRepository.update(
|
||||||
|
{ stripeSubscriptionId: updatedSubscription.id },
|
||||||
|
{ hasReachedCurrentPeriodCap: false },
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
status: getSubscriptionStatus(updatedSubscription.status),
|
status: getSubscriptionStatus(updatedSubscription.status),
|
||||||
hasPaymentMethod: true,
|
hasPaymentMethod: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user