From fe70db3e878afea124fb84b0cd8b9b0cc9867a77 Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Tue, 10 Dec 2024 16:42:14 +0100 Subject: [PATCH] [PM-12765] Display error when attempting to autoscale canceled subscription (#5132) --- .../Services/Implementations/OrganizationService.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs index eebe76bae..49f339cc9 100644 --- a/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs +++ b/src/Core/AdminConsole/Services/Implementations/OrganizationService.cs @@ -14,6 +14,7 @@ using Bit.Core.Auth.Models.Business; using Bit.Core.Auth.Models.Business.Tokenables; using Bit.Core.Auth.Repositories; using Bit.Core.Auth.UserFeatures.TwoFactorAuth.Interfaces; +using Bit.Core.Billing.Constants; using Bit.Core.Billing.Enums; using Bit.Core.Billing.Extensions; using Bit.Core.Billing.Services; @@ -1324,6 +1325,12 @@ public class OrganizationService : IOrganizationService return (false, $"Seat limit has been reached."); } + var subscription = await _paymentService.GetSubscriptionAsync(organization); + if (subscription?.Subscription?.Status == StripeConstants.SubscriptionStatus.Canceled) + { + return (false, "Cannot autoscale with a canceled subscription."); + } + return (true, failureReason); }