1

Whenever the user enters a empty string during checkout, the following error message is flashed:

Credit card number is required. (81714)

Instead of showing that to the user, I would like to show:

Credit card number is needed to process your order.

I believe the code is here: https://github.com/braintree/braintree_ruby/blob/master/lib/braintree/error_codes.rb

Simplified code:

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

Tried with the following decorator without success

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

is this the right approach to accomplish this? is braintree storing the error somewhere else?

I'm on rails 3 and Spree 1.3

Thank you in advance for your help!

neo
  • 4,078
  • 4
  • 25
  • 41
  • I work at Braintree. That file doesn't let you remap the errors, they come back in the response. I'm not sure I understand your question -- why can't you show a custom error? Does Spree automatically map the errors on the object to errors on a form? (I've never used Spree). – agf Nov 03 '14 at 19:24
  • Thank you for your reply, yes, those constants are already initialized. I ended up overriding the Payment class inside Spree, and did something like: if error.message.include?("error_code") then display "my custom message". – neo Nov 03 '14 at 19:32
  • Sounds good. glad you got it figured out. – agf Nov 03 '14 at 20:25

0 Answers0