This is a Braintree Hosted Fields integration example in Rails.
-
Download or clone this Github repo
-
In your terminal, navigate to the root directory and type:
bundle install
-
In the root directory, create a new file called
.env
. Copy the contents ofexample.env
into your new.env
file. Insert your Braintree API credentials into.env
. You can find your API credentials by following these steps. -
Start the rails app:
rails s
- The app should be available on
localhost:3000
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.
- Rails v4.2.10 - The web framework used
- Bootstrap v3.3.7 - HTML and CSS framework for styling
- Braintree - Payment functionality