refactor api customers controller; resolve merge conflict

This commit is contained in:
Andy Brett
2020-11-19 13:49:47 -08:00
parent a466886a32
commit 277d7f44b7

View File

@@ -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