From 3055a7c6f086554bb26e0bdb3d5df9dae26ab434 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Mon, 10 Nov 2025 17:41:17 +0530 Subject: [PATCH] feat: add cancel subscription in controller --- .../api/v1/accounts/concerns/billing_v2.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/enterprise/app/controllers/enterprise/api/v1/accounts/concerns/billing_v2.rb b/enterprise/app/controllers/enterprise/api/v1/accounts/concerns/billing_v2.rb index dc52958bd..d69fc06b3 100644 --- a/enterprise/app/controllers/enterprise/api/v1/accounts/concerns/billing_v2.rb +++ b/enterprise/app/controllers/enterprise/api/v1/accounts/concerns/billing_v2.rb @@ -41,7 +41,19 @@ module Enterprise::Api::V1::Accounts::Concerns::BillingV2 end def cancel_subscription - render json: { success: true, message: 'Subscription cancelled.' } + service = Enterprise::Billing::V2::CancelSubscriptionService.new(account: @account) + result = service.cancel_subscription + + if result[:success] + # Include account ID and updated attributes for frontend store update + @account.reload + render json: result.merge( + id: @account.id, + custom_attributes: @account.custom_attributes + ) + else + render json: { error: result[:message] }, status: :unprocessable_entity + end end def change_pricing_plan