diff --git a/app/models/spree/payment_method.rb b/app/models/spree/payment_method.rb index 049936c42a..d519e3284a 100644 --- a/app/models/spree/payment_method.rb +++ b/app/models/spree/payment_method.rb @@ -110,23 +110,8 @@ module Spree end def self.clean_name - case name - when "Spree::PaymentMethod::Check" - "Cash/EFT/etc. (payments for which automatic validation is not required)" - when "Spree::Gateway::Migs" - "MasterCard Internet Gateway Service (MIGS)" - when "Spree::Gateway::Pin" - "Pin Payments" - when "Spree::Gateway::StripeConnect" - "Stripe" - when "Spree::Gateway::StripeSCA" - "Stripe SCA" - when "Spree::Gateway::PayPalExpress" - "PayPal Express" - else - i = name.rindex('::') + 2 - name[i..-1] - end + i18n_key = "spree.admin.payment_methods.providers." + name.demodulize.downcase + I18n.t(i18n_key) end private diff --git a/config/locales/en.yml b/config/locales/en.yml index 495a94ea50..c3b846af74 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3431,6 +3431,14 @@ See the %{link} to find out more about %{sitename}'s features and to start using deactivation_warning: "De-activating a payment method can make the payment method disappear from your list. Alternatively, you can hide a payment method from the checkout page by setting the option 'Display' to 'back office only'." providers: provider: "Provider" + check: "Cash/EFT/etc. (payments for which automatic validation is not required)" + migs: "MasterCard Internet Gateway Service (MIGS)" + pin: "Pin Payments" + paypalexpress: "PayPal Express" + stripeconnect: "Stripe" + stripesca: "Stripe SCA" + bogus: "Bogus" + bogussimple: "BogusSimple" payments: source_forms: stripe: diff --git a/spec/models/spree/payment_method_spec.rb b/spec/models/spree/payment_method_spec.rb index 0d9fd451ac..46dc7f4860 100644 --- a/spec/models/spree/payment_method_spec.rb +++ b/spec/models/spree/payment_method_spec.rb @@ -58,14 +58,14 @@ module Spree end it "generates a clean name for known Payment Method types" do - expect(Spree::PaymentMethod::Check.clean_name).to eq("Cash/EFT/etc. (payments for which automatic validation is not required)") - expect(Spree::Gateway::Migs.clean_name).to eq("MasterCard Internet Gateway Service (MIGS)") - expect(Spree::Gateway::Pin.clean_name).to eq("Pin Payments") - expect(Spree::Gateway::PayPalExpress.clean_name).to eq("PayPal Express") - expect(Spree::Gateway::StripeConnect.clean_name).to eq("Stripe") - - # Testing else condition - expect(Spree::Gateway::BogusSimple.clean_name).to eq("BogusSimple") + expect(Spree::PaymentMethod::Check.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.check")) + expect(Spree::Gateway::Migs.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.migs")) + expect(Spree::Gateway::Pin.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.pin")) + expect(Spree::Gateway::PayPalExpress.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.paypalexpress")) + expect(Spree::Gateway::StripeConnect.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.stripeconnect")) + expect(Spree::Gateway::StripeSCA.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.stripesca")) + expect(Spree::Gateway::BogusSimple.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.bogussimple")) + expect(Spree::Gateway::Bogus.clean_name).to eq(I18n.t("spree.admin.payment_methods.providers.bogus")) end it "computes the amount of fees" do