Skip to content

Commit

Permalink
Replace model method with its decorated version
Browse files Browse the repository at this point in the history
  • Loading branch information
sauloperez committed Jun 26, 2020
1 parent 2a84583 commit a091ab2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
6 changes: 5 additions & 1 deletion app/models/spree/payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ def profiles_supported?
end

def create_payment_profile
return unless source.is_a?(CreditCard) && source.number && !source.has_payment_profile?
return unless source.is_a?(CreditCard)
return unless source.try(:save_requested_by_customer?)
return unless source.number || source.gateway_payment_profile_id
return unless source.gateway_customer_profile_id.nil?

payment_method.create_profile(self)
rescue ActiveMerchant::ConnectionError => e
gateway_error e
Expand Down
13 changes: 0 additions & 13 deletions app/models/spree/payment_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,5 @@ module Spree
# The issues the callback fixes are not experienced in OFN:
# if a payment fails on checkout the state "failed" is persisted correctly
def persist_invalid; end

private

def create_payment_profile
return unless source.is_a?(CreditCard)
return unless source.try(:save_requested_by_customer?)
return unless source.number || source.gateway_payment_profile_id
return unless source.gateway_customer_profile_id.nil?

payment_method.create_profile(self)
rescue ActiveMerchant::ConnectionError => e
gateway_error e
end
end
end

0 comments on commit a091ab2

Please sign in to comment.