mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-26 05:55:15 +00:00
At closer inspection, almost all logic around which payment actions to display involves only the state of the payment. So I moved the logic there. We now have one list of all possible actions supported by the UX. Then payment methods can declare a list of supported actions. If that's conditional, they can implement the conditions themselves. The payment model itself then still filters the actions based on its state.
28 lines
500 B
Ruby
28 lines
500 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Spree
|
|
class PaymentMethod
|
|
class Check < Spree::PaymentMethod
|
|
def actions
|
|
%w{capture_and_complete_order void}
|
|
end
|
|
|
|
def capture(*_args)
|
|
ActiveMerchant::Billing::Response.new(true, "", {}, {})
|
|
end
|
|
|
|
def void(*_args)
|
|
ActiveMerchant::Billing::Response.new(true, "", {}, {})
|
|
end
|
|
|
|
def payment_source_class
|
|
nil
|
|
end
|
|
|
|
def source_required?
|
|
false
|
|
end
|
|
end
|
|
end
|
|
end
|