Django + Stripe for Humans
The full documentation is at http://dj-stripe.rtfd.org.
- Subscription management
- Works with Django 1.5, 1.4
- Works with Python 3.3, 2.7, 2.6
- Dead-Easy installation (Done, just needs documentation)
- Single-unit purchases (forthcoming)
Install dj-stripe:
pip install dj-stripe
Add djstripe
to your INSTALLED_APPS
:
INSTALLED_APPS +=(
"djstripe",
)
Add the context processor to your TEMPLATE_CONTEXT_PROCESSORS
:
TEMPLATE_CONTEXT_PROCESSORS +=(
'djstripe.context_processors.djstripe_settings',
)
Add your stripe keys:
STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "<your publishable test key>")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "<your secret test key>")
Add some payment plans:
DJSTRIPE_PLANS = {
"monthly": {
"stripe_plan_id": "pro-monthly",
"name": "Web App Pro ($24.99/month)",
"description": "The monthly subscription plan to WebApp",
"price": 2499, # $24.99
"currency": "usd",
"interval": "month"
},
"yearly": {
"stripe_plan_id": "pro-yearly",
"name": "Web App Pro ($199/year)",
"description": "The annual subscription plan to WebApp",
"price": 19900, # $199.00
"currency": "usd",
"interval": "year"
}
}
Add to the urls.py:
url(r'^payments/', include('djstripe.urls', namespace="djstripe")),
Run the commands:
python manage.py syncdb python manage.py migrate # if you are using South python manage.py djstripe_init_customers python manage.py djstripe_init_plans
Start up the webserver:
pip install -r requirements_text.txt coverage run --source djstripe runtests.py coverage report -m