From 91bfc47f01a3ecda435c58c8bd1c5c17215eb88f Mon Sep 17 00:00:00 2001 From: Tanmay Sharma Date: Mon, 24 Nov 2025 19:18:02 +0530 Subject: [PATCH] add change pricing plan view --- .../enterprise/api/v2/billing_controller.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/enterprise/app/controllers/enterprise/api/v2/billing_controller.rb b/enterprise/app/controllers/enterprise/api/v2/billing_controller.rb index 892b6ea10..657ac4ca8 100644 --- a/enterprise/app/controllers/enterprise/api/v2/billing_controller.rb +++ b/enterprise/app/controllers/enterprise/api/v2/billing_controller.rb @@ -42,7 +42,22 @@ class Enterprise::Api::V2::BillingController < Api::BaseController end def change_pricing_plan - raise NotImplementedError, 'Change pricing plan functionality not yet implemented' + service = Enterprise::Billing::V2::ChangePlanService.new(account: @account) + result = service.change_plan( + new_pricing_plan_id: params[:pricing_plan_id], + quantity: params[:quantity]&.to_i + ) + + 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 private