Braintree Hosted Fields

This is a Braintree Hosted Fields integration example in Rails.

Setup

  1. Download or clone this Github repo

  2. In your terminal, navigate to the root directory and type:

bundle install
  1. In the root directory, create a new file called .env. Copy the contents of example.env into your new .env file. Insert your Braintree API credentials into .env. You can find your API credentials by following these steps.

  2. Start the rails app:

rails s
  1. The app should be available on localhost:3000

Testing

When creating transactions, feel free to use the credit cards referenced in this Braintree developer doc. You can use any future expiration date and any valid CVV. I've included a Postal Code field for card verification through AVS. You can change your AVS or CVV rules to check for gateway rejections. The card number, expiration, CVV, and postal code fields are all Hosted Fields. Cardholder name is tokenized with them in the nonce.

Built With