Braintree Express Example
An example Braintree integration for Node in the Express framework.
Setup Instructions
-
Install packages:
npm install
-
Copy the contents of
example.env
into a new file named.env
and fill in your Braintree API credentials. Credentials can be found by navigating to Account > My User > View Authorizations in the Braintree Control Panel. Full instructions can be found on our support site. -
Start the server:
npm start
By default, this runs the app on port
3000
. You can configure the port by setting the environmental variablePORT
.
Running tests
To run unit tests, use npm run test:unit
. These do not require a server and do not make API calls.
To run all tests, run npm test
. This requires the server be up (in a separate shell using npm run dev
or npm start
) to make the relevant API calls to Braintree. npm test
requires that your sandbox Braintree credentials be set up as detailed above.
Testing Transactions
Sandbox transactions must be made with sample credit card numbers, and the response of a Transaction.sale()
call is dependent on the amount of the transaction.
Help
- Found a bug? Have a suggestion for improvement? Want to tell us we're awesome? Submit an issue
- Trouble with your integration? Contact Braintree Support / [email protected]
- Want to contribute? Submit a pull request
Disclaimer
This code is provided as is and is only intended to be used for illustration purposes. This code is not production-ready and is not meant to be used in a production environment. This repository is to be used as a tool to help merchants learn how to integrate with Braintree. Any use of this repository or any of its code in a production environment is highly discouraged.