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 2018-05-24

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. (Source: https://stripe.com/docs/api/python#charges)

# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.
  • application_fee - #. Coming soon with stripe connect functionality
  • balance_transaction - #
  • order - #
  • refunds - #
  • source_transfer - #

Attention

Stripe API_VERSION: model fields audited to 2016-06-05 - @jleclanche

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeCurrencyField) – Amount charged.
  • amount_refunded (StripeCurrencyField) – Amount refunded (can be less than the amount attribute on the charge if a partial refund was issued).
  • captured (StripeBooleanField) – If the charge was created without capturing, this boolean represents whether or not it is still uncaptured or has since been captured.
  • currency (StripeCharField) – Three-letter ISO currency code representing the currency in which the charge was made.
  • customer (ForeignKey to Customer) – The customer associated with this charge.
  • account (ForeignKey to Account) – The account the charge was made on behalf of. Null here indicates that this value was never set.
  • dispute (ForeignKey to Dispute) – Details about the dispute if the charge has been disputed.
  • failure_code (StripeEnumField) – Error code explaining reason for charge failure if available.
  • failure_message (StripeTextField) – Message to user further explaining reason for charge failure if available.
  • fraud_details (StripeJSONField) – Hash with information on fraud assessments for the charge.
  • invoice (ForeignKey to Invoice) – The invoice this charge is for if one exists.
  • outcome (StripeJSONField) – Details about whether or not the payment was accepted, and why.
  • paid (StripeBooleanField) – True if the charge succeeded, or was successfully authorized for later capture, False otherwise.
  • receipt_email (StripeCharField) – The email address that the receipt for this charge was sent to.
  • receipt_number (StripeCharField) – The transaction number that appears on email receipts sent for this charge.
  • refunded (StripeBooleanField) – Whether or not the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
  • shipping (StripeJSONField) – Shipping information for the charge
  • source (PaymentMethodForeignKey to PaymentMethod) – The source used for this charge.
  • statement_descriptor (StripeCharField) – 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) – The status of the payment.
  • transfer (ForeignKey to Transfer) – The transfer to the destination account (only applicable if the charge was created using the destination parameter).
  • transfer_group (StripeCharField) – A string that identifies this transaction as part of a group.
  • fee (StripeCurrencyField) – Fee
  • fee_details (StripeJSONField) – Fee details
  • source_type (StripeEnumField) – The payment source type. If the payment source is supported by dj-stripe, a corresponding model is attached to this Charge via a foreign key matching this field.
  • source_stripe_id (StripeIdField) – The payment source id.
  • fraudulent (StripeBooleanField) – Whether or not this charge was marked as fraudulent.
  • receipt_sent (BooleanField) – Whether or not a receipt was sent for this charge.
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

disputed
refund(amount=None, reason=None)[source]

Initiate a refund. If amount is not provided, then this will be a full refund.

Parameters:
  • amount – 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.
Trye amount:

Decimal

Returns:

Stripe charge object

Return type:

