在Spree和Ruby on Rails上覆盖Braintree信用卡错误消息

时间:2014-10-30 16:19:17

标签: ruby-on-rails ruby spree braintree braintree-rails

每当用户在结帐时输入空字符串时,会闪烁以下错误消息:

Credit card number is required. (81714)

我想展示:

而不是向用户展示
Credit card number is needed to process your order.

我相信代码在这里:https://github.com/braintree/braintree_ruby/blob/master/lib/braintree/error_codes.rb

简化代码:

module Braintree
  module ErrorCodes
    module CreditCard
      NumberIsRequired = "81714"
     end
  end
end

尝试使用以下装饰器

Braintree::ErrorCodes::CreditCard.class_eval do
  NumberIsRequired = "We need a credit card to process your order"
end

这是实现这一目标的正确方法吗?是braintree在其他地方存储错误?

我正在使用rails 3和Spree 1.3

提前感谢您的帮助!

0 个答案:

没有答案