A simple Rails app integrated with the Braintree v.zero API using Hosted Fields v2.
See it in action on Heroku.
bundle
- create a Braintree Sandbox
- create a file
.env
in root and add your Braintree API credentials rails s
- open
localhost:5000
in your preferred browser.
- requests a client token from server:
Braintree::ClientToken.generate
- makes a
braintree.setup()
call to configure Hosted Fields - presents a payment form that uses Hosted Fields
- submits a payment method nonce to server
- provides feedback indicating whether transaction was successful or not
- uses payment method nonce to verify the payment method and store it in vault:
Braintree::PaymentMethod.create()
- creates a transaction using this stored payment method:
Braintree::Transaction.sale()