Models

Models hold the bulk of the functionality included in the dj-stripe package. Each model is tied closely to its corresponding 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

Core Resources

Balance Transaction

class djstripe.models.BalanceTransaction(*args, **kwargs)[source]

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 field 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
  • fee (StripeQuantumCurrencyAmountField) – Fee. Fee (in cents) paid for this transaction.
  • fee_details (JSONField) – Fee details
  • net (StripeQuantumCurrencyAmountField) – Net. Net amount of the transaction, 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 settings.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)[source]

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 identified 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 field 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 charged (as decimal).
  • amount_refunded (StripeDecimalCurrencyAmountField) – Amount refunded. 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 transaction. 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 explaining reason for charge failure if available.
  • fraud_details (JSONField) – Fraud details. Hash with information on fraud assessments 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 accepted, and why.
  • paid (BooleanField) – Paid. True if the charge succeeded, or was successfully authorized 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. PaymentMethod 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.
  • receipt_number (CharField) – Receipt number. The transaction number that appears 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 information 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 identifies this transaction 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 settings.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)[source]

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 values are duplicate, fraudulent, and requested_by_customer. Specifying 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()[source]

Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first 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)[source]

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 field 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 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 identification 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 prefix. The prefix 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 locales (languages), ordered by preference.
  • shipping (JSONField) – Shipping. Shipping information associated with the customer.
  • tax_exempt (StripeEnumField) – Tax exempt. Describes the customer’s tax exemption 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.

Parameters:
  • api_key (string) – The api key to use for this request. Defaults to settings.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)[source]

Get or create a dj-stripe customer.

Parameters:
  • subscriber (User) – The subscriber model instance for which to get or create a customer.
  • livemode (bool) – Whether to get the subscriber in live or test mode.
Customer.legacy_cards

Model field: 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)[source]

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 final amount each billing period.
  • billing_cycle_anchor (datetime) – A future timestamp to anchor the subscription’s billing cycle. This is used to determine the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.
  • trial_end (datetime) – The end datetime of the trial period the customer will get before being charged for the first 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 applied to the subscription. Setting trial_end per subscription is preferred, and this defaults to false. Setting this flag 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 first 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, statement_descriptor=None, idempotency_key=None)[source]

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 transferred 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 customer’s credit card statement.
Customer.add_invoice_item(amount, currency, description=None, discountable=None, invoice=None, metadata=None, subscription=None)[source]

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:
  • 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. Defaults 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 scheduled 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 subscription 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 specified 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)[source]

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)[source]

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()[source]
Customer.has_active_subscription(plan=None)[source]

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 active 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()[source]

Checks to see if this customer has an active subscription to any plan.

Returns:True if there exists an active subscription, False otherwise.
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 subscription.
Raises:MultipleSubscriptionException – Raised if the customer has multiple subscriptions. In this case, use Customer.subscriptions instead.
Customer.can_charge()[source]

Determines if this customer is able to be charged.

Customer.send_invoice()[source]

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()[source]

Attempt to retry collecting payment on the customer’s unpaid invoices.

Customer.has_valid_source()[source]

Check whether the customer has a valid payment source.

Customer.add_coupon(coupon, idempotency_key=None)[source]

Add a coupon to a Customer.

The coupon can be a Coupon object, or a valid Stripe Coupon ID.

Customer.upcoming_invoice(**kwargs)[source]

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)[source]

Stripe documentation: https://stripe.com/docs/api#disputes

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 field 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 fluctuation 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 settings.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

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)[source]

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 configured 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 field 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 flag 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.

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 settings.STRIPE_SECRET_KEY.
  • stripe_account (string) – The optional connected account for which this request is being made.
classmethod Event.process(data)[source]
Event.invoke_webhook_handlers()[source]

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()[source]

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)[source]

