mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-12 03:50:22 +00:00
Extract filters for available PMs into service object
This commit is contained in:
17
lib/open_food_network/available_payment_method_filter.rb
Normal file
17
lib/open_food_network/available_payment_method_filter.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module OpenFoodNetwork
|
||||
class AvailablePaymentMethodFilter
|
||||
def filter!(payment_methods)
|
||||
if stripe_enabled?
|
||||
payment_methods.reject!{ |p| p.type.ends_with?("StripeConnect") && p.preferred_enterprise_id.zero? }
|
||||
else
|
||||
payment_methods.reject!{ |p| p.type.ends_with?("StripeConnect") }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def stripe_enabled?
|
||||
Spree::Config.stripe_connect_enabled && Stripe.publishable_key
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user