Skip to content
Django + Stripe Made Easy
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
djstripe Handle missing SubscriptionItem.quantity on metered plans Mar 17, 2019
docs
tests Handle missing SubscriptionItem.quantity on metered plans Mar 17, 2019
.editorconfig Update .editorconfig to match tan Dec 6, 2018
.gitignore Clean up gitignore Nov 14, 2018
.travis.yml Update versions - Drop py34, added Django 2.2 Feb 14, 2019
AUTHORS.rst Add myself to dev leads list (at jleclanche's suggestion) Feb 4, 2019
CONTRIBUTING.rst
HISTORY.rst Handle missing SubscriptionItem.quantity on metered plans Mar 17, 2019
LICENSE
MANIFEST.in manifest file fix (#137) Jun 2, 2015
README.rst
makemigrations.py
manage.py Drop lines_after_imports setting from isort Dec 12, 2018
setup.cfg Start 2.0.1 changelog Mar 5, 2019
setup.py
tox.ini Update versions - Drop py34, added Django 2.2 Feb 14, 2019

README.rst

dj-stripe

Build Status

Stripe Models for Django.

Introduction

dj-stripe implements all of the Stripe models, for Django. Set up your webhook and start receiving model updates. You will then have a copy of all the Stripe models available in Django models, no API traffic required!

The full documentation is available here: https://dj-stripe.readthedocs.io/

Features

  • Subscriptions
  • Individual charges
  • Stripe Sources
  • Stripe v2 and v3 support
  • Supports Stripe API 2019-02-19

Requirements

  • Django >= 2.0
  • Python >= 3.4
  • Supports Stripe exclusively. For PayPal, see dj-paypal instead.
  • PostgreSQL engine (recommended): >= 9.4
  • MySQL engine: MariaDB >= 10.2 or MySQL >= 5.7

Quickstart

Install dj-stripe:

pip install dj-stripe

Add djstripe to your INSTALLED_APPS:

INSTALLED_APPS =(
    ...
    "djstripe",
    ...
)

Tell Stripe about the webhook (Stripe webhook docs can be found here) using the full URL of your endpoint from the urls.py step above (e.g. https://example.com/stripe/webhook).

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 = False  # Change to True in production
DJSTRIPE_WEBHOOK_SECRET = "whsec_xxx"  # Get it from the section in the Stripe dashboard where you added the webhook endpoint

Add some payment plans via the Stripe.com dashboard.

Add to urls.py:

path("stripe/", include("djstripe.urls", namespace="djstripe")),

Run the commands:

python manage.py migrate

python manage.py djstripe_init_customers

python manage.py djstripe_sync_plans_from_stripe

Running the Tests

Assuming the tests are run against PostgreSQL:

createdb djstripe
pip install tox
tox

Follows Best Practices

This project follows best practices as espoused in Two Scoops of Django: Best Practices for Django 1.11.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.