Skip to content

Repository files navigation

Braintree Flask Example

An example Braintree integration for python in the Flask framework.

Warning

Starting September 1, 2026 the Drop-in SDK will move to a deprecated status and we will no longer make any updates to this SDK. Processing will be supported for 1 year after the deprecation date, but you should upgrade immediately to avoid any disruption.

Starting September 1, 2027 the Drop-in SDK will move to an unsupported status and will no longer be supported by Braintree developers or Braintree Support. Processing for unsupported SDKs can be suspended at any time.

Please migrate to Hosted Fields to continue processing and receiving updates.

Setup Instructions

  1. Install requirements:
pip3 install -r requirements.txt
  1. 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.

  2. Start server:

python3 app.py

By default, this runs the app on port 4567. You can configure the port by setting the environmental variable PORT.

Running tests

Unit tests do not make API calls to Braintree and do not require Braintree credentials. You can run this project's unit tests by calling python test_app.py on the command line.

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.

Pro Tips

Help

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.

About

An example Braintree integration for Flask

Resources

Stars

110 stars

Watchers

67 watching

Forks

Releases

Packages

Used by

Contributors

Languages