Skip to main content

Django + Stripe made easy

Project description

dj-stripe

Documentation Sponsor dj-stripe

Stripe Models for Django.

Introduction

dj-stripe implements all of the Stripe models, for Django. Set up your webhook endpoint and start receiving model updates. You will then have a copy of all the Stripe models available in Django models, as soon as they are updated!

The full documentation is available on Read the Docs.

Features

  • Stripe Core
  • Stripe Billing
  • Stripe Cards (JS v2) and Sources (JS v3)
  • Payment Methods and Payment Intents (SCA support)
  • Support for multiple accounts and API keys
  • Stripe Connect (partial support)
  • Tested with Stripe API 2020-08-27 (see API versions)

Requirements

  • Django 2.2+
  • Python 3.6+
  • PostgreSQL engine (recommended) 9.5+
  • MySQL engine: MariaDB 10.2+ or MySQL 5.7+
  • SQLite: Not recommended in production. Version 3.26+ required.

Quickstart

Install dj-stripe with pip:

pip install dj-stripe

Or with Poetry (recommended):

poetry add dj-stripe

Add djstripe to your INSTALLED_APPS:

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

Add to urls.py:

path("stripe/", include("djstripe.urls", namespace="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 other settings:

STRIPE_LIVE_SECRET_KEY = os.environ.get("STRIPE_LIVE_SECRET_KEY", "<live secret key>")
STRIPE_TEST_SECRET_KEY = os.environ.get("STRIPE_TEST_SECRET_KEY", "<test 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
DJSTRIPE_USE_NATIVE_JSONFIELD = True  # We recommend setting to True for new installations
DJSTRIPE_FOREIGN_KEY_TO_FIELD = "id"  # Set to `"id"` for all new 2.4+ installations

Add some payment plans via the Stripe.com dashboard.

Run the commands:

python manage.py migrate

python manage.py djstripe_sync_models

See https://dj-stripe.readthedocs.io/en/latest/stripe_elements_js.html for notes about usage of the Stripe Elements frontend JS library.

Running the Tests

Assuming the tests are run against PostgreSQL:

createdb djstripe
pytest

Changelog

See release notes on Read the Docs.

Funding this project

Stripe Logo

You can now become a sponsor to dj-stripe with GitHub Sponsors.

We've been bringing dj-stripe to the world for over 7 years and are excited to be able to start dedicating some real resources to the project.

Your sponsorship helps us keep a team of maintainers actively working to improve dj-stripe and ensure it stays up-to-date with the latest Stripe changes. If you're using dj-stripe in a commercial capacity and have the ability to start a sponsorship, we'd greatly appreciate the contribution.

All contributions through GitHub sponsors flow into our Open Collective, which holds our funds and keeps an open ledger on how donations are spent.

Similar libraries

Project details


Release history Release notifications | RSS feed

This version

2.5.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj-stripe-2.5.1.tar.gz (132.0 kB view details)

Uploaded Source

Built Distribution

dj_stripe-2.5.1-py3-none-any.whl (152.2 kB view details)

Uploaded Python 3

File details

Details for the file dj-stripe-2.5.1.tar.gz.

File metadata

  • Download URL: dj-stripe-2.5.1.tar.gz
  • Upload date:
  • Size: 132.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.5 Linux/5.12.13-arch1-2

File hashes

Hashes for dj-stripe-2.5.1.tar.gz
Algorithm Hash digest
SHA256 e6e55919a5f1790c0c6003f6d182b14a09f7c4b6b5361b92c86055fc26427fb9
MD5 b57942d176b663b55c87e56d1503c5fc
BLAKE2b-256 0599ec12ca0cfd5dbb65f94a487e703ba377a2cf4eb86712ba1b2e736b4c1dfc

See more details on using hashes here.

File details

Details for the file dj_stripe-2.5.1-py3-none-any.whl.

File metadata

  • Download URL: dj_stripe-2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 152.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.7 CPython/3.9.5 Linux/5.12.13-arch1-2

File hashes

Hashes for dj_stripe-2.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31e01fa175f60ab76a166e1628c9beebff8f129910b86283977a4d9ca9528277
MD5 3195295af392f3982132202a5cb63848
BLAKE2b-256 febb2eb4d1a021134e74c1d8ff6647c3a6513f75a4fc149fb7b9820ae591d600

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page