mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Most of the time this doesn't get called because source_required: false. But sometimes it [does happen](https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/66329690f4b6380007e8a4f8) I have a feeling that source_required? could be moved to the superclass as payment_source_class.present?. But I don't know enough about this area of the system to try it...
38 lines
812 B
Ruby
38 lines
812 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Spree
|
|
class PaymentMethod
|
|
class Check < Spree::PaymentMethod
|
|
def actions
|
|
%w{capture_and_complete_order void}
|
|
end
|
|
|
|
# Indicates whether its possible to capture the payment
|
|
def can_capture_and_complete_order?(payment)
|
|
['checkout', 'pending'].include?(payment.state)
|
|
end
|
|
|
|
# Indicates whether its possible to void the payment.
|
|
def can_void?(payment)
|
|
payment.state != '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
|