From ac4d721de0aaebcb6edb471bd0ac9e37cb8bde6e Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:51:47 +0100 Subject: [PATCH] Extract #set_payment_amount method --- app/controllers/split_checkout_controller.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index 251d94a8a9..94d61277ef 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -146,14 +146,17 @@ class SplitCheckoutController < ::BaseController payments_attributes: [:payment_method_id] ) - if @order_params[:payments_attributes] - # Set payment amount - @order_params[:payments_attributes].first[:amount] = @order.total - end + set_payment_amount @order_params end + def set_payment_amount + return unless @order_params[:payments_attributes] + + @order_params[:payments_attributes].first[:amount] = @order.total + end + def redirect_to_step case @order.state when "cart", "address", "delivery"