dict

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

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

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. (Source: https://stripe.com/docs/api/python#customers)

# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.
  • discount - #

Attention

Stripe API_VERSION: model fields and methods audited to 2017-06-05 - @jleclanche

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • account_balance (StripeIntegerField) – Current balance, 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 thenext invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfullyapplied to any invoice. This balance is only taken into account for recurring billing purposes (i.e., subscriptions, invoices, invoice items).
  • business_vat_id (StripeCharField) – The customer’s VAT identification number.
  • currency (StripeCharField) – The currency the customer can be charged in for recurring billing purposes (subscriptions, invoices, invoice items).
  • default_source (PaymentMethodForeignKey to PaymentMethod) – Default source
  • delinquent (StripeBooleanField) – Whether or not the latest charge for the customer’s latest invoice has failed.
  • coupon (ForeignKey to Coupon) – Coupon
  • coupon_start (StripeDateTimeField) – If a coupon is present, the date at which it was applied.
  • coupon_end (StripeDateTimeField) – If a coupon is present and has a limited duration, the date that the discount will end.
  • email (StripeTextField) – Email
  • shipping (StripeJSONField) – Shipping information associated with the customer.
  • subscriber (ForeignKey to User) – Subscriber
  • date_purged (DateTimeField) – Date purged
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

classmethod get_or_create(subscriber, livemode=False)[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.
legacy_cards

Transitional property for Customer.sources. Use this instead of Customer.sources if you want to access the legacy Card queryset.

credits

The customer is considered to have credits if their account_balance is below 0.

pending_charges

The customer is considered to have pending charges if their account_balance is above 0.

subscribe(plan, charge_immediately=True, application_fee_percent=None, coupon=None, quantity=None, metadata=None, tax_percent=None, trial_end=None)[source]

Subscribes this customer to a plan.

Parameters not implemented:

  • source - Subscriptions use the customer’s default source. Including the source parameter creates a new source for this customer and overrides the default source. This functionality is not desired; add a source to the customer before attempting to add a subscription.
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.
  • 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.
charge(amount, currency=None, application_fee=None, capture=None, description=None, destination=None, metadata=None, shipping=None, source=None, statement_descriptor=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 transfered to the platform owner’s account.
  • capture (bool) – Whether or not to immediately capture the charge. When false, the charge issues an authorization (or pre-authorization), and will need to be captured later. Uncaptured charges expire in 7 days. Default is True
  • description (string) – An arbitrary string.
  • destination (Account) – An account to make the charge on behalf of.
  • metadata (dict) – A set of key/value pairs useful for storing additional information.
  • shipping (dict) – Shipping information for the charge.
  • source (string, Source) – The source to use for this charge. Must be a source attributed to this customer. If None, the customer’s default source is used. Can be either the id of the source or the source object itself.
  • statement_descriptor (string) – An arbitrary string to be displayed on the customer’s credit card statement.
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.
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
purge()[source]
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.
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.
Throws:TypeError if plan is None and more than one active subscription exists for this customer.
active_subscriptions

Returns active subscriptions (subscriptions with an active status that end in the future).

valid_subscriptions

Returns this cusotmer’s valid subscriptions (subscriptions that aren’t cancelled.

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

Determines if this customer is able to be charged.

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

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

has_valid_source()[source]

Check whether the customer has a valid payment source.

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.

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.

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Dispute

class djstripe.models.Dispute(djstripe_id, stripe_id, livemode, created, metadata, description, djstripe_created, djstripe_updated, amount, currency, evidence, evidence_details, is_charge_refundable, reason, status)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeIntegerField) – Disputed amount. Usually the amount of the charge, but can differ (usually because of currency fluctuation or because only part of the order is disputed).
  • currency (StripeCharField) – Three-letter ISO currency code.
  • evidence (StripeJSONField) – Evidence provided to respond to a dispute.
  • evidence_details (StripeJSONField) – Information about the evidence submission.
  • is_charge_refundable (StripeBooleanField) – 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 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Event

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

Events are POSTed to our webhook url. They provide information about a Stripe event that just happened. Events are processed in detail by their respective models (charge events by the Charge model, etc).

API VERSIONING

This is a tricky matter when it comes to webhooks. See the discussion here.

In this discussion, it is noted that Webhooks are produced in one API version, which will usually be different from the version supported by Stripe plugins (such as djstripe). The solution, described there, is:

  1. validate the receipt of a webhook event by doing an event get using the API version of the received hook event.
  2. retrieve the referenced object (e.g. the Charge, the Customer, etc) using the plugin’s supported API version.
  3. process that event using the retrieved object which will, only now, be in a format that you are certain to understand
# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.
  • pending_webhooks - Unnecessary. Use the dashboard.

Attention

Stripe API_VERSION: model fields and methods audited to 2016-03-07 - @kavdev

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • api_version (StripeCharField) – the API version at which the event data was rendered. Blank for old entries only, all new entries will have this value
  • data (StripeJSONField) – data received at webhook. data should be considered to be garbage until validity check is run and valid flag is set
  • request_id (StripeCharField) – 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 (StripeTextField) – Idempotency key
  • type (StripeCharField) – Stripe’s event description code
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
classmethod process(data)[source]
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).

parts

Gets the event category/verb as a list of parts.

category

Gets the event category string (e.g. ‘customer’).

verb

Gets the event past-tense verb string (e.g. ‘updated’).

customer
str_parts()[source]

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

Return type:list of str
classmethod StripeObject.sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Payout

class djstripe.models.Payout(djstripe_id, stripe_id, livemode, created, metadata, description, djstripe_created, djstripe_updated, amount, arrival_date, currency, destination, failure_code, failure_message, method, statement_descriptor, status, type)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeCurrencyField) – Amount to be transferred to your bank account or debit card.
  • arrival_date (StripeDateTimeField) – Date the payout is expected to arrive in the bank. This factors in delays like weekends or bank holidays.
  • currency (StripeCharField) – Three-letter ISO currency code.
  • destination (ForeignKey to BankAccount) – ID of the bank account or card the payout was sent to.
  • failure_code (StripeEnumField) – Error code explaining reason for transfer failure if available. See https://stripe.com/docs/api/python#transfer_failures.
  • failure_message (StripeTextField) – Message to user further explaining reason for payout failure if available.
  • method (StripeEnumField) – The method used to send this payout. instant is only supported for payouts to debit cards.
  • statement_descriptor (StripeCharField) – Extra information about a payout to be displayed on the user’s bank statement.
  • status (StripeEnumField) – Current status of the payout. A payout will be pending until it is submitted to the bank, at which point it becomes in_transit. I t 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 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

BankAccount

class djstripe.models.BankAccount(djstripe_id, stripe_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
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • account (ForeignKey to Account) – The account the charge was made on behalf of. Null here indicates that this value was never set.
  • account_holder_name (StripeCharField) – The name of the person or business that owns the bank account.
  • account_holder_type (StripeEnumField) – The type of entity that holds the account.
  • bank_name (StripeCharField) – Name of the bank associated with the routing number (e.g., WELLS FARGO).
  • country (StripeCharField) – Two-letter ISO code representing the country the bank account is located in.
  • currency (StripeCharField) – Three-letter ISO currency code
  • customer (ForeignKey to Customer) – Customer
  • default_for_currency (StripeNullBooleanField) – Whether this external account is the default account for its currency.
  • fingerprint (StripeCharField) – Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
  • last4 (StripeCharField) – Last4
  • routing_number (StripeCharField) – The routing transit number for the bank account.
  • status (StripeEnumField) – Status
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Card

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

You can store multiple cards on a customer in order to charge the customer later. (Source: https://stripe.com/docs/api/python#cards)

# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.
  • recipient - On Stripe’s deprecation path.
  • account - #
  • currency - #
  • default_for_currency - #

Attention

Stripe API_VERSION: model fields and methods audited to 2016-03-07 - @kavdev

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • address_city (StripeTextField) – Billing address city.
  • address_country (StripeTextField) – Billing address country.
  • address_line1 (StripeTextField) – Billing address (Line 1).
  • address_line1_check (StripeEnumField) – If address_line1 was provided, results of the check.
  • address_line2 (StripeTextField) – Billing address (Line 2).
  • address_state (StripeTextField) – Billing address state.
  • address_zip (StripeTextField) – Billing address zip code.
  • address_zip_check (StripeEnumField) – If address_zip was provided, results of the check.
  • brand (StripeEnumField) – Card brand.
  • country (StripeCharField) – Two-letter ISO code representing the country of the card.
  • cvc_check (StripeEnumField) – If a CVC was provided, results of the check.
  • dynamic_last4 (StripeCharField) – (For tokenized numbers only.) The last four digits of the device account number.
  • exp_month (StripeIntegerField) – Card expiration month.
  • exp_year (StripeIntegerField) – Card expiration year.
  • fingerprint (StripeTextField) – Uniquely identifies this particular card number.
  • funding (StripeEnumField) – Card funding type.
  • last4 (StripeCharField) – Last four digits of Card number.
  • name (StripeTextField) – Cardholder name.
  • tokenization_method (StripeEnumField) – If the card number is tokenized, this is the method that was used.
  • customer (ForeignKey to Customer) – Customer
classmethod api_list(api_key='', **kwargs)[source]

Call the stripe API’s list operation for this model.

Parameters:api_key (string) – The api key to use for this request. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=None)[source]

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

Get the stripe dashboard url for this object.

remove()[source]

Removes a card from this customer’s account.

classmethod 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:
  • exp_month (Two digit int) – The card’s expiration month.
  • exp_year (Two or Four digit int) – The card’s expiration year.
  • number (string without any separators (no spaces)) – The card number
  • cvc (string) – Card security code.
str_parts()[source]

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

Return type:list of str
classmethod StripeObject.sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Source

class djstripe.models.Source(djstripe_id, stripe_id, livemode, created, metadata, description, djstripe_created, djstripe_updated, amount, client_secret, currency, flow, owner, statement_descriptor, status, type, usage, code_verification, receiver, redirect, source_data, customer)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeCurrencyField) – Amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for single_use sources.
  • client_secret (StripeCharField) – The client secret of the source. Used for client-side retrieval using a publishable key.
  • currency (StripeCharField) – Three-letter ISO currency code
  • flow (StripeEnumField) – The authentication flow of the source.
  • owner (StripeJSONField) – Information about the owner of the payment instrument that may be used or required by particular source types.
  • statement_descriptor (StripeCharField) – Extra information about a source. This will appear on your customer’s statement every time you charge the source.
  • status (StripeEnumField) – The status of the source. Only chargeable sources can be used to create a charge.
  • type (StripeEnumField) – The type of the source.
  • usage (StripeEnumField) – 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 (StripeJSONField) – Information related to the code verification flow. Present if the source is authenticated by a verification code (flow is code_verification).
  • receiver (StripeJSONField) – Information related to the receiver flow. Present if the source is a receiver (flow is receiver).
  • redirect (StripeJSONField) – Information related to the redirect flow. Present if the source is authenticated by a redirect (flow is redirect).
  • source_data (StripeJSONField) – The data corresponding to the source type.
  • customer (ForeignKey to Customer) – Customer
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

detach()[source]

Detach the source from its customer.

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Coupon

class djstripe.models.Coupon(djstripe_id, livemode, created, metadata, description, djstripe_created, djstripe_updated, stripe_id, amount_off, currency, duration, duration_in_months, max_redemptions, percent_off, redeem_by, times_redeemed)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • stripe_id (StripeIdField) – Stripe id
  • amount_off (StripeCurrencyField) – Amount that will be taken off the subtotal of any invoices for this customer.
  • currency (StripeCharField) – Three-letter ISO currency code
  • duration (StripeEnumField) – Describes how long a customer who applies this coupon will get the discount.
  • duration_in_months (StripePositiveIntegerField) – If duration is repeating, the number of months the coupon applies.
  • max_redemptions (StripePositiveIntegerField) – Maximum number of times this coupon can be redeemed, in total, before it is no longer valid.
  • percent_off (StripePositiveIntegerField) – Percent off
  • redeem_by (StripeDateTimeField) – Date after which the coupon can no longer be redeemed. Max 5 years in the future.
  • times_redeemed (StripePositiveIntegerField) – Number of times this coupon has been applied to a customer.
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

human_readable_amount
human_readable
str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

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. (Source: https://stripe.com/docs/api/python#invoices)

# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.
  • discount - #
  • lines - Unnecessary. Check Subscription and InvoiceItems directly.
  • webhooks_delivered_at - #

Attention

Stripe API_VERSION: model fields audited to 2017-06-05 - @jleclanche

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount_due (StripeCurrencyField) – Final amount due 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 (StripeCurrencyField) – The amount, in cents, that was paid.
  • amount_remaining (StripeCurrencyField) – The amount, in cents, that was paid.
  • application_fee (StripeCurrencyField) – The fee in cents that will be applied to the invoice and transferred to the application owner’s Stripe account when the invoice is paid.
  • attempt_count (StripeIntegerField) – 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 (StripeBooleanField) – 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.
  • billing (StripeEnumField) – When charging automatically, Stripe will attempt to pay this invoiceusing the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
  • charge (OneToOneField to Charge) – The latest charge generated for this invoice, if any.
  • closed (StripeBooleanField) – Whether or not the invoice is still trying to collect payment. An invoice is closed if it’s either paid or it has been marked closed. A closed invoice will no longer attempt to collect payment.
  • currency (StripeCharField) – Three-letter ISO currency code.
  • customer (ForeignKey to Customer) – The customer associated with this invoice.
  • date (StripeDateTimeField) – The date on the invoice.
  • due_date (StripeDateTimeField) – The date on which payment for this invoice is due. This value will be null for invoices where billing=charge_automatically.
  • ending_balance (StripeIntegerField) – Ending customer balance after attempting to pay invoice. If the invoice has not been attempted yet, this will be null.
  • forgiven (StripeBooleanField) – Whether or not the invoice has been forgiven. Forgiving an invoice instructs us to update the subscription status as if the invoice were successfully paid. Once an invoice has been forgiven, it cannot be unforgiven or reopened.
  • hosted_invoice_url (StripeCharField) – 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 (StripeCharField) – 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) – The time at which payment will next be attempted.
  • number (StripeCharField) – 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 (StripeBooleanField) – The time at which payment will next be attempted.
  • period_end (StripeDateTimeField) – End of the usage period during which invoice items were added to this invoice.
  • period_start (StripeDateTimeField) – Start of the usage period during which invoice items were added to this invoice.
  • receipt_number (StripeCharField) – This is the transaction number that appears on email receipts sent for this invoice.
  • starting_balance (StripeIntegerField) – Starting customer balance before attempting to pay invoice. If the invoice has not been attempted yet, this will be the current customer balance.
  • statement_descriptor (StripeCharField) – 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.
  • subscription (ForeignKey to Subscription) – The subscription that this invoice was prepared for, if any.
  • subscription_proration_date (StripeDateTimeField) – Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • subtotal (StripeCurrencyField) – Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • tax (StripeCurrencyField) – The amount 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) – 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.
  • total (StripeCurrencyField) – Total after discount.
  • webhooks_delivered_at (StripeDateTimeField) – The time at which webhooks for this invoice were successfully delivered (if the invoice had no webhooks to deliver, this will match date). Invoice payment is delayed until webhooks are delivered, or until all webhook delivery attempts have been exhausted.
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()[source]

