diff --git a/.rubocop_manual_todo.yml b/.rubocop_manual_todo.yml index 8bb05901273..c698a0febed 100644 --- a/.rubocop_manual_todo.yml +++ b/.rubocop_manual_todo.yml @@ -44,7 +44,6 @@ Metrics/LineLength: - app/controllers/spree/admin/adjustments_controller_decorator.rb - app/controllers/spree/admin/base_controller_decorator.rb - app/controllers/spree/admin/orders_controller_decorator.rb - - app/controllers/spree/admin/payments_controller_decorator.rb - app/controllers/spree/credit_cards_controller.rb - app/controllers/spree/paypal_controller_decorator.rb - app/controllers/stripe/callbacks_controller.rb @@ -364,7 +363,7 @@ Metrics/AbcSize: - app/controllers/spree/admin/orders_controller_decorator.rb - app/controllers/spree/admin/overview_controller.rb - app/controllers/spree/admin/payment_methods_controller.rb - - app/controllers/spree/admin/payments_controller_decorator.rb + - app/controllers/spree/admin/payments_controller.rb - app/controllers/spree/admin/products_controller_decorator.rb - app/controllers/spree/admin/reports_controller_decorator.rb - app/controllers/spree/admin/search_controller_decorator.rb @@ -492,7 +491,6 @@ Metrics/CyclomaticComplexity: - app/controllers/admin/enterprise_fees_controller.rb - app/controllers/admin/enterprises_controller.rb - app/controllers/checkout_controller.rb - - app/controllers/spree/admin/payments_controller_decorator.rb - app/controllers/spree/admin/taxons_controller.rb - app/controllers/spree/orders_controller.rb - app/helpers/checkout_helper.rb @@ -522,7 +520,6 @@ Metrics/PerceivedComplexity: - app/controllers/admin/enterprises_controller.rb - app/controllers/api/variants_controller.rb - app/controllers/checkout_controller.rb - - app/controllers/spree/admin/payments_controller_decorator.rb - app/controllers/spree/admin/taxons_controller.rb - app/controllers/spree/orders_controller.rb - app/helpers/checkout_helper.rb @@ -563,7 +560,7 @@ Metrics/MethodLength: - app/controllers/spree/admin/image_settings_controller.rb - app/controllers/spree/admin/orders/customer_details_controller_decorator.rb - app/controllers/spree/admin/payment_methods_controller.rb - - app/controllers/spree/admin/payments_controller_decorator.rb + - app/controllers/spree/admin/payments_controller.rb - app/controllers/spree/admin/products_controller_decorator.rb - app/controllers/spree/admin/reports_controller_decorator.rb - app/controllers/spree/admin/search_controller_decorator.rb diff --git a/app/controllers/spree/admin/payments_controller.rb b/app/controllers/spree/admin/payments_controller.rb index f607b49beaf..8e2151f86cf 100644 --- a/app/controllers/spree/admin/payments_controller.rb +++ b/app/controllers/spree/admin/payments_controller.rb @@ -18,12 +18,7 @@ def new def create @payment = @order.payments.build(object_params) - if @payment.payment_method.is_a?(Spree::Gateway) && - @payment.payment_method.payment_profiles_supported? && - params[:card].present? && - (params[:card] != 'new') - @payment.source = CreditCard.find_by_id(params[:card]) - end + load_payment_source begin unless @payment.save @@ -71,6 +66,15 @@ def fire private + def load_payment_source + if @payment.payment_method.is_a?(Spree::Gateway) && + @payment.payment_method.payment_profiles_supported? && + params[:card].present? && + (params[:card] != 'new') + @payment.source = CreditCard.find_by_id(params[:card]) + end + end + def object_params if params[:payment] && params[:payment_source] &&