Stripe documentation: https://stripe.com/docs/api#file_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 field 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
  • filename (CharField) – Filename. A filename for the file, suitable for saving to a filesystem.
  • purpose (StripeEnumField) – Purpose. The purpose of the uploaded file.
  • size (IntegerField) – Size. The size in bytes of the file upload object.
  • type (StripeEnumField) – Type. The type of the file returned.
  • url (CharField) – Url. A read-only URL where the uploaded file 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 settings.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)[source]

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
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field 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 decimal) 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 transaction. 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) – Failure balance transaction. If the payout failed or was canceled, this will be the balance transaction 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 explaining 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.

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 settings.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)[source]

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 field 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 capturable. Amount (in cents) that can be captured from this PaymentIntent.
  • amount_received (StripeQuantumCurrencyAmountField) – Amount received. Amount (in cents) that was collected by this PaymentIntent.
  • 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, requested_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) – Confirmation method. Confirmation 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 encountered in the previous PaymentIntent confirmation.
  • next_action (JSONField) – Next action. If present, this property tells you what actions you need to take in order for your customer to fulfill 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 flow. Use off_session if your customer may or may not be in your checkout flow. Stripe uses setup_future_usage to dynamically optimize your payment flow 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’ statements. Must contain at least one letter, maximum 22 characters.
  • status (StripeEnumField) – Status. Status of this PaymentIntent, one of requires_payment_method, requires_confirmation, requires_action, processing, requires_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 finalized. See the PaymentIntents Connect usage guide for details.
  • transfer_group (CharField) – Transfer group. A string that identifies 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 settings.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)[source]

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 field 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
  • 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 identifiers 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 first 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.

Parameters:
  • api_key (string) – The api key to use for this request. Defaults to settings.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)[source]

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 field 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 transaction. 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) – Failure balance transaction. If the refund failed, this balance transaction describes the adjustment 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.
  • reason (StripeEnumField) – Reason. Reason for the refund.
  • receipt_number (CharField) – Receipt number. The transaction number that appears 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 settings.STRIPE_SECRET_KEY.
  • stripe_account (string) – The optional connected account for which this request is being made.
Refund.get_stripe_dashboard_url()[source]

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

Payment Methods

BankAccount

class djstripe.models.BankAccount(djstripe_id, id, livemode, created, metadata, description, djstripe_created, djstripe_updated, account, account_holder_name, account_holder_type, bank_name, country, currency, customer, default_for_currency, fingerprint, last4, routing_number, status)[source]
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 field 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 (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 person 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 identifies this particular bank account. 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.

Parameters:data (dict) – stripe object
Return type:cls

Card

class djstripe.models.Card(*args, **kwargs)[source]

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 field 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 address_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
  • 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 identifies this particular card number.
  • 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)[source]

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()[source]

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.

Parameters:data (dict) – stripe object
Return type:cls

PaymentMethod

class djstripe.models.PaymentMethod(*args, **kwargs)[source]

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 field 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 PaymentMethod, this hash contains details about the Card Present payment method.
  • customer (ForeignKey to Customer) – Customer. Customer to which this PaymentMethod 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 specific 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:
  • api_key (string) – The api key to use for this request. Defaults to settings.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='')[source]

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()[source]

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)[source]

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 field 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 decimal) 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 flow 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 verification. Information related to the code verification flow. Present if the source is authenticated by a verification code (flow is code_verification).
  • receiver (JSONField) – Receiver. Information related to the receiver flow. Present if the source is a receiver (flow is receiver).
  • redirect (JSONField) – Redirect. Information related to the redirect flow. Present if the source is authenticated by a redirect (flow 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 settings.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.

Source.detach()[source]

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

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, percent_off, redeem_by, times_redeemed)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field 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 applies this coupon will get the discount.
  • duration_in_months (PositiveIntegerField) – Duration in months. If duration is repeating, the number of months the coupon applies.
  • 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 settings.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)[source]