Get the stripe dashboard url for this object.

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

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

retry()[source]

Retry payment on this invoice if it isn’t paid, closed, or forgiven.

status

Attempts to label this invoice with a status. Note that an invoice can be more than one of the choices. We just set a priority on which status appears.

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
str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

UpcomingInvoice

class djstripe.models.UpcomingInvoice(djstripe_id, stripe_id, livemode, created, metadata, description, djstripe_created, djstripe_updated, amount_due, amount_paid, amount_remaining, application_fee, attempt_count, attempted, billing, charge, closed, currency, customer, date, due_date, ending_balance, forgiven, hosted_invoice_url, invoice_pdf, next_payment_attempt, number, paid, period_end, period_start, receipt_number, starting_balance, statement_descriptor, subscription, subscription_proration_date, subtotal, tax, tax_percent, total, webhooks_delivered_at, invoice_ptr)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount_due (StripeCurrencyField) – Final amount due 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 (StripeCurrencyField) – The amount, in cents, that was paid.
  • amount_remaining (StripeCurrencyField) – The amount, in cents, that was paid.
  • application_fee (StripeCurrencyField) – The fee in cents that will be applied to the invoice and transferred to the application owner’s Stripe account when the invoice is paid.
  • attempt_count (StripeIntegerField) – 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 (StripeBooleanField) – 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.
  • billing (StripeEnumField) – When charging automatically, Stripe will attempt to pay this invoiceusing the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
  • charge (OneToOneField to Charge) – The latest charge generated for this invoice, if any.
  • closed (StripeBooleanField) – Whether or not the invoice is still trying to collect payment. An invoice is closed if it’s either paid or it has been marked closed. A closed invoice will no longer attempt to collect payment.
  • currency (StripeCharField) – Three-letter ISO currency code.
  • customer (ForeignKey to Customer) – The customer associated with this invoice.
  • date (StripeDateTimeField) – The date on the invoice.
  • due_date (StripeDateTimeField) – The date on which payment for this invoice is due. This value will be null for invoices where billing=charge_automatically.
  • ending_balance (StripeIntegerField) – Ending customer balance after attempting to pay invoice. If the invoice has not been attempted yet, this will be null.
  • forgiven (StripeBooleanField) – Whether or not the invoice has been forgiven. Forgiving an invoice instructs us to update the subscription status as if the invoice were successfully paid. Once an invoice has been forgiven, it cannot be unforgiven or reopened.
  • hosted_invoice_url (StripeCharField) – 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 (StripeCharField) – 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) – The time at which payment will next be attempted.
  • number (StripeCharField) – 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 (StripeBooleanField) – The time at which payment will next be attempted.
  • period_end (StripeDateTimeField) – End of the usage period during which invoice items were added to this invoice.
  • period_start (StripeDateTimeField) – Start of the usage period during which invoice items were added to this invoice.
  • receipt_number (StripeCharField) – This is the transaction number that appears on email receipts sent for this invoice.
  • starting_balance (StripeIntegerField) – Starting customer balance before attempting to pay invoice. If the invoice has not been attempted yet, this will be the current customer balance.
  • statement_descriptor (StripeCharField) – 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.
  • subscription (ForeignKey to Subscription) – The subscription that this invoice was prepared for, if any.
  • subscription_proration_date (StripeDateTimeField) – Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • subtotal (StripeCurrencyField) – Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • tax (StripeCurrencyField) – The amount 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) – 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.
  • total (StripeCurrencyField) – Total after discount.
  • webhooks_delivered_at (StripeDateTimeField) – 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.
  • invoice_ptr (OneToOneField to Invoice) – Invoice ptr
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()[source]

