Best Practices

Code vs Text

Most responses from Braintree will include both a code and text. The text is the human-readable description and the code is meant to be consumed programatically. For example, the processor response on transactions has both a code and text.

result.transaction.processor_response_code
#=> "2001"
result.transaction.processor_response_text
#=> "Insufficient Funds"

If you wanted to build some behavior around transactions that were declined due to insufficient funds (for example, asking the users if they would like to only purchase a subset of items in their cart) you would want to check the code rather than the text. The text may vary as we refine it to provide more clarity or additional details, but the codes will remain consistent.

Autocomplete

When building a form that has an input for a credit card number turn off autocomplete so that your customer’s browser won’t save their credit card number.

<form method="POST" action="..." autocomplete="off">