Open n0nick opened 8 years ago
I have seen it also on transactions :
t = card.transactions.build(:amount => amount, :options => {:submit_for_settlement => true})
t.save # is false
t.errors.any? # is false too
This is really dangerous : doing it the rails way, you often check errors, not the result of the save. Thus, you will consider as good some transactions that have been declined !!
When a credit card save fails due to a verification issue, the result includes an empty
errors
object:(see full log.)
When parsing the
Braintree::ErrorResult
object, BraintreeRails only looks at the `errors attribute: persistence.rb#L122.Therefore, in such case, the save fails (returns
false
) but no errors are stored on the object, and there's no relevant error message to show to the user. I've asked Braintree support about this and they said the client code should look into the response object'scredit_card_verification
attribute.Here's an example using Braintree's Sandbox environment, trying to save a credit card number guaranteed to fail (see Unsuccessful credit card verification).