Get the stripe dashboard url for this object.

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.

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

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. (Source: https://stripe.com/docs/api/python#invoiceitems)

# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.

Attention

Stripe API_VERSION: model fields audited to 2017-06-05 - @jleclanche

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeCurrencyField) – Amount invoiced.
  • currency (StripeCharField) – Three-letter ISO currency code.
  • customer (ForeignKey to Customer) – The customer associated with this invoiceitem.
  • date (StripeDateTimeField) – The date on the invoiceitem.
  • discountable (StripeBooleanField) – If True, discounts will apply to this invoice item. Always False for prorations.
  • invoice (ForeignKey to Invoice) – The invoice to which this invoiceitem is attached.
  • period (StripeJSONField) – Period
  • period_end (StripeDateTimeField) – Might be the date when this invoiceitem’s invoice was sent.
  • period_start (StripeDateTimeField) – Might be the date when this invoiceitem was added to the invoice
  • plan (ForeignKey to Plan) – If the invoice item is a proration, the plan of the subscription for which the proration was computed.
  • proration (StripeBooleanField) – Whether or not the invoice item was created automatically as a proration adjustment when the customer switched plans.
  • quantity (StripeIntegerField) – If the invoice item is a proration, the quantity of the subscription for which the proration was computed.
  • subscription (ForeignKey to Subscription) – The subscription that this invoice item has been created for, if any.
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()[source]

