Django + Braintree Made Easy
The full documentation is at http://dj-braintree.rtfd.org.
- Subscription management
- Single-unit purchases
- Works with Django ~=1.9.1, 1.8
- Works with Python 3.5, 3.4, 2.7
- Works with Bootstrap 3
- Built-in migrations
- Dead-Easy installation
- djbraintree namespace so you can have more than one payments related app
- Documented
- Tested
- Current API version (2012-11-07), in progress of being updated
- For braintreepayments.com only
- Support the Braintree Marketplace API (for creating ecommerce platforms, vendors and submerchants)
- Only use or support well-maintained third-party libraries
- For modern Python and Django
Install dj-braintree:
pip install dj-braintree
Add djbraintree
to your INSTALLED_APPS
:
INSTALLED_APPS +=(
"djbraintree",
)
Add your Braintree keys:
BRAINTREE_PUBLIC_KEY = os.environ.get("BRAINTREE_PUBLIC_KEY", "<your publishable key>")
BRAINTREE_PRIVATE_KEY = os.environ.get("BRAINTREE_PRIVATE_KEY", "<your secret key>")
BRAINTREE_MERCHANT_ID = os.environ.get("BRAINTREE_MERCHANT_ID", "<your merchant ID>")
Add to the urls.py:
url(r'^payments/', include('djbraintree.urls', namespace="djbraintree")),
Run the commands:
python manage.py migrate python manage.py djbraintree_init_customers python manage.py djbraintree_init_plans
If you haven't already, add JQuery and the Bootstrap 3.0.0+ JS and CSS to your base template:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css">
<!-- Latest JQuery (IE9+) -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
Also, if you don't have it already, add a javascript block to your base.html file:
{% block javascript %}{% endblock %}
Assuming the tests are run against PostgreSQL:
createdb djbraintree pip install -r requirements_test.txt python runtests.py
This project follows best practices as espoused in Two Scoops of Django: Best Practices for Django 1.8.
- https://github.com/pydanny/dj-stripe - The project after which dj-braintree is modeled. If you prefer Stripe to handle your payments, start here.