Invoices are statements of what a customer owes for a particular billing period, including subscriptions, invoice items, and any automatic proration adjustments if necessary.

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 configured 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 field 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 associated with this invoice, most often the business creating the invoice.
  • account_name (TextField) – Account name. The public name of the business associated 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 specified in amount_due.
  • amount_paid (StripeDecimalCurrencyAmountField) – Amount paid. The amount, (as decimal), that was paid.
  • amount_remaining (StripeDecimalCurrencyAmountField) – Amount remaining. The amount remaining, (as decimal), that is due.
  • application_fee_amount (StripeDecimalCurrencyAmountField) – Application 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 first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first 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 automatically 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 subscription. 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 invoice, if any.
  • collection_method (StripeEnumField) – Collection method. When charging automatically, 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 finalized, this field will equal customer.address. Once the invoice is finalized, this field will no longer be updated.
  • customer_email (TextField) – Customer email. The customer’s email. Until the invoice is finalized, this field will equal customer.email. Once the invoice is finalized, this field will no longer be updated.
  • customer_name (TextField) – Customer name. The customer’s name. Until the invoice is finalized, this field will equal customer.name. Once the invoice is finalized, this field will no longer be updated.
  • customer_phone (TextField) – Customer phone. The customer’s phone number. Until the invoice is finalized, this field will equal customer.phone. Once the invoice is finalized, this field will no longer be updated.
  • customer_shipping (JSONField) – Customer shipping. The customer’s shipping information. Until the invoice is finalized, this field will equal customer.shipping. Once the invoice is finalized, this field will no longer be updated.
  • customer_tax_exempt (StripeEnumField) – Customer tax exempt. The customer’s tax exempt status. Until the invoice is finalized, this field will equal customer.tax_exempt. Once the invoice is finalized, this field 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 associated 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.
  • discount (JSONField) – Discount. Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis.
  • 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.
  • 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 invoice. 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_prefix if it is specified.
  • paid (BooleanField) – Paid. Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer’s account balance.
  • payment_intent (OneToOneField to PaymentIntent) – Payment intent. The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, 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.
  • starting_balance (StripeQuantumCurrencyAmountField) – Starting balance. 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 information consistently, some may display it incorrectly or not at all.
  • status (StripeEnumField) – Status. The status of the invoice, one of draft, open, paid, uncollectible, or void.
  • 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 proration date. Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • subtotal (StripeDecimalCurrencyAmountField) – Subtotal. Total (as decimal) 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 defined, 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 field is inherited from the subscription’s tax_percent field, but can be changed before the invoice is paid. This field defaults to null.
  • threshold_reason (JSONField) – Threshold reason. If billing_reason is set to subscription_threshold this returns more information on which threshold rules triggered the invoice.
  • total (StripeDecimalCurrencyAmountField) – Total (as decimal) after discount.
  • 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_source (PaymentMethodForeignKey to DjstripePaymentMethod) – Default source. The default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription’s default source, if any, or to the customer’s default source.
  • 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:
  • api_key (string) – The api key to use for this request. Defaults to settings.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, subscription_proration_date=None, subscription_quantity=None, subscription_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 identifier of the customer whose upcoming invoice you’d like to retrieve.
  • coupon (str) – The code of the coupon to apply.
  • subscription (Subscription or string (subscription ID)) – The identifier of the subscription to retrieve an invoice for.
  • subscription_plan (Plan or string (plan ID)) – If set, the invoice returned will preview updating the subscription given to this plan, or creating a new subscription to this plan if no subscription is given.
  • subscription_prorate (bool) – If previewing an update to a subscription, this decides whether the preview will show the result of applying prorations or not.
  • subscription_proration_date (datetime) – If previewing an update to a subscription, and doing proration, subscription_proration_date forces the proration to be calculated as though the update was done at the specified time.
  • subscription_quantity (int) – If provided, the invoice returned will preview updating or creating a subscription with that quantity.
  • subscription_trial_end (datetime) – If provided, the invoice returned will preview 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 or uncollectible.

Invoice.plan

Gets the associated plan for this invoice.

In order to provide a consistent view of invoices, the plan object should be taken from the first 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)[source]

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 field 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.
  • 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 settings.STRIPE_SECRET_KEY.
  • stripe_account (string) – The optional connected account for which this request is being made.
InvoiceItem.get_stripe_dashboard_url()[source]

Get the stripe dashboard url for this object.

InvoiceItem.str_parts()[source]

Extend this to add information to the string representation of the object

