dj-stripe Documentation
Release 2.2.3
Alexander Kavanaugh
Feb 25, 2020
Getting Started
1 Contents 3
1.1 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 A note on Stripe API versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 A note on Stripe Elements JS methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4 Checking if a customer has a subscription . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.5 Subscribing a customer to a plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.6 Creating a one-off charge for a customer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.7 Restricting access to only active subscribers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.8 Managing subscriptions and payment sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.9 Creating invoices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.10 Running reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.11 Webhooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.12 Manually syncing data with Stripe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.13 Cookbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.14 Context Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.15 Decorators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.16 Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
1.17 Managers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
1.18 Middleware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
1.19 Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
1.20 Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
1.21 Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
1.22 Contributing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
1.23 Test Fixtures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
1.24 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
1.25 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
1.26 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
1.27 Release Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
2 Constraints 131
Index 133
i
ii
dj-stripe Documentation, Release 2.2.3
ā€¢ Subscription management
ā€¢ Designed for easy implementation of post-registration subscription forms
ā€¢ Single-unit purchases
ā€¢ Works with Django >= 2.1
ā€¢ Works with Python >= 3.5
ā€¢ Built-in migrations
ā€¢ Dead-Easy installation
ā€¢ Leverages the best of the 3rd party Django package ecosystem
ā€¢ djstripe namespace so you can have more than one payments related app
ā€¢ Documented
ā€¢ 100% Tested
Getting Started 1
dj-stripe Documentation, Release 2.2.3
2 Getting Started
CHAPTER 1
Contents
1.1 Installation
1.1.1 Get the distribution
Install dj-stripe:
pip install dj-stripe
1.1.2 Conļ¬guration
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 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>")
(continues on next page)
3
dj-stripe Documentation, Release 2.2.3
(continued from previous page)
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.
Run the commands:
python manage.py migrate
python manage.py djstripe_init_customers
python manage.py djstripe_sync_plans_from_stripe
See https://dj-stripe.readthedocs.io/en/latest/stripe_elements_js.html for notes about usage of the Stripe Elements fron-
tend JS library.
1.1.3 Running Tests
Assuming the tests are run against PostgreSQL:
createdb djstripe
pip install tox
tox
1.2 A note on Stripe API versions
A point that can cause confusion to new users of dj-stripe is that there are several different Stripe API versions in play
at once.
In brief: Donā€™t touch the STRIPE_API_VERSION setting, but donā€™t worry, it doesnā€™t need to match your Stripe
account api version.
See also https://stripe.com/docs/api/versioning
1.2.1 Your Stripe accountā€™s API version
You can ļ¬nd this on your Stripe dashboard labelled ā€œdefaultā€ here: https://dashboard.stripe.com/developers
For new accounts this will be the latest Stripe version. When upgrading version Stripe only allows you to upgrade to
the latest version. See https://stripe.com/docs/upgrades#how-can-i-upgrade-my-api
This is the version used by Stripe when sending webhook data to you (though during webhook processing, dj-stripe re-
fetches the data with its preferred version). Itā€™s also the default version used by the Stripe API, but dj-stripe overrides
the API version when talking to stripe (this override is triggered on import of djstripe.models).
As a result your Stripe account API version is mostly irrelevant, though from time to time we will increase the
minimum supported API version, and itā€™s good practise to regularly upgrade to the latest version with appropriate
testing.
4 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.2.2 Stripeā€™s current latest API version
You can ļ¬nd this on your Stripe dashboard labelled ā€œlatestā€ or in Stripeā€™s API documentation, eg https://stripe.com/
docs/upgrades#api-changelog
This is the version used by new accounts and itā€™s also ā€œtrueā€ internal version of Stripeā€™s API - see https://stripe.com/
blog/api-versioning
1.2.3 dj-stripeā€™s API version
This is the Stripe API version used by dj-stripe in all communication with Stripe, including when processing webhooks
(though webhook data is sent to you by Stripe with your API version, we re-fetch the data with dj-stripeā€™s API version),
this is because the API schema needs to match dj-stripeā€™s Django model schema.
This is deļ¬ned by djstripe.settings.DEFAULT_STRIPE_API_VERSION and can be overridden, though
see the warning about doing this.
1.2.4 dj-stripeā€™s tested version (as mentioned in README)
This is the most recent Stripe account API version used by the maintainers during testing, more recent versions account
versions are probably ļ¬ne though.
1.3 A note on Stripe Elements JS methods
Note: TLDR: If you havenā€™t yet migrated to PaymentIntents, prefer stripe.createSource() over stripe.
createToken() for better compatibility with PaymentMethods.
A point that can cause confusion when integrating Stripe on the web is that there are multiple generations of frontend
JS APIs that use Stripe Elements with stripe js v3.
In descending order of preference these are:
1.3.1 Payment Intents (SCA compliant)
The newest and preferred way of handling payments, which supports SCA compliance (3D secure etc).
See https://stripe.com/docs/payments/payment-intents/web
1.3.2 Charges using stripe.createSource()
This creates Source objects within Stripe, and can be used for various different methods of payment (including, but
not limited to cards), but isnā€™t SCA compliant.
See https://stripe.com/docs/stripe-js/reference#stripe-create-source
The Card Elements Quickstart JS example can be used, except use stripe.createSource instead of stripe.
createToken and the result.source instead of result.token.
See https://github.com/dj-stripe/dj-stripe/blob/master/tests/apps/example/templates/purchase_subscription.html in for
a working example of this.
1.3. A note on Stripe Elements JS methods 5
dj-stripe Documentation, Release 2.2.3
1.3.3 Charges using stripe.createToken()
This predates stripe.createSource, and creates legacy Card objects within Stripe, which have some compati-
bility issues with Payment Methods.
If youā€™re using stripe.createToken, see if you can upgrade to stripe.createSource or ideally to Pay-
ment Intents .
See Card Elements Quickstart JS
1.4 Checking if a customer has a subscription
No content. . . yet
1.5 Subscribing a customer to a plan
For your convenience, dj-stripe provides a djstripe.models.Customer.subscribe() method that will try
to charge the customer immediately unless you specify charge_immediately=False
plan = Plan.objects.get(nickname="one_plan")
customer = Customer.objects.first()
customer.subscribe(plan)
However in some cases djstripe.models.Customer.subscribe() might not support all the arguments
you need for your implementation. When this happens you can just call the ofļ¬cial stripe.Customer.
subscribe().
See this example from tests.apps.example.views.PurchaseSubscriptionView.form_valid
# Create the stripe Customer, by default subscriber Model is User,
# this can be overridden with settings.DJSTRIPE_SUBSCRIBER_MODEL
customer, created = djstripe.models.Customer.get_or_create(subscriber=user)
# Add the source as the customer's default card
customer.add_card(stripe_source)
# Using the Stripe API, create a subscription for this customer,
# using the customer's default payment source
stripe_subscription = stripe.Subscription.create(
customer=customer.id,
items=[{"plan": plan.id}],
billing="charge_automatically",
# tax_percent=15,
api_key=djstripe.settings.STRIPE_SECRET_KEY,
)
# Sync the Stripe API return data to the database,
# this way we don't need to wait for a webhook-triggered sync
subscription = djstripe.models.Subscription.sync_from_stripe_data(
stripe_subscription
)
Note that PaymentMethods can be used instead of Cards/Source by substituting
6 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
# Add the payment method customer's default
customer.add_payment_method(payment_method)
instead of
# Add the source as the customer's default card
customer.add_card(stripe_source)
in the above example. See djstripe.models.Customer.add_payment_method().
1.6 Creating a one-off charge for a customer
No content. . . yet
1.7 Restricting access to only active subscribers
dj-stripe provides three methods to support constraining views to be only accessible to users with active subscriptions:
ā€¢ Middleware approach to constrain entire projects easily.
ā€¢ Class-Based View mixin to constrain individual views.
ā€¢ View decoration to constrain Function-based views.
Warning: anonymous users always raise a ImproperlyConfigured exception.
When anonymous users encounter these components they will raise a django.core.exceptions.
ImproperlyConfigured exception. This is done because dj-stripe is not an authentication system, so it
does a hard error to make it easier for you to catch where content may not be behind authentication systems.
Any project can use one or more of these methods to control access.
1.7.1 Constraining Entire Sites
If you want to quickly constrain an entire site, the djstripe.middleware.
SubscriptionPaymentMiddleware middleware does the following to user requests:
ā€¢ authenticated users are redirected to djstripe.views.SubscribeFormView unless they:
ā€“ have a valid subscription ā€“orā€“
ā€“ are superusers (user.is_superuser==True) ā€“orā€“
ā€“ are staff members (user.is_staff==True).
ā€¢ anonymous users always raise a django.core.exceptions.ImproperlyConfigured exception
when they encounter these systems. This is done because dj-stripe is not an authentication system.
Example:
Step 1: Add the middleware:
1.6. Creating a one-off charge for a customer 7
dj-stripe Documentation, Release 2.2.3
MIDDLEWARE_CLASSES = (
...
'djstripe.middleware.SubscriptionPaymentMiddleware',
...
)
Step 2: Specify exempt URLS:
# sample only - customize to your own needs!
# djstripe pages are automatically exempt!
DJSTRIPE_SUBSCRIPTION_REQUIRED_EXCEPTION_URLS = (
'home',
'about',
"[spam]", # Anything in the dj-spam namespace
)
Using this example any request on this site that isnā€™t on the homepage, about, spam, or djstripe pages is redirected to
djstripe.views.SubscribeFormView.
Note: The extensive list of rules for this feature can be found at https://github.com/dj-stripe/dj-stripe/blob/master/
djstripe/middleware.py.
See also:
ā€¢ Settings
1.7.2 Constraining Class-Based Views
If you want to quickly constrain a single Class-Based View, the djstripe.decorators.
subscription_payment_required decorator does the following to user requests:
ā€¢ authenticated users are redirected to djstripe.views.SubscribeFormView unless they:
ā€“ have a valid subscription ā€“orā€“
ā€“ are superusers (user.is_superuser==True) ā€“orā€“
ā€“ are staff members (user.is_staff==True).
ā€¢ anonymous users always raise a django.core.exceptions.ImproperlyConfigured exception
when they encounter these systems. This is done because dj-stripe is not an authentication system.
Example:
# import necessary Django stuff
from django.http import HttpResponse
from django.views.generic import View
from django.contrib.auth.decorators import login_required
# import the wonderful decorator
from djstripe.decorators import subscription_payment_required
# import method_decorator which allows us to use function
# decorators on Class-Based View dispatch function.
from django.utils.decorators import method_decorator
(continues on next page)
8 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
(continued from previous page)
class MyConstrainedView(View):
def get(self, request,
*
args,
**
kwargs):
return HttpResponse("I like cheese")
@method_decorator(login_required)
@method_decorator(subscription_payment_required)
def dispatch(self,
*
args,
**
kwargs):
return super().dispatch(
*
args,
**
kwargs)
If you are unfamiliar with this technique please read the following documentation here.
1.7.3 Constraining Function-Based Views
If you want to quickly constrain a single Function-Based View, the djstripe.decorators.
subscription_payment_required decorator does the following to user requests:
ā€¢ authenticated users are redirected to djstripe.views.SubscribeFormView unless they:
ā€“ have a valid subscription ā€“orā€“
ā€“ are superusers (user.is_superuser==True) ā€“orā€“
ā€“ are staff members (user.is_staff==True).
ā€¢ anonymous users always raise a django.core.exceptions.ImproperlyConfigured exception
when they encounter these systems. This is done because dj-stripe is not an authentication system.
Example:
# import necessary Django stuff
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse
# import the wonderful decorator
from djstripe.decorators import subscription_payment_required
@login_required
@subscription_payment_required
def my_constrained_view(request):
return HttpResponse("I like cheese")
1.7.4 Donā€™t do this!
Described is an anti-pattern. View logic belongs in views.py, not urls.py.
# DON'T DO THIS!!!
from django.conf.urls import patterns, url
from django.contrib.auth.decorators import login_required
from djstripe.decorators import subscription_payment_required
from contents import views
(continues on next page)
1.7. Restricting access to only active subscribers 9
dj-stripe Documentation, Release 2.2.3
(continued from previous page)
urlpatterns = patterns("",
# Class-Based View anti-pattern
url(
r"^content/$",
# Not using decorators as decorators
# Harder to see what's going on
login_required(
subscription_payment_required(
views.ContentDetailView.as_view()
)
),
name="content_detail"
),
# Function-Based View anti-pattern
url(
r"^content/$",
# Example with function view
login_required(
subscription_payment_required(
views.content_list_view
)
),
name="content_detail"
),
)
1.8 Managing subscriptions and payment sources
1.8.1 Extending subscriptions
Subscription.extend(
*
delta
*
)
Subscriptions can be extended by using the Subscription.extend method, which takes a positive timedelta
as its only property. This method is useful if you want to offer time-cards, gift-cards, or some other external way of
subscribing users or extending subscriptions, while keeping the billing handling within Stripe.
Warning: Subscription extensions are achieved by manipulating the trial_end of the subscription instance,
which means that Stripe will change the status to trialing.
1.9 Creating invoices
No content. . . yet
10 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.9.1 Adding line items to invoices
No content. . . yet
1.10 Running reports
No content. . . yet
1.11 Webhooks
1.11.1 Using webhooks in dj-stripe
dj-stripe comes with native support for webhooks as event listeners.
Events allow you to do things like sending an email to a customer when his payment has failed or trial period is ending.
This is how you use them:
from djstripe import webhooks
@webhooks.handler("customer.subscription.trial_will_end")
def my_handler(event,
**
kwargs):
print("We should probably notify the user at this point")
You can handle all events related to customers like this:
from djstripe import webhooks
@webhooks.handler("customer")
def my_handler(event,
**
kwargs):
print("We should probably notify the user at this point")
You can also handle different events in the same handler:
from djstripe import webhooks
@webhooks.handler("plan", "product")
def my_handler(event,
**
kwargs):
print("Triggered webhook " + event.type)
Warning: In order to get registrations picked up, you need to put them in a module is imported like models.py or
make sure you import it manually.
Webhook event creation and processing is now wrapped in a transaction.atomic() block to better handle
webhook errors. This will prevent any additional database modiļ¬cations you may perform in your custom handler from
being committed should something in the webhook processing chain fail. You can also take advantage of Djangoā€™s
transaction.on_commit() function to only perform an action if the transaction successfully commits (meaning
the Event processing worked):
1.10. Running reports 11
dj-stripe Documentation, Release 2.2.3
from django.db import transaction
from djstripe import webhooks
def do_something():
pass # send a mail, invalidate a cache, fire off a Celery task, etc.
@webhooks.handler("plan", "product")
def my_handler(event,
**
kwargs):
transaction.on_commit(do_something)
1.11.2 Ofļ¬cial documentation
Stripe docs for types of Events: https://stripe.com/docs/api/events/types
Stripe docs for Webhooks: https://stripe.com/docs/webhooks
Django docs for transactions: https://docs.djangoproject.com/en/dev/topics/db/transactions/
#performing-actions-after-commit
1.12 Manually syncing data with Stripe
If youā€™re using dj-stripeā€™s webhook handlers then data will be automatically synced from Stripe to the Django database,
but in some circumstances you may want to manually sync Stripe API data as well.
1.12.1 Command line
You can sync your database with stripe using the manage command djstripe_sync_models, e.g. to populate an
empty database from an existing Stripe account.
With no arguments this will sync all supported models, or a list of models to sync can be provided.
Note that this may be redundant since we recursively sync related objects.
You can manually reprocess events using the management commands djstripe_process_events. By default
this processes all events, but options can be passed to limit the events processed. Note the Stripe API documents a
limitation where events are only guaranteed to be available for 30 days.
1.12.2 In Code
To sync in code, for example if you write to the Stripe API and want to work with the resulting dj-stripe object without
having to wait for the webhook trigger.
This can be done using the classmethod sync_from_stripe_data that exists on all dj-stripe model classes.
E.g. creating a product using the Stripe API, and then syncing the API return data to Django using dj-stripe:
import djstripe.models
import djstripe.settings
import stripe
# stripe API return value is a dict-like object
stripe_data = stripe.Product.create(
api_key=djstripe.settings.STRIPE_SECRET_KEY,
(continues on next page)
12 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
(continued from previous page)
name="Monthly membership base fee",
type="service",
)
# sync_from_stripe_data to save it to the database,
# and recursively update any referenced objects
djstripe_obj = djstripe.models.Product.sync_from_stripe_data(stripe_data)
return djstripe_obj
1.13 Cookbook
This is a list of handy recipes that fall outside the domain of normal usage.
1.13.1 Customer User Model has_active_subscription property
Very useful for working inside of templates or other places where you need to check the subscription status repeatedly.
The cached_property decorator caches the result of has_active_subscription for a object instance, optimizing it for
reuse.
# -
*
- coding: utf-8 -
*
-
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.functional import cached_property
from djstripe.utils import subscriber_has_active_subscription
class User(AbstractUser):
""" Custom fields go here """
def __str__(self):
return self.username
def __unicode__(self):
return self.username
@cached_property
def has_active_subscription(self):
"""Checks if a user has an active subscription."""
return subscriber_has_active_subscription(self)
Usage:
<ul class="actions">
<h2>{{ object }}</h2>
<!-- first use of request.user.has_active_subscription -->
{% if request.user.has_active_subscription %}
<p>
<small>
(continues on next page)
1.13. Cookbook 13
dj-stripe Documentation, Release 2.2.3
(continued from previous page)
<a href="{% url 'things:update' %}">edit</a>
</small>
</p>
{% endif %}
<p>{{ object.description }}</p>
<!-- second use of request.user.has_active_subscription -->
{% if request.user.has_active_subscription %}
<li>
<a href="{% url 'places:create' %}">Add Place</a>
<a href="{% url 'places:list' %}">View Places</a>
</li>
{% endif %}
</ul>
1.13.2 Making individual purchases
On the subscriberā€™s customer object, use the charge method to generate a Stripe charge. In this example, weā€™re using
the user with ID=1 as the subscriber.
from decimal import Decimal
from django.contrib.auth import get_user_model
from djstripe.models import Customer
user = get_user_model().objects.get(id=1)
customer, created = Customer.get_or_create(subscriber=user)
amount = Decimal(10.00)
customer.charge(amount)
Source code for the Customer.charge method is at https://github.com/dj-stripe/dj-stripe/blob/master/djstripe/models.py
1.13.3 REST API
The subscriptions can be accessed through a REST API. Make sure you have Django Rest Framework installed (https:
//github.com/tomchristie/django-rest-framework).
The REST API endpoints require an authenticated user. GET will provide the current subscription of the user. POST
will create a new current subscription. DELETE will cancel the current subscription, based on the settings.
ā€¢ /subscription/ (GET)
ā€“ input
*
None
ā€“ output (200)
*
id (int)
*
created (date)
*
modiļ¬ed (date)
14 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
*
plan (string)
*
quantity (int)
*
start (date)
*
status (string)
*
cancel_at_period_end (boolean)
*
canceled_at (date)
*
current_period_end (date)
*
current_period_start (date)
*
ended_at (date)
*
trial_end (date)
*
trial_start (date)
*
amount (ļ¬‚oat)
*
customer (int)
ā€¢ /subscription/ (POST)
ā€“ input
*
stripe_token (string)
*
plan (string)
*
charge_immediately (boolean, optional) - Does not send an invoice to the Customer immedi-
ately
ā€“ output (201)
*
stripe_token (string)
*
plan (string)
ā€¢ /subscription/ (DELETE)
ā€“ input
*
None
ā€“ Output (204)
*
None
1.14 Context Managers
Last Updated 2018-05-24
1.14.1 Temporary API Version
context_managers.stripe_temporary_api_version(validate=True)
Temporarily replace the global api_version used in stripe API calls with the given value.
The original value is restored as soon as context exits.
1.14. Context Managers 15
dj-stripe Documentation, Release 2.2.3
1.15 Decorators
Last Updated 2018-05-24
1.15.1 Standard Decorators
Payment Required
This couldnā€™t be autodocā€™d for some reason. See djstripe.decorators.subscription_payment_required
1.15.2 Event Handling Decorators
More documentation coming on these soon. For now, see our implementations in djstripe.event_handlers
Speciļ¬c Event(s) Handler
webhooks.handler()
Decorator that registers a function as a webhook handler.
Functions can be registered for event types (e.g. ā€˜customerā€™) or fully qualiļ¬ed event sub-types (e.g. ā€˜cus-
tomer.subscription.deletedā€™).
If an event type is speciļ¬ed, the handler will receive callbacks for ALL webhook events of that type. For
example, if ā€˜customerā€™ is speciļ¬ed, the handler will receive events for ā€˜customer.subscription.createdā€™, ā€˜cus-
tomer.subscription.updatedā€™, etc.
Parameters event_types (str.) ā€“ The event type(s) that should be handled.
All Events Handler
webhooks.handler_all()
Decorator that registers a function as a webhook handler for ALL webhook events.
Handles all webhooks regardless of event type or sub-type.
1.16 Enumerations
Last Updated 2019-09-17
1.16.1 ApiErrorCode
class djstripe.enums.ApiErrorCode
Charge failure error codes.
https://stripe.com/docs/error-codes
account_already_exists = 'account_already_exists'
account_country_invalid_address = 'account_country_invalid_address'
account_invalid = 'account_invalid'
16 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
account_number_invalid = 'account_number_invalid'
alipay_upgrade_required = 'alipay_upgrade_required'
amount_too_large = 'amount_too_large'
amount_too_small = 'amount_too_small'
api_key_expired = 'api_key_expired'
balance_insufficient = 'balance_insufficient'
bank_account_exists = 'bank_account_exists'
bank_account_unusable = 'bank_account_unusable'
bank_account_unverified = 'bank_account_unverified'
bitcoin_upgrade_required = 'bitcoin_upgrade_required'
card_declined = 'card_declined'
charge_already_captured = 'charge_already_captured'
charge_already_refunded = 'charge_already_refunded'
charge_disputed = 'charge_disputed'
charge_exceeds_source_limit = 'charge_exceeds_source_limit'
charge_expired_for_capture = 'charge_expired_for_capture'
choices = (('account_already_exists', 'Account already exists'), ('account_country_invalid_address', 'Account country invalid address'), ('account_invalid', 'Account invalid'), ('account_number_invalid', 'Account number invalid'), ('alipay_upgrade_required', 'Alipay upgrade required'), ('amount_too_large', 'Amount too large'), ('amount_too_small', 'Amount too small'), ('api_key_expired', 'Api key expired'), ('balance_insufficient', 'Balance insufficient'), ('bank_account_exists', 'Bank account exists'), ('bank_account_unusable', 'Bank account unusable'), ('bank_account_unverified', 'Bank account unverified'), ('bitcoin_upgrade_required', 'Bitcoin upgrade required'), ('card_declined', 'Card was declined'), ('charge_already_captured', 'Charge already captured'), ('charge_already_refunded', 'Charge already refunded'), ('charge_disputed', 'Charge disputed'), ('charge_exceeds_source_limit', 'Charge exceeds source limit'), ('charge_expired_for_capture', 'Charge expired for capture'), ('country_unsupported', 'Country unsupported'), ('coupon_expired', 'Coupon expired'), ('customer_max_subscriptions', 'Customer max subscriptions'), ('email_invalid', 'Email invalid'), ('expired_card', 'Expired card'), ('idempotency_key_in_use', 'Idempotency key in use'), ('incorrect_address', 'Incorrect address'), ('incorrect_cvc', 'Incorrect security code'), ('incorrect_number', 'Incorrect number'), ('incorrect_zip', 'ZIP code failed validation'), ('instant_payouts_unsupported', 'Instant payouts unsupported'), ('invalid_card_type', 'Invalid card type'), ('invalid_charge_amount', 'Invalid charge amount'), ('invalid_cvc', 'Invalid security code'), ('invalid_expiry_month', 'Invalid expiration month'), ('invalid_expiry_year', 'Invalid expiration year'), ('invalid_number', 'Invalid number'), ('invalid_source_usage', 'Invalid source usage'), ('invalid_swipe_data', 'Invalid swipe data'), ('invoice_no_customer_line_items', 'Invoice no customer line items'), ('invoice_no_subscription_line_items', 'Invoice no subscription line items'), ('invoice_not_editable', 'Invoice not editable'), ('invoice_upcoming_none', 'Invoice upcoming none'), ('livemode_mismatch', 'Livemode mismatch'), ('missing', 'No card being charged'), ('not_allowed_on_standard_account', 'Not allowed on standard account'), ('order_creation_failed', 'Order creation failed'), ('order_required_settings', 'Order required settings'), ('order_status_invalid', 'Order status invalid'), ('order_upstream_timeout', 'Order upstream timeout'), ('out_of_inventory', 'Out of inventory'), ('parameter_invalid_empty', 'Parameter invalid empty'), ('parameter_invalid_integer', 'Parameter invalid integer'), ('parameter_invalid_string_blank', 'Parameter invalid string blank'), ('parameter_invalid_string_empty', 'Parameter invalid string empty'), ('parameter_missing', 'Parameter missing'), ('parameter_unknown', 'Parameter unknown'), ('parameters_exclusive', 'Parameters exclusive'), ('payment_intent_authentication_failure', 'Payment intent authentication failure'), ('payment_intent_incompatible_payment_method', 'Payment intent incompatible payment method'), ('payment_intent_invalid_parameter', 'Payment intent invalid parameter'), ('payment_intent_payment_attempt_failed', 'Payment intent payment attempt failed'), ('payment_intent_unexpected_state', 'Payment intent unexpected state'), ('payment_method_unactivated', 'Payment method unactivated'), ('payment_method_unexpected_state', 'Payment method unexpected state'), ('payouts_not_allowed', 'Payouts not allowed'), ('platform_api_key_expired', 'Platform api key expired'), ('postal_code_invalid', 'Postal code invalid'), ('processing_error', 'Processing error'), ('product_inactive', 'Product inactive'), ('rate_limit', 'Rate limit'), ('resource_already_exists', 'Resource already exists'), ('resource_missing', 'Resource missing'), ('routing_number_invalid', 'Routing number invalid'), ('secret_key_required', 'Secret key required'), ('sepa_unsupported_account', 'SEPA unsupported account'), ('shipping_calculation_failed', 'Shipping calculation failed'), ('sku_inactive', 'SKU inactive'), ('state_unsupported', 'State unsupported'), ('tax_id_invalid', 'Tax id invalid'), ('taxes_calculation_failed', 'Taxes calculation failed'), ('testmode_charges_only', 'Testmode charges only'), ('tls_version_unsupported', 'TLS version unsupported'), ('token_already_used', 'Token already used'), ('token_in_use', 'Token in use'), ('transfers_not_allowed', 'Transfers not allowed'), ('upstream_order_creation_failed', 'Upstream order creation failed'), ('url_invalid', 'URL invalid'))
country_unsupported = 'country_unsupported'
coupon_expired = 'coupon_expired'
customer_max_subscriptions = 'customer_max_subscriptions'
email_invalid = 'email_invalid'
expired_card = 'expired_card'
idempotency_key_in_use = 'idempotency_key_in_use'
incorrect_address = 'incorrect_address'
incorrect_cvc = 'incorrect_cvc'
incorrect_number = 'incorrect_number'
incorrect_zip = 'incorrect_zip'
instant_payouts_unsupported = 'instant_payouts_unsupported'
invalid_card_type = 'invalid_card_type'
invalid_charge_amount = 'invalid_charge_amount'
invalid_cvc = 'invalid_cvc'
invalid_expiry_month = 'invalid_expiry_month'
invalid_expiry_year = 'invalid_expiry_year'
invalid_number = 'invalid_number'
invalid_source_usage = 'invalid_source_usage'
invalid_swipe_data = 'invalid_swipe_data'
1.16. Enumerations 17
dj-stripe Documentation, Release 2.2.3
invoice_no_customer_line_items = 'invoice_no_customer_line_items'
invoice_no_subscription_line_items = 'invoice_no_subscription_line_items'
invoice_not_editable = 'invoice_not_editable'
invoice_upcoming_none = 'invoice_upcoming_none'
livemode_mismatch = 'livemode_mismatch'
missing = 'missing'
not_allowed_on_standard_account = 'not_allowed_on_standard_account'
order_creation_failed = 'order_creation_failed'
order_required_settings = 'order_required_settings'
order_status_invalid = 'order_status_invalid'
order_upstream_timeout = 'order_upstream_timeout'
out_of_inventory = 'out_of_inventory'
parameter_invalid_empty = 'parameter_invalid_empty'
parameter_invalid_integer = 'parameter_invalid_integer'
parameter_invalid_string_blank = 'parameter_invalid_string_blank'
parameter_invalid_string_empty = 'parameter_invalid_string_empty'
parameter_missing = 'parameter_missing'
parameter_unknown = 'parameter_unknown'
parameters_exclusive = 'parameters_exclusive'
payment_intent_authentication_failure = 'payment_intent_authentication_failure'
payment_intent_incompatible_payment_method = 'payment_intent_incompatible_payment_method'
payment_intent_invalid_parameter = 'payment_intent_invalid_parameter'
payment_intent_payment_attempt_failed = 'payment_intent_payment_attempt_failed'
payment_intent_unexpected_state = 'payment_intent_unexpected_state'
payment_method_unactivated = 'payment_method_unactivated'
payment_method_unexpected_state = 'payment_method_unexpected_state'
payouts_not_allowed = 'payouts_not_allowed'
platform_api_key_expired = 'platform_api_key_expired'
postal_code_invalid = 'postal_code_invalid'
processing_error = 'processing_error'
product_inactive = 'product_inactive'
rate_limit = 'rate_limit'
resource_already_exists = 'resource_already_exists'
resource_missing = 'resource_missing'
routing_number_invalid = 'routing_number_invalid'
secret_key_required = 'secret_key_required'
18 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
sepa_unsupported_account = 'sepa_unsupported_account'
shipping_calculation_failed = 'shipping_calculation_failed'
sku_inactive = 'sku_inactive'
state_unsupported = 'state_unsupported'
tax_id_invalid = 'tax_id_invalid'
taxes_calculation_failed = 'taxes_calculation_failed'
testmode_charges_only = 'testmode_charges_only'
tls_version_unsupported = 'tls_version_unsupported'
token_already_used = 'token_already_used'
token_in_use = 'token_in_use'
transfers_not_allowed = 'transfers_not_allowed'
upstream_order_creation_failed = 'upstream_order_creation_failed'
url_invalid = 'url_invalid'
1.16.2 AccountType
class djstripe.enums.AccountType
choices = (('custom', 'Custom'), ('express', 'Express'), ('standard', 'Standard'))
custom = 'custom'
express = 'express'
standard = 'standard'
1.16.3 BalanceTransactionStatus
class djstripe.enums.BalanceTransactionStatus
available = 'available'
choices = (('available', 'Available'), ('pending', 'Pending'))
pending = 'pending'
1.16.4 BalanceTransactionType
class djstripe.enums.BalanceTransactionType
adjustment = 'adjustment'
advance = 'advance'
advance_funding = 'advance_funding'
application_fee = 'application_fee'
1.16. Enumerations 19
dj-stripe Documentation, Release 2.2.3
application_fee_refund = 'application_fee_refund'
charge = 'charge'
choices = (('adjustment', 'Adjustment'), ('advance', 'Advance'), ('advance_funding', 'Advance funding'), ('application_fee', 'Application fee'), ('application_fee_refund', 'Application fee refund'), ('charge', 'Charge'), ('connect_collection_transfer', 'Connect collection transfer'), ('issuing_authorization_hold', 'Issuing authorization hold'), ('issuing_authorization_release', 'Issuing authorization release'), ('issuing_transaction', 'Issuing transaction'), ('network_cost', 'Network cost'), ('payment', 'Payment'), ('payment_failure_refund', 'Payment failure refund'), ('payment_refund', 'Payment refund'), ('payout', 'Payout'), ('payout_cancel', 'Payout cancellation'), ('payout_failure', 'Payout failure'), ('refund', 'Refund'), ('refund_failure', 'Refund failure'), ('reserve_transaction', 'Reserve transaction'), ('reserved_funds', 'Reserved funds'), ('stripe_fee', 'Stripe fee'), ('stripe_fx_fee', 'Stripe fx fee'), ('tax_fee', 'Tax fee'), ('topup', 'Topup'), ('topup_reversal', 'Topup reversal'), ('transfer', 'Transfer'), ('transfer_cancel', 'Transfer cancel'), ('transfer_refund', 'Transfer refund'), ('validation', 'Validation'))
connect_collection_transfer = 'connect_collection_transfer'
issuing_authorization_hold = 'issuing_authorization_hold'
issuing_authorization_release = 'issuing_authorization_release'
issuing_transaction = 'issuing_transaction'
network_cost = 'network_cost'
payment = 'payment'
payment_failure_refund = 'payment_failure_refund'
payment_refund = 'payment_refund'
payout = 'payout'
payout_cancel = 'payout_cancel'
payout_failure = 'payout_failure'
refund = 'refund'
refund_failure = 'refund_failure'
reserve_transaction = 'reserve_transaction'
reserved_funds = 'reserved_funds'
stripe_fee = 'stripe_fee'
stripe_fx_fee = 'stripe_fx_fee'
tax_fee = 'tax_fee'
topup = 'topup'
topup_reversal = 'topup_reversal'
transfer = 'transfer'
transfer_cancel = 'transfer_cancel'
transfer_refund = 'transfer_refund'
validation = 'validation'
1.16.5 BankAccountHolderType
class djstripe.enums.BankAccountHolderType
choices = (('company', 'Company'), ('individual', 'Individual'))
company = 'company'
individual = 'individual'
20 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.16.6 BankAccountStatus
class djstripe.enums.BankAccountStatus
choices = (('errored', 'Errored'), ('new', 'New'), ('validated', 'Validated'), ('verification_failed', 'Verification failed'), ('verified', 'Verified'))
errored = 'errored'
new = 'new'
validated = 'validated'
verification_failed = 'verification_failed'
verified = 'verified'
1.16.7 BusinessType
class djstripe.enums.BusinessType
choices = (('company', 'Company'), ('individual', 'Individual'))
company = 'company'
individual = 'individual'
1.16.8 CaptureMethod
class djstripe.enums.CaptureMethod
automatic = 'automatic'
choices = (('automatic', 'Automatic'), ('manual', 'Manual'))
manual = 'manual'
1.16.9 CardCheckResult
class djstripe.enums.CardCheckResult
choices = (('fail', 'Fail'), ('pass', 'Pass'), ('unavailable', 'Unavailable'), ('unchecked', 'Unchecked'))
fail = 'fail'
pass_ = 'pass'
unavailable = 'unavailable'
unchecked = 'unchecked'
1.16. Enumerations 21
dj-stripe Documentation, Release 2.2.3
1.16.10 CardBrand
class djstripe.enums.CardBrand
AmericanExpress = 'American Express'
DinersClub = 'Diners Club'
Discover = 'Discover'
JCB = 'JCB'
MasterCard = 'MasterCard'
UnionPay = 'UnionPay'
Unknown = 'Unknown'
Visa = 'Visa'
choices = (('American Express', 'American Express'), ('Diners Club', 'Diners Club'), ('Discover', 'Discover'), ('JCB', 'JCB'), ('MasterCard', 'MasterCard'), ('UnionPay', 'UnionPay'), ('Unknown', 'Unknown'), ('Visa', 'Visa'))
1.16.11 CardFundingType
class djstripe.enums.CardFundingType
choices = (('credit', 'Credit'), ('debit', 'Debit'), ('prepaid', 'Prepaid'), ('unknown', 'Unknown'))
credit = 'credit'
debit = 'debit'
prepaid = 'prepaid'
unknown = 'unknown'
1.16.12 CardTokenizationMethod
class djstripe.enums.CardTokenizationMethod
android_pay = 'android_pay'
apple_pay = 'apple_pay'
choices = (('android_pay', 'Android Pay'), ('apple_pay', 'Apple Pay'))
1.16.13 ChargeStatus
class djstripe.enums.ChargeStatus
choices = (('failed', 'Failed'), ('pending', 'Pending'), ('succeeded', 'Succeeded'))
failed = 'failed'
pending = 'pending'
succeeded = 'succeeded'
22 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.16.14 Conļ¬rmationMethod
class djstripe.enums.ConfirmationMethod
automatic = 'automatic'
choices = (('automatic', 'Automatic'), ('manual', 'Manual'))
manual = 'manual'
1.16.15 CouponDuration
class djstripe.enums.CouponDuration
choices = (('forever', 'Forever'), ('once', 'Once'), ('repeating', 'Multi-month'))
forever = 'forever'
once = 'once'
repeating = 'repeating'
1.16.16 CustomerTaxExempt
class djstripe.enums.CustomerTaxExempt
choices = (('exempt', 'Exempt'), ('none', 'None'), ('reverse', 'Reverse'))
exempt = 'exempt'
none = 'none'
reverse = 'reverse'
1.16.17 DisputeReason
class djstripe.enums.DisputeReason
bank_cannot_process = 'bank_cannot_process'
choices = (('bank_cannot_process', 'Bank cannot process'), ('credit_not_processed', 'Credit not processed'), ('customer_initiated', 'Customer-initiated'), ('debit_not_authorized', 'Debit not authorized'), ('duplicate', 'Duplicate'), ('fraudulent', 'Fraudulent'), ('general', 'General'), ('incorrect_account_details', 'Incorrect account details'), ('insufficient_funds', 'Insufficient funds'), ('product_not_received', 'Product not received'), ('product_unacceptable', 'Product unacceptable'), ('subscription_canceled', 'Subscription canceled'), ('unrecognized', 'Unrecognized'))
credit_not_processed = 'credit_not_processed'
customer_initiated = 'customer_initiated'
debit_not_authorized = 'debit_not_authorized'
duplicate = 'duplicate'
fraudulent = 'fraudulent'
general = 'general'
incorrect_account_details = 'incorrect_account_details'
insufficient_funds = 'insufficient_funds'
1.16. Enumerations 23
dj-stripe Documentation, Release 2.2.3
product_not_received = 'product_not_received'
product_unacceptable = 'product_unacceptable'
subscription_canceled = 'subscription_canceled'
unrecognized = 'unrecognized'
1.16.18 DisputeStatus
class djstripe.enums.DisputeStatus
charge_refunded = 'charge_refunded'
choices = (('charge_refunded', 'Charge refunded'), ('lost', 'Lost'), ('needs_response', 'Needs response'), ('under_review', 'Under review'), ('warning_closed', 'Warning closed'), ('warning_needs_response', 'Warning needs response'), ('warning_under_review', 'Warning under review'), ('won', 'Won'))
lost = 'lost'
needs_response = 'needs_response'
under_review = 'under_review'
warning_closed = 'warning_closed'
warning_needs_response = 'warning_needs_response'
warning_under_review = 'warning_under_review'
won = 'won'
1.16.19 FileUploadPurpose
class djstripe.enums.FileUploadPurpose
choices = (('dispute_evidence', 'Dispute evidence'), ('identity_document', 'Identity document'), ('tax_document_user_upload', 'Tax document user upload'))
dispute_evidence = 'dispute_evidence'
identity_document = 'identity_document'
tax_document_user_upload = 'tax_document_user_upload'
1.16.20 FileUploadType
class djstripe.enums.FileUploadType
choices = (('csv', 'CSV'), ('docx', 'DOCX'), ('jpg', 'JPG'), ('pdf', 'PDF'), ('png', 'PNG'), ('xls', 'XLS'), ('xlsx', 'XLSX'))
csv = 'csv'
docx = 'docx'
jpg = 'jpg'
pdf = 'pdf'
png = 'png'
xls = 'xls'
24 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
xlsx = 'xlsx'
1.16.21 InvoiceBilling
djstripe.enums.InvoiceBilling
alias of djstripe.enums.InvoiceCollectionMethod
1.16.22 IntentUsage
class djstripe.enums.IntentUsage
choices = (('off_session', 'Off session'), ('on_session', 'On session'))
off_session = 'off_session'
on_session = 'on_session'
1.16.23 IntentStatus
class djstripe.enums.IntentStatus
Status of Intents which apply both to PaymentIntents and SetupIntents.
canceled = 'canceled'
choices = (('canceled', 'Cancellation invalidates the intent for future confirmation and cannot be undone.'), ('processing', 'Required actions have been handled.'), ('requires_action', 'Payment Method require additional action, such as 3D secure.'), ('requires_confirmation', 'Intent is ready to be confirmed.'), ('requires_payment_method', 'Intent created and requires a Payment Method to be attached.'))
processing = 'processing'
requires_action = 'requires_action'
requires_confirmation = 'requires_confirmation'
requires_payment_method = 'requires_payment_method'
1.16.24 PaymentIntentStatus
class djstripe.enums.PaymentIntentStatus
canceled = 'canceled'
choices = (('canceled', 'Cancellation invalidates the intent for future confirmation and cannot be undone.'), ('processing', 'Required actions have been handled.'), ('requires_action', 'Payment Method require additional action, such as 3D secure.'), ('requires_capture', 'Capture the funds on the cards which have been put on holds.'), ('requires_confirmation', 'Intent is ready to be confirmed.'), ('requires_payment_method', 'Intent created and requires a Payment Method to be attached.'), ('succeeded', 'The funds are in your account.'))
processing = 'processing'
requires_action = 'requires_action'
requires_capture = 'requires_capture'
requires_confirmation = 'requires_confirmation'
requires_payment_method = 'requires_payment_method'
succeeded = 'succeeded'
1.16. Enumerations 25
dj-stripe Documentation, Release 2.2.3
1.16.25 SetupIntentStatus
class djstripe.enums.SetupIntentStatus
canceled = 'canceled'
choices = (('canceled', 'Cancellation invalidates the intent for future confirmation and cannot be undone.'), ('processing', 'Required actions have been handled.'), ('requires_action', 'Payment Method require additional action, such as 3D secure.'), ('requires_confirmation', 'Intent is ready to be confirmed.'), ('requires_payment_method', 'Intent created and requires a Payment Method to be attached.'), ('succeeded', 'Setup was successful and the payment method is optimized for future payments.'))
processing = 'processing'
requires_action = 'requires_action'
requires_confirmation = 'requires_confirmation'
requires_payment_method = 'requires_payment_method'
succeeded = 'succeeded'
1.16.26 PayoutFailureCode
class djstripe.enums.PayoutFailureCode
Payout failure error codes.
https://stripe.com/docs/api#payout_failures
account_closed = 'account_closed'
account_frozen = 'account_frozen'
bank_account_restricted = 'bank_account_restricted'
bank_ownership_changed = 'bank_ownership_changed'
choices = (('account_closed', 'Bank account has been closed.'), ('account_frozen', 'Bank account has been frozen.'), ('bank_account_restricted', 'Bank account has restrictions on payouts allowed.'), ('bank_ownership_changed', 'Destination bank account has changed ownership.'), ('could_not_process', 'Bank could not process payout.'), ('debit_not_authorized', 'Debit transactions not approved on the bank account.'), ('insufficient_funds', 'Stripe account has insufficient funds.'), ('invalid_account_number', 'Invalid account number'), ('invalid_currency', 'Bank account does not support currency.'), ('no_account', 'Bank account could not be located.'), ('unsupported_card', 'Card no longer supported.'))
could_not_process = 'could_not_process'
debit_not_authorized = 'debit_not_authorized'
insufficient_funds = 'insufficient_funds'
invalid_account_number = 'invalid_account_number'
invalid_currency = 'invalid_currency'
no_account = 'no_account'
unsupported_card = 'unsupported_card'
1.16.27 PayoutMethod
class djstripe.enums.PayoutMethod
choices = (('instant', 'Instant'), ('standard', 'Standard'))
instant = 'instant'
standard = 'standard'
26 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.16.28 PayoutStatus
class djstripe.enums.PayoutStatus
canceled = 'canceled'
choices = (('canceled', 'Canceled'), ('failed', 'Failed'), ('in_transit', 'In transit'), ('paid', 'Paid'), ('pending', 'Pending'))
failed = 'failed'
in_transit = 'in_transit'
paid = 'paid'
pending = 'pending'
1.16.29 PayoutType
class djstripe.enums.PayoutType
bank_account = 'bank_account'
card = 'card'
choices = (('bank_account', 'Bank account'), ('card', 'Card'))
1.16.30 PlanAggregateUsage
class djstripe.enums.PlanAggregateUsage
choices = (('last_during_period', 'Last during period'), ('last_ever', 'Last ever'), ('max', 'Max'), ('sum', 'Sum'))
last_during_period = 'last_during_period'
last_ever = 'last_ever'
max = 'max'
sum = 'sum'
1.16.31 PlanBillingScheme
class djstripe.enums.PlanBillingScheme
choices = (('per_unit', 'Per unit'), ('tiered', 'Tiered'))
per_unit = 'per_unit'
tiered = 'tiered'
1.16. Enumerations 27
dj-stripe Documentation, Release 2.2.3
1.16.32 PlanInterval
class djstripe.enums.PlanInterval
choices = (('day', 'Day'), ('month', 'Month'), ('week', 'Week'), ('year', 'Year'))
day = 'day'
month = 'month'
week = 'week'
year = 'year'
1.16.33 PlanUsageType
class djstripe.enums.PlanUsageType
choices = (('licensed', 'Licensed'), ('metered', 'Metered'))
licensed = 'licensed'
metered = 'metered'
1.16.34 PlanTiersMode
class djstripe.enums.PlanTiersMode
choices = (('graduated', 'Graduated'), ('volume', 'Volume-based'))
graduated = 'graduated'
volume = 'volume'
1.16.35 ProductType
class djstripe.enums.ProductType
choices = (('good', 'Good'), ('service', 'Service'))
good = 'good'
service = 'service'
1.16.36 ScheduledQueryRunStatus
class djstripe.enums.ScheduledQueryRunStatus
canceled = 'canceled'
choices = (('canceled', 'Canceled'), ('failed', 'Failed'), ('timed_out', 'Timed out'))
failed = 'failed'
timed_out = 'timed_out'
28 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.16.37 SourceFlow
class djstripe.enums.SourceFlow
choices = (('code_verification', 'Code verification'), ('none', 'None'), ('receiver', 'Receiver'), ('redirect', 'Redirect'))
code_verification = 'code_verification'
none = 'none'
receiver = 'receiver'
redirect = 'redirect'
1.16.38 SourceStatus
class djstripe.enums.SourceStatus
canceled = 'canceled'
chargeable = 'chargeable'
choices = (('canceled', 'Canceled'), ('chargeable', 'Chargeable'), ('consumed', 'Consumed'), ('failed', 'Failed'), ('pending', 'Pending'))
consumed = 'consumed'
failed = 'failed'
pending = 'pending'
1.16.39 SourceType
class djstripe.enums.SourceType
ach_credit_transfer = 'ach_credit_transfer'
ach_debit = 'ach_debit'
alipay = 'alipay'
bancontact = 'bancontact'
bitcoin = 'bitcoin'
card = 'card'
card_present = 'card_present'
choices = (('ach_credit_transfer', 'ACH Credit Transfer'), ('ach_debit', 'ACH Debit'), ('alipay', 'Alipay'), ('bancontact', 'Bancontact'), ('bitcoin', 'Bitcoin'), ('card', 'Card'), ('card_present', 'Card present'), ('eps', 'EPS'), ('giropay', 'Giropay'), ('ideal', 'iDEAL'), ('p24', 'P24'), ('paper_check', 'Paper check'), ('sepa_credit_transfer', 'SEPA credit transfer'), ('sepa_debit', 'SEPA Direct Debit'), ('sofort', 'SOFORT'), ('three_d_secure', '3D Secure'))
eps = 'eps'
giropay = 'giropay'
ideal = 'ideal'
p24 = 'p24'
paper_check = 'paper_check'
sepa_credit_transfer = 'sepa_credit_transfer'
1.16. Enumerations 29
dj-stripe Documentation, Release 2.2.3
sepa_debit = 'sepa_debit'
sofort = 'sofort'
three_d_secure = 'three_d_secure'
1.16.40 LegacySourceType
class djstripe.enums.LegacySourceType
alipay_account = 'alipay_account'
bank_account = 'bank_account'
bitcoin_receiver = 'bitcoin_receiver'
card = 'card'
choices = (('alipay_account', 'Alipay account'), ('bank_account', 'Bank account'), ('bitcoin_receiver', 'Bitcoin receiver'), ('card', 'Card'))
1.16.41 RefundFailureReason
class djstripe.enums.RefundFailureReason
choices = (('expired_or_canceled_card', 'Expired or canceled card'), ('lost_or_stolen_card', 'Lost or stolen card'), ('unknown', 'Unknown'))
expired_or_canceled_card = 'expired_or_canceled_card'
lost_or_stolen_card = 'lost_or_stolen_card'
unknown = 'unknown'
1.16.42 RefundReason
class djstripe.enums.RefundReason
choices = (('duplicate', 'Duplicate charge'), ('expired_uncaptured_charge', 'Expired uncaptured charge'), ('fraudulent', 'Fraudulent'), ('requested_by_customer', 'Requested by customer'))
duplicate = 'duplicate'
expired_uncaptured_charge = 'expired_uncaptured_charge'
fraudulent = 'fraudulent'
requested_by_customer = 'requested_by_customer'
1.16.43 RefundStatus
class djstripe.enums.RefundStatus
canceled = 'canceled'
choices = (('canceled', 'Canceled'), ('failed', 'Failed'), ('pending', 'Pending'), ('succeeded', 'Succeeded'))
failed = 'failed'
30 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
pending = 'pending'
succeeded = 'succeeded'
1.16.44 SourceUsage
class djstripe.enums.SourceUsage
choices = (('reusable', 'Reusable'), ('single_use', 'Single-use'))
reusable = 'reusable'
single_use = 'single_use'
1.16.45 SourceCodeVeriļ¬cationStatus
class djstripe.enums.SourceCodeVerificationStatus
choices = (('failed', 'Failed'), ('pending', 'Pending'), ('succeeded', 'Succeeded'))
failed = 'failed'
pending = 'pending'
succeeded = 'succeeded'
1.16.46 SourceRedirectFailureReason
class djstripe.enums.SourceRedirectFailureReason
choices = (('declined', 'Declined'), ('processing_error', 'Processing error'), ('user_abort', 'User-aborted'))
declined = 'declined'
processing_error = 'processing_error'
user_abort = 'user_abort'
1.16.47 SourceRedirectStatus
class djstripe.enums.SourceRedirectStatus
choices = (('failed', 'Failed'), ('not_required', 'Not required'), ('pending', 'Pending'), ('succeeded', 'Succeeded'))
failed = 'failed'
not_required = 'not_required'
pending = 'pending'
succeeded = 'succeeded'
1.16. Enumerations 31
dj-stripe Documentation, Release 2.2.3
1.16.48 SubmitTypeStatus
class djstripe.enums.SubmitTypeStatus
auto = 'auto'
book = 'book'
choices = (('auto', 'Auto'), ('book', 'Book'), ('donate', 'donate'), ('pay', 'pay'))
donate = 'donate'
pay = 'pay'
1.16.49 SubscriptionStatus
class djstripe.enums.SubscriptionStatus
active = 'active'
canceled = 'canceled'
choices = (('active', 'Active'), ('canceled', 'Canceled'), ('incomplete', 'Incomplete'), ('incomplete_expired', 'Incomplete Expired'), ('past_due', 'Past due'), ('trialing', 'Trialing'), ('unpaid', 'Unpaid'))
incomplete = 'incomplete'
incomplete_expired = 'incomplete_expired'
past_due = 'past_due'
trialing = 'trialing'
unpaid = 'unpaid'
1.17 Managers
Last Updated 2018-05-24
1.17.1 SubscriptionManager
class djstripe.managers.SubscriptionManager
Manager used in models.Subscription.
started_during(year, month)
Return Subscriptions not in trial status between a certain time range.
active()
Return active Subscriptions.
canceled()
Return canceled Subscriptions.
canceled_during(year, month)
Return Subscriptions canceled during a certain time range.
started_plan_summary_for(year, month)
Return started_during Subscriptions with plan counts annotated.
32 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
active_plan_summary()
Return active Subscriptions with plan counts annotated.
canceled_plan_summary_for(year, month)
Return Subscriptions canceled within a time range with plan counts annotated.
churn()
Return number of canceled Subscriptions divided by active Subscriptions.
1.17.2 TransferManager
class djstripe.managers.TransferManager
Manager used by models.Transfer.
during(year, month)
Return Transfers between a certain time range.
paid_totals_for(year, month)
Return paid Transfers during a certain year, month with total amounts annotated.
1.17.3 ChargeManager
class djstripe.managers.ChargeManager
Manager used by models.Charge.
during(year, month)
Return Charges between a certain time range based on created.
paid_totals_for(year, month)
Return paid Charges during a certain year, month with total amount, fee and refunded annotated.
1.18 Middleware
Last Updated 2018-05-24
1.18.1 SubscriptionPaymentMiddleware
class djstripe.middleware.SubscriptionPaymentMiddleware(get_response=None)
Used to redirect users from subcription-locked request destinations.
Rules:
ā€¢ ā€œ(app_name)ā€ means everything from this app is exempt
ā€¢ ā€œ[namespace]ā€ means everything with this name is exempt
ā€¢ ā€œnamespace:nameā€ means this namespaced URL is exempt
ā€¢ ā€œnameā€ means this URL is exempt
ā€¢ The entire djstripe namespace is exempt
ā€¢ If settings.DEBUG is True, then django-debug-toolbar is exempt
ā€¢ A ā€˜fn:ā€™ preļ¬x means the rest of the URL is fnmatchā€™d.
Example:
1.18. Middleware 33
dj-stripe Documentation, Release 2.2.3
DJSTRIPE_SUBSCRIPTION_REQUIRED_EXCEPTION_URLS = (
"[blogs]", # Anything in the blogs namespace
"products:detail", # A ProductDetail view you want shown to non-payers
"home", # Site homepage
"fn:/accounts
*
", # anything in the accounts/ URL path
)
1.19 Models
Models hold the bulk of the functionality included in the dj-stripe package. Each model is tied closely to its corre-
sponding object in the stripe dashboard. Fields that are not implemented for each model have a short reason behind
the decision in the docstring for each model.
Last Updated 2019-12-21
1.19.1 Core Resources
Balance Transaction
class djstripe.models.BalanceTransaction(*args, **kwargs)
A single transaction that updates the Stripe balance.
Stripe documentation: https://stripe.com/docs/api#balance_transaction_object
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeQuantumCurrencyAmountField) ā€“ Amount. Gross amount of the
transaction, in cents.
ā€¢ available_on (StripeDateTimeField) ā€“ Available on. The date the transactionā€™s
net funds will become available in the Stripe balance.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ exchange_rate (DecimalField) ā€“ Exchange rate
34 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ fee (StripeQuantumCurrencyAmountField) ā€“ Fee. Fee (in cents) paid for this
transaction.
ā€¢ fee_details (JSONField) ā€“ Fee details
ā€¢ net (StripeQuantumCurrencyAmountField) ā€“ Net. Net amount of the transac-
tion, in cents.
ā€¢ status (StripeEnumField) ā€“ Status
ā€¢ type (StripeEnumField) ā€“ Type
classmethod BalanceTransaction.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
BalanceTransaction.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
BalanceTransaction.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod BalanceTransaction.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Charge
class djstripe.models.Charge(*args, **kwargs)
To charge a credit or a debit card, you create a charge object. You can retrieve and refund individual charges as
well as list all charges. Charges are identiļ¬ed by a unique random ID.
Stripe documentation: https://stripe.com/docs/api/python#charges
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
1.19. Models 35
dj-stripe Documentation, Release 2.2.3
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeDecimalCurrencyAmountField) ā€“ Amount. Amount charged (as
decimal).
ā€¢ amount_refunded (StripeDecimalCurrencyAmountField) ā€“ Amount re-
funded. Amount (as decimal) refunded (can be less than the amount attribute on the charge
if a partial refund was issued).
ā€¢ balance_transaction (ForeignKey to BalanceTransaction) ā€“ Balance trans-
action. The balance transaction that describes the impact of this charge on your account
balance (not including refunds or disputes).
ā€¢ captured (BooleanField) ā€“ Captured. If the charge was created without capturing,
this boolean represents whether or not it is still uncaptured or has since been captured.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. The currency in which the
charge was made.
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. The customer associated with this
charge.
ā€¢ account (ForeignKey to Account) ā€“ Account. The account the charge was made on
behalf of. Null here indicates that this value was never set.
ā€¢ dispute (ForeignKey to Dispute) ā€“ Dispute. Details about the dispute if the charge has
been disputed.
ā€¢ failure_code (StripeEnumField) ā€“ Failure code. Error code explaining reason for
charge failure if available.
ā€¢ failure_message (TextField) ā€“ Failure message. Message to user further explain-
ing reason for charge failure if available.
ā€¢ fraud_details (JSONField) ā€“ Fraud details. Hash with information on fraud assess-
ments for the charge.
ā€¢ invoice (ForeignKey to Invoice) ā€“ Invoice. The invoice this charge is for if one exists.
ā€¢ outcome (JSONField) ā€“ Outcome. Details about whether or not the payment was ac-
cepted, and why.
ā€¢ paid (BooleanField) ā€“ Paid. True if the charge succeeded, or was successfully autho-
rized for later capture, False otherwise.
ā€¢ payment_intent (ForeignKey to PaymentIntent) ā€“ Payment intent. PaymentIntent
associated with this charge, if one exists.
ā€¢ payment_method (ForeignKey to PaymentMethod) ā€“ Payment method. Payment-
Method used in this charge.
ā€¢ payment_method_details (JSONField) ā€“ Payment method details. Details about
the payment method at the time of the transaction.
ā€¢ receipt_email (TextField) ā€“ Receipt email. The email address that the receipt for
this charge was sent to.
36 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ receipt_number (CharField) ā€“ Receipt number. The transaction number that ap-
pears on email receipts sent for this charge.
ā€¢ receipt_url (TextField) ā€“ Receipt url. This is the URL to view the receipt for this
charge. The receipt is kept up-to-date to the latest state of the charge, including any refunds.
If the charge is for an Invoice, the receipt will be stylized as an Invoice receipt.
ā€¢ refunded (BooleanField) ā€“ Refunded. Whether or not the charge has been fully
refunded. If the charge is only partially refunded, this attribute will still be false.
ā€¢ shipping (JSONField) ā€“ Shipping. Shipping information for the charge
ā€¢ source (PaymentMethodForeignKey to DjstripePaymentMethod) ā€“ Source. The
source used for this charge.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. An arbitrary string
to be displayed on your customerā€™s credit card statement. The statement description may
not include <>ā€ā€™ characters, and will appear on your customerā€™s statement in capital letters.
Non-ASCII characters are automatically stripped. While most banks display this informa-
tion consistently, some may display it incorrectly or not at all.
ā€¢ status (StripeEnumField) ā€“ Status. The status of the payment.
ā€¢ transfer (ForeignKey to Transfer) ā€“ Transfer. The transfer to the destination account
(only applicable if the charge was created using the destination parameter).
ā€¢ transfer_group (CharField) ā€“ Transfer group. A string that identiļ¬es this transac-
tion as part of a group.
classmethod Charge.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Charge.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Charge.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
Charge.disputed
Charge.refund(amount=None, reason=None)
Initiate a refund. If amount is not provided, then this will be a full refund.
Parameters
ā€¢ amount (Decimal) ā€“ A positive decimal amount representing how much of this charge to
refund. Can only refund up to the unrefunded amount remaining of the charge.
ā€¢ reason ā€“ String indicating the reason for the refund. If set, possible val-
ues are duplicate, fraudulent, and requested_by_customer. Specifying
1.19. Models 37
dj-stripe Documentation, Release 2.2.3
fraudulent as the reason when you believe the charge to be fraudulent will help Stripe
improve their fraud detection algorithms.
ā€¢ reason ā€“ str
Returns Charge object
Return type Charge
Charge.capture()
Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment ļ¬‚ow,
where ļ¬rst you created a charge with the capture option set to False.
See https://stripe.com/docs/api#capture_charge
Charge.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Charge.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Customer
class djstripe.models.Customer(*args, **kwargs)
Customer objects allow you to perform recurring charges and track multiple charges that are associated with the
same customer.
Stripe documentation: https://stripe.com/docs/api/python#customers
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ address (JSONField) ā€“ Address. The customerā€™s address.
ā€¢ balance (StripeQuantumCurrencyAmountField) ā€“ Balance. Current balance
(in cents), if any, being stored on the customerā€™s account. If negative, the customer has
credit to apply to the next invoice. If positive, the customer has an amount owed that will be
38 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
added to the next invoice. The balance does not refer to any unpaid invoices; it solely takes
into account amounts that have yet to be successfully applied to any invoice. This balance is
only taken into account for recurring billing purposes (i.e., subscriptions, invoices, invoice
items).
ā€¢ business_vat_id (CharField) ā€“ Business vat id. The customerā€™s VAT identiļ¬cation
number.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. The currency the customer
can be charged in for recurring billing purposes
ā€¢ default_source (PaymentMethodForeignKey to DjstripePaymentMethod) ā€“
Default source
ā€¢ delinquent (BooleanField) ā€“ Delinquent. Whether or not the latest charge for the
customerā€™s latest invoice has failed.
ā€¢ coupon (ForeignKey to Coupon) ā€“ Coupon
ā€¢ coupon_start (StripeDateTimeField) ā€“ Coupon start. If a coupon is present, the
date at which it was applied.
ā€¢ coupon_end (StripeDateTimeField) ā€“ Coupon end. If a coupon is present and has
a limited duration, the date that the discount will end.
ā€¢ email (TextField) ā€“ Email
ā€¢ invoice_prefix (CharField) ā€“ Invoice preļ¬x. The preļ¬x for the customer used to
generate unique invoice numbers.
ā€¢ invoice_settings (JSONField) ā€“ Invoice settings. The customerā€™s default invoice
settings.
ā€¢ default_payment_method (ForeignKey to PaymentMethod) ā€“ Default payment
method. default payment method used for subscriptions and invoices for the customer.
ā€¢ name (TextField) ā€“ Name. The customerā€™s full name or business name.
ā€¢ phone (TextField) ā€“ Phone. The customerā€™s phone number.
ā€¢ preferred_locales (JSONField) ā€“ Preferred locales. The customerā€™s preferred lo-
cales (languages), ordered by preference.
ā€¢ shipping (JSONField) ā€“ Shipping. Shipping information associated with the customer.
ā€¢ tax_exempt (StripeEnumField) ā€“ Tax exempt. Describes the customerā€™s tax ex-
emption status. When set to reverse, invoice and receipt PDFs include the text ā€œReverse
chargeā€.
ā€¢ subscriber (ForeignKey to User) ā€“ Subscriber
ā€¢ date_purged (DateTimeField) ā€“ Date purged
classmethod Customer.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Customer.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
1.19. Models 39
dj-stripe Documentation, Release 2.2.3
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Customer.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod Customer.get_or_create(subscriber, livemode=False, stripe_account=None)
Get or create a dj-stripe customer.
Parameters
ā€¢ subscriber (User) ā€“ The subscriber model instance for which to get or create a cus-
tomer.
ā€¢ livemode (bool) ā€“ Whether to get the subscriber in live or test mode.
Customer.legacy_cards
Model ļ¬eld: customer, accesses the M2M Card model.
Customer.credits
The customer is considered to have credits if their balance is below 0.
Customer.customer_payment_methods
An iterable of all of the customerā€™s payment methods (sources, then legacy cards)
Customer.pending_charges
The customer is considered to have pending charges if their balance is above 0.
Customer.subscribe(plan, charge_immediately=True, application_fee_percent=None, coupon=None,
quantity=None, metadata=None, tax_percent=None, billing_cycle_anchor=None,
trial_end=None, trial_from_plan=None, trial_period_days=None)
Subscribes this customer to a plan.
Parameters
ā€¢ plan (Plan or string (plan ID)) ā€“ The plan to which to subscribe the customer.
ā€¢ application_fee_percent (Decimal. Precision is 2; anything
more will be ignored. A positive decimal between 1 and 100.) ā€“
This represents the percentage of the subscription invoice subtotal that will be transferred
to the application ownerā€™s Stripe account. The request must be made with an OAuth key in
order to set an application fee percentage.
ā€¢ coupon (string) ā€“ The code of the coupon to apply to this subscription. A coupon
applied to a subscription will only affect invoices created for that particular subscription.
ā€¢ quantity (integer) ā€“ The quantity applied to this subscription. Default is 1.
ā€¢ metadata (dict) ā€“ A set of key/value pairs useful for storing additional information.
ā€¢ tax_percent (Decimal. Precision is 2; anything more will be
ignored. A positive decimal between 1 and 100.) ā€“ This represents the
percentage of the subscription invoice subtotal that will be calculated and added as tax to
the ļ¬nal amount each billing period.
ā€¢ billing_cycle_anchor (datetime) ā€“ A future timestamp to anchor the subscrip-
tionā€™s billing cycle. This is used to determine the date of the ļ¬rst full invoice, and, for plans
with month or year intervals, the day of the month for subsequent invoices.
40 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ trial_end (datetime) ā€“ The end datetime of the trial period the customer will get
before being charged for the ļ¬rst time. If set, this will override the default trial period of the
plan the customer is being subscribed to. The special value now can be provided to end the
customerā€™s trial immediately.
ā€¢ charge_immediately (boolean) ā€“ Whether or not to charge for the subscription
upon creation. If False, an invoice will be created at the end of this period.
ā€¢ trial_from_plan (boolean) ā€“ Indicates if a planā€™s trial_period_days should be ap-
plied to the subscription. Setting trial_end per subscription is preferred, and this defaults to
false. Setting this ļ¬‚ag to true together with trial_end is not allowed.
ā€¢ trial_period_days (integer) ā€“ Integer representing the number of trial period days
before the customer is charged for the ļ¬rst time. This will always overwrite any trials that
might apply via a subscribed plan.
Customer.charge(amount, currency=None, application_fee=None, capture=None, description=None,
destination=None, metadata=None, shipping=None, source=None, state-
ment_descriptor=None, idempotency_key=None)
Creates a charge for this customer.
Parameters not implemented:
ā€¢ receipt_email - Since this is a charge on a customer, the customerā€™s email address is used.
Parameters
ā€¢ amount (Decimal. Precision is 2; anything more will be
ignored.) ā€“ The amount to charge.
ā€¢ currency (string) ā€“ 3-letter ISO code for currency
ā€¢ application_fee (Decimal. Precision is 2; anything more will
be ignored.) ā€“ A fee that will be applied to the charge and transfered to the platform
ownerā€™s account.
ā€¢ capture (bool) ā€“ Whether or not to immediately capture the charge. When false, the
charge issues an authorization (or pre-authorization), and will need to be captured later.
Uncaptured charges expire in 7 days. Default is True
ā€¢ description (string) ā€“ An arbitrary string.
ā€¢ destination (Account) ā€“ An account to make the charge on behalf of.
ā€¢ metadata (dict) ā€“ A set of key/value pairs useful for storing additional information.
ā€¢ shipping (dict) ā€“ Shipping information for the charge.
ā€¢ source (string, Source) ā€“ The source to use for this charge. Must be a source
attributed to this customer. If None, the customerā€™s default source is used. Can be either the
id of the source or the source object itself.
ā€¢ statement_descriptor (string) ā€“ An arbitrary string to be displayed on the cus-
tomerā€™s credit card statement.
Customer.add_invoice_item(amount, currency, description=None, discountable=None, in-
voice=None, metadata=None, subscription=None)
Adds an arbitrary charge or credit to the customerā€™s upcoming invoice. Different than creating a charge. Charges
are separate bills that get processed immediately. Invoice items are appended to the customerā€™s next invoice.
This is extremely useful when adding surcharges to subscriptions.
Parameters
1.19. Models 41
dj-stripe Documentation, Release 2.2.3
ā€¢ amount (Decimal. Precision is 2; anything more will be
ignored.) ā€“ The amount to charge.
ā€¢ currency (string) ā€“ 3-letter ISO code for currency
ā€¢ description (string) ā€“ An arbitrary string.
ā€¢ discountable (boolean) ā€“ Controls whether discounts apply to this invoice item. De-
faults to False for prorations or negative invoice items, and True for all other invoice items.
ā€¢ invoice (Invoice or string (invoice ID)) ā€“ An existing invoice to add this
invoice item to. When left blank, the invoice item will be added to the next upcoming sched-
uled invoice. Use this when adding invoice items in response to an invoice.created
webhook. You cannot add an invoice item to an invoice that has already been paid, attempted
or closed.
ā€¢ metadata (dict) ā€“ A set of key/value pairs useful for storing additional information.
ā€¢ subscription (Subscription or string (subscription ID)) ā€“ A sub-
scription to add this invoice item to. When left blank, the invoice item will be be added
to the next upcoming scheduled invoice. When set, scheduled invoices for subscriptions
other than the speciļ¬ed subscription will ignore the invoice item. Use this when you want to
express that an invoice item has been accrued within the context of a particular subscription.
Customer.add_card(source, set_default=True)
Adds a card to this customerā€™s account.
Parameters
ā€¢ source (string, dict) ā€“ Either a token, like the ones returned by our Stripe.js, or a
dictionary containing a userā€™s credit card details. Stripe will automatically validate the card.
ā€¢ set_default (boolean) ā€“ Whether or not to set the source as the customerā€™s default
source
Customer.add_payment_method(payment_method, set_default=True)
Adds an already existing payment method to this customerā€™s account
Parameters
ā€¢ payment_method (str, PaymentMethod) ā€“ PaymentMethod to be attached to the
customer
ā€¢ set_default (bool) ā€“ If true, this will be set as the default_payment_method
Return type PaymentMethod
Customer.purge()
Customer.has_active_subscription(plan=None)
Checks to see if this customer has an active subscription to the given plan.
Parameters plan (Plan or string (plan ID)) ā€“ The plan for which to check for an ac-
tive subscription. If plan is None and there exists only one active subscription, this method
will check if that subscription is valid. Calling this method with no plan and multiple valid
subscriptions for this customer will throw an exception.
Returns True if there exists an active subscription, False otherwise.
Throws TypeError if plan is None and more than one active subscription exists for this customer.
Customer.has_any_active_subscription()
Checks to see if this customer has an active subscription to any plan.
Returns True if there exists an active subscription, False otherwise.
42 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Customer.active_subscriptions
Returns active subscriptions (subscriptions with an active status that end in the future).
Customer.valid_subscriptions
Returns this customerā€™s valid subscriptions (subscriptions that arenā€™t canceled or incomplete_expired).
Customer.subscription
Shortcut to get this customerā€™s subscription.
Returns None if the customer has no subscriptions, the subscription if the customer has a subscrip-
tion.
Raises MultipleSubscriptionException ā€“ Raised if the customer has multiple subscrip-
tions. In this case, use Customer.subscriptions instead.
Customer.can_charge()
Determines if this customer is able to be charged.
Customer.send_invoice()
Pay and send the customerā€™s latest invoice.
Returns True if an invoice was able to be created and paid, False otherwise (typically if there was
nothing to invoice).
Customer.retry_unpaid_invoices()
Attempt to retry collecting payment on the customerā€™s unpaid invoices.
Customer.has_valid_source()
Check whether the customer has a valid payment source.
Customer.add_coupon(coupon, idempotency_key=None)
Add a coupon to a Customer.
The coupon can be a Coupon object, or a valid Stripe Coupon ID.
Customer.upcoming_invoice(**kwargs)
Gets the upcoming preview invoice (singular) for this customer.
See Invoice.upcoming().
The customer argument to the upcoming() call is automatically set by this method.
Customer.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Customer.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Dispute
class djstripe.models.Dispute(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#disputes
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
1.19. Models 43
dj-stripe Documentation, Release 2.2.3
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeQuantumCurrencyAmountField) ā€“ Amount. Disputed amount
(in cents). Usually the amount of the charge, but can differ (usually because of currency
ļ¬‚uctuation or because only part of the order is disputed).
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ evidence (JSONField) ā€“ Evidence. Evidence provided to respond to a dispute.
ā€¢ evidence_details (JSONField) ā€“ Evidence details. Information about the evidence
submission.
ā€¢ is_charge_refundable (BooleanField) ā€“ Is charge refundable. If true, it is still
possible to refund the disputed payment. Once the payment has been fully refunded, no
further funds will be withdrawn from your Stripe account as a result of this dispute.
ā€¢ reason (StripeEnumField) ā€“ Reason
ā€¢ status (StripeEnumField) ā€“ Status
classmethod Dispute.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Dispute.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Dispute.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
Dispute.str_parts()
Extend this to add information to the string representation of the object
44 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Return type list of str
classmethod Dispute.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Event
class djstripe.models.Event(*args, **kwargs)
Events are Stripeā€™s way of letting you know when something interesting happens in your account. When an
interesting event occurs, a new Event object is created and POSTed to the conļ¬gured webhook URL if the Event
type matches.
Stripe documentation: https://stripe.com/docs/api/events
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ api_version (CharField) ā€“ Api version. the API version at which the event data was
rendered. Blank for old entries only, all new entries will have this value
ā€¢ data (JSONField) ā€“ Data. data received at webhook. data should be considered to be
garbage until validity check is run and valid ļ¬‚ag is set
ā€¢ request_id (CharField) ā€“ Request id. Information about the request that triggered
this event, for traceability purposes. If empty string then this is an old entry without that
data. If Null then this is not an old entry, but a Stripe ā€˜automatedā€™ event with no associated
request.
ā€¢ idempotency_key (TextField) ā€“ Idempotency key
ā€¢ type (CharField) ā€“ Type. Stripeā€™s event description code
classmethod Event.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
1.19. Models 45
dj-stripe Documentation, Release 2.2.3
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Event.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
classmethod Event.process(data)
Event.invoke_webhook_handlers()
Invokes any webhook handlers that have been registered for this event based on event type or event sub-type.
See event handlers registered in the djstripe.event_handlers module (or handlers registered in djstripe
plugins or contrib packages).
Event.parts
Gets the event category/verb as a list of parts.
Event.category
Gets the event category string (e.g. ā€˜customerā€™).
Event.verb
Gets the event past-tense verb string (e.g. ā€˜updatedā€™).
Event.customer
Event.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Event.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
File Upload
class djstripe.models.FileUpload(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#ļ¬le_uploads
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
46 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ filename (CharField) ā€“ Filename. A ļ¬lename for the ļ¬le, suitable for saving to a
ļ¬lesystem.
ā€¢ purpose (StripeEnumField) ā€“ Purpose. The purpose of the uploaded ļ¬le.
ā€¢ size (IntegerField) ā€“ Size. The size in bytes of the ļ¬le upload object.
ā€¢ type (StripeEnumField) ā€“ Type. The type of the ļ¬le returned.
ā€¢ url (CharField) ā€“ Url. A read-only URL where the uploaded ļ¬le can be accessed.
classmethod FileUpload.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
FileUpload.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
classmethod FileUpload.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Payout
class djstripe.models.Payout(*args, **kwargs)
A Payout object is created when you receive funds from Stripe, or when you initiate a payout to either a bank
account or debit card of a connected Stripe account.
Stripe documentation: https://stripe.com/docs/api#payouts
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
1.19. Models 47
dj-stripe Documentation, Release 2.2.3
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeDecimalCurrencyAmountField) ā€“ Amount. Amount (as deci-
mal) to be transferred to your bank account or debit card.
ā€¢ arrival_date (StripeDateTimeField) ā€“ Arrival date. Date the payout is expected
to arrive in the bank. This factors in delays like weekends or bank holidays.
ā€¢ balance_transaction (ForeignKey to BalanceTransaction) ā€“ Balance transac-
tion. Balance transaction that describes the impact on your account balance.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ destination (ForeignKey to BankAccount) ā€“ Destination. Bank account or card the
payout was sent to.
ā€¢ failure_balance_transaction (ForeignKey to BalanceTransaction) ā€“ Fail-
ure balance transaction. If the payout failed or was canceled, this will be the balance trans-
action that reversed the initial balance transaction, and puts the funds from the failed payout
back in your balance.
ā€¢ failure_code (StripeEnumField) ā€“ Failure code. Error code explaining reason for
transfer failure if available. See https://stripe.com/docs/api/python#transfer_failures.
ā€¢ failure_message (TextField) ā€“ Failure message. Message to user further explain-
ing reason for payout failure if available.
ā€¢ method (StripeEnumField) ā€“ Method. The method used to send this payout. instant
is only supported for payouts to debit cards.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. Extra information
about a payout to be displayed on the userā€™s bank statement.
ā€¢ status (StripeEnumField) ā€“ Status. Current status of the payout. A payout will be
pending until it is submitted to the bank, at which point it becomes in_transit. It will then
change to paid if the transaction goes through. If it does not go through successfully, its
status will change to failed or canceled.
ā€¢ type (StripeEnumField) ā€“ Type
classmethod Payout.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
48 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Returns an iterator over all items in the query
Payout.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Payout.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
Payout.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Payout.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
PaymentIntent
class djstripe.models.PaymentIntent(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#payment_intents
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeQuantumCurrencyAmountField) ā€“ Amount. Amount (in cents)
intended to be collected by this PaymentIntent.
ā€¢ amount_capturable (StripeQuantumCurrencyAmountField) ā€“ Amount cap-
turable. Amount (in cents) that can be captured from this PaymentIntent.
ā€¢ amount_received (StripeQuantumCurrencyAmountField) ā€“ Amount re-
ceived. Amount (in cents) that was collected by this PaymentIntent.
1.19. Models 49
dj-stripe Documentation, Release 2.2.3
ā€¢ canceled_at (StripeDateTimeField) ā€“ Canceled at. Populated when status is
canceled, this is the time at which the PaymentIntent was canceled. Measured in seconds
since the Unix epoch.
ā€¢ cancellation_reason (StripeEnumField) ā€“ Cancellation reason. Reason
for cancellation of this PaymentIntent, either user-provided (duplicate, fraudulent, re-
quested_by_customer, or abandoned) or generated by Stripe internally (failed_invoice,
void_invoice, or automatic).
ā€¢ capture_method (StripeEnumField) ā€“ Capture method. Capture method of this
PaymentIntent, one of automatic or manual.
ā€¢ client_secret (TextField) ā€“ Client secret. The client secret of this PaymentIntent.
Used for client-side retrieval using a publishable key.
ā€¢ confirmation_method (StripeEnumField) ā€“ Conļ¬rmation method. Conļ¬rma-
tion method of this PaymentIntent, one of manual or automatic.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. Customer this PaymentIntent is for
if one exists.
ā€¢ description (TextField) ā€“ Description. An arbitrary string attached to the object.
Often useful for displaying to users.
ā€¢ last_payment_error (JSONField) ā€“ Last payment error. The payment error en-
countered in the previous PaymentIntent conļ¬rmation.
ā€¢ next_action (JSONField) ā€“ Next action. If present, this property tells you what ac-
tions you need to take in order for your customer to fulļ¬ll a payment using the provided
source.
ā€¢ on_behalf_of (ForeignKey to Account) ā€“ On behalf of. The account (if any) for which
the funds of the PaymentIntent are intended.
ā€¢ payment_method (ForeignKey to PaymentMethod) ā€“ Payment method. Payment
method used in this PaymentIntent.
ā€¢ payment_method_types (JSONField) ā€“ Payment method types. The list of payment
method types (e.g. card) that this PaymentIntent is allowed to use.
ā€¢ receipt_email (CharField) ā€“ Receipt email. Email address that the receipt for the
resulting payment will be sent to.
ā€¢ setup_future_usage (StripeEnumField) ā€“ Setup future usage. Indicates that you
intend to make future payments with this PaymentIntentā€™s payment method. If present, the
payment method used with this PaymentIntent can be attached to a Customer, even after
the transaction completes. Use on_session if you intend to only reuse the payment method
when your customer is present in your checkout ļ¬‚ow. Use off_session if your customer
may or may not be in your checkout ļ¬‚ow. Stripe uses setup_future_usage to dynamically
optimize your payment ļ¬‚ow and comply with regional legislation and network rules. For
example, if your customer is impacted by SCA, using off_session will ensure that they are
authenticated while processing this PaymentIntent. You will then be able to make later
off-session payments for this customer.
ā€¢ shipping (JSONField) ā€“ Shipping. Shipping information for this PaymentIntent.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. For non-card charges,
you can use this value as the complete description that appears on your customersā€™ state-
ments. Must contain at least one letter, maximum 22 characters.
50 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ status (StripeEnumField) ā€“ Status. Status of this PaymentIntent, one
of requires_payment_method, requires_conļ¬rmation, requires_action, processing, re-
quires_capture, canceled, or succeeded. You can read more about PaymentIntent statuses
here.
ā€¢ transfer_data (JSONField) ā€“ Transfer data. The data with which to automatically
create a Transfer when the payment is ļ¬nalized. See the PaymentIntents Connect usage
guide for details.
ā€¢ transfer_group (CharField) ā€“ Transfer group. A string that identiļ¬es the resulting
payment as part of a group. See the PaymentIntents Connect usage guide for details.
classmethod PaymentIntent.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
PaymentIntent.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
PaymentIntent.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
PaymentIntent.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod PaymentIntent.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Product
class djstripe.models.Product(*args, **kwargs)
Stripe documentation: - https://stripe.com/docs/api#products - https://stripe.com/docs/api#service_products
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
1.19. Models 51
dj-stripe Documentation, Release 2.2.3
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ name (TextField) ā€“ Name. The productā€™s name, meant to be displayable to the customer.
Applicable to both service and good types.
ā€¢ type (StripeEnumField) ā€“ Type. The type of the product. The product is either of
type good, which is eligible for use with Orders and SKUs, or service, which is eligible for
use with Subscriptions and Plans.
ā€¢ active (NullBooleanField) ā€“ Active. Whether the product is currently available for
purchase. Only applicable to products of type=good.
ā€¢ attributes (JSONField) ā€“ Attributes. A list of up to 5 attributes that each SKU can
provide values for (e.g., [ā€œcolorā€, ā€œsizeā€]). Only applicable to products of type=good.
ā€¢ caption (TextField) ā€“ Caption. A short one-line description of the product, meant to
be displayableto the customer. Only applicable to products of type=good.
ā€¢ deactivate_on (JSONField) ā€“ Deactivate on. An array of connect application iden-
tiļ¬ers that cannot purchase this product. Only applicable to products of type=good.
ā€¢ images (JSONField) ā€“ Images. A list of up to 8 URLs of images for this product, meant
to be displayable to the customer. Only applicable to products of type=good.
ā€¢ package_dimensions (JSONField) ā€“ Package dimensions. The dimensions of this
product for shipping purposes. A SKU associated with this product can override this value
by having its own package_dimensions. Only applicable to products of type=good.
ā€¢ shippable (NullBooleanField) ā€“ Shippable. Whether this product is a shipped
good. Only applicable to products of type=good.
ā€¢ url (CharField) ā€“ Url. A URL of a publicly-accessible webpage for this product. Only
applicable to products of type=good.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. Extra information
about a product which will appear on your customerā€™s credit card statement. In the case
that multiple products are billed at once, the ļ¬rst statement descriptor will be used. Only
available on products of type=ā€˜serviceā€˜.
ā€¢ unit_label (CharField) ā€“ Unit label
classmethod Product.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Product.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
52 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Product.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod Product.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Refund
class djstripe.models.Refund(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#refund_object
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeQuantumCurrencyAmountField) ā€“ Amount. Amount, in cents.
ā€¢ balance_transaction (ForeignKey to BalanceTransaction) ā€“ Balance transac-
tion. Balance transaction that describes the impact on your account balance.
ā€¢ charge (ForeignKey to Charge) ā€“ Charge. The charge that was refunded
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ failure_balance_transaction (ForeignKey to BalanceTransaction) ā€“ Fail-
ure balance transaction. If the refund failed, this balance transaction describes the adjust-
ment made on your account balance that reverses the initial balance transaction.
ā€¢ failure_reason (StripeEnumField) ā€“ Failure reason. If the refund failed, the
reason for refund failure if known.
1.19. Models 53
dj-stripe Documentation, Release 2.2.3
ā€¢ reason (StripeEnumField) ā€“ Reason. Reason for the refund.
ā€¢ receipt_number (CharField) ā€“ Receipt number. The transaction number that ap-
pears on email receipts sent for this charge.
ā€¢ status (StripeEnumField) ā€“ Status. Status of the refund.
classmethod Refund.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Refund.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Refund.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod Refund.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
1.19.2 Payment Methods
BankAccount
class djstripe.models.BankAccount(djstripe_id, id, livemode, created, metadata, descrip-
tion, djstripe_created, djstripe_updated, account, ac-
count_holder_name, account_holder_type, bank_name,
country, currency, customer, default_for_currency, ļ¬nger-
print, last4, routing_number, status)
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
54 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ account (ForeignKey to Account) ā€“ Account. The account the charge was made on
behalf of. Null here indicates that this value was never set.
ā€¢ account_holder_name (TextField) ā€“ Account holder name. The name of the per-
son or business that owns the bank account.
ā€¢ account_holder_type (StripeEnumField) ā€“ Account holder type. The type of
entity that holds the account.
ā€¢ bank_name (CharField) ā€“ Bank name. Name of the bank associated with the routing
number (e.g., WELLS FARGO).
ā€¢ country (CharField) ā€“ Country. Two-letter ISO code representing the country the
bank account is located in.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ customer (ForeignKey to Customer) ā€“ Customer
ā€¢ default_for_currency (NullBooleanField) ā€“ Default for currency. Whether
this external account is the default account for its currency.
ā€¢ fingerprint (CharField) ā€“ Fingerprint. Uniquely identiļ¬es this particular bank ac-
count. You can use this attribute to check whether two bank accounts are the same.
ā€¢ last4 (CharField) ā€“ Last4
ā€¢ routing_number (CharField) ā€“ Routing number. The routing transit number for the
bank account.
ā€¢ status (StripeEnumField) ā€“ Status
classmethod BankAccount.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
BankAccount.api_retrieve(api_key=None, stripe_account=None)
BankAccount.get_stripe_dashboard_url()
BankAccount.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod BankAccount.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
1.19. Models 55
dj-stripe Documentation, Release 2.2.3
Parameters data (dict) ā€“ stripe object
Return type cls
Card
class djstripe.models.Card(*args, **kwargs)
You can store multiple cards on a customer in order to charge the customer later.
This is a legacy model which only applies to the ā€œv2ā€ Stripe API (eg. Checkout.js). You should strive to use
the Stripe ā€œv3ā€ API (eg. Stripe Elements). Also see: https://stripe.com/docs/stripe-js/elements/migrating When
using Elements, you will not be using Card objects. Instead, you will use Source objects. A Source object of
type ā€œcardā€ is equivalent to a Card object. However, Card objects cannot be converted into Source objects by
Stripe at this time.
Stripe documentation: https://stripe.com/docs/api/python#cards
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ address_city (TextField) ā€“ Address city. City/District/Suburb/Town/Village.
ā€¢ address_country (TextField) ā€“ Address country. Billing address country.
ā€¢ address_line1 (TextField) ā€“ Address line1. Street address/PO Box/Company
name.
ā€¢ address_line1_check (StripeEnumField) ā€“ Address line1 check. If ad-
dress_line1 was provided, results of the check.
ā€¢ address_line2 (TextField) ā€“ Address line2. Apartment/Suite/Unit/Building.
ā€¢ address_state (TextField) ā€“ Address state. State/County/Province/Region.
ā€¢ address_zip (TextField) ā€“ Address zip. ZIP or postal code.
ā€¢ address_zip_check (StripeEnumField) ā€“ Address zip check. If address_zip was
provided, results of the check.
ā€¢ brand (StripeEnumField) ā€“ Brand. Card brand.
ā€¢ country (CharField) ā€“ Country. Two-letter ISO code representing the country of the
card.
ā€¢ customer (ForeignKey to Customer) ā€“ Customer
56 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ cvc_check (StripeEnumField) ā€“ Cvc check. If a CVC was provided, results of the
check.
ā€¢ dynamic_last4 (CharField) ā€“ Dynamic last4. (For tokenized numbers only.) The
last four digits of the device account number.
ā€¢ exp_month (IntegerField) ā€“ Exp month. Card expiration month.
ā€¢ exp_year (IntegerField) ā€“ Exp year. Card expiration year.
ā€¢ fingerprint (CharField) ā€“ Fingerprint. Uniquely identiļ¬es this particular card num-
ber.
ā€¢ funding (StripeEnumField) ā€“ Funding. Card funding type.
ā€¢ last4 (CharField) ā€“ Last4. Last four digits of Card number.
ā€¢ name (TextField) ā€“ Name. Cardholder name.
ā€¢ tokenization_method (StripeEnumField) ā€“ Tokenization method. If the card
number is tokenized, this is the method that was used.
classmethod Card.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Card.api_retrieve(api_key=None, stripe_account=None)
Card.get_stripe_dashboard_url()
Card.remove()
Removes a legacy source from this customerā€™s account.
classmethod Card.create_token(number, exp_month, exp_year, cvc, api_key=ā€, **kwargs)
Creates a single use token that wraps the details of a credit card. This token can be used in place of a credit
card dictionary with any API method. These tokens can only be used once: by creating a new charge object, or
attaching them to a customer. (Source: https://stripe.com/docs/api/python#create_card_token)
Parameters
ā€¢ number (str) ā€“ The card number without any separators (no spaces)
ā€¢ exp_month (int) ā€“ The cardā€™s expiration month. (two digits)
ā€¢ exp_year (int) ā€“ The cardā€™s expiration year. (four digits)
ā€¢ cvc (str) ā€“ Card security code.
ā€¢ api_key (str) ā€“
Return type stripe.Token
Card.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Card.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
1.19. Models 57
dj-stripe Documentation, Release 2.2.3
Parameters data (dict) ā€“ stripe object
Return type cls
PaymentMethod
class djstripe.models.PaymentMethod(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#payment_methods
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ billing_details (JSONField) ā€“ Billing details. Billing information associated with
the PaymentMethod that may be used or required by particular types of payment methods.
ā€¢ card (JSONField) ā€“ Card. If this is a card PaymentMethod, this hash contains details
about the card.
ā€¢ card_present (JSONField) ā€“ Card present. If this is an card_present Payment-
Method, this hash contains details about the Card Present payment method.
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. Customer to which this Payment-
Method is saved.This will not be set when the PaymentMethod has not been saved to a
Customer.
ā€¢ type (CharField) ā€“ Type. The type of the PaymentMethod. An additional hash is
included on the PaymentMethod with a name matching this value. It contains additional
information speciļ¬c to the PaymentMethod type.
classmethod PaymentMethod.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
PaymentMethod.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
58 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
PaymentMethod.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod PaymentMethod.attach(payment_method, customer, api_key=ā€)
Attach a payment method to a customer :param payment_method: :type payment_method: str, PaymentMethod
:param customer: :type customer: Union[str, Customer] :param api_key: :type api_key: str :return: :rtype:
PaymentMethod
PaymentMethod.detach()
Detach the payment method from its customer.
Returns Returns true if the payment method was newly detached, false if it was already detached
Return type bool
PaymentMethod.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod PaymentMethod.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Source
class djstripe.models.Source(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#sources
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
1.19. Models 59
dj-stripe Documentation, Release 2.2.3
ā€¢ amount (StripeDecimalCurrencyAmountField) ā€“ Amount. Amount (as deci-
mal) associated with the source. This is the amount for which the source will be chargeable
once ready. Required for single_use sources.
ā€¢ client_secret (CharField) ā€“ Client secret. The client secret of the source. Used for
client-side retrieval using a publishable key.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ flow (StripeEnumField) ā€“ Flow. The authentication ļ¬‚ow of the source.
ā€¢ owner (JSONField) ā€“ Owner. Information about the owner of the payment instrument
that may be used or required by particular source types.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. Extra information
about a source. This will appear on your customerā€™s statement every time you charge the
source.
ā€¢ status (StripeEnumField) ā€“ Status. The status of the source. Only chargeable
sources can be used to create a charge.
ā€¢ type (StripeEnumField) ā€“ Type. The type of the source.
ā€¢ usage (StripeEnumField) ā€“ Usage. Whether this source should be reusable or not.
Some source types may or may not be reusable by construction, while other may leave the
option at creation.
ā€¢ code_verification (JSONField) ā€“ Code veriļ¬cation. Information related to the
code veriļ¬cation ļ¬‚ow. Present if the source is authenticated by a veriļ¬cation code (ļ¬‚ow is
code_veriļ¬cation).
ā€¢ receiver (JSONField) ā€“ Receiver. Information related to the receiver ļ¬‚ow. Present if
the source is a receiver (ļ¬‚ow is receiver).
ā€¢ redirect (JSONField) ā€“ Redirect. Information related to the redirect ļ¬‚ow. Present if
the source is authenticated by a redirect (ļ¬‚ow is redirect).
ā€¢ source_data (JSONField) ā€“ Source data. The data corresponding to the source type.
ā€¢ customer (ForeignKey to Customer) ā€“ Customer
classmethod Source.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Source.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Source.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
60 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Source.detach()
Detach the source from its customer.
Returns
Return type bool
Source.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Source.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
1.19.3 Billing
Coupon
class djstripe.models.Coupon(djstripe_id, livemode, created, metadata, description,
djstripe_created, djstripe_updated, id, amount_off, currency,
duration, duration_in_months, max_redemptions, name, per-
cent_off, redeem_by, times_redeemed)
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ amount_off (StripeDecimalCurrencyAmountField) ā€“ Amount off. Amount
(as decimal) that will be taken off the subtotal of any invoices for this customer.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ duration (StripeEnumField) ā€“ Duration. Describes how long a customer who ap-
plies this coupon will get the discount.
ā€¢ duration_in_months (PositiveIntegerField) ā€“ Duration in months. If dura-
tion is repeating, the number of months the coupon applies.
1.19. Models 61
dj-stripe Documentation, Release 2.2.3
ā€¢ max_redemptions (PositiveIntegerField) ā€“ Max redemptions. Maximum
number of times this coupon can be redeemed, in total, before it is no longer valid.
ā€¢ name (TextField) ā€“ Name. Name of the coupon displayed to customers on for instance
invoices or receipts.
ā€¢ percent_off (StripePercentField) ā€“ Percent off. Percent that will be taken off
the subtotal of any invoices for this customer for the duration of the coupon. For example, a
coupon with percent_off of 50 will make a $100 invoice $50 instead.
ā€¢ redeem_by (StripeDateTimeField) ā€“ Redeem by. Date after which the coupon can
no longer be redeemed. Max 5 years in the future.
ā€¢ times_redeemed (PositiveIntegerField) ā€“ Times redeemed. Number of times
this coupon has been applied to a customer.
classmethod Coupon.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Coupon.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Coupon.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
Coupon.human_readable_amount
Coupon.human_readable
Coupon.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Coupon.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Invoice
class djstripe.models.Invoice(*args, **kwargs)
Invoices are statements of what a customer owes for a particular billing period, including subscriptions, invoice
items, and any automatic proration adjustments if necessary.
62 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Once an invoice is created, payment is automatically attempted. Note that the payment, while automatic, does
not happen exactly at the time of invoice creation. If you have conļ¬gured webhooks, the invoice will wait until
one hour after the last webhook is successfully sent (or the last webhook times out after failing).
Any customer credit on the account is applied before determining how much is due for that invoice (the amount
that will be actually charged). If the amount due for the invoice is less than 50 cents (the minimum for a charge),
we add the amount to the customerā€™s running account balance to be added to the next invoice. If this amount is
negative, it will act as a credit to offset the next invoice. Note that the customer account balance does not include
unpaid invoices; it only includes balances that need to be taken into account when calculating the amount due
for the next invoice.
Stripe documentation: https://stripe.com/docs/api/python#invoices
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ account_country (CharField) ā€“ Account country. The country of the business as-
sociated with this invoice, most often the business creating the invoice.
ā€¢ account_name (TextField) ā€“ Account name. The public name of the business asso-
ciated with this invoice, most often the business creating the invoice.
ā€¢ amount_due (StripeDecimalCurrencyAmountField) ā€“ Amount due. Final
amount due (as decimal) at this time for this invoice. If the invoiceā€™s total is smaller than
the minimum charge amount, for example, or if there is account credit that can be applied to
the invoice, the amount_due may be 0. If there is a positive starting_balance for the invoice
(the customer owes money), the amount_due will also take that into account. The charge
that gets generated for the invoice will be for the amount speciļ¬ed in amount_due.
ā€¢ amount_paid (StripeDecimalCurrencyAmountField) ā€“ Amount paid. The
amount, (as decimal), that was paid.
ā€¢ amount_remaining (StripeDecimalCurrencyAmountField) ā€“ Amount re-
maining. The amount remaining, (as decimal), that is due.
ā€¢ application_fee_amount (StripeDecimalCurrencyAmountField) ā€“ Ap-
plication fee amount. The fee (as decimal) that will be applied to the invoice and transferred
to the application ownerā€™s Stripe account when the invoice is paid.
ā€¢ attempt_count (IntegerField) ā€“ Attempt count. Number of payment attempts
made for this invoice, from the perspective of the payment retry schedule. Any payment
attempt counts as the ļ¬rst attempt, and subsequently only automatic retries increment the
1.19. Models 63
dj-stripe Documentation, Release 2.2.3
attempt count. In other words, manual payment attempts after the ļ¬rst attempt do not affect
the retry schedule.
ā€¢ attempted (BooleanField) ā€“ Attempted. Whether or not an attempt has been made
to pay the invoice. An invoice is not attempted until 1 hour after the invoice.created
webhook, for example, so you might not want to display that invoice as unpaid to your users.
ā€¢ auto_advance (NullBooleanField) ā€“ Auto advance. Controls whether Stripe will
perform automatic collection of the invoice. When false, the invoiceā€™s state will not auto-
matically advance without an explicit action.
ā€¢ billing_reason (StripeEnumField) ā€“ Billing reason. Indicates the reason why
the invoice was created. subscription_cycle indicates an invoice created by a subscription
advancing into a new period. subscription_create indicates an invoice created due to creating
a subscription. subscription_update indicates an invoice created due to updating a subscrip-
tion. subscription is set for all old invoices to indicate either a change to a subscription or a
period advancement. manual is set for all invoices unrelated to a subscription (for example:
created via the invoice editor). The upcoming value is reserved for simulated invoices per
the upcoming invoice endpoint. subscription_threshold indicates an invoice created due to
a billing threshold being reached.
ā€¢ charge (OneToOneField to Charge) ā€“ Charge. The latest charge generated for this in-
voice, if any.
ā€¢ closed (NullBooleanField) ā€“ Closed. Whether or not the invoice is still trying to
collect payment. An invoice is closed if itā€™s either paid or it has been marked closed. A
closed invoice will no longer attempt to collect payment.
ā€¢ collection_method (StripeEnumField) ā€“ Collection method. When charging au-
tomatically, Stripe will attempt to pay this invoice using the default source attached to the
customer. When sending an invoice, Stripe will email this invoice to the customer with
payment instructions.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. The customer associated with this
invoice.
ā€¢ customer_address (JSONField) ā€“ Customer address. The customerā€™s address. Until
the invoice is ļ¬nalized, this ļ¬eld will equal customer.address. Once the invoice is ļ¬nalized,
this ļ¬eld will no longer be updated.
ā€¢ customer_email (TextField) ā€“ Customer email. The customerā€™s email. Until the
invoice is ļ¬nalized, this ļ¬eld will equal customer.email. Once the invoice is ļ¬nalized, this
ļ¬eld will no longer be updated.
ā€¢ customer_name (TextField) ā€“ Customer name. The customerā€™s name. Until the
invoice is ļ¬nalized, this ļ¬eld will equal customer.name. Once the invoice is ļ¬nalized, this
ļ¬eld will no longer be updated.
ā€¢ customer_phone (TextField) ā€“ Customer phone. The customerā€™s phone number.
Until the invoice is ļ¬nalized, this ļ¬eld will equal customer.phone_. Once the invoice is
ļ¬nalized, this ļ¬eld will no longer be updated.
ā€¢ customer_shipping (JSONField) ā€“ Customer shipping. The customerā€™s shipping
information. Until the invoice is ļ¬nalized, this ļ¬eld will equal customer.shipping. Once the
invoice is ļ¬nalized, this ļ¬eld will no longer be updated.
64 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ customer_tax_exempt (StripeEnumField) ā€“ Customer tax exempt. The cus-
tomerā€™s tax exempt status. Until the invoice is ļ¬nalized, this ļ¬eld will equal cus-
tomer.tax_exempt. Once the invoice is ļ¬nalized, this ļ¬eld will no longer be updated.
ā€¢ default_payment_method (ForeignKey to PaymentMethod) ā€“ Default payment
method. Default payment method for the invoice. It must belong to the customer asso-
ciated with the invoice. If not set, defaults to the subscriptionā€™s default payment method, if
any, or to the default payment method in the customerā€™s invoice settings.
ā€¢ due_date (StripeDateTimeField) ā€“ Due date. The date on which payment for this
invoice is due. This value will be null for invoices where billing=charge_automatically.
ā€¢ ending_balance (StripeQuantumCurrencyAmountField) ā€“ Ending balance.
Ending customer balance (in cents) after attempting to pay invoice. If the invoice has not
been attempted yet, this will be null.
ā€¢ footer (TextField) ā€“ Footer. Footer displayed on the invoice.
ā€¢ forgiven (NullBooleanField) ā€“ Forgiven. Whether or not the invoice has been for-
given. Forgiving an invoice instructs us to update the subscription status as if the invoice
were successfully paid. Once an invoice has been forgiven, it cannot be unforgiven or re-
opened.
ā€¢ hosted_invoice_url (TextField) ā€“ Hosted invoice url. The URL for the hosted
invoice page, which allows customers to view and pay an invoice. If the invoice has not
been frozen yet, this will be null.
ā€¢ invoice_pdf (TextField) ā€“ Invoice pdf. The link to download the PDF for the in-
voice. If the invoice has not been frozen yet, this will be null.
ā€¢ next_payment_attempt (StripeDateTimeField) ā€“ Next payment attempt. The
time at which payment will next be attempted.
ā€¢ number (CharField) ā€“ Number. A unique, identifying string that appears on emails sent
to the customer for this invoice. This starts with the customerā€™s unique invoice_preļ¬x if it is
speciļ¬ed.
ā€¢ paid (BooleanField) ā€“ Paid. The time at which payment will next be attempted.
ā€¢ payment_intent (OneToOneField to PaymentIntent) ā€“ Payment intent. The Pay-
mentIntent associated with this invoice. The PaymentIntent is generated when the invoice is
ļ¬nalized, and can then be used to pay the invoice.Note that voiding an invoice will cancel
the PaymentIntent
ā€¢ period_end (StripeDateTimeField) ā€“ Period end. End of the usage period during
which invoice items were added to this invoice.
ā€¢ period_start (StripeDateTimeField) ā€“ Period start. Start of the usage period
during which invoice items were added to this invoice.
ā€¢ post_payment_credit_notes_amount (StripeQuantumCurrencyAmountField)
ā€“ Post payment credit notes amount. Total amount (in cents) of all post-payment credit
notes issued for this invoice.
ā€¢ pre_payment_credit_notes_amount (StripeQuantumCurrencyAmountField)
ā€“ Pre payment credit notes amount. Total amount (in cents) of all pre-payment credit notes
issued for this invoice.
ā€¢ receipt_number (CharField) ā€“ Receipt number. This is the transaction number that
appears on email receipts sent for this invoice.
1.19. Models 65
dj-stripe Documentation, Release 2.2.3
ā€¢ starting_balance (StripeQuantumCurrencyAmountField) ā€“ Starting bal-
ance. Starting customer balance (in cents) before attempting to pay invoice. If the invoice
has not been attempted yet, this will be the current customer balance.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. An arbitrary string
to be displayed on your customerā€™s credit card statement. The statement description may
not include <>ā€ā€™ characters, and will appear on your customerā€™s statement in capital letters.
Non-ASCII characters are automatically stripped. While most banks display this informa-
tion consistently, some may display it incorrectly or not at all.
ā€¢ status_transitions (JSONField) ā€“ Status transitions
ā€¢ subscription (ForeignKey to Subscription) ā€“ Subscription. The subscription that
this invoice was prepared for, if any.
ā€¢ subscription_proration_date (StripeDateTimeField) ā€“ Subscription pro-
ration date. Only set for upcoming invoices that preview prorations. The time used to
calculate prorations.
ā€¢ subtotal (StripeDecimalCurrencyAmountField) ā€“ Subtotal. Total (as deci-
mal) of all subscriptions, invoice items, and prorations on the invoice before any discount or
tax is applied.
ā€¢ tax (StripeDecimalCurrencyAmountField) ā€“ Tax. The amount (as decimal)
of tax included in the total, calculated from tax_percent and the subtotal. If no
tax_percent is deļ¬ned, this value will be null.
ā€¢ tax_percent (StripePercentField) ā€“ Tax percent. This percentage of the subtotal
has been added to the total amount of the invoice, including invoice line items and discounts.
This ļ¬eld is inherited from the subscriptionā€™s tax_percent ļ¬eld, but can be changed
before the invoice is paid. This ļ¬eld defaults to null.
ā€¢ threshold_reason (JSONField) ā€“ Threshold reason. If billing_reason is set to sub-
scription_threshold this returns more information on which threshold rules triggered the
invoice.
ā€¢ total (StripeDecimalCurrencyAmountField) ā€“ Total (as decimal) after dis-
count.
ā€¢ webhooks_delivered_at (StripeDateTimeField) ā€“ Webhooks delivered at.
The time at which webhooks for this invoice were successfully delivered (if the invoice had
no webhooks to deliver, this will match date). Invoice payment is delayed until webhooks
are delivered, or until all webhook delivery attempts have been exhausted.
ā€¢ default_tax_rates (ManyToManyField) ā€“ Default tax rates. The tax rates applied
to this invoice, if any.
classmethod Invoice.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Invoice.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
66 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Invoice.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod Invoice.upcoming(api_key=ā€, customer=None, coupon=None, subscription=None,
subscription_plan=None, subscription_prorate=None, subscrip-
tion_proration_date=None, subscription_quantity=None, subscrip-
tion_trial_end=None, **kwargs)
Gets the upcoming preview invoice (singular) for a customer.
At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are
pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discount
that is applicable to the customer. (Source: https://stripe.com/docs/api#upcoming_invoice)
Important: Note that when you are viewing an upcoming invoice, you are simply viewing a preview.
Parameters
ā€¢ customer (Customer or string (customer ID)) ā€“ The identiļ¬er of the cus-
tomer whose upcoming invoice youā€™d like to retrieve.
ā€¢ coupon (str) ā€“ The code of the coupon to apply.
ā€¢ subscription (Subscription or string (subscription ID)) ā€“ The
identiļ¬er of the subscription to retrieve an invoice for.
ā€¢ subscription_plan (Plan or string (plan ID)) ā€“ If set, the invoice re-
turned will preview updating the subscription given to this plan, or creating a new sub-
scription to this plan if no subscription is given.
ā€¢ subscription_prorate (bool) ā€“ If previewing an update to a subscription, this de-
cides whether the preview will show the result of applying prorations or not.
ā€¢ subscription_proration_date (datetime) ā€“ If previewing an update to a sub-
scription, and doing proration, subscription_proration_date forces the proration to be calcu-
lated as though the update was done at the speciļ¬ed time.
ā€¢ subscription_quantity (int) ā€“ If provided, the invoice returned will preview up-
dating or creating a subscription with that quantity.
ā€¢ subscription_trial_end (datetime) ā€“ If provided, the invoice returned will pre-
view updating or creating a subscription with that trial end.
Returns The upcoming preview invoice.
Return type UpcomingInvoice
Invoice.retry()
Retry payment on this invoice if it isnā€™t paid, closed, or forgiven.
Invoice.status
Invoice.plan
Gets the associated plan for this invoice.
1.19. Models 67
dj-stripe Documentation, Release 2.2.3
In order to provide a consistent view of invoices, the plan object should be taken from the ļ¬rst invoice item that
has one, rather than using the plan associated with the subscription.
Subscriptions (and their associated plan) are updated by the customer and represent what is current, but invoice
items are immutable within the invoice and stay static/unchanged.
In other words, a plan retrieved from an invoice item will represent the plan as it was at the time an invoice was
issued. The plan retrieved from the subscription will be the currently active plan.
Returns The associated plan for the invoice.
Return type djstripe.Plan
Invoice.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Invoice.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
InvoiceItem
class djstripe.models.InvoiceItem(*args, **kwargs)
Sometimes you want to add a charge or credit to a customer but only actually charge the customerā€™s card at the
end of a regular billing cycle. This is useful for combining several charges to minimize per-transaction fees or
having Stripe tabulate your usage-based billing totals.
Stripe documentation: https://stripe.com/docs/api/python#invoiceitems
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeDecimalCurrencyAmountField) ā€“ Amount. Amount invoiced
(as decimal).
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
68 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. The customer associated with this
invoiceitem.
ā€¢ date (StripeDateTimeField) ā€“ Date. The date on the invoiceitem.
ā€¢ discountable (BooleanField) ā€“ Discountable. If True, discounts will apply to this
invoice item. Always False for prorations.
ā€¢ invoice (ForeignKey to Invoice) ā€“ Invoice. The invoice to which this invoiceitem is
attached.
ā€¢ period (JSONField) ā€“ Period
ā€¢ period_end (StripeDateTimeField) ā€“ Period end. Might be the date when this
invoiceitemā€™s invoice was sent.
ā€¢ period_start (StripeDateTimeField) ā€“ Period start. Might be the date when this
invoiceitem was added to the invoice
ā€¢ plan (ForeignKey to Plan) ā€“ Plan. If the invoice item is a proration, the plan of the
subscription for which the proration was computed.
ā€¢ proration (BooleanField) ā€“ Proration. Whether or not the invoice item was created
automatically as a proration adjustment when the customer switched plans.
ā€¢ quantity (IntegerField) ā€“ Quantity. If the invoice item is a proration, the quantity
of the subscription for which the proration was computed.
ā€¢ subscription (ForeignKey to Subscription) ā€“ Subscription. The subscription that
this invoice item has been created for, if any.
ā€¢ tax_rates (ManyToManyField) ā€“ Tax rates. The tax rates which apply to this invoice
item. When set, the default_tax_rates on the invoice do not apply to this invoice item.
classmethod InvoiceItem.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
InvoiceItem.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
InvoiceItem.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod InvoiceItem.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
1.19. Models 69
dj-stripe Documentation, Release 2.2.3
InvoiceItem
class djstripe.models.InvoiceItem(*args, **kwargs)
Sometimes you want to add a charge or credit to a customer but only actually charge the customerā€™s card at the
end of a regular billing cycle. This is useful for combining several charges to minimize per-transaction fees or
having Stripe tabulate your usage-based billing totals.
Stripe documentation: https://stripe.com/docs/api/python#invoiceitems
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeDecimalCurrencyAmountField) ā€“ Amount. Amount invoiced
(as decimal).
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. The customer associated with this
invoiceitem.
ā€¢ date (StripeDateTimeField) ā€“ Date. The date on the invoiceitem.
ā€¢ discountable (BooleanField) ā€“ Discountable. If True, discounts will apply to this
invoice item. Always False for prorations.
ā€¢ invoice (ForeignKey to Invoice) ā€“ Invoice. The invoice to which this invoiceitem is
attached.
ā€¢ period (JSONField) ā€“ Period
ā€¢ period_end (StripeDateTimeField) ā€“ Period end. Might be the date when this
invoiceitemā€™s invoice was sent.
ā€¢ period_start (StripeDateTimeField) ā€“ Period start. Might be the date when this
invoiceitem was added to the invoice
ā€¢ plan (ForeignKey to Plan) ā€“ Plan. If the invoice item is a proration, the plan of the
subscription for which the proration was computed.
ā€¢ proration (BooleanField) ā€“ Proration. Whether or not the invoice item was created
automatically as a proration adjustment when the customer switched plans.
ā€¢ quantity (IntegerField) ā€“ Quantity. If the invoice item is a proration, the quantity
of the subscription for which the proration was computed.
70 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ subscription (ForeignKey to Subscription) ā€“ Subscription. The subscription that
this invoice item has been created for, if any.
ā€¢ tax_rates (ManyToManyField) ā€“ Tax rates. The tax rates which apply to this invoice
item. When set, the default_tax_rates on the invoice do not apply to this invoice item.
classmethod InvoiceItem.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
InvoiceItem.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
InvoiceItem.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
InvoiceItem.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod InvoiceItem.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Plan
class djstripe.models.Plan(*args, **kwargs)
A subscription plan contains the pricing information for different products and feature levels on your site.
Stripe documentation: https://stripe.com/docs/api/python#plans)
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
1.19. Models 71
dj-stripe Documentation, Release 2.2.3
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ active (BooleanField) ā€“ Active. Whether the plan is currently available for new
subscriptions.
ā€¢ aggregate_usage (StripeEnumField) ā€“ Aggregate usage. Speciļ¬es a usage ag-
gregation strategy for plans of usage_type=metered. Allowed values are sum for summing
up all usage during a period, last_during_period for picking the last usage record reported
within a period, last_ever for picking the last usage record ever (across period bounds) or
max which picks the usage record with the maximum reported usage during a period. De-
faults to sum.
ā€¢ amount (StripeDecimalCurrencyAmountField) ā€“ Amount. Amount (as deci-
mal) to be charged on the interval speciļ¬ed.
ā€¢ billing_scheme (StripeEnumField) ā€“ Billing scheme. Describes how to compute
the price per period. Either per_unit or tiered. per_unit indicates that the ļ¬xed amount (spec-
iļ¬ed in amount) will be charged per unit in quantity (for plans with usage_type=licensed),
or per unit of total usage (for plans with usage_type=metered). tiered indicates that the unit
pricing will be computed using a tiering strategy as deļ¬ned using the tiers and tiers_mode
attributes.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ interval (StripeEnumField) ā€“ Interval. The frequency with which a subscription
should be billed.
ā€¢ interval_count (IntegerField) ā€“ Interval count. The number of intervals (speci-
ļ¬ed in the interval property) between each subscription billing.
ā€¢ nickname (TextField) ā€“ Nickname. A brief description of the plan, hidden from cus-
tomers.
ā€¢ product (ForeignKey to Product) ā€“ Product. The product whose pricing this plan de-
termines.
ā€¢ tiers (JSONField) ā€“ Tiers. Each element represents a pricing tier. This parameter
requires billing_scheme to be set to tiered.
ā€¢ tiers_mode (StripeEnumField) ā€“ Tiers mode. Deļ¬nes if the tiering price should be
graduated or volume based. In volume-based tiering, the maximum quantity within a period
determines the per unit price, in graduated tiering pricing can successively change as the
quantity grows.
ā€¢ transform_usage (JSONField) ā€“ Transform usage. Apply a transformation to the
reported usage or set quantity before computing the billed price. Cannot be combined with
tiers.
ā€¢ trial_period_days (IntegerField) ā€“ Trial period days. Number of trial period
days granted when subscribing a customer to this plan. Null if the plan has no trial period.
ā€¢ usage_type (StripeEnumField) ā€“ Usage type. Conļ¬gures how the quantity per pe-
riod should be determined, can be either metered or licensed. licensed will automatically
72 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
bill the quantity set for a plan when adding it to a subscription, metered will aggregate the
total usage based on usage records. Defaults to licensed.
ā€¢ name (TextField) ā€“ Name. Name of the plan, to be displayed on invoices and in the
web interface.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. An arbitrary string
to be displayed on your customerā€™s credit card statement. The statement description may
not include <>ā€ā€™ characters, and will appear on your customerā€™s statement in capital letters.
Non-ASCII characters are automatically stripped. While most banks display this informa-
tion consistently, some may display it incorrectly or not at all.
classmethod Plan.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Plan.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Plan.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod Plan.get_or_create(**kwargs)
Get or create a Plan.
Plan.amount_in_cents
Plan.human_readable_price
Plan.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Plan.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Subscription
class djstripe.models.Subscription(*args, **kwargs)
Subscriptions allow you to charge a customerā€™s card on a recurring basis. A subscription ties a customer to a
particular plan youā€™ve created.
A subscription still in its trial period is trialing and moves to active when the trial period is over.
1.19. Models 73
dj-stripe Documentation, Release 2.2.3
When payment to renew the subscription fails, the subscription becomes past_due. After Stripe has exhausted
all payment retry attempts, the subscription ends up with a status of either canceled or unpaid depending
on your retry settings.
Note that when a subscription has a status of unpaid, no subsequent invoices will be attempted (invoices will
be created, but then immediately automatically closed.
Additionally, updating customer card details will not lead to Stripe retrying the latest invoice.). After receiving
updated card details from a customer, you may choose to reopen and pay their closed invoices.
Stripe documentation: https://stripe.com/docs/api/python#subscriptions
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ application_fee_percent (StripePercentField) ā€“ Application fee percent.
A positive decimal that represents the fee percentage of the subscription invoice amount that
will be transferred to the application ownerā€™s Stripe account each billing period.
ā€¢ billing (StripeEnumField) ā€“ Billing. Either charge_automatically, or
send_invoice. When charging automatically, Stripe will attempt to pay this subscription
at the end of the cycle using the default source attached to the customer. When sending an
invoice, Stripe will email your customer an invoice with payment instructions.
ā€¢ billing_cycle_anchor (StripeDateTimeField) ā€“ Billing cycle anchor. Deter-
mines the date of the ļ¬rst full invoice, and, for plans with month or year intervals, the day
of the month for subsequent invoices.
ā€¢ cancel_at_period_end (BooleanField) ā€“ Cancel at period end. If the
subscription has been canceled with the at_period_end ļ¬‚ag set to true,
cancel_at_period_end on the subscription will be true. You can use this attribute
to determine whether a subscription that has a status of active is scheduled to be canceled at
the end of the current period.
ā€¢ canceled_at (StripeDateTimeField) ā€“ Canceled at. If the subscription has
been canceled, the date of that cancellation. If the subscription was canceled with
cancel_at_period_end, canceled_at will still reļ¬‚ect the date of the initial cancel-
lation request, not the end of the subscription period when the subscription is automatically
moved to a canceled state.
ā€¢ current_period_end (StripeDateTimeField) ā€“ Current period end. End of the
current period for which the subscription has been invoiced. At the end of this period, a new
invoice will be created.
74 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ current_period_start (StripeDateTimeField) ā€“ Current period start. Start of
the current period for which the subscription has been invoiced.
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. The customer associated with this
subscription.
ā€¢ days_until_due (IntegerField) ā€“ Days until due. Number of days a customer has
to pay invoices generated by this subscription. This value will be null for subscriptions
where billing=charge_automatically.
ā€¢ ended_at (StripeDateTimeField) ā€“ Ended at. If the subscription has ended (either
because it was canceled or because the customer was switched to a subscription to a new
plan), the date the subscription ended.
ā€¢ pending_setup_intent (ForeignKey to SetupIntent) ā€“ Pending setup intent. We
can use this SetupIntent to collect user authentication when creating a subscription without
immediate payment or updating a subscriptionā€™s payment method, allowing you to optimize
for off-session payments.
ā€¢ plan (ForeignKey to Plan) ā€“ Plan. The plan associated with this subscription. This value
will be null for multi-plan subscriptions
ā€¢ quantity (IntegerField) ā€“ Quantity. The quantity applied to this subscription. This
value will be null for multi-plan subscriptions
ā€¢ start (StripeDateTimeField) ā€“ Start. Date of the last substantial change to this
subscription. For example, a change to the items array, or a change of status, will reset this
timestamp.
ā€¢ status (StripeEnumField) ā€“ Status. The status of this subscription.
ā€¢ tax_percent (StripePercentField) ā€“ Tax percent. A positive decimal (with at
most two decimal places) between 1 and 100. This represents the percentage of the sub-
scription invoice subtotal that will be calculated and added as tax to the ļ¬nal amount each
billing period.
ā€¢ trial_end (StripeDateTimeField) ā€“ Trial end. If the subscription has a trial, the
end of that trial.
ā€¢ trial_start (StripeDateTimeField) ā€“ Trial start. If the subscription has a trial,
the beginning of that trial.
ā€¢ default_tax_rates (ManyToManyField) ā€“ Default tax rates. The tax rates that
will apply to any subscription item that does not have tax_rates set. Invoices created will
have their default_tax_rates populated from the subscription.
classmethod Subscription.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Subscription.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
1.19. Models 75
dj-stripe Documentation, Release 2.2.3
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Subscription.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
Subscription.update(plan=None, application_fee_percent=None, billing_cycle_anchor=None,
coupon=None, prorate=False, proration_date=None, metadata=None, quan-
tity=None, tax_percent=None, trial_end=None)
See Customer.subscribe()
Parameters
ā€¢ plan (Plan or string (plan ID)) ā€“ The plan to which to subscribe the customer.
ā€¢ application_fee_percent ā€“
ā€¢ billing_cycle_anchor ā€“
ā€¢ coupon ā€“
ā€¢ prorate (boolean) ā€“ Whether or not to prorate when switching plans. Default is True.
ā€¢ proration_date (datetime) ā€“ If set, the proration will be calculated as though the
subscription was updated at the given time. This can be used to apply exactly the same pro-
ration that was previewed with upcoming invoice endpoint. It can also be used to implement
custom proration logic, such as prorating by day instead of by second, by providing the time
that you wish to use for proration calculations.
ā€¢ metadata ā€“
ā€¢ quantity ā€“
ā€¢ tax_percent ā€“
ā€¢ trial_end ā€“
Note: The default value for prorate is the DJSTRIPE_PRORATION_POLICY setting.
Important: Updating a subscription by changing the plan or quantity creates a new Subscription in Stripe
(and dj-stripe).
Subscription.extend(delta)
Extends this subscription by the provided delta.
Parameters delta (timedelta) ā€“ The timedelta by which to extend this subscription.
Subscription.cancel(at_period_end=True)
Cancels this subscription. If you set the at_period_end parameter to true, the subscription will remain active
until the end of the period, at which point it will be canceled and not renewed. By default, the subscription
is terminated immediately. In either case, the customer will not be charged again for the subscription. Note,
however, that any pending invoice items that youā€™ve created will still be charged for at the end of the period
unless manually deleted. If youā€™ve set the subscription to cancel at period end, any pending prorations will also
be left in place and collected at the end of the period, but if the subscription is set to cancel immediately, pending
prorations will be removed.
By default, all unpaid invoices for the customer will be closed upon subscription cancellation. We do this in
order to prevent unexpected payment retries once the customer has canceled a subscription. However, you
can reopen the invoices manually after subscription cancellation to have us proceed with automatic retries, or
76 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
you could even re-attempt payment yourself on all unpaid invoices before allowing the customer to cancel the
subscription at all.
Parameters at_period_end (boolean) ā€“ A ļ¬‚ag that if set to true will delay the cancellation
of the subscription until the end of the current period. Default is False.
Important: If a subscription is canceled during a trial period, the at_period_end ļ¬‚ag will be overridden
to False so that the trial ends immediately and the customerā€™s card isnā€™t charged.
Subscription.reactivate()
Reactivates this subscription.
If a customerā€™s subscription is canceled with at_period_end set to True and it has not yet reached the end
of the billing period, it can be reactivated. Subscriptions canceled immediately cannot be reactivated. (Source:
https://stripe.com/docs/subscriptions/canceling-pausing)
Warning: Reactivating a fully canceled Subscription will fail silently. Be sure to check the returned
Subscriptionā€™s status.
Subscription.is_period_current()
Returns True if this subscriptionā€™s period is current, false otherwise.
Subscription.is_status_current()
Returns True if this subscriptionā€™s status is current (active or trialing), false otherwise.
Subscription.is_status_temporarily_current()
A status is temporarily current when the subscription is canceled with the at_period_end ļ¬‚ag. The sub-
scription is still active, but is technically canceled and weā€™re just waiting for it to run out.
You could use this method to give customers limited service after theyā€™ve canceled. For example, a video
on demand service could only allow customers to download their libraries and do nothing else when their
subscription is temporarily current.
Subscription.is_valid()
Returns True if this subscriptionā€™s status and period are current, false otherwise.
Subscription.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Subscription.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
SubscriptionItem
class djstripe.models.SubscriptionItem(*args, **kwargs)
Subscription items allow you to create customer subscriptions with more than one plan, making it easy to
represent complex billing relationships.
Stripe documentation: https://stripe.com/docs/api#subscription_items
1.19. Models 77
dj-stripe Documentation, Release 2.2.3
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ plan (ForeignKey to Plan) ā€“ Plan. The plan the customer is subscribed to.
ā€¢ quantity (PositiveIntegerField) ā€“ Quantity. The quantity of the plan to which
the customer should be subscribed.
ā€¢ subscription (ForeignKey to Subscription) ā€“ Subscription. The subscription this
subscription item belongs to.
ā€¢ tax_rates (ManyToManyField) ā€“ Tax rates. The tax rates which apply to this sub-
scription_item. When set, the default_tax_rates on the subscription do not apply to this
subscription_item.
classmethod SubscriptionItem.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
SubscriptionItem.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
SubscriptionItem.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod SubscriptionItem.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
78 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Return type cls
TaxRate
class djstripe.models.TaxRate(*args, **kwargs)
Tax rates can be applied to invoices and subscriptions to collect tax.
Stripe documentation: https://stripe.com/docs/api/tax_rates
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ active (BooleanField) ā€“ Active. Defaults to true. When set to false, this tax rate
cannot be applied to objects in the API, but will still be applied to subscriptions and invoices
that already have it set.
ā€¢ display_name (CharField) ā€“ Display name. The display name of the tax rates as it
will appear to your customer on their receipt email, PDF, and the hosted invoice page.
ā€¢ inclusive (BooleanField) ā€“ Inclusive. This speciļ¬es if the tax rate is inclusive or
exclusive.
ā€¢ jurisdiction (CharField) ā€“ Jurisdiction. The jurisdiction for the tax rate.
ā€¢ percentage (StripePercentField) ā€“ Percentage. This represents the tax rate per-
cent out of 100.
classmethod TaxRate.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
TaxRate.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
1.19. Models 79
dj-stripe Documentation, Release 2.2.3
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
TaxRate.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod TaxRate.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
UpcomingInvoice
class djstripe.models.UpcomingInvoice(*args, **kwargs)
The preview of an upcoming invoice - does not exist in the Django database.
See BaseInvoice.upcoming()
Logically it should be set abstract, but that doesnā€™t quite work since we do actually want to instantiate the model
and use relations.
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ account_country (CharField) ā€“ Account country. The country of the business as-
sociated with this invoice, most often the business creating the invoice.
ā€¢ account_name (TextField) ā€“ Account name. The public name of the business asso-
ciated with this invoice, most often the business creating the invoice.
ā€¢ amount_due (StripeDecimalCurrencyAmountField) ā€“ Amount due. Final
amount due (as decimal) at this time for this invoice. If the invoiceā€™s total is smaller than
the minimum charge amount, for example, or if there is account credit that can be applied to
the invoice, the amount_due may be 0. If there is a positive starting_balance for the invoice
(the customer owes money), the amount_due will also take that into account. The charge
that gets generated for the invoice will be for the amount speciļ¬ed in amount_due.
ā€¢ amount_paid (StripeDecimalCurrencyAmountField) ā€“ Amount paid. The
amount, (as decimal), that was paid.
80 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ amount_remaining (StripeDecimalCurrencyAmountField) ā€“ Amount re-
maining. The amount remaining, (as decimal), that is due.
ā€¢ application_fee_amount (StripeDecimalCurrencyAmountField) ā€“ Ap-
plication fee amount. The fee (as decimal) that will be applied to the invoice and transferred
to the application ownerā€™s Stripe account when the invoice is paid.
ā€¢ attempt_count (IntegerField) ā€“ Attempt count. Number of payment attempts
made for this invoice, from the perspective of the payment retry schedule. Any payment
attempt counts as the ļ¬rst attempt, and subsequently only automatic retries increment the
attempt count. In other words, manual payment attempts after the ļ¬rst attempt do not affect
the retry schedule.
ā€¢ attempted (BooleanField) ā€“ Attempted. Whether or not an attempt has been made
to pay the invoice. An invoice is not attempted until 1 hour after the invoice.created
webhook, for example, so you might not want to display that invoice as unpaid to your users.
ā€¢ auto_advance (NullBooleanField) ā€“ Auto advance. Controls whether Stripe will
perform automatic collection of the invoice. When false, the invoiceā€™s state will not auto-
matically advance without an explicit action.
ā€¢ billing_reason (StripeEnumField) ā€“ Billing reason. Indicates the reason why
the invoice was created. subscription_cycle indicates an invoice created by a subscription
advancing into a new period. subscription_create indicates an invoice created due to creating
a subscription. subscription_update indicates an invoice created due to updating a subscrip-
tion. subscription is set for all old invoices to indicate either a change to a subscription or a
period advancement. manual is set for all invoices unrelated to a subscription (for example:
created via the invoice editor). The upcoming value is reserved for simulated invoices per
the upcoming invoice endpoint. subscription_threshold indicates an invoice created due to
a billing threshold being reached.
ā€¢ charge (OneToOneField to Charge) ā€“ Charge. The latest charge generated for this in-
voice, if any.
ā€¢ closed (NullBooleanField) ā€“ Closed. Whether or not the invoice is still trying to
collect payment. An invoice is closed if itā€™s either paid or it has been marked closed. A
closed invoice will no longer attempt to collect payment.
ā€¢ collection_method (StripeEnumField) ā€“ Collection method. When charging au-
tomatically, Stripe will attempt to pay this invoice using the default source attached to the
customer. When sending an invoice, Stripe will email this invoice to the customer with
payment instructions.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ customer (ForeignKey to Customer) ā€“ Customer. The customer associated with this
invoice.
ā€¢ customer_address (JSONField) ā€“ Customer address. The customerā€™s address. Until
the invoice is ļ¬nalized, this ļ¬eld will equal customer.address. Once the invoice is ļ¬nalized,
this ļ¬eld will no longer be updated.
ā€¢ customer_email (TextField) ā€“ Customer email. The customerā€™s email. Until the
invoice is ļ¬nalized, this ļ¬eld will equal customer.email. Once the invoice is ļ¬nalized, this
ļ¬eld will no longer be updated.
ā€¢ customer_name (TextField) ā€“ Customer name. The customerā€™s name. Until the
invoice is ļ¬nalized, this ļ¬eld will equal customer.name. Once the invoice is ļ¬nalized, this
ļ¬eld will no longer be updated.
1.19. Models 81
dj-stripe Documentation, Release 2.2.3
ā€¢ customer_phone (TextField) ā€“ Customer phone. The customerā€™s phone number.
Until the invoice is ļ¬nalized, this ļ¬eld will equal customer.phone_. Once the invoice is
ļ¬nalized, this ļ¬eld will no longer be updated.
ā€¢ customer_shipping (JSONField) ā€“ Customer shipping. The customerā€™s shipping
information. Until the invoice is ļ¬nalized, this ļ¬eld will equal customer.shipping. Once the
invoice is ļ¬nalized, this ļ¬eld will no longer be updated.
ā€¢ customer_tax_exempt (StripeEnumField) ā€“ Customer tax exempt. The cus-
tomerā€™s tax exempt status. Until the invoice is ļ¬nalized, this ļ¬eld will equal cus-
tomer.tax_exempt. Once the invoice is ļ¬nalized, this ļ¬eld will no longer be updated.
ā€¢ default_payment_method (ForeignKey to PaymentMethod) ā€“ Default payment
method. Default payment method for the invoice. It must belong to the customer asso-
ciated with the invoice. If not set, defaults to the subscriptionā€™s default payment method, if
any, or to the default payment method in the customerā€™s invoice settings.
ā€¢ due_date (StripeDateTimeField) ā€“ Due date. The date on which payment for this
invoice is due. This value will be null for invoices where billing=charge_automatically.
ā€¢ ending_balance (StripeQuantumCurrencyAmountField) ā€“ Ending balance.
Ending customer balance (in cents) after attempting to pay invoice. If the invoice has not
been attempted yet, this will be null.
ā€¢ footer (TextField) ā€“ Footer. Footer displayed on the invoice.
ā€¢ forgiven (NullBooleanField) ā€“ Forgiven. Whether or not the invoice has been for-
given. Forgiving an invoice instructs us to update the subscription status as if the invoice
were successfully paid. Once an invoice has been forgiven, it cannot be unforgiven or re-
opened.
ā€¢ hosted_invoice_url (TextField) ā€“ Hosted invoice url. The URL for the hosted
invoice page, which allows customers to view and pay an invoice. If the invoice has not
been frozen yet, this will be null.
ā€¢ invoice_pdf (TextField) ā€“ Invoice pdf. The link to download the PDF for the in-
voice. If the invoice has not been frozen yet, this will be null.
ā€¢ next_payment_attempt (StripeDateTimeField) ā€“ Next payment attempt. The
time at which payment will next be attempted.
ā€¢ number (CharField) ā€“ Number. A unique, identifying string that appears on emails sent
to the customer for this invoice. This starts with the customerā€™s unique invoice_preļ¬x if it is
speciļ¬ed.
ā€¢ paid (BooleanField) ā€“ Paid. The time at which payment will next be attempted.
ā€¢ payment_intent (OneToOneField to PaymentIntent) ā€“ Payment intent. The Pay-
mentIntent associated with this invoice. The PaymentIntent is generated when the invoice is
ļ¬nalized, and can then be used to pay the invoice.Note that voiding an invoice will cancel
the PaymentIntent
ā€¢ period_end (StripeDateTimeField) ā€“ Period end. End of the usage period during
which invoice items were added to this invoice.
ā€¢ period_start (StripeDateTimeField) ā€“ Period start. Start of the usage period
during which invoice items were added to this invoice.
ā€¢ post_payment_credit_notes_amount (StripeQuantumCurrencyAmountField)
ā€“ Post payment credit notes amount. Total amount (in cents) of all post-payment credit
notes issued for this invoice.
82 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ pre_payment_credit_notes_amount (StripeQuantumCurrencyAmountField)
ā€“ Pre payment credit notes amount. Total amount (in cents) of all pre-payment credit notes
issued for this invoice.
ā€¢ receipt_number (CharField) ā€“ Receipt number. This is the transaction number that
appears on email receipts sent for this invoice.
ā€¢ starting_balance (StripeQuantumCurrencyAmountField) ā€“ Starting bal-
ance. Starting customer balance (in cents) before attempting to pay invoice. If the invoice
has not been attempted yet, this will be the current customer balance.
ā€¢ statement_descriptor (CharField) ā€“ Statement descriptor. An arbitrary string
to be displayed on your customerā€™s credit card statement. The statement description may
not include <>ā€ā€™ characters, and will appear on your customerā€™s statement in capital letters.
Non-ASCII characters are automatically stripped. While most banks display this informa-
tion consistently, some may display it incorrectly or not at all.
ā€¢ status_transitions (JSONField) ā€“ Status transitions
ā€¢ subscription (ForeignKey to Subscription) ā€“ Subscription. The subscription that
this invoice was prepared for, if any.
ā€¢ subscription_proration_date (StripeDateTimeField) ā€“ Subscription pro-
ration date. Only set for upcoming invoices that preview prorations. The time used to
calculate prorations.
ā€¢ subtotal (StripeDecimalCurrencyAmountField) ā€“ Subtotal. Total (as deci-
mal) of all subscriptions, invoice items, and prorations on the invoice before any discount or
tax is applied.
ā€¢ tax (StripeDecimalCurrencyAmountField) ā€“ Tax. The amount (as decimal)
of tax included in the total, calculated from tax_percent and the subtotal. If no
tax_percent is deļ¬ned, this value will be null.
ā€¢ tax_percent (StripePercentField) ā€“ Tax percent. This percentage of the subtotal
has been added to the total amount of the invoice, including invoice line items and discounts.
This ļ¬eld is inherited from the subscriptionā€™s tax_percent ļ¬eld, but can be changed
before the invoice is paid. This ļ¬eld defaults to null.
ā€¢ threshold_reason (JSONField) ā€“ Threshold reason. If billing_reason is set to sub-
scription_threshold this returns more information on which threshold rules triggered the
invoice.
ā€¢ total (StripeDecimalCurrencyAmountField) ā€“ Total (as decimal) after dis-
count.
ā€¢ webhooks_delivered_at (StripeDateTimeField) ā€“ Webhooks delivered at.
The time at which webhooks for this invoice were successfully delivered (if the invoice had
no webhooks to deliver, this will match date). Invoice payment is delayed until webhooks
are delivered, or until all webhook delivery attempts have been exhausted.
classmethod UpcomingInvoice.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
1.19. Models 83
dj-stripe Documentation, Release 2.2.3
UpcomingInvoice.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
UpcomingInvoice.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
UpcomingInvoice.invoiceitems
Gets the invoice items associated with this upcoming invoice.
This differs from normal (non-upcoming) invoices, in that upcoming invoices are in-memory and do not persist
to the database. Therefore, all of the data comes from the Stripe API itself.
Instead of returning a normal queryset for the invoiceitems, this will return a mock of a queryset, but with the
data fetched from Stripe - It will act like a normal queryset, but mutation will silently fail.
UpcomingInvoice.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod UpcomingInvoice.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
UsageRecord
class djstripe.models.UsageRecord(*args, **kwargs)
Usage records allow you to continually report usage and metrics to Stripe for metered billing of plans.
Stripe documentation: https://stripe.com/docs/api#usage_records
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
84 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ quantity (PositiveIntegerField) ā€“ Quantity. The quantity of the plan to which
the customer should be subscribed.
ā€¢ subscription_item (ForeignKey to SubscriptionItem) ā€“ Subscription item.
The subscription item this usage record contains data for.
classmethod UsageRecord.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
UsageRecord.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
UsageRecord.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod UsageRecord.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
1.19.4 Connect
Account
class djstripe.models.Account(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#account
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
1.19. Models 85
dj-stripe Documentation, Release 2.2.3
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ branding_icon (ForeignKey to FileUpload) ā€“ Branding icon. An icon for the ac-
count. Must be square and at least 128px x 128px.
ā€¢ branding_logo (ForeignKey to FileUpload) ā€“ Branding logo. A logo for the account
that will be used in Checkout instead of the icon and without the accountā€™s name next to it
if provided. Must be at least 128px x 128px.
ā€¢ business_profile (JSONField) ā€“ Business proļ¬le. Optional information related to
the business.
ā€¢ business_type (StripeEnumField) ā€“ Business type. The business type.
ā€¢ charges_enabled (BooleanField) ā€“ Charges enabled. Whether the account can
create live charges
ā€¢ country (CharField) ā€“ Country. The country of the account
ā€¢ company (JSONField) ā€“ Company. Information about the company or business. This
ļ¬eld is null unless business_type is set to company.
ā€¢ default_currency (StripeCurrencyCodeField) ā€“ Default currency. The cur-
rency this account has chosen to use as the default
ā€¢ details_submitted (BooleanField) ā€“ Details submitted. Whether account details
have been submitted. Standard accounts cannot receive payouts before this is true.
ā€¢ email (CharField) ā€“ Email. The primary userā€™s email address.
ā€¢ individual (JSONField) ā€“ Individual. Information about the person represented by
the account. This ļ¬eld is null unless business_type is set to individual.
ā€¢ payouts_enabled (BooleanField) ā€“ Payouts enabled. Whether Stripe can send
payouts to this account
ā€¢ product_description (CharField) ā€“ Product description. Internal-only descrip-
tion of the product sold or service provided by the business. Itā€™s used by Stripe for risk and
underwriting purposes.
ā€¢ requirements (JSONField) ā€“ Requirements. Information about the requirements for
the account, including what information needs to be collected, and by when.
ā€¢ settings (JSONField) ā€“ Settings. Account options for customizing how the account
functions within Stripe.
ā€¢ type (StripeEnumField) ā€“ Type. The Stripe account type.
ā€¢ tos_acceptance (JSONField) ā€“ Tos acceptance. Details on the acceptance of the
Stripe Services Agreement
classmethod Account.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
86 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Account.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Account.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod Account.get_connected_account_from_token(access_token)
classmethod Account.get_default_account()
Account.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Account.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Application Fee
class djstripe.models.ApplicationFee(*args, **kwargs)
When you collect a transaction fee on top of a charge made for your user (using Connect), an ApplicationFee is
created in your account.
Stripe documentation: https://stripe.com/docs/api#application_fees
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
1.19. Models 87
dj-stripe Documentation, Release 2.2.3
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeQuantumCurrencyAmountField) ā€“ Amount. Amount earned, in
cents.
ā€¢ amount_refunded (StripeQuantumCurrencyAmountField) ā€“ Amount re-
funded. Amount in cents refunded (can be less than the amount attribute on the fee if a
partial refund was issued)
ā€¢ balance_transaction (ForeignKey to BalanceTransaction) ā€“ Balance transac-
tion. Balance transaction that describes the impact on your account balance.
ā€¢ charge (ForeignKey to Charge) ā€“ Charge. The charge that the application fee was taken
from.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ refunded (BooleanField) ā€“ Refunded. Whether the fee has been fully refunded. If
the fee is only partially refunded, this attribute will still be false.
classmethod ApplicationFee.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
ApplicationFee.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
ApplicationFee.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod ApplicationFee.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Country Spec
class djstripe.models.CountrySpec(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#country_specs
Parameters
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
88 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ id (CharField) ā€“ Id
ā€¢ default_currency (StripeCurrencyCodeField) ā€“ Default currency. The de-
fault currency for this country. This applies to both payment methods and bank accounts.
ā€¢ supported_bank_account_currencies (JSONField) ā€“ Supported bank ac-
count currencies. Currencies that can be accepted in the speciļ¬c country (for transfers).
ā€¢ supported_payment_currencies (JSONField) ā€“ Supported payment currencies.
Currencies that can be accepted in the speciļ¬ed country (for payments).
ā€¢ supported_payment_methods (JSONField) ā€“ Supported payment methods. Pay-
ment methods available in the speciļ¬ed country.
ā€¢ supported_transfer_countries (JSONField) ā€“ Supported transfer countries.
Countries that can accept transfers from the speciļ¬ed country.
ā€¢ verification_fields (JSONField) ā€“ Veriļ¬cation ļ¬elds. Lists the types of veriļ¬-
cation data needed to keep an account open.
classmethod CountrySpec.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
CountrySpec.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
CountrySpec.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod CountrySpec.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Transfer
class djstripe.models.Transfer(*args, **kwargs)
When Stripe sends you money or you initiate a transfer to a bank account, debit card, or connected Stripe
account, a transfer object will be created.
Stripe documentation: https://stripe.com/docs/api/python#transfers
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
1.19. Models 89
dj-stripe Documentation, Release 2.2.3
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeDecimalCurrencyAmountField) ā€“ Amount. The amount trans-
ferred
ā€¢ amount_reversed (StripeDecimalCurrencyAmountField) ā€“ Amount re-
versed. The amount (as decimal) reversed (can be less than the amount attribute on the
transfer if a partial reversal was issued).
ā€¢ balance_transaction (ForeignKey to BalanceTransaction) ā€“ Balance transac-
tion. Balance transaction that describes the impact on your account balance.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ destination (StripeIdField) ā€“ Destination. ID of the bank account, card, or Stripe
account the transfer was sent to.
ā€¢ destination_payment (StripeIdField) ā€“ Destination payment. If the destination
is a Stripe account, this will be the ID of the payment that the destination account received
for the transfer.
ā€¢ reversed (BooleanField) ā€“ Reversed. Whether or not the transfer has been fully
reversed. If the transfer is only partially reversed, this attribute will still be false.
ā€¢ source_transaction (StripeIdField) ā€“ Source transaction. ID of the charge (or
other transaction) that was used to fund the transfer. If null, the transfer was funded from
the available balance.
ā€¢ source_type (StripeEnumField) ā€“ Source type. The source balance from which
this transfer came.
ā€¢ transfer_group (CharField) ā€“ Transfer group. A string that identiļ¬es this transac-
tion as part of a group.
classmethod Transfer.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
Transfer.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
90 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
Transfer.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
Transfer.str_parts()
Extend this to add information to the string representation of the object
Return type list of str
classmethod Transfer.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
Transfer Reversal
class djstripe.models.TransferReversal(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#transfer_reversals
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ amount (StripeQuantumCurrencyAmountField) ā€“ Amount. Amount, in cents.
ā€¢ balance_transaction (ForeignKey to BalanceTransaction) ā€“ Balance transac-
tion. Balance transaction that describes the impact on your account balance.
ā€¢ currency (StripeCurrencyCodeField) ā€“ Currency. Three-letter ISO currency
code
ā€¢ transfer (ForeignKey to Transfer) ā€“ Transfer. The transfer that was reversed.
classmethod TransferReversal.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
1.19. Models 91
dj-stripe Documentation, Release 2.2.3
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
TransferReversal.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
TransferReversal.get_stripe_dashboard_url()
Get the stripe dashboard url for this object.
classmethod TransferReversal.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
1.19.5 Fraud
TODO
1.19.6 Orders
TODO
1.19.7 Sigma
ScheduledQueryRun
class djstripe.models.ScheduledQueryRun(*args, **kwargs)
Stripe documentation: https://stripe.com/docs/api#scheduled_queries
Parameters
ā€¢ djstripe_id (BigAutoField) ā€“ Id
ā€¢ id (StripeIdField) ā€“ Id
ā€¢ livemode (NullBooleanField) ā€“ Livemode. Null here indicates that the livemode
status is unknown or was previously unrecorded. Otherwise, this ļ¬eld indicates whether this
record comes from Stripe test mode or live mode operation.
ā€¢ created (StripeDateTimeField) ā€“ Created. The datetime this object was created
in stripe.
92 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ metadata (JSONField) ā€“ Metadata. A set of key/value pairs that you can attach to an
object. It can be useful for storing additional information about an object in a structured
format.
ā€¢ description (TextField) ā€“ Description. A description of this object.
ā€¢ djstripe_created (DateTimeField) ā€“ Djstripe created
ā€¢ djstripe_updated (DateTimeField) ā€“ Djstripe updated
ā€¢ data_load_time (StripeDateTimeField) ā€“ Data load time. When the query was
run, Sigma contained a snapshot of your Stripe data at this time.
ā€¢ error (JSONField) ā€“ Error. If the query run was not succeesful, contains information
about the failure.
ā€¢ file (ForeignKey to FileUpload) ā€“ File. The ļ¬le object representing the results of the
query.
ā€¢ result_available_until (StripeDateTimeField) ā€“ Result available until.
Time at which the result expires and is no longer available for download.
ā€¢ sql (TextField) ā€“ Sql. SQL for the query.
ā€¢ status (StripeEnumField) ā€“ Status. The queryā€™s execution status.
ā€¢ title (TextField) ā€“ Title. Title of the query.
classmethod ScheduledQueryRun.api_list(api_key=ā€, **kwargs)
Call the stripe APIā€™s list operation for this model.
Parameters api_key (string) ā€“ The api key to use for this request. Defaults to
djstripe_settings.STRIPE_SECRET_KEY.
See Stripe documentation for accepted kwargs for each object.
Returns an iterator over all items in the query
ScheduledQueryRun.api_retrieve(api_key=None, stripe_account=None)
Call the stripe APIā€™s retrieve operation for this model.
Parameters
ā€¢ api_key (string) ā€“ The api key to use for this request. Defaults to set-
tings.STRIPE_SECRET_KEY.
ā€¢ stripe_account (string) ā€“ The optional connected account for which this request is
being made.
classmethod ScheduledQueryRun.sync_from_stripe_data(data)
Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
Parameters data (dict) ā€“ stripe object
Return type cls
1.19.8 Webhooks
WebhookEventTrigger
class djstripe.models.WebhookEventTrigger(*args, **kwargs)
An instance of a request that reached the server endpoint for Stripe webhooks.
1.19. Models 93
dj-stripe Documentation, Release 2.2.3
Webhook Events are initially UNTRUSTED, as it is possible for any web entity to post any data to our webhook
url. Data posted may be valid Stripe information, garbage, or even malicious. The ā€˜validā€™ ļ¬‚ag in this model
monitors this.
Parameters
ā€¢ id (BigAutoField) ā€“ Id
ā€¢ remote_ip (GenericIPAddressField) ā€“ Remote ip. IP address of the request
client.
ā€¢ headers (JSONField) ā€“ Headers
ā€¢ body (TextField) ā€“ Body
ā€¢ valid (BooleanField) ā€“ Valid. Whether or not the webhook event has passed valida-
tion
ā€¢ processed (BooleanField) ā€“ Processed. Whether or not the webhook event has been
successfully processed
ā€¢ exception (CharField) ā€“ Exception
ā€¢ traceback (TextField) ā€“ Traceback. Traceback if an exception was thrown during
processing
ā€¢ event (ForeignKey to Event) ā€“ Event. Event object contained in the (valid) Webhook
ā€¢ djstripe_version (CharField) ā€“ Djstripe version. The version of dj-stripe when
the webhook was received
ā€¢ created (DateTimeField) ā€“ Created
ā€¢ updated (DateTimeField) ā€“ Updated
WebhookEventTrigger.json_body
WebhookEventTrigger.is_test_event
classmethod WebhookEventTrigger.from_request(request)
Create, validate and process a WebhookEventTrigger given a Django request object.
The process is three-fold: 1. Create a WebhookEventTrigger object from a Django request. 2. Validate the
WebhookEventTrigger as a Stripe event using the API. 3. If valid, process it into an Event object (and child
resource).
1.20 Settings
1.20.1 STRIPE_API_VERSION (=ā€˜2019-05-16ā€™)
The API version used to communicate with the Stripe API is conļ¬gurable, and defaults to the latest version that has
been tested as working. Using a value other than the default is allowed, as a string in the format of YYYY-MM-DD.
For example, you can specify ā€˜2017-01-27ā€™ to use that API version:
STRIPE_API_VERSION = '2017-01-27'
However you do so at your own risk, as using a value other than the default might result in incompatibilities between
Stripe and this library, especially if Stripe has labelled the differences between API versions as ā€œMajorā€. Even small
differences such as a new enumeration value might cause issues.
For this reason it is best to assume that only the default version is supported.
94 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
For more information on API versioning, see the stripe documentation.
See also A note on Stripe API versions.
1.20.2 DJSTRIPE_IDEMPOTENCY_KEY_CALLBACK (=djstripe.settings._get_idempotency_key)
A function which will return an idempotency key for a particular object_type and action pair. By default, this is set
to a function which will create a djstripe.IdempotencyKey object and return its uuid. You may want to
customize this if you want to give your idempotency keys a different lifecycle than they normally would get.
The function takes the following signature:
def get_idempotency_key(object_type: str, action: str, livemode: bool):
return "<idempotency key>"
The function MUST return a string suitably random for the object_type/action pair, and usable in the Stripe
Idempotency-Key HTTP header. For more information, see the stripe documentation.
1.20.3 DJSTRIPE_PRORATION_POLICY (=False)
By default, plans are not prorated in dj-stripe. Concretely, this is how this translates:
1) If a customer cancels their plan during a trial, the cancellation is effective right away.
2) If a customer cancels their plan outside of a trial, their subscription remains active until the subscriptionā€™s period
end, and they do not receive a refund.
3) If a customer switches from one plan to another, the new plan becomes effective right away, and the customer is
billed for the new planā€™s amount.
Assigning True to DJSTRIPE_PRORATION_POLICY reverses the functioning of item 2 (plan cancellation) by
making a cancellation effective right away and refunding the unused balance to the customer, and affects the function-
ing of item 3 (plan change) by prorating the previous customerā€™s plan towards their new planā€™s amount.
1.20.4 DJSTRIPE_SUBSCRIPTION_REQUIRED_EXCEPTION_URLS (=())
Used by djstripe.middleware.SubscriptionPaymentMiddleware
Rules:
ā€¢ ā€œ(app_name)ā€ means everything from this app is exempt
ā€¢ ā€œ[namespace]ā€ means everything with this name is exempt
ā€¢ ā€œnamespace:nameā€ means this namespaced URL is exempt
ā€¢ ā€œnameā€ means this URL is exempt
ā€¢ The entire djstripe namespace is exempt
ā€¢ If settings.DEBUG is True, then django-debug-toolbar is exempt
Example:
DJSTRIPE_SUBSCRIPTION_REQUIRED_EXCEPTION_URLS = (
"(allauth)", # anything in the django-allauth URLConf
"[blogs]", # Anything in the blogs namespace
"products:detail", # A ProductDetail view you want shown to non-payers
(continues on next page)
1.20. Settings 95
dj-stripe Documentation, Release 2.2.3
(continued from previous page)
"home", # Site homepage
)
Note: Adding app_names to applications.
To make the (allauth) work, you may need to deļ¬ne an app_name in the include() function in the URLConf.
For example:
# in urls.py
url(r'^accounts/', include('allauth.urls', app_name="allauth")),
1.20.5 DJSTRIPE_SUBSCRIBER_CUSTOMER_KEY (=ā€djstripe_subscriberā€)
Every Customer object created in Stripe is tagged with metadata This setting controls what the name of the key in
Stripe should be. The key name must be a string no more than 40 characters long.
You may set this to None or "" to disable that behaviour altogether. This is probably not something you want to do,
though.
1.20.6 DJSTRIPE_SUBSCRIBER_MODEL (=settings.AUTH_USER_MODEL)
If the AUTH_USER_MODEL doesnā€™t represent the object your applicationā€™s subscription holder, you may deļ¬ne a
subscriber model to use here. It should be a string in the form of ā€˜app.modelā€™.
Rules:
ā€¢ DJSTRIPE_SUBSCRIBER_MODEL must have an email ļ¬eld. If your existing model has no email ļ¬eld, add
an email property that deļ¬nes an email address to use.
ā€¢ You must also implement DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK.
Example Model:
class Organization(models.Model):
name = CharField(max_length=200, unique=True)
subdomain = CharField(max_length=63, unique=True, verbose_name="Organization
Ė“ā†’Subdomain")
owner = ForeignKey(settings.AUTH_USER_MODEL, related_name="organization_owner",
Ė“ā†’verbose_name="Organization Owner")
@property
def email(self):
return self.owner.email
1.20.7 DJSTRIPE_SUBSCRIBER_MODEL_MIGRATION_DEPENDENCY
(=ā€__ļ¬rst__ā€)
If the model referenced in DJSTRIPE_SUBSCRIBER_MODEL is not created in the __first__ migration of an app
you can specify the migration name to depend on here. For example: ā€œ0003_here_the_subscriber_model_was_addedā€
96 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.20.8 DJSTRIPE_SUBSCRIBER_MODEL_REQUEST_CALLBACK (=None)
If you choose to use a custom subscriber model, youā€™ll need a way to pull it from request. Thatā€™s where this callback
comes in. It must be a callable or importable string to a callable that takes a request object and returns an instance of
DJSTRIPE_SUBSCRIBER_MODEL
Examples:
middleware.py
class DynamicOrganizationIDMiddleware(object):
""" Adds the current organization's ID based on the subdomain."""
def process_request(self, request):
subdomain = parse_subdomain(request.get_host())
try:
organization = Organization.objects.get(subdomain=subdomain)
except Organization.DoesNotExist:
return TemplateResponse(request=request, template='404.html', status=404)
else:
organization_id = organization.id
request.organization_id = organization_id
settings.py
def organization_request_callback(request):
""" Gets an organization instance from the id passed through ``request``"""
from <models_path> import Organization # Import models here to avoid an
Ė“ā†’``AppRegistryNotReady`` exception
return Organization.objects.get(id=request.organization_id)
Note: This callback only becomes active when DJSTRIPE_SUBSCRIBER_MODEL is set.
1.20.9 DJSTRIPE_USE_NATIVE_JSONFIELD (=False)
Setting this to True will make the various dj-stripe JSON ļ¬elds use django.contrib.postgres.fields.
JSONField instead of the jsonfield library (which internally uses text ļ¬elds).
The native Django JSONField uses the postgres jsonb column type, which efļ¬ciently stores JSON and can be queried
far more conveniently. Django also supports querying JSONField with the ORM.
Note: This is only supported on Postgres databases.
Note: Migrating between native and non-native must be done manually.
1.20. Settings 97
dj-stripe Documentation, Release 2.2.3
1.20.10 DJSTRIPE_WEBHOOK_URL (=rā€^webhook/$ā€)
This is where you can set Stripe.com to send webhook response. You can set this to what you want to prevent
unnecessary hijinks from unfriendly people.
As this is embedded in the URLConf, this must be a resolvable regular expression.
1.20.11 DJSTRIPE_WEBHOOK_SECRET (=ā€ā€œ)
If this is set to a non-empty value, webhook signatures will be veriļ¬ed.
Learn more about webhook signature veriļ¬cation.
1.20.12 DJSTRIPE_WEBHOOK_VALIDATION= (=ā€verify_signatureā€)
This setting controls which type of validation is done on webhooks. Value can be "verify_signature" for sig-
nature veriļ¬cation (recommended default), "retrieve_event" for event retrieval (makes an extra HTTP request),
or None for no validation at all.
1.20.13 DJSTRIPE_WEBHOOK_TOLERANCE (=300)
Controls the milliseconds tolerance which wards against replay attacks. Leave this to its default value unless you know
what youā€™re doing.
1.20.14 DJSTRIPE_WEBHOOK_EVENT_CALLBACK (=None)
Webhook event callbacks allow an application to take control of what happens when an event from Stripe is received.
It must be a callable or importable string to a callable that takes an event object.
One suggestion is to put the event onto a task queue (such as celery) for asynchronous processing.
Examples:
callbacks.py
def webhook_event_callback(event):
""" Dispatches the event to celery for processing. """
from . import tasks
# Ansychronous hand-off to celery so that we can continue immediately
tasks.process_webhook_event.s(event).apply_async()
tasks.py
from stripe.error import StripeError
@shared_task(bind=True)
def process_webhook_event(self, event):
""" Processes events from Stripe asynchronously. """
logger.info("Processing Stripe event: %s", str(event))
try:
event.process(raise_exception=True)
except StripeError as exc:
logger.error("Failed to process Stripe event: %s", str(event))
raise self.retry(exc=exc, countdown=60) # retry after 60 seconds
98 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
settings.py
DJSTRIPE_WEBHOOK_EVENT_CALLBACK = 'callbacks.webhook_event_callback'
1.20.15 STRIPE_API_HOST (= unset)
If set, this sets the base API host for Stripe. You may want to set this to, for example, "http://
localhost:12111" if you are running stripe-mock.
If this is set in production (DEBUG=False), a warning will be raised on manage.py check.
1.21 Utilities
Last Updated 2018-05-24
1.21.1 Subscriber Has Active Subscription Check
utils.subscriber_has_active_subscription(plan=None)
Helper function to check if a subscriber has an active subscription.
Throws improperlyConļ¬gured if the subscriber is an instance of AUTH_USER_MODEL and
get_user_model().is_anonymous == True.
Activate subscription rules (or):
ā€¢ customer has active subscription
If the subscriber is an instance of AUTH_USER_MODEL, active subscription rules (or):
ā€¢ customer has active subscription
ā€¢ user.is_superuser
ā€¢ user.is_staff
Parameters
ā€¢ subscriber (dj-stripe subscriber) ā€“ The subscriber for which to check for an
active subscription.
ā€¢ plan (Plan or string (plan ID)) ā€“ The plan for which to check for an active
subscription. If plan is None and there exists only one subscription, this method will check
if that subscription is active. Calling this method with no plan and multiple subscriptions
will throw an exception.
1.21.2 Supported Currency Choice Generator
utils.get_supported_currency_choices()
Pull a stripe accountā€™s supported currencies and returns a choices tuple of those supported currencies.
Parameters api_key (str) ā€“ The api key associated with the account from which to pull data.
1.21. Utilities 99
dj-stripe Documentation, Release 2.2.3
1.21.3 Clear Expired Idempotency Keys
utils.clear_expired_idempotency_keys()
1.21.4 Convert Stripe Timestamp to Datetime
utils.convert_tstamp()
Convert a Stripe API timestamp response (unix epoch) to a native datetime.
Return type datetime
1.21.5 Friendly Currency Amount String
utils.get_friendly_currency_amount(currency)
1.22 Contributing
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
1.22.1 Types of Contributions
Report Bugs
Report bugs at https://github.com/dj-stripe/dj-stripe/issues.
If you are reporting a bug, please include:
ā€¢ The version of python and Django youā€™re running
ā€¢ Detailed steps to reproduce the bug.
Fix Bugs
Look through the GitHub issues for bugs. Anything tagged with ā€œbugā€ is open to whoever wants to implement it.
Implement Features
Look through the GitHub issues for features. Anything tagged with ā€œfeatureā€ is open to whoever wants to implement
it.
Write Documentation
dj-stripe could always use more documentation, whether as part of the ofļ¬cial dj-stripe docs, in docstrings, or even on
the web in blog posts, articles, and such.
If you are adding to dj-stripeā€™s documentation, you can see your changes by running tox -e docs. The documen-
tation will be generated in the docs/ directory, and you can open docs/_build/html/index.html in a web
browser.
100 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Submit Feedback
The best way to send feedback is to ļ¬le an issue at https://github.com/dj-stripe/dj-stripe/issues.
If you are proposing a feature:
ā€¢ Explain in detail how it would work.
ā€¢ Keep the scope as narrow as possible, to make it easier to implement.
ā€¢ Remember that this is a volunteer-driven project, and that contributions are welcome :)
Contributor Discussion
For questions regarding contributions to dj-stripe, another avenue is our Discord channel at https://discord.gg/UJY8fcc.
1.22.2 Get Started!
Ready to contribute? Hereā€™s how to set up dj-stripe for local development.
1. Fork the dj-stripe repo on GitHub.
2. Clone your fork locally:
$ git clone [email protected]:your_name_here/dj-stripe.git
3. Set up your test database. If youā€™re running tests using PostgreSQL:
$ createdb djstripe
or if you want to test vs sqlite (for convenience) or MySQL, they can be selected by setting this environment
variable:
$ export DJSTRIPE_TEST_DB_VENDOR=sqlite
or
$ export DJSTRIPE_TEST_DB_VENDOR=mysql
For postgres and mysql, the database host,port,username and password can be set with environment variables,
see tests/settings.py
4. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you
set up your fork for local development:
$ mkvirtualenv dj-stripe
$ cd dj-stripe/
$ python setup.py develop
5. Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
6. When youā€™re done making changes, check that your changes pass the tests. A quick test run can be done as
follows:
1.22. Contributing 101
dj-stripe Documentation, Release 2.2.3
$ DJSTRIPE_TEST_DB_VENDOR=sqlite pytest --reuse-db
You should also check that the tests pass with other python and Django versions with tox. pytest will output both
command line and html coverage statistics and will warn you if your changes caused code coverage to drop.:
$ pip install tox
$ tox
7. If your changes altered the models you may need to generate Django migrations:
$ DJSTRIPE_TEST_DB_VENDOR=sqlite ./manage.py makemigrations
8. Commit your changes and push your branch to GitHub:
$ git add .
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature
9. Submit a pull request through the GitHub website.
10. Congratulations, youā€™re now a dj-stripe contributor! Have some <3 from us.
1.22.3 Preferred Django Model Field Types
When mapping from Stripe API ļ¬eld types to Django model ļ¬elds, we try to follow Django best practises where
practical.
The following types should be preferred for ļ¬elds that map to the Stripe API (which is almost all ļ¬elds in our models).
Strings
ā€¢ Stripe API string ļ¬elds have a default maximum length of 5,000 characters.
ā€¢ In some cases a maximum length (maxLength) is speciļ¬ed in the Stripe OpenAPI schema.
ā€¢ We follow Djangoā€™s recommendation and avoid using null on string ļ¬elds (which means we store "" for string
ļ¬elds that are null in stripe). Note that is enforced in the sync logic in StripeModel._stripe_object_to_record.
ā€¢ For long string ļ¬elds (eg above 255 characters) we prefer TextField over Charfield.
Therefore the default type for string ļ¬elds that donā€™t have a maxLength speciļ¬ed in the Stripe OpenAPI schema should
usually be:
str_field = TextField(max_length=5000, default=", blank=True, help_text="...")
Enumerations
Fields that have a deļ¬ned set of values can be implemented using StripeEnumField.
Hash (dictionaries)
Use the JSONField in djstripe.fields, see also the DJSTRIPE_USE_NATIVE_JSONFIELD setting.
102 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
Currency amounts
Stripe handles all currency amounts as integer cents, we currently have a mixture of ļ¬elds as integer cents and decimal
(eg dollar, euro etc) values, but we are aiming to standardise on cents (see https://github.com/dj-stripe/dj-stripe/issues/
955).
All new currency amount ļ¬elds should use StripeQuantumCurrencyAmountField.
Dates and Datetimes
The Stripe API uses an integer timestamp (seconds since the Unix epoch) for dates and datetimes. We store this as a
datetime ļ¬eld, using StripeDateTimeField.
1.22.4 Django Migration Policy
Migrations are considered a breaking change, so itā€™s not usually not acceptable to add a migration to a stable branch,
it will be a new MAJOR.MINOR.0 release.
A workaround to this in the case that the Stripe API data isnā€™t compatible with out model (eg Stripe is sending null
to a non-null ļ¬eld) is to implement the _manipulate_stripe_object_hook classmethod on the model.
Avoid new migrations with non-schema changes
If a code change produces a migration that doesnā€™t alter the database schema (eg changing help_text) then instead
of adding a new migration you can edit the most recent migration that affects the ļ¬eld in question.
e.g.: https://github.com/dj-stripe/dj-stripe/commit/e2762c38918a90f00c42ecf21187a920bd3a2087
Squash of unreleased migrations on master
We aim to keep the number of migration ļ¬les per release to a minimum per MINOR release.
In the case where there are several unreleased migrations on master between releases, we squash migrations immedi-
ately before release.
So if youā€™re using the master branch with unreleased migrations, ensure you migrate with the squashed migration
before upgrading to the next major release.
For more details see the Squash migrations section of the Release process.
1.22.5 Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests.
2. The pull request must not drop code coverage below the current level.
3. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function
with a docstring.
4. If the pull request makes changes to a model, include Django migrations.
5. The pull request should work for Python 3.6+. Check https://travis-ci.org/dj-stripe/dj-stripe/pull_requests and
make sure that the tests pass for all supported Python versions.
1.22. Contributing 103
dj-stripe Documentation, Release 2.2.3
6. Code formatting: Make sure to install black and isort with pip install black isort and run
black .; isort -y at the dj-stripe root to keep a consistent style.
1.23 Test Fixtures
dj-stripeā€™s unit tests rely on ļ¬xtures to represent Stripe API and webhook data.
1.23.1 Rationale
These ļ¬xtures are partly hand-coded and partly generated by creating objects in Stripe and then retrieved via the API.
Each approach has pros and cons:
Hand-coding the ļ¬xtures allows them to be crafted speciļ¬cally for a test case. They can also be terse, and nested
objects can be done by reference to avoid duplication. But maintaining or upgrading them is a painstaking manual
process.
Generating the ļ¬xtures via Stripe gives the big advantage that Stripe schema changes are automatically represented
in the ļ¬xtures, which should allow us to upgrade dj-stripeā€™s schema to match Stripe much more easily. This would
be done by updating dj-stripeā€™s targeted API version (DEFAULT_STRIPE_API_VERSION), regenerating the ļ¬xtures,
and updating the model to match the ļ¬xture changes. The down side is itā€™s tricky to regenerate ļ¬xture ļ¬les without
introducing big changes (eg to object ids) - the script does this by mapping a dummy id to various objects.
1.23.2 Regenerating the test ļ¬xtures
To regenerate the test ļ¬xtures (e.g. to populate the ļ¬xtures with new API ļ¬elds from Stripe), do the following:
1. (one time only) Create a new Stripe account called ā€œdj-stripe scratchā€, with country set to United States. (we
use US so the currency matches the existing ļ¬xtures matches, in the future it would be good to test for other
countries).
2. If you already had this account ready and want to start again from scratch, you can delete all of the test data via
the button in Settings > Data https://dashboard.stripe.com/account/data
3. Activate a virtualenv with the dj-stripe project (see Getting Started)
4. Set the dj-stripe secret key environment variable to the secret key for this account (export
STRIPE_SECRET_KEY=sk_test_...)
5. Run the manage command to create the test objects in your stripe account if they donā€™t already exist, and
regenerate the local ļ¬xture ļ¬les from them:
$ ./manage.py regenerate_test_fixtures
The command tries to avoid inconsequential changes to the ļ¬xtures (e.g the created timestamp) by restoring a whitelist
of values from the existing ļ¬xtures.
This functionality can be disabled by passing the parameter ā€“update-sideeffect-ļ¬elds.
1.24 Credits
1.24.1 Development Lead
ā€¢ Alexander Kavanaugh (@kavdev)
104 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ Daniel Greenfeld <[email protected]>
ā€¢ Jerome Leclanche (@jleclanche)
ā€¢ Lee Skillen (@lskillen)
ā€¢ John Carter (@therefromhere)
1.24.2 Contributors
ā€¢ Audrey Roy Greenfeld (@audreyr)
ā€¢ Buddy Lindsley (@buddylindsey)
ā€¢ Yasmine Charif (@dollydagr)
ā€¢ Mahdi Yusuf (@myusuf3)
ā€¢ Luis Montiel <[email protected]>
ā€¢ Kulbir Singh (@kulbir)
ā€¢ Dustin Farris (@dustinfarris)
ā€¢ Liwen S (@sunliwen)
ā€¢ centrove
ā€¢ Chris Halpert (@cphalpert)
ā€¢ Thomas Parslow (@almost)
ā€¢ Leonid Shvechikov (@shvechikov)
ā€¢ sromero84
ā€¢ Peter Baumgartner (@ipmb)
ā€¢ Vikas (@vikasgulati)
ā€¢ Colton Allen (@cmanallen)
ā€¢ Filip Wasilewski (@nigma)
ā€¢ Martin Hill (@martinhill)
ā€¢ Michael Thornhill <[email protected]>
ā€¢ Tobias Lorenz (@Tyrdall)
ā€¢ Ben Whalley
ā€¢ nanvel
ā€¢ jRobb (@jamesbrobb)
ā€¢ Areski Belaid (@areski)
ā€¢ JosĆ© Padilla (@jpadilla)
ā€¢ Ben Murden (@benmurden)
ā€¢ Philippe Luickx (@philippeluickx)
ā€¢ Chriss MejĆ­a (@chrissmejia)
ā€¢ Bill Huneke (@wahuneke)
ā€¢ Matt Shaw (@unformatt)
1.24. Credits 105
dj-stripe Documentation, Release 2.2.3
ā€¢ Chris Trengove (@ctrengove)
ā€¢ Caleb Hattingh (@cjrh)
ā€¢ Nicolas Delaby (@ticosax)
ā€¢ MichaĆ«l Krens (@michi88)
ā€¢ Yuri Prezument (@yprez)
ā€¢ Raphael Deem (@r0ļ¬‚s)
ā€¢ Irfan Ahmad (@erfaan)
ā€¢ Slava Kyrachevsky (@scream4ik)
ā€¢ Alec Brunelle (@aleccool213)
ā€¢ James Hiew (@jameshiew)
ā€¢ Dan Koch (@dmkoch)
ā€¢ Denis Orehovsky (@apirobot)
1.25 History
1.25.1 2.2.3 (2020-02-25)
ā€¢ Changed JSONField dependency back to jsonļ¬eld from jsonļ¬eld2 (see Warning about safe uninstall of json-
ļ¬eld2 on upgrade).
Warning about safe uninstall of jsonļ¬eld2 on upgrade
Warning: Both jsonļ¬eld and jsonļ¬eld2 use the same import path, so if upgrading from dj-stripe~=2.2.0 in an
existing virtualenv, be sure to uninstall jsonļ¬eld2 ļ¬rst. eg:
# ensure jsonfield is uninstalled before we install jsonfield2
pip uninstall jsonfield2 -y && pip install "dj-stripe>=2.3.0dev"
Otherwise, pip uninstall jsonfield2 will remove jsonļ¬eldā€™s jsonfield module from
site-packages, which would cause errors like ImportError: cannot import name
'JSONField' from 'jsonfield' (unknown location)
If you have hit this ImportError already after upgrading, running this should resolve it:
# remove both jsonfield packages before reinstall to fix ImportError:
pip uninstall jsonfield jsonfield2 -y && pip install "dj-stripe>=2.3.0dev"
Note that this is only necessary if upgrading from dj-stripe 2.2.x, which temporarily depended on jsonļ¬eld2. This
process is not necessary if upgrading from an earlier version of dj-stripe.
1.25.2 2.2.2 (2020-01-20)
This is a bugļ¬x-only version:
ā€¢ Fixed handling of TaxRate events (#1094).
106 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.25.3 2.2.1 (2020-01-14)
This is a bugļ¬x-only version:
ā€¢ Fixed bad package build.
1.25.4 2.2.0 (2020-01-13)
ā€¢ Changed JSONField dependency package from jsonļ¬eld to jsonļ¬eld2, for Django 3 compatibility (see Warn-
ing about safe uninstall of jsonļ¬eld on upgrade). Note that Django 2.1 requires jsonļ¬eld<3.1.
ā€¢ Added support for Django 3.0 (requires jsonļ¬eld2>=3.0.3).
ā€¢ Added support for python 3.8.
ā€¢ Refactored UpcomingInvoice, so itā€™s no longer a subclass of Invoice (to allow Invoice to use
ManyToManyFields).
ā€¢ Dropped previously-deprecated Account ļ¬elds (see https://stripe.com/docs/upgrades#2019-02-19 ):
ā€“ .business_name
ā€“ .business_primary_color
ā€“ .business_url (changed to a property)
ā€“ .debit_negative_balances
ā€“ .decline_charge_on
ā€“ .display_name
ā€“ .legal_entity
ā€“ .payout_schedule
ā€“ .payout_statement_descriptor
ā€“ .statement_descriptor
ā€“ .support_email
ā€“ .support_phone
ā€“ .support_url
ā€“ .timezone
ā€“ .verification
ā€¢ Dropped previously-deprecated Account.business_logo property (renamed to .branding_icon)
ā€¢ Dropped previously-deprecated Customer.account_balance property (renamed to .balance)
ā€¢ Dropped previously-deprecated properties Invoice.application_fee, Invoice.date
ā€¢ Dropped previously-deprecated enum PaymentMethodType (use DjstripePaymentMethodType in-
stead)
ā€¢ Renamed Invoice.billing to .collection_method (added deprecated property for the old name).
ā€¢ Updated Invoice model to add missing ļ¬elds.
ā€¢ Added TaxRate model, and Invoice.default_tax_rates, InvoiceItem.tax_rates,
Invoice.total_tax_amounts, Subscription.default_tax_rates, SubscriptionItem.
tax_rates (#1027).
1.25. History 107
dj-stripe Documentation, Release 2.2.3
ā€¢ Change urls.py to use the new style urls.
ā€¢ Update forward relation ļ¬elds in the admin to be raw id ļ¬elds.
ā€¢ Updated StripeQuantumCurrencyAmountField and StripeDecimalCurrencyAmountField
to support Stripe Large Charges (#1045).
ā€¢ Update event handling so customer.subscription.deleted updates subscriptions to
status="canceled" instead of deleting it from our database, to match Stripeā€™s behaviour (#599).
ā€¢ Added missing Refund.reason value, increases ļ¬eld width (#1075).
ā€¢ Fixed Refund.status deļ¬nition, reduces ļ¬eld width (#1076).
ā€¢ Deprecated non-standard Invoice.status (renamed to Invoice.legacy_status) to make way for
the Stripe ļ¬eld (preparation for #1020).
Warning about safe uninstall of jsonļ¬eld on upgrade
Warning: Both jsonļ¬eld and jsonļ¬eld2 use the same import path, so if upgrading to dj-stripe>=2.2 in an existing
virtualenv, be sure to uninstall jsonļ¬eld ļ¬rst. eg:
# ensure jsonfield is uninstalled before we install jsonfield2
pip uninstall jsonfield -y && pip install "dj-stripe>=2.2.0dev"
Otherwise, pip uninstall jsonfield will remove jsonļ¬eld2ā€™s jsonfield module from
site-packages, which would cause errors like ImportError: cannot import name
'JSONField' from 'jsonfield' (unknown location)
If you have hit this ImportError already after upgrading, running this should resolve it:
# remove both jsonfield packages before reinstall to fix ImportError:
pip uninstall jsonfield jsonfield2 -y && pip install "dj-stripe>=2.2.0dev"
Note on usage of Stripe Elements JS
See https://dj-stripe.readthedocs.io/en/latest/stripe_elements_js.html for notes about usage of the Stripe Elements fron-
tend JS library.
TLDR: if you havenā€™t yet migrated to PaymentIntents, prefer stripe.createSource() to stripe.
createToken().
1.25.5 2.1.1 (2019-10-01)
This is a bugļ¬x-only version:
ā€¢ Updated webhook signals list (#1000).
ā€¢ Fixed issue syncing PaymentIntent with destination charge (#960).
ā€¢ Fixed Customer.subscription & .valid_subscriptions() to ignore
status=incomplete_expired (#1006).
ā€¢ Fixed error on paymentmethod.detached event with card_xxx payment methods (#967).
ā€¢ Added PaymentMethod.detach() (#943).
108 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ Updated help_text on all currency ļ¬elds to make it clear if theyā€™re holding integer
cents (StripeQuantumCurrencyAmountField) or decimal dollar (or euro, pound etc)
(StripeDecimalCurrencyAmountField) (#999)
ā€¢ Documented our preferred Django model ļ¬eld types (#986)
Upcoming migration of currency ļ¬elds (storage as cents instead of dollars)
Please be aware that weā€™re looking at standardising our currency storage ļ¬elds as integer quanta (cents) instead of
Decimal (dollar) values, to match stripe.
This is intended to be part of the 3.0 release, since it will involve some breaking changes. See #955 for details and
discussion.
1.25.6 2.1.0 (2019-09-12)
ā€¢ Dropped Django 2.0 support
ā€¢ The Python stripe library minimum version is now 2.32.0, also 2.36.0 is excluded due to a regression
(#991).
ā€¢ Dropped previously-deprecated Charge.fee_details property.
ā€¢ Dropped previously-deprecated Transfer.fee_details property.
ā€¢ Dropped previously-deprecated field_name parameter to sync_from_stripe_data
ā€¢ Dropped previously-deprecated alias StripeObject of StripeModel
ā€¢ Dropped previously-deprecated alias PaymentMethod of DjstripePaymentMethod
ā€¢ Dropped previously-deprecated properties Charge.source_type and Charge.source_stripe_id
ā€¢ enums.PaymentMethodType has been deprecated, use enums.DjstripePaymentMethodType
ā€¢ Made SubscriptionItem.quantity nullable as per Plans with usage_type="metered" (follow-up
to #865)
ā€¢ Added manage commands djstripe_sync_models and djstripe_process_events (#727, #89)
ā€¢ Fixed issue with re-creating a customer after Customer.purge() (#916)
ā€¢ Fixed sync of Customer Bank Accounts (#829)
ā€¢ Fixed Subscription.is_status_temporarily_current() (#852)
ā€¢ New models
ā€“ Payment Intent
ā€“ Setup Intent
ā€“ Payment Method
ā€“ Session
ā€¢ Added ļ¬elds to Customer model: address, invoice_prefix, invoice_settings, phone,
preferred_locales, tax_exempt
Changes from API 2018-11-08:
ā€¢ Added Invoice.auto_advance, deprecated Invoice.closed and Invoice.forgiven, see https:
//stripe.com/docs/billing/invoices/migrating-new-invoice-states#autoadvance
1.25. History 109
dj-stripe Documentation, Release 2.2.3
Changes from API 2019-02-19:
ā€¢ Major changes to Account ļ¬elds, see https://stripe.com/docs/upgrades#2019-02-19 , updated Account ļ¬elds to
match API 2019-02-19:
ā€¢ Added Account.business_profile, .business_type, .company, .individual, .
requirements, .settings
ā€¢ Deprecated the existing ļ¬elds, to be removed in 2.2
ā€¢ Special handling of the icon and logo ļ¬elds:
ā€“ Renamed Account.business_logo to Account.branding_icon (note that in Stripeā€™s
API Account.business_logo was renamed to Account.settings.branding_icon, and
Account.business_logo_large (which we didnā€™t have a ļ¬eld for) was renamed to Account.
settings.branding_logo)
ā€“ Added deprecated property for Account.business_logo
ā€“ Added Account.branding_logo as a ForeignKey
ā€“ Populate Account.branding_icon and .branding_logo from the new Account.
settings.branding.icon and .logo
Changes from API 2019-03-14:
ā€¢ Renamed Invoice.application_fee to Invoice.application_fee_amount (added deprecated
property for the old name)
ā€¢ Removed Invoice.date, in place of Invoice.created (added deprecated property for the old name)
ā€¢ Added Invoice.status_transitions
ā€¢ Renamed Customer.account_balance to Customer.balance (added deprecated property for the old
name)
ā€¢ Renamed Customer.payment_methods to Customer.customer_payment_methods
ā€¢ Added new SubscriptionStatus.incomplete and SubscriptionStatus.
incomplete_expired statuses (#974)
ā€¢ Added new BalanceTransactionType values (#983)
Squashed dev migrations
As per our migration policy unreleased migrations on the master branch (migration numbers >=0004) have been
squashed.
If you have been using the 2.1.0dev branch from master, youā€™ll need to run the squashed migrations migrations before
upgrading to >=2.1.0.
The simplest way to do this is to pip install dj-stripe==2.1.0rc0 and migrate, alternatively check out
the 2.1.0rc0 git tag.
1.25.7 2.0.5 (2019-09-12)
This is a bugļ¬x-only version:
ā€¢ Avoid stripe==2.36.0 due to regression (#991)
110 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.25.8 2.0.4 (2019-09-09)
This is a bugļ¬x-only version:
ā€¢ Fixed irreversible migration (#909)
1.25.9 2.0.3 (2019-06-11)
This is a bugļ¬x-only version:
ā€¢ In _get_or_create_from_stripe_object, wrap create _create_from_stripe_object in
transaction, ļ¬xes TransactionManagementError on race condition in webhook processing (#877/#903).
1.25.10 2.0.2 (2019-06-09)
This is a bugļ¬x-only version:
ā€¢ Donā€™t save event objects if the webhook processing fails (#832).
ā€¢ Fixed IntegrityError when REMOTE_ADDR is an empty string.
ā€¢ Deprecated field_name parameter to sync_from_stripe_data
1.25.11 2.0.1 (2019-04-29)
This is a bugļ¬x-only version:
ā€¢ Fixed an error on invoiceitem.updated (#848).
ā€¢ Handle test webhook properly in recent versions of Stripe API (#779). At some point 2018 Stripe silently
changed the ID used for test events and evt_00000000000000 is not used anymore.
ā€¢ Fixed OperationalError seen in migration 0003 on postgres (#850).
ā€¢ Fixed issue with migration 0003 not being unapplied correctly (#882).
ā€¢ Fixup missing SubscriptionItem.quantity on Plans with usage_type="metered" (#865).
ā€¢ Fixed Plan.create() (#870).
1.25.12 2.0.0 (2019-03-01)
ā€¢ The Python stripe library minimum version is now 2.3.0.
ā€¢ PaymentMethod has been renamed to DjstripePaymentMethod (#841). An alias remains but will be
removed in the next version.
ā€¢ Dropped support for Django < 2.0, Python < 3.4.
ā€¢ Dropped previously-deprecated stripe_objects module.
ā€¢ Dropped previously-deprecated stripe_timestamp ļ¬eld.
ā€¢ Dropped previously-deprecated Charge.receipt_number ļ¬eld.
ā€¢ Dropped previously-deprecated StripeSource alias for Card
ā€¢ Dropped previously-deprecated SubscriptionView, CancelSubscriptionView and
CancelSubscriptionForm.
1.25. History 111
dj-stripe Documentation, Release 2.2.3
ā€¢ Removed the default value from DJSTRIPE_SUBSCRIPTION_REDIRECT.
ā€¢ All stripe_id ļ¬elds have been renamed id.
ā€¢ Charge.source_type has been deprecated. Use Charge.source.type.
ā€¢ Charge.source_stripe_id has been deprecated. Use Charge.source.id.
ā€¢ All deprecated Transfer ļ¬elds (Stripe API < 2017-04-06), have been dropped. This includes date,
destination_type (type), failure_code, failure_message, statement_descriptor and
status.
ā€¢ Fixed IntegrityError when REMOTE_ADDR is missing (#640).
ā€¢ New models: - ApplicationFee - ApplicationFeeRefund - BalanceTransaction -
CountrySpec - ScheduledQuery - SubscriptionItem - TransferReversal - UsageRecord
ā€¢ The fee and fee_details attributes of both the Charge and Transfer objects are no longer stored
in the database. Instead, they access their respective new balance_transaction foreign key. Note that
fee_details has been deprecated on both models.
ā€¢ The fraudulent attribute on Charge is now a property that checks the fraud_details ļ¬eld.
ā€¢ Object key validity is now always enforced (#503).
ā€¢ Customer.sources no longer refers to a Card queryset, but to a Source queryset. In order to correctly
transition, you should change all your references to customer.sources to customer.legacy_cards
instead. The legacy_cards attribute already exists in 1.2.0.
ā€¢ Customer.sources_v3 is now named Customer.sources.
ā€¢ A new property Customer.payment_methods is now available, which allows you to iterate over all of a
customerā€™s payment methods (sources then cards).
ā€¢ Card.customer is now nullable and cards are no longer deleted when their corresponding customer is deleted
(#654).
ā€¢ Webhook signature veriļ¬cation is now available and is preferred. Set the DJSTRIPE_WEBHOOK_SECRET
setting to your secret to start using it.
ā€¢ StripeObject has been renamed StripeModel. An alias remains but will be removed in the next version.
ā€¢ The metadata key used in the Customer object can now be conļ¬gured by changing the
DJSTRIPE_SUBSCRIBER_CUSTOMER_KEY setting. Setting this to None or an empty string now also dis-
ables the behaviour altogether.
ā€¢ Text-type ļ¬elds in dj-stripe will no longer ever be None. Instead, any falsy text ļ¬eld will return an empty string.
ā€¢ Switched test runner to pytest-django
ā€¢ StripeModel.sync_from_stripe_data() will now automatically retrieve related objects and popu-
late foreign keys (#681)
ā€¢ Added Coupon.name
ā€¢ Added Transfer.balance_transaction
ā€¢ Exceptions in webhooks are now re-raised as well as saved in the database (#833)
1.25.13 1.2.4 (2019-02-27)
This is a bugļ¬x-only version:
ā€¢ Allow billing_cycle_anchor argument when creating a subscription (#814)
112 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
ā€¢ Fixup plan amount null with tier plans (#781)
ā€¢ Update Cancel subscription view tests to match backport in f64af57
ā€¢ Implement Invoice._manipulate_stripe_object_hook for compatability with API 2018-11-08 (#771)
ā€¢ Fix product webhook for type=ā€goodā€ (#724)
ā€¢ Add trial_from_plan, trial_period_days args to Customer.subscribe() (#709)
1.25.14 1.2.3 (2018-10-13)
This is a bugļ¬x-only version:
ā€¢ Updated Subscription.cancel() for compatibility with Stripe 2018-08-23 (#723)
1.25.15 1.2.2 (2018-08-11)
This is a bugļ¬x-only version:
ā€¢ Fixed an error with request.urlconf in some setups (#562)
ā€¢ Always save text-type ļ¬elds as empty strings in db instead of null (#713)
ā€¢ Fix support for DJSTRIPE_SUBSCRIBER_MODEL_MIGRATION_DEPENDENCY (#707)
ā€¢ Fix reactivate() with Stripe API 2018-02-28 and above
1.25.16 1.2.1 (2018-07-18)
This is a bugļ¬x-only version:
ā€¢ Fixed various Python 2.7 compatibility issues
ā€¢ Fixed issues with max_length of receipt_number
ā€¢ Fixed various ļ¬elds incorrectly marked as required
ā€¢ Handle product webhook calls
ā€¢ Fix compatibility with stripe-python 2.0.0
1.25.17 1.2.0 (2018-06-11)
The dj-stripe 1.2.0 release resets all migrations.
Do not upgrade to 1.2.0 directly from 1.0.1 or below. You must upgrade to 1.1.0 ļ¬rst.
Please read the 1.1.0 release notes below for more information.
1.25.18 1.1.0 (2018-06-11)
In dj-stripe 1.1.0, we made a lot of changes to models in order to bring the dj-stripe model state much closer to the
upstream API objects. If you are a current user of dj-stripe, you will most likely have to make changes in order to
upgrade. Please read the full changelog below. If you are having trouble upgrading, you may ask for help by ļ¬ling an
issue on GitHub.
1.25. History 113
dj-stripe Documentation, Release 2.2.3
Migration reset
The next version of dj-stripe, 1.2.0, will reset all the migrations to 0001_initial. Migrations are currently in an
unmaintainable state.
What this means is you will not be able to upgrade directly to dj-stripe 1.2.0. You must go through 1.1.0 ļ¬rst,
run ā€˜ā€˜manage.py migrate djstripeā€˜ā€˜, then upgrade to 1.2.0.
Python 2.7 end-of-life
dj-stripe 1.1.0 drops support for Django 1.10 and adds support for Django 2.0. Django 1.11+ and Python 2.7+ or 3.4+
are required.
Support for Python versions older than 3.5, and Django versions older than 2.0, will be dropped in dj-stripe 2.0.0.
Backwards-incompatible changes and deprecations
Removal of polymorphic models
The model architecture of dj-stripe has been simpliļ¬ed. Polymorphic models have been dropped and the old base
StripeCustomer, StripeCharge, StripeInvoice, etc models have all been merged into the top-level Customer, Charge,
Invoice, etc models.
Importing those legacy models from djstripe.stripe_objects will yield the new ones. This is deprecated
and support for this will be dropped in dj-stripe 2.0.0.
Full support for Stripe Sources (Support for v3 stripe.js)
Stripe sources (src_XXXX) are objects that can arbitrarily reference any of the payment method types that Stripe
supports. However, the legacy Card object (with object IDs like card_XXXX or cc_XXXX) is not a Source object,
and cannot be turned into a Source object at this time.
In order to support both Card and Source objects in ForeignKeys, a new model PaymentMethod has been devised
(renamed to DjstripePaymentMethod in 2.0). That model can resolve into a Card, a Source, or a BankAccount
object.
ā€¢ The ā€˜ā€˜default_sourceā€˜ā€˜ attribute on ā€˜ā€˜Customerā€˜ā€˜ now refers to a ā€˜ā€˜PaymentMethodā€˜ā€˜ object. You will need
to call .resolve() on it to get the Card or Source in question.
ā€¢ References to Customer.sources expecting a queryset of Card objects should be updated to Customer.
legacy_cards.
ā€¢ The legacy StripeSource name refers to the Card model. This will be removed in dj-stripe 2.0.0. Update
your references to either Card or Source.
ā€¢ enums.SourceType has been renamed to enums.LegacySourceType. enums.SourceType now
refers to the actual Stripe Source types enum.
Core ļ¬elds renamed
ā€¢ The numeric id ļ¬eld has been renamed to djstripe_id. This avoids a clash with the upstream stripe id.
Accessing .id is deprecated and **will reference the upstream stripe_id in dj-stripe 2.0.0
114 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.25.19 1.0.0 (2017-08-12)
Itā€™s ļ¬nally here! Weā€™ve made signiļ¬cant changes to the codebase and are now compliant with stripe API version
2017-06-05.
I want to give a huge thanks to all of our contributors for their help in making this happen, especially Bill Huneke
(@wahuneke) for his impressive design work and @jleclanche for really pushing this release along.
I also want to welcome onboard two more maintainers, @jleclanche and @lskillen. Theyā€™ve stepped up and have
graciously dedicated their resources to making dj-stripe such an amazing package.
Almost all methods now mimic the parameters of those same methods in the stripe API. Note that some methods
do not have some parameters implemented. This is intentional. That being said, expect all method signatures to be
different than those in previous versions of dj-stripe.
Finally, please note that there is still a bit of work ahead of us. Not everything in the Stripe API is currently supported
by dj-stripe ā€“ weā€™re working on it. That said, v1.0.0 has been thoroughly tested and is veriļ¬ed stable in production
applications.
A few things to get excited for
ā€¢ Multiple subscription support (ļ¬nally)
ā€¢ Multiple sources support (currently limited to Cards)
ā€¢ Idempotency support (See #455, #460 for discussion ā€“ big thanks to @jleclanche)
ā€¢ Full model documentation
ā€¢ Objects that come through webhooks are now tied to the API version set in dj-stripe. No more errors if dj-stripe
falls behind the newest stripe API version.
ā€¢ Any create/update action on an object automatically syncs the object.
ā€¢ Concurrent LIVE and TEST mode support (Thanks to @jleclanche). Note that youā€™ll run into issues if
livemode isnā€™t set on your existing customer objects.
ā€¢ All choices are now enum-based (Thanks @jleclanche, See #520). Access them from the new djstripe.
enums module. The ability to check against model property based choices will be deprecated in 1.1
ā€¢ Support for the Coupon model, and coupons on Customer objects.
ā€¢ Support for the Payout/Transfer split from api version 2017-04-06.
What still needs to be done (in v1.1.0)
ā€¢ Documentation. Our original documentation was not very helpful, but it covered the important bits. It will be
very out of date after this update and will need to be rewritten. If you feel like helping, we could use all the help
we can get to get this pushed out asap.
ā€¢ Master sync re-write. This sounds scary, but really isnā€™t. The current management methods run sync methods
on Customer that arenā€™t very helpful and are due for removal. My plan is to write something that ļ¬rst updates
local data (via api_retrieve and sync_from_stripe_data) and then pulls all objects from Stripe and
populates the local database with any records that donā€™t already exist there.
You might be wondering, ā€œWhy are they releasing this if there are only a few things left?ā€ Well, that thinking
turned this into a two year release. . . Trust me, this is a good thing.
1.25. History 115
dj-stripe Documentation, Release 2.2.3
Signiļ¬cant changes (mostly backwards-incompatible)
ā€¢ Idempotency. #460 introduces idempotency keys and implements idempotency for Customer.
get_or_create(). Idempotency will be enabled for all calls that need it.
ā€¢ Improved Admin Interface. This is almost complete. See #451 and #452.
ā€¢ Drop non-trivial endpoint views. Weā€™re dropping everything except the webhook endpoint and the subscription
cancel endpoint. See #428.
ā€¢ Drop support for sending receipts. Stripe now handles this for you. See #478.
ā€¢ Drop support for plans as settings, including custom plan hierarchy (if you want this, write something custom)
and the dynamic trial callback. Weā€™ve decided to gut having plans as settings. Stripe should be your source of
truth; create your plans there and sync them down manually. If you need to create plans locally for testing, etc.,
simply use the ORM to create Plan models. The sync rewrite will make this drop less annoying.
ā€¢ Orphan Customer Sync. We will now sync Customer objects from Stripe even if they arenā€™t linked to local
subscriber objects. You can link up subscribers to those Customers manually.
ā€¢ Concurrent Live and Test Mode. dj-stripe now supports test-mode and live-mode Customer objects con-
currently. As a result, the User.customer One-to-One reverse-relationship is now the User.djstripe_customers
RelatedManager. (Thanks @jleclanche) #440. Youā€™ll run into some dj-stripe check issues if you donā€™t update
your KEY settings accordingly. Check our GitHub issue tracker for help on this.
SETTINGS
ā€¢ The PLAN_CHOICES, PLAN_LIST, and PAYMENT_PLANS objects are removed. Use Plan.objects.all() in-
stead.
ā€¢ The plan_from_stripe_id function is removed. Use Plan.objects.get(stripe_id=)
SYNCING
ā€¢ sync_plans no longer takes an api_key
ā€¢ sync methods no longer take a cu parameter
ā€¢ All sync methods are now private. Weā€™re in the process of building a better syncing mechanism.
UTILITIES
ā€¢ dj-stripe decorators now take a plan argument. If youā€™re passing in a custom test function to
subscriber_passes_pay_test, be sure to account for this new argument.
MIXINS
ā€¢ The context provided by dj-stripeā€™s mixins has changed. PaymentsContextMixin now provides
STRIPE_PUBLIC_KEY and plans (changed to Plan.objects.all()). SubscriptionMixin now
provides customer and is_plans_plural.
ā€¢ Weā€™ve removed the SubscriptionPaymentRequiredMixin. Use @method_decorator("dispatch",
subscription_payment_required) instead.
116 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
MIDDLEWARE
ā€¢ dj-stripe middleware doesnā€™t support multiple subscriptions.
SIGNALS
ā€¢ Local custom signals are deprecated in favor of Stripe webhooks:
ā€¢ cancelled -> WEBHOOK_SIGNALS[ā€œcustomer.subscription.deletedā€]
ā€¢ card_changed -> WEBHOOK_SIGNALS[ā€œcustomer.source.updatedā€]
ā€¢ subscription_made -> WEBHOOK_SIGNALS[ā€œcustomer.subscription.createdā€]
WEBHOOK EVENTS
ā€¢ The Event Handlers designed by @wahuneke are the new way to handle events that come through webhooks.
Deļ¬nitely take a look at event_handlers.py and webhooks.py.
EXCEPTIONS
ā€¢ SubscriptionUpdateFailure and SubscriptionCancellationFailure exceptions are re-
moved. There should no longer be a case where they would have been useful. Catch native stripe errors in
their place instead.
MODELS
CHARGE
ā€¢ Charge.charge_created -> Charge.stripe_timestamp
ā€¢ Charge.card_last_4 and Charge.card_kind are removed. Use Charge.source.last4 and
Charge.source.brand (if the source is a Card)
ā€¢ Charge.invoice is no longer a foreign key to the Invoice model. Invoice now has a OneToOne relation-
ship with Charge. (Charge.invoice will still work, but will no longer be represented in the database).
CUSTOMER
ā€¢ dj-stripe now supports test mode and live mode Customer objects concurrently (See #440). As a re-
sult, the <subscriber_model>.customer OneToOne reverse relationship is no longer a thing. You
should now instead add a customer property to your subscriber model that checks whether youā€™re in
live or test mode (see djstripe.settings.STRIPE_LIVE_MODE as an example) and grabs the customer from
<subscriber_model>.djstripe_customers with a simple livemode= ļ¬lter.
ā€¢ Customer no longer has a current_subscription property. Weā€™ve added a subscription property
that should suit your needs.
ā€¢ With the advent of multiple subscriptions, the behavior of Customer.subscribe() has changed. Before,
calling subscribe() when a customer was already subscribed to a plan would switch the customer to
the new plan with an option to prorate. Now calling subscribe() simply subscribes that customer to a new
plan in addition to itā€™s current subsription. Use Subscription.update() to change a subscriptionā€™s plan
instead.
1.25. History 117
dj-stripe Documentation, Release 2.2.3
ā€¢ Customer.cancel_subscription() is removed. Use Subscription.cancel() instead.
ā€¢ The Customer.update_plan_quantity() method is removed. Use Subscription.update() in-
stead.
ā€¢ CustomerManager is now SubscriptionManager and works on the Subscription model instead
of the Customer model.
ā€¢ Customer.has_valid_card() is now Customer.has_valid_source().
ā€¢ Customer.update_card() now takes an id. If the id is not supplied, the default source is updated.
ā€¢ Customer.stripe_customer property is removed. Use Customer.api_retrieve() instead.
ā€¢ The at_period_end parameter of Customer.cancel_subscription() now actually follows the
DJSTRIPE_PRORATION_POLICY setting.
ā€¢ Customer.card_fingerprint, Customer.card_last_4, Customer.card_kind,
Customer.card_exp_month, Customer.card_exp_year are all removed. Check Customer.
default_source (if itā€™s a Card) or one of the sources in Customer.sources (again, if itā€™s a Card)
instead.
ā€¢ The invoice_id parameter of Customer.add_invoice_item is now named invoice and can be
either an Invoice object or the stripe_id of an Invoice.
EVENT
ā€¢ Event.kind -> Event.type
ā€¢ Removed Event.validated_message. Just check if the event is valid - no need to double check (we do
that for you)
TRANSFER
ā€¢ Removed Transfer.update_status()
ā€¢ Removed Transfer.event
ā€¢ TransferChargeFee is removed. It hasnā€™t been used in a while due to a broken API version. Use
Transfer.fee_details instead.
ā€¢ Any ļ¬elds that were in Transfer.summary no longer exist and are therefore deprecated (unused but not
removed from the database). Because of this, TransferManager now only aggregates total_sum
INVOICE
ā€¢ Invoice.attempts -> Invoice.attempt_count
ā€¢ InvoiceItems are no longer created when Invoices are synced. You must now sync InvoiceItems directly.
INVOICEITEM
ā€¢ Removed InvoiceItem.line_type
118 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
PLAN
ā€¢ Plan no longer has a stripe_plan property. Use api_retrieve() instead.
ā€¢ Plan.currency no longer uses choices. Use the get_supported_currency_choices() utility and
create your own custom choices list instead.
ā€¢ Plan interval choices are now in Plan.INTERVAL_TYPE_CHOICES
SUBSCRIPTION
ā€¢ Subscription.is_period_current() now checks for a current trial end if the current period has
ended. This change means subscriptions extended with Subscription.extend() will now be seen as
valid.
MIGRATIONS
Weā€™ll sync your current records with Stripe in a migration. It will take a while, but itā€™s the only way we can ensure
data integrity. There were some ļ¬elds for which we needed to temporarily add placeholder defaults, so just make sure
you have a customer with ID 1 and a plan with ID 1 and you shouldnā€™t run into any issues (create dummy values for
these if need be and delete them after the migration).
BIG HUGE NOTE - DONā€™T OVERLOOK THIS
Warning: Subscription and InvoiceItem migration is not possible because old records donā€™t have Stripe IDs (so
we canā€™t sync them). Our approach is to delete all local subscription and invoiceitem objects and re-sync them
from Stripe.
We 100% recommend you create a backup of your database before performing this upgrade.
Other changes
ā€¢ Postgres users now have access to the DJSTRIPE_USE_NATIVE_JSONFIELD setting. (Thanks @jleclanche)
#517, #523
ā€¢ Charge receipts now take DJSTRIPE_SEND_INVOICE_RECEIPT_EMAILS into account (Thanks @r0ļ¬‚s)
ā€¢ Clariļ¬ed/modiļ¬ed installation documentation (Thanks @pydanny)
ā€¢ Corrected and revised ANONYMOUS_USER_ERROR_MSG (Thanks @pydanny)
ā€¢ Added fnmatching to SubscriptionPaymentMiddleware (Thanks @pydanny)
ā€¢ SubscriptionPaymentMiddleware.process_request() functionality broken up into multiple
methods, making local customizations easier (Thanks @pydanny)
ā€¢ Fully qualiļ¬ed events are now supported by event handlers as strings e.g. ā€˜customer.subscription.deletedā€™
(Thanks @lskillen) #316
ā€¢ runtests now accepts positional arguments for declaring which tests to run (Thanks @lskillen) #317
ā€¢ It is now possible to reprocess events in both code and the admin interface (Thanks @lskillen) #318
ā€¢ The conļ¬rm page now checks that a valid card exists. (Thanks @scream4ik) #325
ā€¢ Added support for viewing upcoming invoices (Thanks @lskillen) #320
1.25. History 119
dj-stripe Documentation, Release 2.2.3
ā€¢ Event handler improvements and bugļ¬xes (Thanks @lskillen) #321
ā€¢ API list() method bugļ¬xes (Thanks @lskillen) #322
ā€¢ Added support for a custom webhook event handler (Thanks @lskillen) #323
ā€¢ Django REST Framework contrib package improvements (Thanks @aleccool213) #334
ā€¢ Added tax_percent to CreateSubscriptionSerializer (Thanks @aleccool213) #349
ā€¢ Fixed incorrectly assigned application_fee in Charge calls (Thanks @kronok) #382
ā€¢ Fixed bug caused by API change (Thanks @jessamynsmith) #353
ā€¢ Added inline documentation to pretty much everything and enforced docsytle via ļ¬‚ake8 (Thanks @aleccool213)
ā€¢ Fixed outdated method call in template (Thanks @kandoio) #391
ā€¢ Customer is correctly purged when subscriber is deleted, regardless of how the deletion happened (Thanks
@lskillen) #396
ā€¢ Test webhooks are now properly captured and logged. No more bounced requests to Stripe! (Thanks
@jameshiew) #408
ā€¢ CancelSubscriptionView redirect is now more ļ¬‚exible (Thanks @jleclanche) #418
ā€¢ Customer.sync_cards() (Thanks @jleclanche) #438
ā€¢ Many stability ļ¬xes, bugļ¬xes, and code cleanup (Thanks @jleclanche)
ā€¢ Support syncing canceled subscriptions (Thanks @jleclanche) #443
ā€¢ Improved admin interface (Thanks @jleclanche with @jameshiew) #451
ā€¢ Support concurrent TEST + LIVE API keys (Fix webhook event processing for both modes) (Thanks @jle-
clanche) #461
ā€¢ Added Stripe Dashboard link to admin change panel (Thanks @jleclanche) #465
ā€¢ Implemented Plan.amount_in_cents (Thanks @jleclanche) #466
ā€¢ Implemented Subscription.reactivate() (Thanks @jleclanche) #470
ā€¢ Added Plan.human_readable_price (Thanks @jleclanche) #498
ā€¢ (Re)attach the Subscriber when we ļ¬nd itā€™s id attached to a customer on Customer sync (Thanks @jleclanche)
#500
ā€¢ Made API version conļ¬gurable (with dj-stripe recommended default) (Thanks @lskillen) #504
1.25.20 0.8.0 (2015-12-30)
ā€¢ better plan ordering documentation (Thanks @cjrh)
ā€¢ added a conļ¬rmation page when choosing a subscription (Thanks @chrissmejia, @areski)
ā€¢ setup.py reverse dependency ļ¬x (#258/#268) (Thanks @ticosax)
ā€¢ Dropped ofļ¬cial support for Django 1.7 (no code changes were made)
ā€¢ Python 3.5 support, Django 1.9.1 support
ā€¢ Migration improvements (Thanks @michi88)
ā€¢ Fixed ā€œInvoice matching query does not existā€ bug (#263) (Thanks @mthornhill)
ā€¢ Fixed duplicate content in account view (Thanks @areski)
120 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.25.21 0.7.0 (2015-09-22)
ā€¢ dj-stripe now responds to the invoice.created event (Thanks @wahuneke)
ā€¢ dj-stripe now cancels subscriptions and purges customers during sync if they were deleted from the stripe dash-
board (Thanks @unformatt)
ā€¢ dj-stripe now checks for an active stripe subscription in the update_plan_quantity call (Thanks @ctren-
gove)
ā€¢ Event processing is now handled by ā€œevent handlersā€ - functions outside of models that respond to various
event types and subtypes. Documentation on how to tie into the event handler system coming soon. (Thanks
@wahuneke)
ā€¢ Experimental Python 3.5 support
ā€¢ Support for Django 1.6 and lower is now ofļ¬cially gone.
ā€¢ Much, much more!
1.25.22 0.6.0 (2015-07-12)
ā€¢ Support for Django 1.6 and lower is now deprecated.
ā€¢ Improved test harness now tests coverage and pep8
ā€¢ SubscribeFormView and ChangePlanView no longer populate self.error with form errors
ā€¢ InvoiceItems.plan can now be null (as it is with individual charges), resolving #140 (Thanks @awechsler and
@MichelleGlauser for help troubleshooting)
ā€¢ Email templates are now packaged during distribution.
ā€¢ sync_plans now takes an optional api_key
ā€¢ 100% test coverage
ā€¢ Stripe ID is now returned as part of each modelā€™s str method (Thanks @areski)
ā€¢ Customer model now stores card expiration month and year (Thanks @jpadilla)
ā€¢ Ability to extend subscriptions (Thanks @TigerDX)
ā€¢ Support for plan heirarchies (Thanks @chrissmejia)
ā€¢ Rest API endpoints for Subscriptions [contrib] (Thanks @philippeluickx)
ā€¢ Admin interface search by email funtionality is removed (#221) (Thanks @jpadilla)
1.25.23 0.5.0 (2015-05-25)
ā€¢ Began deprecation of support for Django 1.6 and lower.
ā€¢ Added formal support for Django 1.8.
ā€¢ Removed the StripeSubscriptionSignupForm
ā€¢ Removed djstripe.safe_settings. Settings are now all located in djstripe.settings
ā€¢ DJSTRIPE_TRIAL_PERIOD_FOR_SUBSCRIBER_CALLBACK can no longer be a module string
ā€¢ The sync_subscriber argument has been renamed from subscriber_model to subscriber
ā€¢ Moved available currencies to the DJSTRIPE_CURRENCIES setting (Thanks @martinhill)
1.25. History 121
dj-stripe Documentation, Release 2.2.3
ā€¢ Allow passing of extra parameters to stripe Charge API (Thanks @mthornhill)
ā€¢ Support for all available arguments when syncing plans (Thanks @jamesbrobb)
ā€¢ charge.refund() now returns the refunded charge object (Thanks @mthornhill)
ā€¢ Charge model now has captured ļ¬eld and a capture method (Thanks @mthornhill)
ā€¢ Subscription deleted webhook bugļ¬x
ā€¢ South migrations are now up to date (Thanks @Tyrdall)
1.25.24 0.4.0 (2015-04-05)
ā€¢ Formal Python 3.3+/Django 1.7 Support (including migrations)
ā€¢ Removed Python 2.6 from Travis CI build. (Thanks @audreyr)
ā€¢ Dropped Django 1.4 support. (Thanks @audreyr)
ā€¢ Deprecated the djstripe.forms.StripeSubscriptionSignupForm. Making this form work easily
with both dj-stripe and django-allauth required too much abstraction. It will be removed in the 0.5.0
release.
ā€¢ Add the ability to add invoice items for a customer (Thanks @kavdev)
ā€¢ Add the ability to use a custom customer model (Thanks @kavdev)
ā€¢ Added setting to disable Invoice receipt emails (Thanks Chris Halpert)
ā€¢ Enable proration when customer upgrades plan, and pass proration policy and cancellation at period end for
upgrades in settings. (Thanks Yasmine Charif)
ā€¢ Removed the redundant context processor. (Thanks @kavdev)
ā€¢ Fixed create a token call in change_card.html (Thanks @dollydagr)
ā€¢ Fix charge.dispute.closed typo. (Thanks @ipmb)
ā€¢ Fix contributing docs formatting. (Thanks @audreyr)
ā€¢ Fix subscription canceled_at_period_end ļ¬eld sync on plan upgrade (Thanks @nigma)
ā€¢ Remove ā€œaccountā€ bug in Middleware (Thanks @sromero84)
ā€¢ Fix correct plan selection on subscription in subscribe_form template. (Thanks Yasmine Charif)
ā€¢ Fix subscription status in account, _subscription_status, and cancel_subscription templates. (Thanks Yasmine
Charif)
ā€¢ Now using user.get_username() instead of user.username, to support custom User models. (Thanks
@shvechikov)
ā€¢ Update remaining DOM Ids for Bootstrap 3. (Thanks Yasmine Charif)
ā€¢ Update publish command in setup.py. (Thanks @pydanny)
ā€¢ Explicitly specify toxā€™s virtual environment names. (Thanks @audreyr)
ā€¢ Manually call django.setup() to populate apps registry. (Thanks @audreyr)
1.25.25 0.3.5 (2014-05-01)
ā€¢ Fixed djstripe_init_customers management command so it works with custom user models.
122 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.25.26 0.3.4 (2014-05-01)
ā€¢ Clarify documentation for redirects on app_name.
ā€¢ If settings.DEBUG is True, then django-debug-toolbar is exempt from redirect to subscription form.
ā€¢ Use collections.OrderedDict to ensure that plans are listed in order of price.
ā€¢ Add ordereddict library to support Python 2.6 users.
ā€¢ Switch from __unicode__ to __str__ methods on models to better support Python 3.
ā€¢ Add python_2_unicode_compatible decorator to Models.
ā€¢ Check for PY3 so the unicode(self.user) in models.Customer doesnā€™t blow up in Python 3.
1.25.27 0.3.3 (2014-04-24)
ā€¢ Increased the extendability of the views by removing as many hard-coded URLs as possible and replacing them
with success_url and other attributes/methods.
ā€¢ Added single unit purchasing to the cookbook
1.25.28 0.3.2 (2014-01-16)
ā€¢ Made Yasmine Charif a core committer
ā€¢ Take into account trial days in a subscription plan (Thanks Yasmine Charif)
ā€¢ Correct invoice period end value (Thanks Yasmine Charif)
ā€¢ Make plan cancellation and plan change consistently not prorating (Thanks Yasmine Charif)
ā€¢ Fix circular import when ACCOUNT_SIGNUP_FORM_CLASS is deļ¬ned (Thanks Dustin Farris)
ā€¢ Add send e-mail receipt action in charges admin panel (Thanks Buddy Lindsay)
ā€¢ Add created ļ¬eld to all ModelAdmins to help with internal auditing (Thanks Kulbir Singh)
1.25.29 0.3.1 (2013-11-14)
ā€¢ Cancellation ļ¬x (Thanks Yasmine Charif)
ā€¢ Add setup.cfg for wheel generation (Thanks Charlie Denton)
1.25.30 0.3.0 (2013-11-12)
ā€¢ Fully tested against Django 1.6, 1.5, and 1.4
ā€¢ Fix boolean default issue in models (from now on they are all default to False).
ā€¢ Replace duplicated code with djstripe.utils.user_has_active_subscription.
1.25. History 123
dj-stripe Documentation, Release 2.2.3
1.25.31 0.2.9 (2013-09-06)
ā€¢ Cancellation added to views.
ā€¢ Support for kwargs on charge and invoice fetching.
ā€¢ def charge() now supports send_receipt ļ¬‚ag, default to True.
ā€¢ Fixed templates to work with Bootstrap 3.0.0 column design.
1.25.32 0.2.8 (2013-09-02)
ā€¢ Improved usage documentation.
ā€¢ Corrected order of ļ¬elds in StripeSubscriptionSignupForm.
ā€¢ Corrected transaction history template layout.
ā€¢ Updated models to take into account when settings.USE_TZ is disabled.
1.25.33 0.2.7 (2013-08-24)
ā€¢ Add handy rest_framework permission class.
ā€¢ Fixing attribution for django-stripe-payments.
ā€¢ Add new status to Invoice model.
1.25.34 0.2.6 (2013-08-20)
ā€¢ Changed name of division tag to djdiv.
ā€¢ Added safe_setting.py module to handle edge cases when working with custom user models.
ā€¢ Added cookbook page in the documentation.
1.25.35 0.2.5 (2013-08-18)
ā€¢ Fixed bug in initial checkout
ā€¢ You canā€™t purchase the same plan that you currently have.
1.25.36 0.2.4 (2013-08-18)
ā€¢ Recursive package ļ¬nding.
1.25.37 0.2.3 (2013-08-16)
ā€¢ Fix packaging so all submodules are loaded
1.25.38 0.2.2 (2013-08-15)
ā€¢ Added Registration + Subscription form
124 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.25.39 0.2.1 (2013-08-12)
ā€¢ Fixed a bug on CurrentSubscription tests
ā€¢ Improved usage documentation
ā€¢ Added to migration from other tools documentation
1.25.40 0.2.0 (2013-08-12)
ā€¢ Cancellation of plans now works.
ā€¢ Upgrades and downgrades of plans now work.
ā€¢ Changing of cards now works.
ā€¢ Added breadcrumbs to improve navigation.
ā€¢ Improved installation instructions.
ā€¢ Consolidation of test instructions.
ā€¢ Minor improvement to django-stripe-payments documentation
ā€¢ Added coverage.py to test process.
ā€¢ Added south migrations.
ā€¢ Fixed the subscription_payment_required function-based view decorator.
ā€¢ Removed unnecessary django-crispy-forms
1.25.41 0.1.7 (2013-08-08)
ā€¢ Middleware excepts all of the djstripe namespaced URLs. This way people can pay.
1.25.42 0.1.6 (2013-08-08)
ā€¢ Fixed a couple template paths
ā€¢ Fixed the manifest so we include html, images.
1.25.43 0.1.5 (2013-08-08)
ā€¢ Fixed the manifest so we include html, css, js, images.
1.25.44 0.1.4 (2013-08-08)
ā€¢ Change PaymentRequiredMixin to SubscriptionPaymentRequiredMixin
ā€¢ Add subscription_payment_required function-based view decorator
ā€¢ Added SubscriptionPaymentRedirectMiddleware
ā€¢ Much nicer accounts view display
ā€¢ Much improved subscription form display
ā€¢ Payment plans can have decimals
1.25. History 125
dj-stripe Documentation, Release 2.2.3
ā€¢ Payment plans can have custom images
1.25.45 0.1.3 (2013-08-7)
ā€¢ Added account view
ā€¢ Added Customer.get_or_create method
ā€¢ Added djstripe_sync_customers management command
ā€¢ sync ļ¬le for all code that keeps things in sync with stripe
ā€¢ Use client-side JavaScript to get history data asynchronously
ā€¢ More user friendly action views
1.25.46 0.1.2 (2013-08-6)
ā€¢ Admin working
ā€¢ Better publish statement
ā€¢ Fix dependencies
1.25.47 0.1.1 (2013-08-6)
ā€¢ Ported internals from django-stripe-payments
ā€¢ Began writing the views
ā€¢ Travis-CI
ā€¢ All tests passing on Python 2.7 and 3.3
ā€¢ All tests passing on Django 1.4 and 1.5
ā€¢ Began model cleanup
ā€¢ Better form
ā€¢ Provide better response from management commands
1.25.48 0.1.0 (2013-08-5)
ā€¢ First release on PyPI.
1.26 Support
No content. . . yet
126 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.27 Release Process
Contents
ā€¢ Release Process
ā€“ Squash migrations
ā€“ Tag + package squashed migrations as rc package (optional)
ā€“ Prepare changes for the release commit
ā€“ Create signed release commit tag
ā€“ Update/create stable branch
ā€“ Conļ¬gure readthedocs
ā€“ Release on pypi
Attention: Before MAJOR or MINOR releases:
ā€¢ Review deprecation notes (eg search for ā€œdeprecatedā€) and remove deprecated features as appropriate
ā€¢ Squash migrations (ONLY on unreleased migrations) - see below
1.27.1 Squash migrations
If thereā€™s more than one unreleased migration on master consider squashing them with squashmigrations, im-
mediately before tagging the new release:
ā€¢ Create a new squashed migration with ./manage.py squashmigrations (only squash migrations that
have never been in a tagged release)
ā€¢ Commit the squashed migration on master with a commit message like ā€œSquash x.y.0dev migrationsā€ (this will
allow users who running master to safely upgrade, see note below about rc package)
ā€¢ Then transition the squashed migration to a normal migration as per Django:
ā€“ Delete all the migration ļ¬les it replaces
ā€“ Update all migrations that depend on the deleted migrations to depend on the squashed migration
instead
ā€“ Remove the replaces attribute in the Migration class of the squashed migration (this is how Django
tells that it is a squashed migration)
ā€¢ Commit these changes to master with a message like ā€œTransition squashed migration to normal migrationā€
ā€¢ Then do the normal release process - bump version as another commit and tag the release
See https://docs.djangoproject.com/en/dev/topics/migrations/#migration-squashing
1.27.2 Tag + package squashed migrations as rc package (optional)
As a convenience to users who are running master, an rc version can be created to package the squashed migration.
1.27. Release Process 127
dj-stripe Documentation, Release 2.2.3
To do this, immediately after the ā€œSquash x.y.0dev migrationsā€ commit, follow the steps below but with a x.y.0rc0
version to tag and package a rc version.
Users who have been using the x.y.0dev code from master can then run the squashed migrations migrations before
upgrading to >=x.y.0.
The simplest way to do this is to pip install dj-stripe==x.y.0rc0 and migrate, or alternatively check
out the x.y.0rc0 git tag and migrate.
1.27.3 Prepare changes for the release commit
ā€¢ Choose your version number (using https://semver.org/ )
ā€“ if thereā€™s a new migration, it should be a MAJOR.0.0 or MAJOR.MINOR.0 version.
ā€¢ Review and update HISTORY.rst
ā€“ Add a section for this release version
ā€“ Set date on this release version
ā€“ Check that summary of feature/ļ¬xes is since the last release is up to date
ā€¢ Update package version number in setup.cfg
ā€¢ Review and update supported API version in README.rst (this is the most recent Stripe account version
tested against, not DEFAULT_STRIPE_API_VERSION)
ā€¢ git add to stage these changes
1.27.4 Create signed release commit tag
Note: Before doing this you should have a GPG key set up on github
If you donā€™t have a GPG key already, one method is via https://keybase.io/ , and then add it to your github proļ¬le.
ā€¢ Create a release tag with the above staged changes (where $VERSION is the version number to be released:
$ git commit -m "Release $VERSION"
$ git tag -fsm "Release $VERSION" $VERSION
This can be expressed as a bash function as follows:
git_release() { git commit -m "Release $1" && git tag -fsm "Release $1" $1; }
ā€¢ Push the commit and tag:
$ git push --follow-tags
1.27.5 Update/create stable branch
Push these changes to the appropriate stable/MAJOR.MINOR version branch (eg stable/2.0) if theyā€™re not
already - note that this will trigger the readthedocs build
128 Chapter 1. Contents
dj-stripe Documentation, Release 2.2.3
1.27.6 Conļ¬gure readthedocs
If this is this is a new stable branch then do the following on https://readthedocs.org/dashboard/dj-stripe/versions/
ā€¢ Find the new stable/MAJOR.MINOR branch name and mark it as active (and then save).
1.27.7 Release on pypi
See https://packaging.python.org/tutorials/packaging-projects/#generating-distribution-archives
1.27. Release Process 129
dj-stripe Documentation, Release 2.2.3
130 Chapter 1. Contents
CHAPTER 2
Constraints
1. For stripe.com only
2. Only use or support well-maintained third-party libraries
3. For modern Python and Django
131
dj-stripe Documentation, Release 2.2.3
132 Chapter 2. Constraints
Index
A
Account (class in djstripe.models), 85
account_already_exists
(djstripe.enums.ApiErrorCode attribute),
16
account_closed (djstripe.enums.PayoutFailureCode
attribute), 26
account_country_invalid_address
(djstripe.enums.ApiErrorCode attribute),
16
account_frozen (djstripe.enums.PayoutFailureCode
attribute), 26
account_invalid (djstripe.enums.ApiErrorCode at-
tribute), 16
account_number_invalid
(djstripe.enums.ApiErrorCode attribute),
16
AccountType (class in djstripe.enums), 19
ach_credit_transfer (djstripe.enums.SourceType
attribute), 29
ach_debit (djstripe.enums.SourceType attribute), 29
active (djstripe.enums.SubscriptionStatus attribute),
32
active() (djstripe.managers.SubscriptionManager
method), 32
active_plan_summary()
(djstripe.managers.SubscriptionManager
method), 32
active_subscriptions (djstripe.models.Customer
attribute), 42
add_card() (djstripe.models.Customer method), 42
add_coupon() (djstripe.models.Customer method), 43
add_invoice_item() (djstripe.models.Customer
method), 41
add_payment_method() (djstripe.models.Customer
method), 42
adjustment (djstripe.enums.BalanceTransactionType
attribute), 19
advance (djstripe.enums.BalanceTransactionType at-
tribute), 19
advance_funding (djstripe.enums.BalanceTransactionType
attribute), 19
alipay (djstripe.enums.SourceType attribute), 29
alipay_account (djstripe.enums.LegacySourceType
attribute), 30
alipay_upgrade_required
(djstripe.enums.ApiErrorCode attribute),
17
AmericanExpress (djstripe.enums.CardBrand
attribute), 22
amount_in_cents (djstripe.models.Plan attribute),
73
amount_too_large (djstripe.enums.ApiErrorCode
attribute), 17
amount_too_small (djstripe.enums.ApiErrorCode
attribute), 17
android_pay (djstripe.enums.CardTokenizationMethod
attribute), 22
api_key_expired (djstripe.enums.ApiErrorCode at-
tribute), 17
api_list() (djstripe.models.Account class method),
86
api_list() (djstripe.models.ApplicationFee class
method), 88
api_list() (djstripe.models.BalanceTransaction
class method), 35
api_list() (djstripe.models.BankAccount class
method), 55
api_list() (djstripe.models.Card class method), 57
api_list() (djstripe.models.Charge class method), 37
api_list() (djstripe.models.CountrySpec class
method), 89
api_list() (djstripe.models.Coupon class method),
62
api_list() (djstripe.models.Customer class method),
39
api_list() (djstripe.models.Dispute class method),
44
api_list() (djstripe.models.Event class method), 45
133
dj-stripe Documentation, Release 2.2.3
api_list() (djstripe.models.FileUpload class
method), 47
api_list() (djstripe.models.Invoice class method), 66
api_list() (djstripe.models.InvoiceItem class
method), 69, 71
api_list() (djstripe.models.PaymentIntent class
method), 51
api_list() (djstripe.models.PaymentMethod class
method), 58
api_list() (djstripe.models.Payout class method), 48
api_list() (djstripe.models.Plan class method), 73
api_list() (djstripe.models.Product class method),
52
api_list() (djstripe.models.Refund class method), 54
api_list() (djstripe.models.ScheduledQueryRun
class method), 93
api_list() (djstripe.models.Source class method), 60
api_list() (djstripe.models.Subscription class
method), 75
api_list() (djstripe.models.SubscriptionItem class
method), 78
api_list() (djstripe.models.TaxRate class method),
79
api_list() (djstripe.models.Transfer class method),
90
api_list() (djstripe.models.TransferReversal class
method), 91
api_list() (djstripe.models.UpcomingInvoice class
method), 83
api_list() (djstripe.models.UsageRecord class
method), 85
api_retrieve() (djstripe.models.Account method),
87
api_retrieve() (djstripe.models.ApplicationFee
method), 88
api_retrieve() (djstripe.models.BalanceTransaction
method), 35
api_retrieve() (djstripe.models.BankAccount
method), 55
api_retrieve() (djstripe.models.Card method), 57
api_retrieve() (djstripe.models.Charge method),
37
api_retrieve() (djstripe.models.CountrySpec
method), 89
api_retrieve() (djstripe.models.Coupon method),
62
api_retrieve() (djstripe.models.Customer method),
39
api_retrieve() (djstripe.models.Dispute method),
44
api_retrieve() (djstripe.models.Event method), 46
api_retrieve() (djstripe.models.FileUpload
method), 47
api_retrieve() (djstripe.models.Invoice method),
66
api_retrieve() (djstripe.models.InvoiceItem
method), 69, 71
api_retrieve() (djstripe.models.PaymentIntent
method), 51
api_retrieve() (djstripe.models.PaymentMethod
method), 58
api_retrieve() (djstripe.models.Payout method),
49
api_retrieve() (djstripe.models.Plan method), 73
api_retrieve() (djstripe.models.Product method),
52
api_retrieve() (djstripe.models.Refund method),
54
api_retrieve() (djstripe.models.ScheduledQueryRun
method), 93
api_retrieve() (djstripe.models.Source method), 60
api_retrieve() (djstripe.models.Subscription
method), 75
api_retrieve() (djstripe.models.SubscriptionItem
method), 78
api_retrieve() (djstripe.models.TaxRate method),
79
api_retrieve() (djstripe.models.Transfer method),
90
api_retrieve() (djstripe.models.TransferReversal
method), 92
api_retrieve() (djstripe.models.UpcomingInvoice
method), 83
api_retrieve() (djstripe.models.UsageRecord
method), 85
ApiErrorCode (class in djstripe.enums), 16
apple_pay (djstripe.enums.CardTokenizationMethod
attribute), 22
application_fee (djstripe.enums.BalanceTransactionType
attribute), 19
application_fee_refund
(djstripe.enums.BalanceTransactionType
attribute), 19
ApplicationFee (class in djstripe.models), 87
attach() (djstripe.models.PaymentMethod class
method), 59
auto (djstripe.enums.SubmitTypeStatus attribute), 32
automatic (djstripe.enums.CaptureMethod attribute),
21
automatic (djstripe.enums.Conļ¬rmationMethod at-
tribute), 23
available (djstripe.enums.BalanceTransactionStatus
attribute), 19
B
balance_insufficient
(djstripe.enums.ApiErrorCode attribute),
17
134 Index
dj-stripe Documentation, Release 2.2.3
BalanceTransaction (class in djstripe.models), 34
BalanceTransactionStatus (class in
djstripe.enums), 19
BalanceTransactionType (class in
djstripe.enums), 19
bancontact (djstripe.enums.SourceType attribute), 29
bank_account (djstripe.enums.LegacySourceType at-
tribute), 30
bank_account (djstripe.enums.PayoutType attribute),
27
bank_account_exists
(djstripe.enums.ApiErrorCode attribute),
17
bank_account_restricted
(djstripe.enums.PayoutFailureCode attribute),
26
bank_account_unusable
(djstripe.enums.ApiErrorCode attribute),
17
bank_account_unverified
(djstripe.enums.ApiErrorCode attribute),
17
bank_cannot_process
(djstripe.enums.DisputeReason attribute),
23
bank_ownership_changed
(djstripe.enums.PayoutFailureCode attribute),
26
BankAccount (class in djstripe.models), 54
BankAccountHolderType (class in djstripe.enums),
20
BankAccountStatus (class in djstripe.enums), 21
bitcoin (djstripe.enums.SourceType attribute), 29
bitcoin_receiver (djstripe.enums.LegacySourceType
attribute), 30
bitcoin_upgrade_required
(djstripe.enums.ApiErrorCode attribute),
17
book (djstripe.enums.SubmitTypeStatus attribute), 32
BusinessType (class in djstripe.enums), 21
C
can_charge() (djstripe.models.Customer method), 43
cancel() (djstripe.models.Subscription method), 76
canceled (djstripe.enums.IntentStatus attribute), 25
canceled (djstripe.enums.PaymentIntentStatus at-
tribute), 25
canceled (djstripe.enums.PayoutStatus attribute), 27
canceled (djstripe.enums.RefundStatus attribute), 30
canceled (djstripe.enums.ScheduledQueryRunStatus
attribute), 28
canceled (djstripe.enums.SetupIntentStatus attribute),
26
canceled (djstripe.enums.SourceStatus attribute), 29
canceled (djstripe.enums.SubscriptionStatus at-
tribute), 32
canceled() (djstripe.managers.SubscriptionManager
method), 32
canceled_during()
(djstripe.managers.SubscriptionManager
method), 32
canceled_plan_summary_for()
(djstripe.managers.SubscriptionManager
method), 33
capture() (djstripe.models.Charge method), 38
CaptureMethod (class in djstripe.enums), 21
Card (class in djstripe.models), 56
card (djstripe.enums.LegacySourceType attribute), 30
card (djstripe.enums.PayoutType attribute), 27
card (djstripe.enums.SourceType attribute), 29
card_declined (djstripe.enums.ApiErrorCode
attribute), 17
card_present (djstripe.enums.SourceType attribute),
29
CardBrand (class in djstripe.enums), 22
CardCheckResult (class in djstripe.enums), 21
CardFundingType (class in djstripe.enums), 22
CardTokenizationMethod (class in
djstripe.enums), 22
category (djstripe.models.Event attribute), 46
Charge (class in djstripe.models), 35
charge (djstripe.enums.BalanceTransactionType
attribute), 20
charge() (djstripe.models.Customer method), 41
charge_already_captured
(djstripe.enums.ApiErrorCode attribute),
17
charge_already_refunded
(djstripe.enums.ApiErrorCode attribute),
17
charge_disputed (djstripe.enums.ApiErrorCode at-
tribute), 17
charge_exceeds_source_limit
(djstripe.enums.ApiErrorCode attribute),
17
charge_expired_for_capture
(djstripe.enums.ApiErrorCode attribute),
17
charge_refunded (djstripe.enums.DisputeStatus at-
tribute), 24
chargeable (djstripe.enums.SourceStatus attribute),
29
ChargeManager (class in djstripe.managers), 33
ChargeStatus (class in djstripe.enums), 22
choices (djstripe.enums.AccountType attribute), 19
choices (djstripe.enums.ApiErrorCode attribute), 17
choices (djstripe.enums.BalanceTransactionStatus at-
tribute), 19
Index 135
dj-stripe Documentation, Release 2.2.3
choices (djstripe.enums.BalanceTransactionType at-
tribute), 20
choices (djstripe.enums.BankAccountHolderType at-
tribute), 20
choices (djstripe.enums.BankAccountStatus attribute),
21
choices (djstripe.enums.BusinessType attribute), 21
choices (djstripe.enums.CaptureMethod attribute), 21
choices (djstripe.enums.CardBrand attribute), 22
choices (djstripe.enums.CardCheckResult attribute),
21
choices (djstripe.enums.CardFundingType attribute),
22
choices (djstripe.enums.CardTokenizationMethod at-
tribute), 22
choices (djstripe.enums.ChargeStatus attribute), 22
choices (djstripe.enums.Conļ¬rmationMethod at-
tribute), 23
choices (djstripe.enums.CouponDuration attribute),
23
choices (djstripe.enums.CustomerTaxExempt at-
tribute), 23
choices (djstripe.enums.DisputeReason attribute), 23
choices (djstripe.enums.DisputeStatus attribute), 24
choices (djstripe.enums.FileUploadPurpose attribute),
24
choices (djstripe.enums.FileUploadType attribute), 24
choices (djstripe.enums.IntentStatus attribute), 25
choices (djstripe.enums.IntentUsage attribute), 25
choices (djstripe.enums.LegacySourceType attribute),
30
choices (djstripe.enums.PaymentIntentStatus at-
tribute), 25
choices (djstripe.enums.PayoutFailureCode attribute),
26
choices (djstripe.enums.PayoutMethod attribute), 26
choices (djstripe.enums.PayoutStatus attribute), 27
choices (djstripe.enums.PayoutType attribute), 27
choices (djstripe.enums.PlanAggregateUsage at-
tribute), 27
choices (djstripe.enums.PlanBillingScheme attribute),
27
choices (djstripe.enums.PlanInterval attribute), 28
choices (djstripe.enums.PlanTiersMode attribute), 28
choices (djstripe.enums.PlanUsageType attribute), 28
choices (djstripe.enums.ProductType attribute), 28
choices (djstripe.enums.RefundFailureReason at-
tribute), 30
choices (djstripe.enums.RefundReason attribute), 30
choices (djstripe.enums.RefundStatus attribute), 30
choices (djstripe.enums.ScheduledQueryRunStatus at-
tribute), 28
choices (djstripe.enums.SetupIntentStatus attribute),
26
choices (djstripe.enums.SourceCodeVeriļ¬cationStatus
attribute), 31
choices (djstripe.enums.SourceFlow attribute), 29
choices (djstripe.enums.SourceRedirectFailureReason
attribute), 31
choices (djstripe.enums.SourceRedirectStatus at-
tribute), 31
choices (djstripe.enums.SourceStatus attribute), 29
choices (djstripe.enums.SourceType attribute), 29
choices (djstripe.enums.SourceUsage attribute), 31
choices (djstripe.enums.SubmitTypeStatus attribute),
32
choices (djstripe.enums.SubscriptionStatus attribute),
32
churn() (djstripe.managers.SubscriptionManager
method), 33
clear_expired_idempotency_keys()
(djstripe.utils method), 100
code_verification (djstripe.enums.SourceFlow at-
tribute), 29
company (djstripe.enums.BankAccountHolderType at-
tribute), 20
company (djstripe.enums.BusinessType attribute), 21
ConfirmationMethod (class in djstripe.enums), 23
connect_collection_transfer
(djstripe.enums.BalanceTransactionType
attribute), 20
consumed (djstripe.enums.SourceStatus attribute), 29
convert_tstamp() (djstripe.utils method), 100
could_not_process
(djstripe.enums.PayoutFailureCode attribute),
26
country_unsupported
(djstripe.enums.ApiErrorCode attribute),
17
CountrySpec (class in djstripe.models), 88
Coupon (class in djstripe.models), 61
coupon_expired (djstripe.enums.ApiErrorCode at-
tribute), 17
CouponDuration (class in djstripe.enums), 23
create_token() (djstripe.models.Card class
method), 57
credit (djstripe.enums.CardFundingType attribute), 22
credit_not_processed
(djstripe.enums.DisputeReason attribute),
23
credits (djstripe.models.Customer attribute), 40
csv (djstripe.enums.FileUploadType attribute), 24
custom (djstripe.enums.AccountType attribute), 19
Customer (class in djstripe.models), 38
customer (djstripe.models.Event attribute), 46
customer_initiated
(djstripe.enums.DisputeReason attribute),
23
136 Index
dj-stripe Documentation, Release 2.2.3
customer_max_subscriptions
(djstripe.enums.ApiErrorCode attribute),
17
customer_payment_methods
(djstripe.models.Customer attribute), 40
CustomerTaxExempt (class in djstripe.enums), 23
D
day (djstripe.enums.PlanInterval attribute), 28
debit (djstripe.enums.CardFundingType attribute), 22
debit_not_authorized
(djstripe.enums.DisputeReason attribute),
23
debit_not_authorized
(djstripe.enums.PayoutFailureCode attribute),
26
declined (djstripe.enums.SourceRedirectFailureReason
attribute), 31
detach() (djstripe.models.PaymentMethod method),
59
detach() (djstripe.models.Source method), 60
DinersClub (djstripe.enums.CardBrand attribute), 22
Discover (djstripe.enums.CardBrand attribute), 22
Dispute (class in djstripe.models), 43
dispute_evidence (djstripe.enums.FileUploadPurpose
attribute), 24
disputed (djstripe.models.Charge attribute), 37
DisputeReason (class in djstripe.enums), 23
DisputeStatus (class in djstripe.enums), 24
docx (djstripe.enums.FileUploadType attribute), 24
donate (djstripe.enums.SubmitTypeStatus attribute), 32
duplicate (djstripe.enums.DisputeReason attribute),
23
duplicate (djstripe.enums.RefundReason attribute),
30
during() (djstripe.managers.ChargeManager
method), 33
during() (djstripe.managers.TransferManager
method), 33
E
email_invalid (djstripe.enums.ApiErrorCode
attribute), 17
eps (djstripe.enums.SourceType attribute), 29
errored (djstripe.enums.BankAccountStatus attribute),
21
Event (class in djstripe.models), 45
exempt (djstripe.enums.CustomerTaxExempt attribute),
23
expired_card (djstripe.enums.ApiErrorCode at-
tribute), 17
expired_or_canceled_card
(djstripe.enums.RefundFailureReason at-
tribute), 30
expired_uncaptured_charge
(djstripe.enums.RefundReason attribute),
30
express (djstripe.enums.AccountType attribute), 19
extend() (djstripe.models.Subscription method), 76
F
fail (djstripe.enums.CardCheckResult attribute), 21
failed (djstripe.enums.ChargeStatus attribute), 22
failed (djstripe.enums.PayoutStatus attribute), 27
failed (djstripe.enums.RefundStatus attribute), 30
failed (djstripe.enums.ScheduledQueryRunStatus at-
tribute), 28
failed (djstripe.enums.SourceCodeVeriļ¬cationStatus
attribute), 31
failed (djstripe.enums.SourceRedirectStatus attribute),
31
failed (djstripe.enums.SourceStatus attribute), 29
FileUpload (class in djstripe.models), 46
FileUploadPurpose (class in djstripe.enums), 24
FileUploadType (class in djstripe.enums), 24
forever (djstripe.enums.CouponDuration attribute),
23
fraudulent (djstripe.enums.DisputeReason attribute),
23
fraudulent (djstripe.enums.RefundReason attribute),
30
from_request() (djstripe.models.WebhookEventTrigger
class method), 94
G
general (djstripe.enums.DisputeReason attribute), 23
get_connected_account_from_token()
(djstripe.models.Account class method), 87
get_default_account() (djstripe.models.Account
class method), 87
get_friendly_currency_amount()
(djstripe.utils method), 100
get_or_create() (djstripe.models.Customer class
method), 40
get_or_create() (djstripe.models.Plan class
method), 73
get_stripe_dashboard_url()
(djstripe.models.Account method), 87
get_stripe_dashboard_url()
(djstripe.models.ApplicationFee method),
88
get_stripe_dashboard_url()
(djstripe.models.BalanceTransaction method),
35
get_stripe_dashboard_url()
(djstripe.models.BankAccount method), 55
get_stripe_dashboard_url()
(djstripe.models.Card method), 57
Index 137
dj-stripe Documentation, Release 2.2.3
get_stripe_dashboard_url()
(djstripe.models.Charge method), 37
get_stripe_dashboard_url()
(djstripe.models.CountrySpec method), 89
get_stripe_dashboard_url()
(djstripe.models.Coupon method), 62
get_stripe_dashboard_url()
(djstripe.models.Customer method), 40
get_stripe_dashboard_url()
(djstripe.models.Dispute method), 44
get_stripe_dashboard_url()
(djstripe.models.Invoice method), 67
get_stripe_dashboard_url()
(djstripe.models.InvoiceItem method), 69,
71
get_stripe_dashboard_url()
(djstripe.models.PaymentIntent method),
51
get_stripe_dashboard_url()
(djstripe.models.PaymentMethod method),
59
get_stripe_dashboard_url()
(djstripe.models.Payout method), 49
get_stripe_dashboard_url()
(djstripe.models.Plan method), 73
get_stripe_dashboard_url()
(djstripe.models.Product method), 53
get_stripe_dashboard_url()
(djstripe.models.Refund method), 54
get_stripe_dashboard_url()
(djstripe.models.Source method), 60
get_stripe_dashboard_url()
(djstripe.models.Subscription method), 76
get_stripe_dashboard_url()
(djstripe.models.SubscriptionItem method),
78
get_stripe_dashboard_url()
(djstripe.models.TaxRate method), 80
get_stripe_dashboard_url()
(djstripe.models.Transfer method), 91
get_stripe_dashboard_url()
(djstripe.models.TransferReversal method),
92
get_stripe_dashboard_url()
(djstripe.models.UpcomingInvoice method), 84
get_stripe_dashboard_url()
(djstripe.models.UsageRecord method), 85
get_supported_currency_choices()
(djstripe.utils method), 99
giropay (djstripe.enums.SourceType attribute), 29
good (djstripe.enums.ProductType attribute), 28
graduated (djstripe.enums.PlanTiersMode attribute),
28
H
handler() (djstripe.webhooks method), 16
handler_all() (djstripe.webhooks method), 16
has_active_subscription()
(djstripe.models.Customer method), 42
has_any_active_subscription()
(djstripe.models.Customer method), 42
has_valid_source() (djstripe.models.Customer
method), 43
human_readable (djstripe.models.Coupon attribute),
62
human_readable_amount (djstripe.models.Coupon
attribute), 62
human_readable_price (djstripe.models.Plan at-
tribute), 73
I
ideal (djstripe.enums.SourceType attribute), 29
idempotency_key_in_use
(djstripe.enums.ApiErrorCode attribute),
17
identity_document
(djstripe.enums.FileUploadPurpose attribute),
24
in_transit (djstripe.enums.PayoutStatus attribute),
27
incomplete (djstripe.enums.SubscriptionStatus
attribute), 32
incomplete_expired
(djstripe.enums.SubscriptionStatus attribute),
32
incorrect_account_details
(djstripe.enums.DisputeReason attribute),
23
incorrect_address (djstripe.enums.ApiErrorCode
attribute), 17
incorrect_cvc (djstripe.enums.ApiErrorCode
attribute), 17
incorrect_number (djstripe.enums.ApiErrorCode
attribute), 17
incorrect_zip (djstripe.enums.ApiErrorCode
attribute), 17
individual (djstripe.enums.BankAccountHolderType
attribute), 20
individual (djstripe.enums.BusinessType attribute),
21
instant (djstripe.enums.PayoutMethod attribute), 26
instant_payouts_unsupported
(djstripe.enums.ApiErrorCode attribute),
17
insufficient_funds
(djstripe.enums.DisputeReason attribute),
23
138 Index
dj-stripe Documentation, Release 2.2.3
insufficient_funds
(djstripe.enums.PayoutFailureCode attribute),
26
IntentStatus (class in djstripe.enums), 25
IntentUsage (class in djstripe.enums), 25
invalid_account_number
(djstripe.enums.PayoutFailureCode attribute),
26
invalid_card_type (djstripe.enums.ApiErrorCode
attribute), 17
invalid_charge_amount
(djstripe.enums.ApiErrorCode attribute),
17
invalid_currency (djstripe.enums.PayoutFailureCode
attribute), 26
invalid_cvc (djstripe.enums.ApiErrorCode at-
tribute), 17
invalid_expiry_month
(djstripe.enums.ApiErrorCode attribute),
17
invalid_expiry_year
(djstripe.enums.ApiErrorCode attribute),
17
invalid_number (djstripe.enums.ApiErrorCode at-
tribute), 17
invalid_source_usage
(djstripe.enums.ApiErrorCode attribute),
17
invalid_swipe_data
(djstripe.enums.ApiErrorCode attribute),
17
Invoice (class in djstripe.models), 62
invoice_no_customer_line_items
(djstripe.enums.ApiErrorCode attribute),
17
invoice_no_subscription_line_items
(djstripe.enums.ApiErrorCode attribute), 18
invoice_not_editable
(djstripe.enums.ApiErrorCode attribute),
18
invoice_upcoming_none
(djstripe.enums.ApiErrorCode attribute),
18
InvoiceBilling (in module djstripe.enums), 25
InvoiceItem (class in djstripe.models), 68, 70
invoiceitems (djstripe.models.UpcomingInvoice at-
tribute), 84
invoke_webhook_handlers()
(djstripe.models.Event method), 46
is_period_current()
(djstripe.models.Subscription method), 77
is_status_current()
(djstripe.models.Subscription method), 77
is_status_temporarily_current()
(djstripe.models.Subscription method), 77
is_test_event (djstripe.models.WebhookEventTrigger
attribute), 94
is_valid() (djstripe.models.Subscription method), 77
issuing_authorization_hold
(djstripe.enums.BalanceTransactionType
attribute), 20
issuing_authorization_release
(djstripe.enums.BalanceTransactionType
attribute), 20
issuing_transaction
(djstripe.enums.BalanceTransactionType
attribute), 20
J
JCB (djstripe.enums.CardBrand attribute), 22
jpg (djstripe.enums.FileUploadType attribute), 24
json_body (djstripe.models.WebhookEventTrigger at-
tribute), 94
L
last_during_period
(djstripe.enums.PlanAggregateUsage at-
tribute), 27
last_ever (djstripe.enums.PlanAggregateUsage at-
tribute), 27
legacy_cards (djstripe.models.Customer attribute),
40
LegacySourceType (class in djstripe.enums), 30
licensed (djstripe.enums.PlanUsageType attribute),
28
livemode_mismatch (djstripe.enums.ApiErrorCode
attribute), 18
lost (djstripe.enums.DisputeStatus attribute), 24
lost_or_stolen_card
(djstripe.enums.RefundFailureReason at-
tribute), 30
M
manual (djstripe.enums.CaptureMethod attribute), 21
manual (djstripe.enums.Conļ¬rmationMethod attribute),
23
MasterCard (djstripe.enums.CardBrand attribute), 22
max (djstripe.enums.PlanAggregateUsage attribute), 27
metered (djstripe.enums.PlanUsageType attribute), 28
missing (djstripe.enums.ApiErrorCode attribute), 18
month (djstripe.enums.PlanInterval attribute), 28
N
needs_response (djstripe.enums.DisputeStatus at-
tribute), 24
network_cost (djstripe.enums.BalanceTransactionType
attribute), 20
new (djstripe.enums.BankAccountStatus attribute), 21
Index 139
dj-stripe Documentation, Release 2.2.3
no_account (djstripe.enums.PayoutFailureCode at-
tribute), 26
none (djstripe.enums.CustomerTaxExempt attribute), 23
none (djstripe.enums.SourceFlow attribute), 29
not_allowed_on_standard_account
(djstripe.enums.ApiErrorCode attribute),
18
not_required (djstripe.enums.SourceRedirectStatus
attribute), 31
O
off_session (djstripe.enums.IntentUsage attribute),
25
on_session (djstripe.enums.IntentUsage attribute), 25
once (djstripe.enums.CouponDuration attribute), 23
order_creation_failed
(djstripe.enums.ApiErrorCode attribute),
18
order_required_settings
(djstripe.enums.ApiErrorCode attribute),
18
order_status_invalid
(djstripe.enums.ApiErrorCode attribute),
18
order_upstream_timeout
(djstripe.enums.ApiErrorCode attribute),
18
out_of_inventory (djstripe.enums.ApiErrorCode
attribute), 18
P
p24 (djstripe.enums.SourceType attribute), 29
paid (djstripe.enums.PayoutStatus attribute), 27
paid_totals_for()
(djstripe.managers.ChargeManager method),
33
paid_totals_for()
(djstripe.managers.TransferManager method),
33
paper_check (djstripe.enums.SourceType attribute),
29
parameter_invalid_empty
(djstripe.enums.ApiErrorCode attribute),
18
parameter_invalid_integer
(djstripe.enums.ApiErrorCode attribute),
18
parameter_invalid_string_blank
(djstripe.enums.ApiErrorCode attribute),
18
parameter_invalid_string_empty
(djstripe.enums.ApiErrorCode attribute),
18
parameter_missing (djstripe.enums.ApiErrorCode
attribute), 18
parameter_unknown (djstripe.enums.ApiErrorCode
attribute), 18
parameters_exclusive
(djstripe.enums.ApiErrorCode attribute),
18
parts (djstripe.models.Event attribute), 46
pass_ (djstripe.enums.CardCheckResult attribute), 21
past_due (djstripe.enums.SubscriptionStatus at-
tribute), 32
pay (djstripe.enums.SubmitTypeStatus attribute), 32
payment (djstripe.enums.BalanceTransactionType at-
tribute), 20
payment_failure_refund
(djstripe.enums.BalanceTransactionType
attribute), 20
payment_intent_authentication_failure
(djstripe.enums.ApiErrorCode attribute), 18
payment_intent_incompatible_payment_method
(djstripe.enums.ApiErrorCode attribute), 18
payment_intent_invalid_parameter
(djstripe.enums.ApiErrorCode attribute),
18
payment_intent_payment_attempt_failed
(djstripe.enums.ApiErrorCode attribute), 18
payment_intent_unexpected_state
(djstripe.enums.ApiErrorCode attribute),
18
payment_method_unactivated
(djstripe.enums.ApiErrorCode attribute),
18
payment_method_unexpected_state
(djstripe.enums.ApiErrorCode attribute),
18
payment_refund (djstripe.enums.BalanceTransactionType
attribute), 20
PaymentIntent (class in djstripe.models), 49
PaymentIntentStatus (class in djstripe.enums), 25
PaymentMethod (class in djstripe.models), 58
Payout (class in djstripe.models), 47
payout (djstripe.enums.BalanceTransactionType
attribute), 20
payout_cancel (djstripe.enums.BalanceTransactionType
attribute), 20
payout_failure (djstripe.enums.BalanceTransactionType
attribute), 20
PayoutFailureCode (class in djstripe.enums), 26
PayoutMethod (class in djstripe.enums), 26
payouts_not_allowed
(djstripe.enums.ApiErrorCode attribute),
18
PayoutStatus (class in djstripe.enums), 27
PayoutType (class in djstripe.enums), 27
140 Index
dj-stripe Documentation, Release 2.2.3
pdf (djstripe.enums.FileUploadType attribute), 24
pending (djstripe.enums.BalanceTransactionStatus at-
tribute), 19
pending (djstripe.enums.ChargeStatus attribute), 22
pending (djstripe.enums.PayoutStatus attribute), 27
pending (djstripe.enums.RefundStatus attribute), 30
pending (djstripe.enums.SourceCodeVeriļ¬cationStatus
attribute), 31
pending (djstripe.enums.SourceRedirectStatus at-
tribute), 31
pending (djstripe.enums.SourceStatus attribute), 29
pending_charges (djstripe.models.Customer at-
tribute), 40
per_unit (djstripe.enums.PlanBillingScheme at-
tribute), 27
Plan (class in djstripe.models), 71
plan (djstripe.models.Invoice attribute), 67
PlanAggregateUsage (class in djstripe.enums), 27
PlanBillingScheme (class in djstripe.enums), 27
PlanInterval (class in djstripe.enums), 28
PlanTiersMode (class in djstripe.enums), 28
PlanUsageType (class in djstripe.enums), 28
platform_api_key_expired
(djstripe.enums.ApiErrorCode attribute),
18
png (djstripe.enums.FileUploadType attribute), 24
postal_code_invalid
(djstripe.enums.ApiErrorCode attribute),
18
prepaid (djstripe.enums.CardFundingType attribute),
22
process() (djstripe.models.Event class method), 46
processing (djstripe.enums.IntentStatus attribute), 25
processing (djstripe.enums.PaymentIntentStatus at-
tribute), 25
processing (djstripe.enums.SetupIntentStatus at-
tribute), 26
processing_error (djstripe.enums.ApiErrorCode
attribute), 18
processing_error (djstripe.enums.SourceRedirectFailureReason
attribute), 31
Product (class in djstripe.models), 51
product_inactive (djstripe.enums.ApiErrorCode
attribute), 18
product_not_received
(djstripe.enums.DisputeReason attribute),
23
product_unacceptable
(djstripe.enums.DisputeReason attribute),
24
ProductType (class in djstripe.enums), 28
purge() (djstripe.models.Customer method), 42
R
rate_limit (djstripe.enums.ApiErrorCode attribute),
18
reactivate() (djstripe.models.Subscription method),
77
receiver (djstripe.enums.SourceFlow attribute), 29
redirect (djstripe.enums.SourceFlow attribute), 29
Refund (class in djstripe.models), 53
refund (djstripe.enums.BalanceTransactionType
attribute), 20
refund() (djstripe.models.Charge method), 37
refund_failure (djstripe.enums.BalanceTransactionType
attribute), 20
RefundFailureReason (class in djstripe.enums), 30
RefundReason (class in djstripe.enums), 30
RefundStatus (class in djstripe.enums), 30
remove() (djstripe.models.Card method), 57
repeating (djstripe.enums.CouponDuration at-
tribute), 23
requested_by_customer
(djstripe.enums.RefundReason attribute),
30
requires_action (djstripe.enums.IntentStatus at-
tribute), 25
requires_action (djstripe.enums.PaymentIntentStatus
attribute), 25
requires_action (djstripe.enums.SetupIntentStatus
attribute), 26
requires_capture (djstripe.enums.PaymentIntentStatus
attribute), 25
requires_confirmation
(djstripe.enums.IntentStatus attribute), 25
requires_confirmation
(djstripe.enums.PaymentIntentStatus attribute),
25
requires_confirmation
(djstripe.enums.SetupIntentStatus attribute), 26
requires_payment_method
(djstripe.enums.IntentStatus attribute), 25
requires_payment_method
(djstripe.enums.PaymentIntentStatus attribute),
25
requires_payment_method
(djstripe.enums.SetupIntentStatus attribute), 26
reserve_transaction
(djstripe.enums.BalanceTransactionType
attribute), 20
reserved_funds (djstripe.enums.BalanceTransactionType
attribute), 20
resource_already_exists
(djstripe.enums.ApiErrorCode attribute),
18
resource_missing (djstripe.enums.ApiErrorCode
attribute), 18
Index 141
dj-stripe Documentation, Release 2.2.3
retry() (djstripe.models.Invoice method), 67
retry_unpaid_invoices()
(djstripe.models.Customer method), 43
reusable (djstripe.enums.SourceUsage attribute), 31
reverse (djstripe.enums.CustomerTaxExempt at-
tribute), 23
routing_number_invalid
(djstripe.enums.ApiErrorCode attribute),
18
S
ScheduledQueryRun (class in djstripe.models), 92
ScheduledQueryRunStatus (class in
djstripe.enums), 28
secret_key_required
(djstripe.enums.ApiErrorCode attribute),
18
send_invoice() (djstripe.models.Customer method),
43
sepa_credit_transfer
(djstripe.enums.SourceType attribute), 29
sepa_debit (djstripe.enums.SourceType attribute), 29
sepa_unsupported_account
(djstripe.enums.ApiErrorCode attribute),
18
service (djstripe.enums.ProductType attribute), 28
SetupIntentStatus (class in djstripe.enums), 26
shipping_calculation_failed
(djstripe.enums.ApiErrorCode attribute),
19
single_use (djstripe.enums.SourceUsage attribute),
31
sku_inactive (djstripe.enums.ApiErrorCode at-
tribute), 19
sofort (djstripe.enums.SourceType attribute), 30
Source (class in djstripe.models), 59
SourceCodeVerificationStatus (class in
djstripe.enums), 31
SourceFlow (class in djstripe.enums), 29
SourceRedirectFailureReason (class in
djstripe.enums), 31
SourceRedirectStatus (class in djstripe.enums),
31
SourceStatus (class in djstripe.enums), 29
SourceType (class in djstripe.enums), 29
SourceUsage (class in djstripe.enums), 31
standard (djstripe.enums.AccountType attribute), 19
standard (djstripe.enums.PayoutMethod attribute), 26
started_during() (djstripe.managers.SubscriptionManager
method), 32
started_plan_summary_for()
(djstripe.managers.SubscriptionManager
method), 32
state_unsupported (djstripe.enums.ApiErrorCode
attribute), 19
status (djstripe.models.Invoice attribute), 67
str_parts() (djstripe.models.Account method), 87
str_parts() (djstripe.models.BankAccount method),
55
str_parts() (djstripe.models.Card method), 57
str_parts() (djstripe.models.Charge method), 38
str_parts() (djstripe.models.Coupon method), 62
str_parts() (djstripe.models.Customer method), 43
str_parts() (djstripe.models.Dispute method), 44
str_parts() (djstripe.models.Event method), 46
str_parts() (djstripe.models.Invoice method), 68
str_parts() (djstripe.models.InvoiceItem method),
71
str_parts() (djstripe.models.PaymentIntent
method), 51
str_parts() (djstripe.models.PaymentMethod
method), 59
str_parts() (djstripe.models.Payout method), 49
str_parts() (djstripe.models.Plan method), 73
str_parts() (djstripe.models.Source method), 61
str_parts() (djstripe.models.Subscription method),
77
str_parts() (djstripe.models.Transfer method), 91
str_parts() (djstripe.models.UpcomingInvoice
method), 84
stripe_fee (djstripe.enums.BalanceTransactionType
attribute), 20
stripe_fx_fee (djstripe.enums.BalanceTransactionType
attribute), 20
stripe_temporary_api_version()
(djstripe.context_managers method), 15
SubmitTypeStatus (class in djstripe.enums), 32
subscribe() (djstripe.models.Customer method), 40
subscriber_has_active_subscription()
(djstripe.utils method), 99
Subscription (class in djstripe.models), 73
subscription (djstripe.models.Customer attribute),
43
subscription_canceled
(djstripe.enums.DisputeReason attribute),
24
SubscriptionItem (class in djstripe.models), 77
SubscriptionManager (class in djstripe.managers),
32
SubscriptionPaymentMiddleware (class in
djstripe.middleware), 33
SubscriptionStatus (class in djstripe.enums), 32
succeeded (djstripe.enums.ChargeStatus attribute), 22
succeeded (djstripe.enums.PaymentIntentStatus
attribute), 25
succeeded (djstripe.enums.RefundStatus attribute), 31
142 Index
dj-stripe Documentation, Release 2.2.3
succeeded (djstripe.enums.SetupIntentStatus at-
tribute), 26
succeeded (djstripe.enums.SourceCodeVeriļ¬cationStatus
attribute), 31
succeeded (djstripe.enums.SourceRedirectStatus at-
tribute), 31
sum (djstripe.enums.PlanAggregateUsage attribute), 27
sync_from_stripe_data()
(djstripe.models.Account class method),
87
sync_from_stripe_data()
(djstripe.models.ApplicationFee class method),
88
sync_from_stripe_data()
(djstripe.models.BalanceTransaction class
method), 35
sync_from_stripe_data()
(djstripe.models.BankAccount class method),
55
sync_from_stripe_data() (djstripe.models.Card
class method), 57
sync_from_stripe_data()
(djstripe.models.Charge class method), 38
sync_from_stripe_data()
(djstripe.models.CountrySpec class method),
89
sync_from_stripe_data()
(djstripe.models.Coupon class method),
62
sync_from_stripe_data()
(djstripe.models.Customer class method),
43
sync_from_stripe_data()
(djstripe.models.Dispute class method),
45
sync_from_stripe_data() (djstripe.models.Event
class method), 46
sync_from_stripe_data()
(djstripe.models.FileUpload class method),
47
sync_from_stripe_data()
(djstripe.models.Invoice class method), 68
sync_from_stripe_data()
(djstripe.models.InvoiceItem class method), 69,
71
sync_from_stripe_data()
(djstripe.models.PaymentIntent class method),
51
sync_from_stripe_data()
(djstripe.models.PaymentMethod class
method), 59
sync_from_stripe_data()
(djstripe.models.Payout class method), 49
sync_from_stripe_data() (djstripe.models.Plan
class method), 73
sync_from_stripe_data()
(djstripe.models.Product class method),
53
sync_from_stripe_data()
(djstripe.models.Refund class method), 54
sync_from_stripe_data()
(djstripe.models.ScheduledQueryRun class
method), 93
sync_from_stripe_data()
(djstripe.models.Source class method), 61
sync_from_stripe_data()
(djstripe.models.Subscription class method),
77
sync_from_stripe_data()
(djstripe.models.SubscriptionItem class
method), 78
sync_from_stripe_data()
(djstripe.models.TaxRate class method),
80
sync_from_stripe_data()
(djstripe.models.Transfer class method),
91
sync_from_stripe_data()
(djstripe.models.TransferReversal class
method), 92
sync_from_stripe_data()
(djstripe.models.UpcomingInvoice class
method), 84
sync_from_stripe_data()
(djstripe.models.UsageRecord class method),
85
T
tax_document_user_upload
(djstripe.enums.FileUploadPurpose attribute),
24
tax_fee (djstripe.enums.BalanceTransactionType at-
tribute), 20
tax_id_invalid (djstripe.enums.ApiErrorCode at-
tribute), 19
taxes_calculation_failed
(djstripe.enums.ApiErrorCode attribute),
19
TaxRate (class in djstripe.models), 79
testmode_charges_only
(djstripe.enums.ApiErrorCode attribute),
19
three_d_secure (djstripe.enums.SourceType at-
tribute), 30
tiered (djstripe.enums.PlanBillingScheme attribute),
27
timed_out (djstripe.enums.ScheduledQueryRunStatus
attribute), 28
Index 143
dj-stripe Documentation, Release 2.2.3
tls_version_unsupported
(djstripe.enums.ApiErrorCode attribute),
19
token_already_used
(djstripe.enums.ApiErrorCode attribute),
19
token_in_use (djstripe.enums.ApiErrorCode at-
tribute), 19
topup (djstripe.enums.BalanceTransactionType at-
tribute), 20
topup_reversal (djstripe.enums.BalanceTransactionType
attribute), 20
Transfer (class in djstripe.models), 89
transfer (djstripe.enums.BalanceTransactionType at-
tribute), 20
transfer_cancel (djstripe.enums.BalanceTransactionType
attribute), 20
transfer_refund (djstripe.enums.BalanceTransactionType
attribute), 20
TransferManager (class in djstripe.managers), 33
TransferReversal (class in djstripe.models), 91
transfers_not_allowed
(djstripe.enums.ApiErrorCode attribute),
19
trialing (djstripe.enums.SubscriptionStatus at-
tribute), 32
U
unavailable (djstripe.enums.CardCheckResult
attribute), 21
unchecked (djstripe.enums.CardCheckResult at-
tribute), 21
under_review (djstripe.enums.DisputeStatus at-
tribute), 24
UnionPay (djstripe.enums.CardBrand attribute), 22
Unknown (djstripe.enums.CardBrand attribute), 22
unknown (djstripe.enums.CardFundingType attribute),
22
unknown (djstripe.enums.RefundFailureReason at-
tribute), 30
unpaid (djstripe.enums.SubscriptionStatus attribute),
32
unrecognized (djstripe.enums.DisputeReason at-
tribute), 24
unsupported_card (djstripe.enums.PayoutFailureCode
attribute), 26
upcoming() (djstripe.models.Invoice class method), 67
upcoming_invoice() (djstripe.models.Customer
method), 43
UpcomingInvoice (class in djstripe.models), 80
update() (djstripe.models.Subscription method), 76
upstream_order_creation_failed
(djstripe.enums.ApiErrorCode attribute),
19
url_invalid (djstripe.enums.ApiErrorCode at-
tribute), 19
UsageRecord (class in djstripe.models), 84
user_abort (djstripe.enums.SourceRedirectFailureReason
attribute), 31
V
valid_subscriptions (djstripe.models.Customer
attribute), 43
validated (djstripe.enums.BankAccountStatus at-
tribute), 21
validation (djstripe.enums.BalanceTransactionType
attribute), 20
verb (djstripe.models.Event attribute), 46
verification_failed
(djstripe.enums.BankAccountStatus attribute),
21
verified (djstripe.enums.BankAccountStatus at-
tribute), 21
Visa (djstripe.enums.CardBrand attribute), 22
volume (djstripe.enums.PlanTiersMode attribute), 28
W
warning_closed (djstripe.enums.DisputeStatus at-
tribute), 24
warning_needs_response
(djstripe.enums.DisputeStatus attribute),
24
warning_under_review
(djstripe.enums.DisputeStatus attribute),
24
WebhookEventTrigger (class in djstripe.models),
93
week (djstripe.enums.PlanInterval attribute), 28
won (djstripe.enums.DisputeStatus attribute), 24
X
xls (djstripe.enums.FileUploadType attribute), 24
xlsx (djstripe.enums.FileUploadType attribute), 24
Y
year (djstripe.enums.PlanInterval attribute), 28
144 Index