Testing Braintree on Ruby on Rails
I’m using Braintree with a Ruby on Rails app via the braintree_ruby gem.
I needed to test responses in some of my tests. Here’s how I was able to simulate some transactions.
I created a transaction, such as this:
result = Braintree::Transaction.sale( :amount => “100.00”, :payment_method_nonce => nonce_from_the_client )
To simulate different types of transactions, I changed nonce_from_the_client to the different options here putting the string in quotation marks.
result = Braintree::Transaction.sale( :amount => “2000.00”, :payment_method_nonce => “fake-processor-declined-visa-nonce” )