From 6d9a518616e258613a5d0f5103d3afb45fe3f722 Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Fri, 26 Jun 2020 18:06:01 +0200 Subject: [PATCH] Move method from decorator to model --- app/models/spree/payment.rb | 10 +++++++--- app/models/spree/payment_decorator.rb | 10 ---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/models/spree/payment.rb b/app/models/spree/payment.rb index b3976fcb8d..82276d427b 100644 --- a/app/models/spree/payment.rb +++ b/app/models/spree/payment.rb @@ -89,11 +89,15 @@ module Spree end # see https://github.com/spree/spree/issues/981 + # + # Import from future Spree v.2.3.0 d470b31798f37 def build_source return if source_attributes.nil? - if payment_method and payment_method.payment_source_class - self.source = payment_method.payment_source_class.new(source_attributes) - end + return unless payment_method.andand.payment_source_class + + self.source = payment_method.payment_source_class.new(source_attributes) + source.payment_method_id = payment_method.id + source.user_id = order.user_id if order end def actions diff --git a/app/models/spree/payment_decorator.rb b/app/models/spree/payment_decorator.rb index 91b958c159..c333fc531d 100644 --- a/app/models/spree/payment_decorator.rb +++ b/app/models/spree/payment_decorator.rb @@ -60,16 +60,6 @@ module Spree end end - # Import from future Spree v.2.3.0 d470b31798f37 - def build_source - return if source_attributes.nil? - return unless payment_method.andand.payment_source_class - - self.source = payment_method.payment_source_class.new(source_attributes) - source.payment_method_id = payment_method.id - source.user_id = order.user_id if order - end - private def calculate_refund_amount(refund_amount = nil)