mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-26 05:55:15 +00:00
Move list of payment actions from card to gateway
We currently ask the credit card first which payment actions like "void" it supports. But all the logic is not card specifc. It depends on the payment method which actions it supports. And instead of having two different classes potentially being the source of truth for actions, I prefer leaving that responsibility with exactly one class, the payment method. I'll move the `can_?` methods next.
This commit is contained in:
@@ -63,10 +63,6 @@ module Spree
|
||||
"XXXX-XXXX-XXXX-#{last_digits}"
|
||||
end
|
||||
|
||||
def actions
|
||||
%w{capture_and_complete_order void credit resend_authorization_email}
|
||||
end
|
||||
|
||||
def can_resend_authorization_email?(payment)
|
||||
payment.requires_authorization?
|
||||
end
|
||||
|
||||
@@ -13,6 +13,10 @@ module Spree
|
||||
preference :server, :string, default: 'live'
|
||||
preference :test_mode, :boolean, default: false
|
||||
|
||||
def actions
|
||||
%w{capture_and_complete_order void credit resend_authorization_email}
|
||||
end
|
||||
|
||||
def payment_source_class
|
||||
CreditCard
|
||||
end
|
||||
|
||||
@@ -152,9 +152,9 @@ module Spree
|
||||
end
|
||||
|
||||
def actions
|
||||
return [] unless payment_source.respond_to?(:actions)
|
||||
return [] unless payment_method.respond_to?(:actions)
|
||||
|
||||
payment_source.actions.select do |action|
|
||||
payment_method.actions.select do |action|
|
||||
!payment_source.respond_to?("can_#{action}?") ||
|
||||
payment_source.__send__("can_#{action}?", self)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user