diff --git a/app/controllers/split_checkout_controller.rb b/app/controllers/split_checkout_controller.rb index 63ca43a42b..ac3eefad89 100644 --- a/app/controllers/split_checkout_controller.rb +++ b/app/controllers/split_checkout_controller.rb @@ -71,6 +71,7 @@ class SplitCheckoutController < ::BaseController @order.select_shipping_method(params[:shipping_method_id]) @order.update(order_params) + @order.updater.update_totals_and_states validate_current_step! diff --git a/spec/controllers/split_checkout_controller_spec.rb b/spec/controllers/split_checkout_controller_spec.rb index 9d73967e63..e70836fc02 100644 --- a/spec/controllers/split_checkout_controller_spec.rb +++ b/spec/controllers/split_checkout_controller_spec.rb @@ -142,6 +142,34 @@ describe SplitCheckoutController, type: :controller do end end + context "with payment fees" do + let(:payment_method_with_fee) do + create(:payment_method, :flat_rate, amount: "1.23", distributors: [distributor]) + end + let(:checkout_params) do + { + order: { + payments_attributes: [ + { payment_method_id: payment_method_with_fee.id } + ] + } + } + end + + it "applies the fee and updates the order total" do + put :update, params: params + + expect(response).to redirect_to checkout_step_path(:summary) + + order.reload + + expect(order.state).to eq "confirmation" + expect(order.payments.first.adjustment.amount).to eq 1.23 + expect(order.adjustment_total).to eq 1.23 + expect(order.total).to eq order.item_total + order.adjustment_total + end + end + context "with a saved credit card" do let!(:saved_card) { create(:stored_credit_card, user: user) } let(:checkout_params) do