Return type:list of str
classmethod InvoiceItem.sync_from_stripe_data(data)[source]

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)[source]

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 field 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. Whether the plan is currently available for new subscriptions.
  • aggregate_usage (StripeEnumField) – Aggregate usage. Specifies a usage aggregation 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. Defaults to sum.
  • amount (StripeDecimalCurrencyAmountField) – Amount. Amount (as decimal) to be charged on the interval specified.
  • billing_scheme (StripeEnumField) – Billing scheme. Describes how to compute the price per period. Either per_unit or tiered. per_unit indicates that the fixed amount (specified 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 defined 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 (specified in the interval property) between each subscription billing.
  • nickname (TextField) – Nickname. A brief description of the plan, hidden from customers.
  • product (ForeignKey to Product) – Product. The product whose pricing this plan determines.
  • tiers (JSONField) – Tiers. Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered.
  • tiers_mode (StripeEnumField) – Tiers mode. Defines 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. Configures how the quantity per period should be determined, can be either metered or licensed. licensed will automatically 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 information 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 settings.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)[source]

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)[source]

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.

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 field 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_cycle_anchor (StripeDateTimeField) – Billing cycle anchor. Determines the date of the first 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 flag 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 reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state.
  • collection_method (StripeEnumField) – Collection method. 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.
  • 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.
  • 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.
  • default_payment_method (ForeignKey to PaymentMethod) – Default payment method. The default payment method for the subscription. It must belong to the customer associated with the subscription. If not set, invoices will use the default payment method in the customer’s invoice settings.
  • default_source (PaymentMethodForeignKey to DjstripePaymentMethod) – Default source. The default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If not set, defaults to the customer’s default source.
  • discount (JSONField) – Discount
  • 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.
  • next_pending_invoice_item_invoice (StripeDateTimeField) – Next pending invoice item invoice. Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at pending_invoice_item_interval.
  • pending_invoice_item_interval (JSONField) – Pending invoice item interval. Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling Create an invoice for the given subscription at the specified interval.
  • 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.
  • pending_update (JSONField) – Pending update. If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid.
  • 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.
  • start_date (StripeDateTimeField) – Start date. Date when the subscription was first created. The date might differ from the created date due to backdating.
  • 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 subscription invoice subtotal that will be calculated and added as tax to the final 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 settings.STRIPE_SECRET_KEY.
  • 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, quantity=None, tax_percent=None, trial_end=None)[source]

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 proration 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)[source]

Extends this subscription by the provided delta.

Parameters:delta (timedelta) – The timedelta by which to extend this subscription.
Subscription.cancel(at_period_end=True)[source]

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 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 flag 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 flag will be overridden to False so that the trial ends immediately and the customer’s card isn’t charged.

Subscription.reactivate()[source]

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()[source]

Returns True if this subscription’s period is current, false otherwise.

Subscription.is_status_current()[source]

Returns True if this subscription’s status is current (active or trialing), false otherwise.

Subscription.is_status_temporarily_current()[source]

A status is temporarily current when the subscription is canceled with the at_period_end flag. The subscription 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()[source]

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)[source]

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

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 field 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 subscription_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 settings.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
Return type:cls

TaxRate

