Braintree Hosted Fields

This is a Braintree Hosted Fields integration example in PHP.

Setup

  1. Download or clone this Github repo

  2. If you have not installed Composer globally, user your terminal to navigate to the root directory and type:

php composer.phar install

Otherwise, simply use:

composer install
  1. In the root directory, Composer should have created a new file called .env. If not, 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 PHP app:

php bin/console server:run
  1. The app should be available on localhost:8000

Testing

When creating transaction, 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 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