From 0f133bb2d80e225dc822a3eedc74c2e40e818b74 Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Fri, 24 Apr 2026 08:00:12 -0700 Subject: [PATCH] RE1-T115 Fixing Paddle new sub issue --- .../User/Controllers/SubscriptionController.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Web/Resgrid.Web/Areas/User/Controllers/SubscriptionController.cs b/Web/Resgrid.Web/Areas/User/Controllers/SubscriptionController.cs index b1c3ee0e..c841a7dd 100644 --- a/Web/Resgrid.Web/Areas/User/Controllers/SubscriptionController.cs +++ b/Web/Resgrid.Web/Areas/User/Controllers/SubscriptionController.cs @@ -67,6 +67,17 @@ public SubscriptionController(IDepartmentsService departmentsService, IUsersServ #endregion Private Members and Constructors + private static bool ShouldUsePaddleForSubscriptionFlow(Payment currentPayment, string paddleCustomerId) + { + if (!string.IsNullOrWhiteSpace(paddleCustomerId)) + return true; + + if (currentPayment != null && !currentPayment.IsFreePlan()) + return currentPayment.Method == (int)PaymentMethods.Paddle; + + return Config.PaymentProviderConfig.IsPaddleActive(); + } + [HttpGet] [Authorize] public async Task SelectRegistrationPlan(string discountCode = null) @@ -81,7 +92,7 @@ public async Task SelectRegistrationPlan(string discountCode = nu model.DiscountCode = discountCode; var paddleCustomerId = await _departmentSettingsService.GetPaddleCustomerIdForDepartmentAsync(DepartmentId); - bool isPaddleDepartment = !string.IsNullOrWhiteSpace(paddleCustomerId); + bool isPaddleDepartment = ShouldUsePaddleForSubscriptionFlow(currentPayment, paddleCustomerId); model.IsPaddleDepartment = isPaddleDepartment; model.PaddleEnvironment = Config.PaymentProviderConfig.GetPaddleEnvironment(); model.PaddleClientToken = Config.PaymentProviderConfig.GetPaddleClientToken(); @@ -232,8 +243,7 @@ public async Task Index() model.AddonCost = "0"; var paddleCustomerId = await _departmentSettingsService.GetPaddleCustomerIdForDepartmentAsync(DepartmentId); - bool isPaddleDepartment = !string.IsNullOrWhiteSpace(paddleCustomerId) - || (model.Payment != null && model.Payment.Method == (int)PaymentMethods.Paddle); + bool isPaddleDepartment = ShouldUsePaddleForSubscriptionFlow(model.Payment, paddleCustomerId); model.IsPaddleDepartment = isPaddleDepartment; if (isPaddleDepartment)