mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Lazy load payment method classes
This avoids any class reloading issues in dev, simplifies most of the code path and opens up for refactoring. The only reason we still load the class is to call `clean_name` on it for the translation key. We can probably do better.
This commit is contained in:
@@ -14,7 +14,7 @@ module Spree
|
||||
Spree::PaymentMethod::Check
|
||||
Spree::Gateway::PayPalExpress
|
||||
Spree::Gateway::StripeSCA
|
||||
}.index_with(&:constantize).freeze
|
||||
}.freeze
|
||||
|
||||
def create
|
||||
force_environment
|
||||
@@ -117,7 +117,7 @@ module Spree
|
||||
end
|
||||
|
||||
def validate_payment_method_provider
|
||||
valid_payment_methods = PAYMENT_METHODS.keys
|
||||
valid_payment_methods = PAYMENT_METHODS
|
||||
return if valid_payment_methods.include?(params[:payment_method][:type])
|
||||
|
||||
flash[:error] = Spree.t(:invalid_payment_provider)
|
||||
@@ -133,13 +133,13 @@ module Spree
|
||||
end
|
||||
|
||||
def load_providers
|
||||
providers = PAYMENT_METHODS.values.sort_by(&:name)
|
||||
providers = PAYMENT_METHODS.sort
|
||||
|
||||
unless show_stripe?
|
||||
providers.reject! { |provider| stripe_provider?(provider) }
|
||||
end
|
||||
|
||||
providers
|
||||
providers.map(&:constantize)
|
||||
end
|
||||
|
||||
# Show Stripe as an option if enabled, or if the
|
||||
@@ -165,7 +165,7 @@ module Spree
|
||||
end
|
||||
|
||||
def stripe_provider?(provider)
|
||||
provider.name.ends_with?("StripeSCA")
|
||||
provider.ends_with?("StripeSCA")
|
||||
end
|
||||
|
||||
def base_params
|
||||
|
||||
Reference in New Issue
Block a user