dj-stripe

2.10.3 · active · verified Wed Apr 15

dj-stripe seamlessly integrates Stripe payments with Django applications, providing a robust, database-backed representation of Stripe models. It handles webhooks, subscriptions, and customer management out-of-the-box. The current version is 2.10.3, and it maintains an active development pace with frequent minor and major releases.

Warnings

Install

Imports

Quickstart

To get started with dj-stripe, add it to your `INSTALLED_APPS`, configure your Stripe API keys (test and live) in `settings.py`, and include dj-stripe's URLs in your project's `urls.py`. Remember to run `python manage.py migrate` after installation to create the necessary database tables. For webhooks, configure them via the Django admin (since 2.7.0).

import os

# settings.py
INSTALLED_APPS = [
    # ... other apps
    'djstripe',
    # ...
]

STRIPE_LIVE_MODE = False  # Set to True for production
STRIPE_TEST_SECRET_KEY = os.environ.get('STRIPE_TEST_SECRET_KEY', 'sk_test_YOUR_TEST_SECRET_KEY')
STRIPE_LIVE_SECRET_KEY = os.environ.get('STRIPE_LIVE_SECRET_KEY', 'sk_live_YOUR_LIVE_SECRET_KEY')

STRIPE_TEST_PUBLIC_KEY = os.environ.get('STRIPE_TEST_PUBLIC_KEY', 'pk_test_YOUR_TEST_PUBLIC_KEY')
STRIPE_LIVE_PUBLIC_KEY = os.environ.get('STRIPE_LIVE_PUBLIC_KEY', 'pk_live_YOUR_LIVE_PUBLIC_KEY')

# urls.py
from django.urls import path, include

urlpatterns = [
    # ... other paths
    path('djstripe/', include('djstripe.urls', namespace="djstripe")),
    # ...
]

# Run migrations
# python manage.py migrate

view raw JSON →