class djstripe.models.TaxRate(*args, **kwargs)[source]

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 field 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 specifies 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 percent 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 settings.STRIPE_SECRET_KEY.
  • 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)[source]

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 field 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 associated with this invoice, most often the business creating the invoice.
  • account_name (TextField) – Account name. The public name of the business associated 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 specified in amount_due.
  • amount_paid (StripeDecimalCurrencyAmountField) – Amount paid. The amount, (as decimal), that was paid.
  • amount_remaining (StripeDecimalCurrencyAmountField) – Amount remaining. The amount remaining, (as decimal), that is due.
  • application_fee_amount (StripeDecimalCurrencyAmountField) – Application 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 first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first 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 automatically 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 subscription. 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 invoice, if any.
  • collection_method (StripeEnumField) – Collection method. When charging automatically, 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 finalized, this field will equal customer.address. Once the invoice is finalized, this field will no longer be updated.
  • customer_email (TextField) – Customer email. The customer’s email. Until the invoice is finalized, this field will equal customer.email. Once the invoice is finalized, this field will no longer be updated.
  • customer_name (TextField) – Customer name. The customer’s name. Until the invoice is finalized, this field will equal customer.name. Once the invoice is finalized, this field will no longer be updated.
  • customer_phone (TextField) – Customer phone. The customer’s phone number. Until the invoice is finalized, this field will equal customer.phone. Once the invoice is finalized, this field will no longer be updated.
  • customer_shipping (JSONField) – Customer shipping. The customer’s shipping information. Until the invoice is finalized, this field will equal customer.shipping. Once the invoice is finalized, this field will no longer be updated.
  • customer_tax_exempt (StripeEnumField) – Customer tax exempt. The customer’s tax exempt status. Until the invoice is finalized, this field will equal customer.tax_exempt. Once the invoice is finalized, this field 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 associated 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.
  • discount (JSONField) – Discount. Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis.
  • 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.
  • 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 invoice. 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_prefix if it is specified.
  • paid (BooleanField) – Paid. Whether payment was successfully collected for this invoice. An invoice can be paid (most commonly) with a charge or with credit from the customer’s account balance.
  • payment_intent (OneToOneField to PaymentIntent) – Payment intent. The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized, 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.
  • starting_balance (StripeQuantumCurrencyAmountField) – Starting balance. 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 information consistently, some may display it incorrectly or not at all.
  • status (StripeEnumField) – Status. The status of the invoice, one of draft, open, paid, uncollectible, or void.
  • 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 proration date. Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • subtotal (StripeDecimalCurrencyAmountField) – Subtotal. Total (as decimal) 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 defined, 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 field is inherited from the subscription’s tax_percent field, but can be changed before the invoice is paid. This field defaults to null.
  • threshold_reason (JSONField) – Threshold reason. If billing_reason is set to subscription_threshold this returns more information on which threshold rules triggered the invoice.
  • total (StripeDecimalCurrencyAmountField) – Total (as decimal) after discount.
  • 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_source (PaymentMethodForeignKey to DjstripePaymentMethod) – Default source. The default payment source for the invoice. It must belong to the customer associated with the invoice and be in a chargeable state. If not set, defaults to the subscription’s default source, if any, or to the customer’s default source.
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
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 settings.STRIPE_SECRET_KEY.
  • stripe_account (string) – The optional connected account for which this request is being made.
UpcomingInvoice.get_stripe_dashboard_url()[source]

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)[source]

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 field 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
  • 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 settings.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

Connect

Account

class djstripe.models.Account(*args, **kwargs)[source]

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 field 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
  • branding_icon (ForeignKey to FileUpload) – Branding icon. An icon for the account. 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 profile. 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 field is null unless business_type is set to company.
  • default_currency (StripeCurrencyCodeField) – Default currency. The currency 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 field 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 description 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.

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 settings.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)[source]
classmethod Account.get_default_account()[source]
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)[source]

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 field 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 earned, in cents.
  • amount_refunded (StripeQuantumCurrencyAmountField) – Amount refunded. 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 transaction. 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 settings.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)[source]

Stripe documentation: https://stripe.com/docs/api#country_specs

Parameters:
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • id (CharField) – Id
  • default_currency (StripeCurrencyCodeField) – Default currency. The default currency for this country. This applies to both payment methods and bank accounts.
  • supported_bank_account_currencies (JSONField) – Supported bank account currencies. Currencies that can be accepted in the specific country (for transfers).
  • supported_payment_currencies (JSONField) – Supported payment currencies. Currencies that can be accepted in the specified country (for payments).
  • supported_payment_methods (JSONField) – Supported payment methods. Payment methods available in the specified country.
  • supported_transfer_countries (JSONField) – Supported transfer countries. Countries that can accept transfers from the specified country.
  • verification_fields (JSONField) – Verification fields. Lists the types of verification 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 settings.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)[source]

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
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field 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 transferred
  • amount_reversed (StripeDecimalCurrencyAmountField) – Amount reversed. 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 transaction. 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 identifies this transaction 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.

Parameters:
  • api_key (string) – The api key to use for this request. Defaults to settings.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()[source]

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)[source]

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 field 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 transaction. 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.

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 settings.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

Fraud

TODO

Orders

TODO

Sigma

ScheduledQueryRun

class djstripe.models.ScheduledQueryRun(*args, **kwargs)[source]

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 field 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
  • 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 file 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 settings.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

Webhooks

WebhookEventTrigger

class djstripe.models.WebhookEventTrigger(*args, **kwargs)[source]

An instance of a request that reached the server endpoint for Stripe webhooks.

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’ flag 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 validation
  • 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)[source]

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).