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:
Maikel Linke
2026-02-17 14:07:11 +11:00
parent ce96b58800
commit 303b91af5e
3 changed files with 6 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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