This is a Braintree Hosted Fields integration example in PHP.
-
Download or clone this Github repo
-
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
-
In the root directory, Composer should have created a new file called
.env
. If not, 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 PHP app:
php bin/console server:run
- The app should be available on
localhost:8000
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.