At the command line:
$ easy_install dj-stripe
Or, if you have virtualenvwrapper installed:
$ mkvirtualenv dj-stripe $ pip install dj-stripe
Or for development, first fork it and then:
$ git clone https://github.com/<yourname>/dj-stripe/ $ python setup.py develop
Add djstripe
to your INSTALLED_APPS
:
INSTALLED_APPS +=(
"djstripe",
)
Add your stripe keys:
STRIPE_PUBLIC_KEY = os.environ.get("STRIPE_PUBLIC_KEY", "<your publishable key>")
STRIPE_SECRET_KEY = os.environ.get("STRIPE_SECRET_KEY", "<your secret key>")
Add some payment plans:
DJSTRIPE_PLANS = {
"monthly": {
"stripe_plan_id": "pro-monthly",
"name": "Web App Pro ($25/month)",
"description": "The monthly subscription plan to WebApp",
"price": 2500, # $25.00
"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"
}
}
Note
Stripe Plan creation
Not all properties listed in the plans above are used by Stripe - i.e 'description', which is used to display the plans description within specific templates.
Although any arbitrary property you require can be added to each plan listed in DJ_STRIPE_PLANS, only specific properties are used by Stripe. The full list of required and optional arguments can be found here.
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 python manage.py djstripe_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="https://netdna.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://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="https://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 djstripe pip install -r requirements_test.txt python runtests.py