Get the stripe dashboard url for this object.

str_parts()[source]

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Plan

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

A subscription plan contains the pricing information for different products and feature levels on your site. (Source: https://stripe.com/docs/api/python#plans)

# = Mapping the values of this field isn’t currently on our roadmap. Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.

Attention

Stripe API_VERSION: model fields and methods audited to 2016-03-07 - @kavdev

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • aggregate_usage (StripeEnumField) – 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 (StripeCurrencyField) – Amount to be charged on the interval specified.
  • billing_scheme (StripeEnumField) – 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 (StripeCharField) – Three-letter ISO currency code
  • interval (StripeEnumField) – The frequency with which a subscription should be billed.
  • interval_count (StripeIntegerField) – The number of intervals (specified in the interval property) between each subscription billing.
  • nickname (StripeCharField) – A brief description of the plan, hidden from customers.
  • product (ForeignKey to Product) – The product whose pricing this plan determines.
  • tiers (StripeJSONField) – Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered.
  • tiers_mode (StripeEnumField) – 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 (StripeJSONField) – Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with tiers.
  • trial_period_days (StripeIntegerField) – Number of trial period days granted when subscribing a customer to this plan. Null if the plan has no trial period.
  • usage_type (StripeEnumField) – 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 (StripeTextField) – Name of the plan, to be displayed on invoices and in the web interface.
  • statement_descriptor (StripeCharField) – 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 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

classmethod get_or_create(**kwargs)[source]

Get or create a Plan.

amount_in_cents
human_readable_price
str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

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. (Source: https://stripe.com/docs/api/python#subscriptions)

# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.
  • discount - #

Attention

Stripe API_VERSION: model fields and methods audited to 2016-03-07 - @kavdev

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • application_fee_percent (StripePercentField) – A positive decimal that represents the fee percentage of the subscription invoice amount that will be transferred to the application owner’s Stripe account each billing period.
  • billing (StripeEnumField) – Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions.
  • billing_cycle_anchor (StripeDateTimeField) – 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 (StripeBooleanField) – 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) – 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.
  • current_period_end (StripeDateTimeField) – 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) – Start of the current period for which the subscription has been invoiced.
  • customer (ForeignKey to Customer) – The customer associated with this subscription.
  • days_until_due (StripeIntegerField) – Number of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where billing=charge_automatically.
  • ended_at (StripeDateTimeField) – 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.
  • plan (ForeignKey to Plan) – The plan associated with this subscription.
  • quantity (StripeIntegerField) – The quantity applied to this subscription.
  • start (StripeDateTimeField) – Date the subscription started.
  • status (StripeEnumField) – The status of this subscription.
  • tax_percent (StripePercentField) – 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) – If the subscription has a trial, the end of that trial.
  • trial_start (StripeDateTimeField) – If the subscription has a trial, the beginning of that trial.
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

