From 8ff30863ee77f5a84f73e4026ae0b13dea5f9b43 Mon Sep 17 00:00:00 2001 From: Cy Okeke Date: Mon, 28 Apr 2025 12:15:21 +0100 Subject: [PATCH] enable the downgrade of free org --- .../Controllers/OrganizationsController.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Admin/AdminConsole/Controllers/OrganizationsController.cs b/src/Admin/AdminConsole/Controllers/OrganizationsController.cs index cb163f400a..dad5ca8f35 100644 --- a/src/Admin/AdminConsole/Controllers/OrganizationsController.cs +++ b/src/Admin/AdminConsole/Controllers/OrganizationsController.cs @@ -255,6 +255,12 @@ public class OrganizationsController : Controller Seats = organization.Seats }; + if (model.PlanType == PlanType.Free && model.Seats > 2) + { + TempData["Error"] = "Organizations with more than 2 seats cannot be downgraded to the Free plan"; + return RedirectToAction("Edit", new { id }); + } + UpdateOrganization(organization, model); var plan = await _pricingClient.GetPlanOrThrow(organization.PlanType); @@ -484,6 +490,11 @@ public class OrganizationsController : Controller organization.GatewayCustomerId = model.GatewayCustomerId; organization.GatewaySubscriptionId = model.GatewaySubscriptionId; } + + if (model.PlanType == PlanType.Free && organization.GatewaySubscriptionId is not null) + { + organization.GatewaySubscriptionId = null; + } } private async Task HandlePotentialProviderSeatScalingAsync(