From 277d7f44b7ed2a32e1389ceee4301581f30d8ff0 Mon Sep 17 00:00:00 2001 From: Andy Brett Date: Thu, 19 Nov 2020 13:49:47 -0800 Subject: [PATCH] refactor api customers controller; resolve merge conflict --- app/controllers/api/customers_controller.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/customers_controller.rb b/app/controllers/api/customers_controller.rb index 33ac9d403d..7cb702a824 100644 --- a/app/controllers/api/customers_controller.rb +++ b/app/controllers/api/customers_controller.rb @@ -14,24 +14,24 @@ module Api client_secret = RecurringPayments.setup_for(@customer) if params[:customer][:allow_charges] if @customer.update(customer_params) - add_recurring_payment_info(@customer, client_secret) + add_recurring_payment_info(client_secret) render json: @customer, serializer: CustomerSerializer, status: :ok else invalid_resource!(@customer) end end + private + + def add_recurring_payment_info(client_secret) + return unless client_secret + + @customer.gateway_recurring_payment_client_secret = client_secret + @customer.gateway_shop_id = @customer.enterprise.stripe_account&.stripe_user_id + end + def customer_params params.require(:customer).permit(:code, :email, :enterprise_id, :allow_charges) end - - private - - def add_recurring_payment_info(customer, client_secret) - return unless client_secret - - customer.gateway_recurring_payment_client_secret = client_secret - customer.gateway_shop_id = customer.enterprise.stripe_account&.stripe_user_id - end end end