feat: add update subscription in controller

This commit is contained in:
Tanmay Deep Sharma
2025-11-10 17:42:09 +05:30
parent 4c1a047c94
commit f31666f877
@@ -45,7 +45,22 @@ module Enterprise::Api::V1::Accounts::Concerns::BillingV2
end
def change_pricing_plan
render json: { success: true, message: 'Pricing plan changed.' }
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