Prevent Stripe-based payment methods that are not linked to a StripeAccount from displaying in the checkout

This commit is contained in:
Rob Harrington
2017-09-22 16:24:15 +10:00
parent 7ba99c0fe0
commit 90007d7114
3 changed files with 17 additions and 7 deletions

View File

@@ -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