Django + Stripe Made Easy
The full documentation is at http://dj-stripe.rtfd.org.
- Subscription management
- Designed for easy implementation of post-registration subscription forms
- Single-unit purchases
- Works with Django >= 1.11
- Works with Python 3.6, 3.5, 3.4, 2.7
- Built-in migrations
- Dead-Easy installation
- Leverages the best of the 3rd party Django package ecosystem
- djstripe namespace so you can have more than one payments related app
- Documented
- 100% Tested
- Current API version (2017-06-05), in progress of being updated
- For stripe.com only
- Only use or support well-maintained third-party libraries
- For modern Python and Django
Install dj-stripe:
pip install dj-stripe
Add djstripe
to your INSTALLED_APPS
:
INSTALLED_APPS =(
...
"djstripe",
...
)
Add your Stripe keys and set the operating mode:
STRIPE_LIVE_PUBLIC_KEY = os.environ.get("STRIPE_LIVE_PUBLIC_KEY", "<your publishable key>")
STRIPE_LIVE_SECRET_KEY = os.environ.get("STRIPE_LIVE_SECRET_KEY", "<your secret key>")
STRIPE_TEST_PUBLIC_KEY = os.environ.get("STRIPE_TEST_PUBLIC_KEY", "<your publishable key>")
STRIPE_TEST_SECRET_KEY = os.environ.get("STRIPE_TEST_SECRET_KEY", "<your secret key>")
STRIPE_LIVE_MODE = <True or False>
Add some payment plans via the Stripe.com dashboard or the django ORM.
Add to the urls.py:
url(r'^payments/', include('djstripe.urls', namespace="djstripe")),
Run the commands:
python manage.py migrate python manage.py djstripe_init_customers
Assuming the tests are run against PostgreSQL:
createdb djstripe pip install tox tox
This project follows best practices as espoused in Two Scoops of Django: Best Practices for Django 1.11.