mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-12 03:50:22 +00:00
Prevent Stripe-based payment methods that are not linked to a StripeAccount from displaying in the checkout
This commit is contained in:
@@ -2,7 +2,7 @@ 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? }
|
||||
payment_methods.reject!{ |p| p.type.ends_with?("StripeConnect") && stripe_configuration_incomplete?(p) }
|
||||
else
|
||||
payment_methods.reject!{ |p| p.type.ends_with?("StripeConnect") }
|
||||
end
|
||||
@@ -13,5 +13,11 @@ module OpenFoodNetwork
|
||||
def stripe_enabled?
|
||||
Spree::Config.stripe_connect_enabled && Stripe.publishable_key
|
||||
end
|
||||
|
||||
def stripe_configuration_incomplete?(payment_method)
|
||||
return true if payment_method.preferred_enterprise_id.zero?
|
||||
|
||||
payment_method.stripe_account_id.blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user