Skip to content
lyang edited this page Mar 17, 2013 · 5 revisions

Braintree Configurations

All Braintree::Configuration can be set through BraintreeRails::Configuration. Those are just simple delegate.

So the following two are exactly the same. Those delegations are provided for your convenience. Feel free to use either one.

BraintreeRails::Configuration.environment = :sandbox
BraintreeRails::Configuration.logger = Logger.new('log/braintree.log')
BraintreeRails::Configuration.merchant_id = ENV['MERCHANT_ID']
BraintreeRails::Configuration.public_key = ENV['PUBLIC_KEY']
BraintreeRails::Configuration.private_key = ENV['PRIVATE_KEY']
Braintree::Configuration.environment = :sandbox
Braintree::Configuration.logger = Logger.new('log/braintree.log')
Braintree::Configuration.merchant_id = ENV['MERCHANT_ID']
Braintree::Configuration.public_key = ENV['PUBLIC_KEY']
Braintree::Configuration.private_key = ENV['PRIVATE_KEY']

BraintreeRails Configurations

In addition to those delegations, there are also some BraintreeRails specific configurations you might want to set.

BraintreeRails::Configuration.mode = BraintreeRails::Configuration::Mode::JS
BraintreeRails::Configuration.require_postal_code = true
BraintreeRails::Configuration.require_street_address = true

mode

  • BraintreeRails::Configuration::Mode::JS (default)

    This is the default mode. Assumes Braintree.js is used on the client side. This mode will not peek into the format of the encrypted data, for example number and cvv in BraintreeRails::CreditCard and BraintreeRails::Transaction. And, encrypted data will be cleared after each create or update.

  • BraintreeRails::Configuration::Mode::S2S

    Unless you have a very rock solid reason to get unencrypted credit card info, you should not use this mode. In this mode, additional validations will be turned on for CreditCard number and cvv, etc. And those sensitive data wont be automatically cleared after API calls.

  • BraintreeRails::Configuration::Mode::TR

    This mode is similar to JS mode, but does not clear sensitive data. You shouldn't have sensitive data in the first place if you implemented TR correctly.

require_postal_code (default true)

  • This is true by default.

    You should require AVS check whenever possible to reduce fraud risk. If set to false, BraintreeRails::Address validation will not require postal_code to be present.

require_street_address (default true)

  • This is true by default.

    You should require AVS check whenever possible to reduce fraud risk. If set to false, BraintreeRails::Address validation will not require street_address to be present.

Clone this wiki locally