mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Let people choose which payment methods are available to customers on order cycles
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module OpenFoodNetwork
|
||||
class AvailablePaymentMethodFilter
|
||||
def filter!(payment_methods)
|
||||
if stripe_enabled?
|
||||
payment_methods.to_a.reject! do |payment_method|
|
||||
payment_method.type.ends_with?("StripeSCA") &&
|
||||
stripe_configuration_incomplete?(payment_method)
|
||||
end
|
||||
else
|
||||
payment_methods.to_a.reject! do |payment_method|
|
||||
payment_method.type.ends_with?("StripeSCA")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def stripe_enabled?
|
||||
Spree::Config.stripe_connect_enabled && Stripe.publishable_key
|
||||
end
|
||||
|
||||
def stripe_configuration_incomplete?(payment_method)
|
||||
payment_method.preferred_enterprise_id.nil? ||
|
||||
payment_method.preferred_enterprise_id.zero? ||
|
||||
payment_method.stripe_account_id.blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user