update(plan=None, application_fee_percent=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.
  • 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.

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

extend(delta)[source]

Extends this subscription by the provided delta.

Parameters:delta (timedelta) – The timedelta by which to extend this 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 cancelled 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.

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.

is_period_current()[source]

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

is_status_current()[source]

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

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.

is_valid()[source]

Returns True if this subscription’s status and period are current, false otherwise.

str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

Account

class djstripe.models.Account(djstripe_id, stripe_id, livemode, created, metadata, description, djstripe_created, djstripe_updated, business_logo, business_name, business_primary_color, business_url, charges_enabled, country, debit_negative_balances, decline_charge_on, default_currency, details_submitted, display_name, email, legal_entity, payout_schedule, payout_statement_descriptor, payouts_enabled, product_description, statement_descriptor, support_email, support_phone, support_url, timezone, type, tos_acceptance, verification)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • business_logo (ForeignKey to FileUpload) – Business logo
  • business_name (StripeCharField) – The publicly visible name of the business
  • business_primary_color (StripeCharField) – A CSS hex color value representing the primary branding color for this account
  • business_url (StripeCharField) – The publicly visible website of the business
  • charges_enabled (StripeBooleanField) – Whether the account can create live charges
  • country (StripeCharField) – The country of the account
  • debit_negative_balances (StripeNullBooleanField) – A Boolean indicating if Stripe should try to reclaim negative balances from an attached bank account.
  • decline_charge_on (StripeJSONField) – Account-level settings to automatically decline certain types of charges regardless of the decision of the card issuer
  • default_currency (StripeCharField) – The currency this account has chosen to use as the default
  • details_submitted (StripeBooleanField) – Whether account details have been submitted. Standard accounts cannot receive payouts before this is true.
  • display_name (StripeCharField) – The display name for this account. This is used on the Stripe Dashboard to differentiate between accounts.
  • email (StripeCharField) – The primary user’s email address.
  • legal_entity (StripeJSONField) – Information about the legal entity itself, including about the associated account representative
  • payout_schedule (StripeJSONField) – Details on when funds from charges are available, and when they are paid out to an external account.
  • payout_statement_descriptor (StripeCharField) – The text that appears on the bank account statement for payouts.
  • payouts_enabled (StripeBooleanField) – Whether Stripe can send payouts to this account
  • product_description (StripeCharField) – Internal-only description of the product sold or service provided by the business. It’s used by Stripe for risk and underwriting purposes.
  • statement_descriptor (StripeCharField) – The default text that appears on credit card statements when a charge is made directly on the account
  • support_email (StripeCharField) – A publicly shareable support email address for the business
  • support_phone (StripeCharField) – A publicly shareable support phone number for the business
  • support_url (StripeCharField) – A publicly shareable URL that provides support for this account
  • timezone (StripeCharField) – The timezone used in the Stripe Dashboard for this account.
  • type (StripeEnumField) – The Stripe account type.
  • tos_acceptance (StripeJSONField) – Details on the acceptance of the Stripe Services Agreement
  • verification (StripeJSONField) – Information on the verification state of the account, including what information is needed and by when
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

classmethod get_connected_account_from_token(access_token)[source]
classmethod get_default_account()[source]
str_parts()

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

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. (Source: https://stripe.com/docs/api/python#transfers)

# = Mapping the values of this field isn’t currently on our roadmap.
Please use the stripe dashboard to check the value of this field instead.

Fields not implemented:

  • object - Unnecessary. Just check the model name.
  • application_fee - #
  • balance_transaction - #
  • reversals - #

Attention

Stripe API_VERSION: model fields and methods audited to 2016-03-07 - @kavdev

Parameters:
  • djstripe_id (BigAutoField) – Id
  • stripe_id (StripeIdField) – Stripe id
  • livemode (StripeNullBooleanField) – 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) – The datetime this object was created in stripe.
  • metadata (StripeJSONField) – 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 (StripeTextField) – A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeCurrencyField) – The amount transferred
  • amount_reversed (StripeCurrencyField) – The amount reversed (can be less than the amount attribute on the transfer if a partial reversal was issued).
  • currency (StripeCharField) – Three-letter ISO currency code.
  • destination (StripeIdField) – ID of the bank account, card, or Stripe account the transfer was sent to.
  • destination_payment (StripeIdField) – If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer.
  • reversed (StripeBooleanField) – 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) – 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) – The source balance from which this transfer came.
  • transfer_group (StripeCharField) – A string that identifies this transaction as part of a group.
  • date (StripeDateTimeField) – Date the transfer is scheduled to arrive in the bank. This doesn’t factor in delays like weekends or bank holidays.
  • destination_type (StripeCharField) – The type of the transfer destination.
  • failure_code (StripeEnumField) – Error code explaining reason for transfer failure if available. See https://stripe.com/docs/api/python#transfer_failures.
  • failure_message (StripeTextField) – Message to user further explaining reason for transfer failure if available.
  • statement_descriptor (StripeCharField) – 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) – The current status of the transfer. A transfer 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.
  • fee (StripeCurrencyField) – Fee
  • fee_details (StripeJSONField) – Fee details
classmethod 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. Defualts to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
api_retrieve(api_key=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.
get_stripe_dashboard_url()

Get the stripe dashboard url for this object.

str_parts()[source]

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

Return type:list of str
classmethod sync_from_stripe_data(data)

Syncs this object from the stripe data provided.

Parameters:data (dict) – stripe object

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) – IP address of the request client.
  • headers (JSONField) – Headers
  • body (TextField) – Body
  • valid (BooleanField) – Whether or not the webhook event has passed validation
  • processed (BooleanField) – Whether or not the webhook event has been successfully processed
  • exception (CharField) – Exception
  • traceback (TextField) – Traceback if an exception was thrown during processing
  • event (ForeignKey to Event) – Event object contained in the (valid) Webhook
  • djstripe_version (CharField) – The version of dj-stripe when the webhook was received
  • created (DateTimeField) – Created
  • updated (DateTimeField) – Updated
json_body
is_test_event
classmethod 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).