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

Core Resources

Balance Transaction

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

A single transaction that updates the Stripe balance.

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeQuantumCurrencyAmountField) – Amount. Gross amount of the transaction, in cents.
  • available_on (StripeDateTimeField) – Available on. The date the transaction’s net funds will become available in the Stripe balance.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • exchange_rate (DecimalField) – Exchange rate
  • fee (StripeQuantumCurrencyAmountField) – Fee. Fee (in cents) paid for this transaction.
  • fee_details (JSONField) – Fee details
  • net (StripeQuantumCurrencyAmountField) – Net. Net amount of the transaction, in cents.
  • status (StripeEnumField) – Status
  • type (StripeEnumField) – Type
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Charge

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

To charge a credit or a debit card, you create a charge object. You can retrieve and refund individual charges as well as list all charges. Charges are identified by a unique random ID.

Stripe documentation: https://stripe.com/docs/api/python#charges

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeDecimalCurrencyAmountField) – Amount. Amount charged.
  • amount_refunded (StripeDecimalCurrencyAmountField) – Amount refunded. Amount refunded (can be less than the amount attribute on the charge if a partial refund was issued).
  • balance_transaction (ForeignKey to BalanceTransaction) – Balance transaction. The balance transaction that describes the impact of this charge on your account balance (not including refunds or disputes).
  • captured (BooleanField) – Captured. If the charge was created without capturing, this boolean represents whether or not it is still uncaptured or has since been captured.
  • currency (StripeCurrencyCodeField) – Currency. The currency in which the charge was made.
  • customer (ForeignKey to Customer) – Customer. The customer associated with this charge.
  • account (ForeignKey to Account) – Account. The account the charge was made on behalf of. Null here indicates that this value was never set.
  • dispute (ForeignKey to Dispute) – Dispute. Details about the dispute if the charge has been disputed.
  • failure_code (StripeEnumField) – Failure code. Error code explaining reason for charge failure if available.
  • failure_message (TextField) – Failure message. Message to user further explaining reason for charge failure if available.
  • fraud_details (JSONField) – Fraud details. Hash with information on fraud assessments for the charge.
  • invoice (ForeignKey to Invoice) – Invoice. The invoice this charge is for if one exists.
  • outcome (JSONField) – Outcome. Details about whether or not the payment was accepted, and why.
  • paid (BooleanField) – Paid. True if the charge succeeded, or was successfully authorized for later capture, False otherwise.
  • receipt_email (TextField) – Receipt email. The email address that the receipt for this charge was sent to.
  • receipt_number (CharField) – Receipt number. The transaction number that appears on email receipts sent for this charge.
  • refunded (BooleanField) – Refunded. Whether or not the charge has been fully refunded. If the charge is only partially refunded, this attribute will still be false.
  • shipping (JSONField) – Shipping. Shipping information for the charge
  • source (PaymentMethodForeignKey to DjstripePaymentMethod) – Source. The source used for this charge.
  • statement_descriptor (CharField) – Statement descriptor. An arbitrary string to be displayed on your customer’s credit card statement. The statement description may not include <>”’ characters, and will appear on your customer’s statement in capital letters. Non-ASCII characters are automatically stripped. While most banks display this information consistently, some may display it incorrectly or not at all.
  • status (StripeEnumField) – Status. The status of the payment.
  • transfer (ForeignKey to Transfer) – Transfer. The transfer to the destination account (only applicable if the charge was created using the destination parameter).
  • transfer_group (CharField) – Transfer group. A string that identifies this transaction as part of a group.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

Stripe documentation: https://stripe.com/docs/api/python#customers

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • account_balance (IntegerField) – Account balance. 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 the next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account for recurring billing purposes (i.e., subscriptions, invoices, invoice items).
  • business_vat_id (CharField) – Business vat id. The customer’s VAT identification number.
  • currency (StripeCurrencyCodeField) – Currency. The currency the customer can be charged in for recurring billing purposes
  • default_source (PaymentMethodForeignKey to DjstripePaymentMethod) – Default source
  • delinquent (BooleanField) – Delinquent. Whether or not the latest charge for the customer’s latest invoice has failed.
  • coupon (ForeignKey to Coupon) – Coupon
  • coupon_start (StripeDateTimeField) – Coupon start. If a coupon is present, the date at which it was applied.
  • coupon_end (StripeDateTimeField) – Coupon end. If a coupon is present and has a limited duration, the date that the discount will end.
  • email (TextField) – Email
  • shipping (JSONField) – Shipping. 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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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

Model field: customer, accesses the M2M Card model.

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, billing_cycle_anchor=None, trial_end=None, trial_from_plan=None, trial_period_days=None)[source]

Subscribes this customer to a plan.

Parameters:
  • plan (Plan or string (plan ID)) – The plan to which to subscribe the customer.
  • application_fee_percent (Decimal. Precision is 2; anything more will be ignored. A positive decimal between 1 and 100.) – This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner’s Stripe account. The request must be made with an OAuth key in order to set an application fee percentage.
  • coupon (string) – The code of the coupon to apply to this subscription. A coupon applied to a subscription will only affect invoices created for that particular subscription.
  • quantity (integer) – The quantity applied to this subscription. Default is 1.
  • metadata (dict) – A set of key/value pairs useful for storing additional information.
  • tax_percent (Decimal. Precision is 2; anything more will be ignored. A positive decimal between 1 and 100.) – This represents the percentage of the subscription invoice subtotal that will be calculated and added as tax to the final amount each billing period.
  • billing_cycle_anchor (datetime) – A future timestamp to anchor the subscription’s billing cycle. This is used to determine the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.
  • trial_end (datetime) – The end datetime of the trial period the customer will get before being charged for the first time. If set, this will override the default trial period of the plan the customer is being subscribed to. The special value now can be provided to end the customer’s trial immediately.
  • charge_immediately (boolean) – Whether or not to charge for the subscription upon creation. If False, an invoice will be created at the end of this period.
  • trial_from_plan (boolean) – Indicates if a plan’s trial_period_days should be applied to the subscription. Setting trial_end per subscription is preferred, and this defaults to false. Setting this flag to true together with trial_end is not allowed.
  • trial_period_days (integer) – Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan.
charge(amount, currency=None, application_fee=None, capture=None, description=None, destination=None, metadata=None, shipping=None, source=None, statement_descriptor=None, idempotency_key=None)[source]

Creates a charge for this customer.

Parameters not implemented:

  • receipt_email - Since this is a charge on a customer, the customer’s email address is used.
Parameters:
  • amount (Decimal. Precision is 2; anything more will be ignored.) – The amount to charge.
  • currency (string) – 3-letter ISO code for currency
  • application_fee (Decimal. Precision is 2; anything more will be ignored.) – A fee that will be applied to the charge and 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.
active_subscriptions

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

valid_subscriptions

Returns this customer’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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Dispute

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

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeQuantumCurrencyAmountField) – Amount. Disputed amount. Usually the amount of the charge, but can differ (usually because of currency fluctuation or because only part of the order is disputed).
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • evidence (JSONField) – Evidence. Evidence provided to respond to a dispute.
  • evidence_details (JSONField) – Evidence details. Information about the evidence submission.
  • is_charge_refundable (BooleanField) – Is charge refundable. If true, it is still possible to refund the disputed payment. Once the payment has been fully refunded, no further funds will be withdrawn from your Stripe account as a result of this dispute.
  • reason (StripeEnumField) – Reason
  • status (StripeEnumField) – Status
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Event

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

Events are Stripe’s way of letting you know when something interesting happens in your account. When an interesting event occurs, a new Event object is created and POSTed to the configured webhook URL if the Event type matches.

Stripe documentation: https://stripe.com/docs/api/events

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • api_version (CharField) – Api version. the API version at which the event data was rendered. Blank for old entries only, all new entries will have this value
  • data (JSONField) – Data. data received at webhook. data should be considered to be garbage until validity check is run and valid flag is set
  • request_id (CharField) – Request id. Information about the request that triggered this event, for traceability purposes. If empty string then this is an old entry without that data. If Null then this is not an old entry, but a Stripe ‘automated’ event with no associated request.
  • idempotency_key (TextField) – Idempotency key
  • type (CharField) – Type. Stripe’s event description code
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

File Upload

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

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • filename (CharField) – Filename. A filename for the file, suitable for saving to a filesystem.
  • purpose (StripeEnumField) – Purpose. The purpose of the uploaded file.
  • size (IntegerField) – Size. The size in bytes of the file upload object.
  • type (StripeEnumField) – Type. The type of the file returned.
  • url (CharField) – Url. A read-only URL where the uploaded file can be accessed.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Payout

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

A Payout object is created when you receive funds from Stripe, or when you initiate a payout to either a bank account or debit card of a connected Stripe account.

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeDecimalCurrencyAmountField) – Amount. Amount to be transferred to your bank account or debit card.
  • arrival_date (StripeDateTimeField) – Arrival date. Date the payout is expected to arrive in the bank. This factors in delays like weekends or bank holidays.
  • balance_transaction (ForeignKey to BalanceTransaction) – Balance transaction. Balance transaction that describes the impact on your account balance.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • destination (ForeignKey to BankAccount) – Destination. ID of the bank account or card the payout was sent to.
  • failure_balance_transaction (ForeignKey to BalanceTransaction) – Failure balance transaction. If the payout failed or was canceled, this will be the balance transaction that reversed the initial balance transaction, and puts the funds from the failed payout back in your balance.
  • failure_code (StripeEnumField) – Failure code. Error code explaining reason for transfer failure if available. See https://stripe.com/docs/api/python#transfer_failures.
  • failure_message (TextField) – Failure message. Message to user further explaining reason for payout failure if available.
  • method (StripeEnumField) – Method. The method used to send this payout. instant is only supported for payouts to debit cards.
  • statement_descriptor (CharField) – Statement descriptor. Extra information about a payout to be displayed on the user’s bank statement.
  • status (StripeEnumField) – Status. Current status of the payout. A payout will be pending until it is submitted to the bank, at which point it becomes in_transit. 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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Product

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

Stripe documentation: - https://stripe.com/docs/api#products - https://stripe.com/docs/api#service_products

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • name (TextField) – Name. The product’s name, meant to be displayable to the customer. Applicable to both service and good types.
  • type (StripeEnumField) – Type. The type of the product. The product is either of type good, which is eligible for use with Orders and SKUs, or service, which is eligible for use with Subscriptions and Plans.
  • active (NullBooleanField) – Active. Whether the product is currently available for purchase. Only applicable to products of type=good.
  • attributes (JSONField) – Attributes. A list of up to 5 attributes that each SKU can provide values for (e.g., [“color”, “size”]). Only applicable to products of type=good.
  • caption (TextField) – Caption. A short one-line description of the product, meant to be displayableto the customer. Only applicable to products of type=good.
  • deactivate_on (JSONField) – Deactivate on. An array of connect application identifiers that cannot purchase this product. Only applicable to products of type=good.
  • images (JSONField) – Images. A list of up to 8 URLs of images for this product, meant to be displayable to the customer. Only applicable to products of type=good.
  • package_dimensions (JSONField) – Package dimensions. The dimensions of this product for shipping purposes. A SKU associated with this product can override this value by having its own package_dimensions. Only applicable to products of type=good.
  • shippable (NullBooleanField) – Shippable. Whether this product is a shipped good. Only applicable to products of type=good.
  • url (CharField) – Url. A URL of a publicly-accessible webpage for this product. Only applicable to products of type=good.
  • statement_descriptor (CharField) – Statement descriptor. Extra information about a product which will appear on your customer’s credit card statement. In the case that multiple products are billed at once, the first statement descriptor will be used. Only available on products of type=`service`.
  • unit_label (CharField) – Unit label
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Refund

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

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeQuantumCurrencyAmountField) – Amount. Amount, in cents.
  • balance_transaction (ForeignKey to BalanceTransaction) – Balance transaction. Balance transaction that describes the impact on your account balance.
  • charge (ForeignKey to Charge) – Charge. The charge that was refunded
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • failure_balance_transaction (ForeignKey to BalanceTransaction) – Failure balance transaction. If the refund failed, this balance transaction describes the adjustment made on your account balance that reverses the initial balance transaction.
  • failure_reason (StripeEnumField) – Failure reason. If the refund failed, the reason for refund failure if known.
  • reason (StripeEnumField) – Reason. Reason for the refund.
  • receipt_number (CharField) – Receipt number. The transaction number that appears on email receipts sent for this charge.
  • status (StripeEnumField) – Status. Status of the refund.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Payment Methods

BankAccount

class djstripe.models.BankAccount(djstripe_id, id, livemode, created, metadata, description, djstripe_created, djstripe_updated, account, account_holder_name, account_holder_type, bank_name, country, currency, customer, default_for_currency, fingerprint, last4, routing_number, status)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • account (ForeignKey to Account) – Account. The account the charge was made on behalf of. Null here indicates that this value was never set.
  • account_holder_name (TextField) – Account holder name. The name of the person or business that owns the bank account.
  • account_holder_type (StripeEnumField) – Account holder type. The type of entity that holds the account.
  • bank_name (CharField) – Bank name. Name of the bank associated with the routing number (e.g., WELLS FARGO).
  • country (CharField) – Country. Two-letter ISO code representing the country the bank account is located in.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • customer (ForeignKey to Customer) – Customer
  • default_for_currency (NullBooleanField) – Default for currency. Whether this external account is the default account for its currency.
  • fingerprint (CharField) – Fingerprint. Uniquely identifies this particular bank account. You can use this attribute to check whether two bank accounts are the same.
  • last4 (CharField) – Last4
  • routing_number (CharField) – Routing number. The routing transit number for the bank account.
  • status (StripeEnumField) – Status
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

This is a legacy model which only applies to the “v2” Stripe API (eg. Checkout.js). You should strive to use the Stripe “v3” API (eg. Stripe Elements). Also see: https://stripe.com/docs/stripe-js/elements/migrating When using Elements, you will not be using Card objects. Instead, you will use Source objects. A Source object of type “card” is equivalent to a Card object. However, Card objects cannot be converted into Source objects by Stripe at this time.

Stripe documentation: https://stripe.com/docs/api/python#cards

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • address_city (TextField) – Address city. City/District/Suburb/Town/Village.
  • address_country (TextField) – Address country. Billing address country.
  • address_line1 (TextField) – Address line1. Street address/PO Box/Company name.
  • address_line1_check (StripeEnumField) – Address line1 check. If address_line1 was provided, results of the check.
  • address_line2 (TextField) – Address line2. Apartment/Suite/Unit/Building.
  • address_state (TextField) – Address state. State/County/Province/Region.
  • address_zip (TextField) – Address zip. ZIP or postal code.
  • address_zip_check (StripeEnumField) – Address zip check. If address_zip was provided, results of the check.
  • brand (StripeEnumField) – Brand. Card brand.
  • country (CharField) – Country. Two-letter ISO code representing the country of the card.
  • customer (ForeignKey to Customer) – Customer
  • cvc_check (StripeEnumField) – Cvc check. If a CVC was provided, results of the check.
  • dynamic_last4 (CharField) – Dynamic last4. (For tokenized numbers only.) The last four digits of the device account number.
  • exp_month (IntegerField) – Exp month. Card expiration month.
  • exp_year (IntegerField) – Exp year. Card expiration year.
  • fingerprint (CharField) – Fingerprint. Uniquely identifies this particular card number.
  • funding (StripeEnumField) – Funding. Card funding type.
  • last4 (CharField) – Last4. Last four digits of Card number.
  • name (TextField) – Name. Cardholder name.
  • tokenization_method (StripeEnumField) – Tokenization method. If the card number is tokenized, this is the method that was used.
classmethod 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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Source

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

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeDecimalCurrencyAmountField) – Amount. Amount associated with the source. This is the amount for which the source will be chargeable once ready. Required for single_use sources.
  • client_secret (CharField) – Client secret. The client secret of the source. Used for client-side retrieval using a publishable key.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • flow (StripeEnumField) – Flow. The authentication flow of the source.
  • owner (JSONField) – Owner. Information about the owner of the payment instrument that may be used or required by particular source types.
  • statement_descriptor (CharField) – Statement descriptor. Extra information about a source. This will appear on your customer’s statement every time you charge the source.
  • status (StripeEnumField) – Status. The status of the source. Only chargeable sources can be used to create a charge.
  • type (StripeEnumField) – Type. The type of the source.
  • usage (StripeEnumField) – Usage. Whether this source should be reusable or not. Some source types may or may not be reusable by construction, while other may leave the option at creation.
  • code_verification (JSONField) – Code verification. Information related to the code verification flow. Present if the source is authenticated by a verification code (flow is code_verification).
  • receiver (JSONField) – Receiver. Information related to the receiver flow. Present if the source is a receiver (flow is receiver).
  • redirect (JSONField) – Redirect. Information related to the redirect flow. Present if the source is authenticated by a redirect (flow is redirect).
  • source_data (JSONField) – Source data. The data corresponding to the source type.
  • customer (ForeignKey to Customer) – Customer
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Billing

Coupon

class djstripe.models.Coupon(djstripe_id, livemode, created, metadata, description, djstripe_created, djstripe_updated, id, amount_off, currency, duration, duration_in_months, max_redemptions, name, percent_off, redeem_by, times_redeemed)[source]
Parameters:
  • djstripe_id (BigAutoField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • id (StripeIdField) – Id
  • amount_off (StripeDecimalCurrencyAmountField) – Amount off. Amount that will be taken off the subtotal of any invoices for this customer.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • duration (StripeEnumField) – Duration. Describes how long a customer who applies this coupon will get the discount.
  • duration_in_months (PositiveIntegerField) – Duration in months. If duration is repeating, the number of months the coupon applies.
  • max_redemptions (PositiveIntegerField) – Max redemptions. Maximum number of times this coupon can be redeemed, in total, before it is no longer valid.
  • name (TextField) – Name. Name of the coupon displayed to customers on for instance invoices or receipts.
  • percent_off (StripePercentField) – Percent off. Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon. For example, a coupon with percent_off of 50 will make a $100 invoice $50 instead.
  • redeem_by (StripeDateTimeField) – Redeem by. Date after which the coupon can no longer be redeemed. Max 5 years in the future.
  • times_redeemed (PositiveIntegerField) – Times redeemed. Number of times this coupon has been applied to a customer.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

Stripe documentation: https://stripe.com/docs/api/python#invoices

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount_due (StripeDecimalCurrencyAmountField) – Amount due. 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 (StripeDecimalCurrencyAmountField) – Amount paid. The amount, in cents, that was paid.
  • amount_remaining (StripeDecimalCurrencyAmountField) – Amount remaining. The amount remaining, in cents, that is due.
  • application_fee (StripeDecimalCurrencyAmountField) – Application fee. 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 (IntegerField) – Attempt count. Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
  • attempted (BooleanField) – Attempted. Whether or not an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the invoice.created webhook, for example, so you might not want to display that invoice as unpaid to your users.
  • billing (StripeEnumField) – Billing. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
  • charge (OneToOneField to Charge) – Charge. The latest charge generated for this invoice, if any.
  • closed (NullBooleanField) – Closed. Whether or not the invoice is still trying to collect payment. An invoice is closed if it’s either paid or it has been marked closed. A closed invoice will no longer attempt to collect payment.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • customer (ForeignKey to Customer) – Customer. The customer associated with this invoice.
  • date (StripeDateTimeField) – Date. The date on the invoice.
  • due_date (StripeDateTimeField) – Due date. The date on which payment for this invoice is due. This value will be null for invoices where billing=charge_automatically.
  • ending_balance (IntegerField) – Ending balance. Ending customer balance after attempting to pay invoice. If the invoice has not been attempted yet, this will be null.
  • forgiven (NullBooleanField) – Forgiven. 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 (TextField) – Hosted invoice url. The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been frozen yet, this will be null.
  • invoice_pdf (TextField) – Invoice pdf. The link to download the PDF for the invoice. If the invoice has not been frozen yet, this will be null.
  • next_payment_attempt (StripeDateTimeField) – Next payment attempt. The time at which payment will next be attempted.
  • number (CharField) – Number. A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer’s unique invoice_prefix if it is specified.
  • paid (BooleanField) – Paid. The time at which payment will next be attempted.
  • period_end (StripeDateTimeField) – Period end. End of the usage period during which invoice items were added to this invoice.
  • period_start (StripeDateTimeField) – Period start. Start of the usage period during which invoice items were added to this invoice.
  • receipt_number (CharField) – Receipt number. This is the transaction number that appears on email receipts sent for this invoice.
  • starting_balance (IntegerField) – Starting balance. 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 (CharField) – Statement descriptor. An arbitrary string to be displayed on your customer’s credit card statement. The statement description may not include <>”’ characters, and will appear on your customer’s statement in capital letters. Non-ASCII characters are automatically stripped. While most banks display this information consistently, some may display it incorrectly or not at all.
  • subscription (ForeignKey to Subscription) – Subscription. The subscription that this invoice was prepared for, if any.
  • subscription_proration_date (StripeDateTimeField) – Subscription proration date. Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • subtotal (StripeDecimalCurrencyAmountField) – Subtotal. Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • tax (StripeDecimalCurrencyAmountField) – Tax. 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) – Tax percent. This percentage of the subtotal has been added to the total amount of the invoice, including invoice line items and discounts. This field is inherited from the subscription’s tax_percent field, but can be changed before the invoice is paid. This field defaults to null.
  • total (StripeDecimalCurrencyAmountField) – Total after discount.
  • webhooks_delivered_at (StripeDateTimeField) – Webhooks delivered at. The time at which webhooks for this invoice were successfully delivered (if the invoice had no webhooks to deliver, this will match date). Invoice payment is delayed until webhooks are delivered, or until all webhook delivery attempts have been exhausted.
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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

Stripe documentation: https://stripe.com/docs/api/python#invoiceitems

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeDecimalCurrencyAmountField) – Amount. Amount invoiced.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • customer (ForeignKey to Customer) – Customer. The customer associated with this invoiceitem.
  • date (StripeDateTimeField) – Date. The date on the invoiceitem.
  • discountable (BooleanField) – Discountable. If True, discounts will apply to this invoice item. Always False for prorations.
  • invoice (ForeignKey to Invoice) – Invoice. The invoice to which this invoiceitem is attached.
  • period (JSONField) – Period
  • period_end (StripeDateTimeField) – Period end. Might be the date when this invoiceitem’s invoice was sent.
  • period_start (StripeDateTimeField) – Period start. Might be the date when this invoiceitem was added to the invoice
  • plan (ForeignKey to Plan) – Plan. If the invoice item is a proration, the plan of the subscription for which the proration was computed.
  • proration (BooleanField) – Proration. Whether or not the invoice item was created automatically as a proration adjustment when the customer switched plans.
  • quantity (IntegerField) – Quantity. If the invoice item is a proration, the quantity of the subscription for which the proration was computed.
  • subscription (ForeignKey to Subscription) – Subscription. The subscription that this invoice item has been created for, if any.
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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)[source]

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

Stripe documentation: https://stripe.com/docs/api/python#invoiceitems

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeDecimalCurrencyAmountField) – Amount. Amount invoiced.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • customer (ForeignKey to Customer) – Customer. The customer associated with this invoiceitem.
  • date (StripeDateTimeField) – Date. The date on the invoiceitem.
  • discountable (BooleanField) – Discountable. If True, discounts will apply to this invoice item. Always False for prorations.
  • invoice (ForeignKey to Invoice) – Invoice. The invoice to which this invoiceitem is attached.
  • period (JSONField) – Period
  • period_end (StripeDateTimeField) – Period end. Might be the date when this invoiceitem’s invoice was sent.
  • period_start (StripeDateTimeField) – Period start. Might be the date when this invoiceitem was added to the invoice
  • plan (ForeignKey to Plan) – Plan. If the invoice item is a proration, the plan of the subscription for which the proration was computed.
  • proration (BooleanField) – Proration. Whether or not the invoice item was created automatically as a proration adjustment when the customer switched plans.
  • quantity (IntegerField) – Quantity. If the invoice item is a proration, the quantity of the subscription for which the proration was computed.
  • subscription (ForeignKey to Subscription) – Subscription. The subscription that this invoice item has been created for, if any.
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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)[source]

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

Stripe documentation: https://stripe.com/docs/api/python#plans)

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • active (BooleanField) – Active. Whether the plan is currently available for new subscriptions.
  • aggregate_usage (StripeEnumField) – Aggregate usage. Specifies a usage aggregation strategy for plans of usage_type=metered. Allowed values are sum for summing up all usage during a period, last_during_period for picking the last usage record reported within a period, last_ever for picking the last usage record ever (across period bounds) or max which picks the usage record with the maximum reported usage during a period. Defaults to sum.
  • amount (StripeDecimalCurrencyAmountField) – Amount. Amount to be charged on the interval specified.
  • billing_scheme (StripeEnumField) – Billing scheme. Describes how to compute the price per period. Either per_unit or tiered. per_unit indicates that the fixed amount (specified in amount) will be charged per unit in quantity (for plans with usage_type=licensed), or per unit of total usage (for plans with usage_type=metered). tiered indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers and tiers_mode attributes.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • interval (StripeEnumField) – Interval. The frequency with which a subscription should be billed.
  • interval_count (IntegerField) – Interval count. The number of intervals (specified in the interval property) between each subscription billing.
  • nickname (TextField) – Nickname. A brief description of the plan, hidden from customers.
  • product (ForeignKey to Product) – Product. The product whose pricing this plan determines.
  • tiers (JSONField) – Tiers. Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered.
  • tiers_mode (StripeEnumField) – Tiers mode. Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price, in graduated tiering pricing can successively change as the quantity grows.
  • transform_usage (JSONField) – Transform usage. Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with tiers.
  • trial_period_days (IntegerField) – Trial period days. Number of trial period days granted when subscribing a customer to this plan. Null if the plan has no trial period.
  • usage_type (StripeEnumField) – Usage type. Configures how the quantity per period should be determined, can be either metered or licensed. licensed will automatically bill the quantity set for a plan when adding it to a subscription, metered will aggregate the total usage based on usage records. Defaults to licensed.
  • name (TextField) – Name. Name of the plan, to be displayed on invoices and in the web interface.
  • statement_descriptor (CharField) – Statement descriptor. An arbitrary string to be displayed on your customer’s credit card statement. The statement description may not include <>”’ characters, and will appear on your customer’s statement in capital letters. Non-ASCII characters are automatically stripped. While most banks display this information consistently, some may display it incorrectly or not at all.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

Stripe documentation: https://stripe.com/docs/api/python#subscriptions

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • application_fee_percent (StripePercentField) – Application fee percent. A positive decimal that represents the fee percentage of the subscription invoice amount that will be transferred to the application owner’s Stripe account each billing period.
  • billing (StripeEnumField) – Billing. Either charge_automatically, or send_invoice. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions.
  • billing_cycle_anchor (StripeDateTimeField) – Billing cycle anchor. Determines the date of the first full invoice, and, for plans with month or year intervals, the day of the month for subsequent invoices.
  • cancel_at_period_end (BooleanField) – Cancel at period end. If the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period.
  • canceled_at (StripeDateTimeField) – Canceled at. If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with cancel_at_period_end, canceled_at will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state.
  • current_period_end (StripeDateTimeField) – Current period end. End of the current period for which the subscription has been invoiced. At the end of this period, a new invoice will be created.
  • current_period_start (StripeDateTimeField) – Current period start. Start of the current period for which the subscription has been invoiced.
  • customer (ForeignKey to Customer) – Customer. The customer associated with this subscription.
  • days_until_due (IntegerField) – Days until due. Number of days a customer has to pay invoices generated by this subscription. This value will be null for subscriptions where billing=charge_automatically.
  • ended_at (StripeDateTimeField) – Ended at. If the subscription has ended (either because it was canceled or because the customer was switched to a subscription to a new plan), the date the subscription ended.
  • plan (ForeignKey to Plan) – Plan. The plan associated with this subscription. This value will be null for multi-plan subscriptions
  • quantity (IntegerField) – Quantity. The quantity applied to this subscription. This value will be null for multi-plan subscriptions
  • start (StripeDateTimeField) – Start. Date the subscription started.
  • status (StripeEnumField) – Status. The status of this subscription.
  • tax_percent (StripePercentField) – Tax percent. A positive decimal (with at most two decimal places) between 1 and 100. This represents the percentage of the subscription invoice subtotal that will be calculated and added as tax to the final amount each billing period.
  • trial_end (StripeDateTimeField) – Trial end. If the subscription has a trial, the end of that trial.
  • trial_start (StripeDateTimeField) – Trial start. If the subscription has a trial, the beginning of that trial.
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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, billing_cycle_anchor=None, coupon=None, prorate=False, proration_date=None, metadata=None, quantity=None, tax_percent=None, trial_end=None)[source]

See Customer.subscribe()

Parameters:
  • plan (Plan or string (plan ID)) – The plan to which to subscribe the customer.
  • application_fee_percent
  • billing_cycle_anchor
  • coupon
  • prorate (boolean) – Whether or not to prorate when switching plans. Default is True.
  • proration_date (datetime) – If set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same proration that was previewed with upcoming invoice endpoint. It can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations.
  • metadata
  • quantity
  • tax_percent
  • trial_end

Note

The default value for prorate is the DJSTRIPE_PRORATION_POLICY setting.

Important

Updating a subscription by changing the plan or quantity creates a new Subscription in Stripe (and dj-stripe).

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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

SubscriptionItem

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

Subscription items allow you to create customer subscriptions with more than one plan, making it easy to represent complex billing relationships.

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • plan (ForeignKey to Plan) – Plan. The plan the customer is subscribed to.
  • quantity (PositiveIntegerField) – Quantity. The quantity of the plan to which the customer should be subscribed.
  • subscription (ForeignKey to Subscription) – Subscription. The subscription this subscription item belongs to.
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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

UpcomingInvoice

class djstripe.models.UpcomingInvoice(djstripe_id, 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
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount_due (StripeDecimalCurrencyAmountField) – Amount due. 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 (StripeDecimalCurrencyAmountField) – Amount paid. The amount, in cents, that was paid.
  • amount_remaining (StripeDecimalCurrencyAmountField) – Amount remaining. The amount remaining, in cents, that is due.
  • application_fee (StripeDecimalCurrencyAmountField) – Application fee. 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 (IntegerField) – Attempt count. Number of payment attempts made for this invoice, from the perspective of the payment retry schedule. Any payment attempt counts as the first attempt, and subsequently only automatic retries increment the attempt count. In other words, manual payment attempts after the first attempt do not affect the retry schedule.
  • attempted (BooleanField) – Attempted. Whether or not an attempt has been made to pay the invoice. An invoice is not attempted until 1 hour after the invoice.created webhook, for example, so you might not want to display that invoice as unpaid to your users.
  • billing (StripeEnumField) – Billing. When charging automatically, Stripe will attempt to pay this invoice using the default source attached to the customer. When sending an invoice, Stripe will email this invoice to the customer with payment instructions.
  • charge (OneToOneField to Charge) – Charge. The latest charge generated for this invoice, if any.
  • closed (NullBooleanField) – Closed. Whether or not the invoice is still trying to collect payment. An invoice is closed if it’s either paid or it has been marked closed. A closed invoice will no longer attempt to collect payment.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • customer (ForeignKey to Customer) – Customer. The customer associated with this invoice.
  • date (StripeDateTimeField) – Date. The date on the invoice.
  • due_date (StripeDateTimeField) – Due date. The date on which payment for this invoice is due. This value will be null for invoices where billing=charge_automatically.
  • ending_balance (IntegerField) – Ending balance. Ending customer balance after attempting to pay invoice. If the invoice has not been attempted yet, this will be null.
  • forgiven (NullBooleanField) – Forgiven. 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 (TextField) – Hosted invoice url. The URL for the hosted invoice page, which allows customers to view and pay an invoice. If the invoice has not been frozen yet, this will be null.
  • invoice_pdf (TextField) – Invoice pdf. The link to download the PDF for the invoice. If the invoice has not been frozen yet, this will be null.
  • next_payment_attempt (StripeDateTimeField) – Next payment attempt. The time at which payment will next be attempted.
  • number (CharField) – Number. A unique, identifying string that appears on emails sent to the customer for this invoice. This starts with the customer’s unique invoice_prefix if it is specified.
  • paid (BooleanField) – Paid. The time at which payment will next be attempted.
  • period_end (StripeDateTimeField) – Period end. End of the usage period during which invoice items were added to this invoice.
  • period_start (StripeDateTimeField) – Period start. Start of the usage period during which invoice items were added to this invoice.
  • receipt_number (CharField) – Receipt number. This is the transaction number that appears on email receipts sent for this invoice.
  • starting_balance (IntegerField) – Starting balance. 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 (CharField) – Statement descriptor. An arbitrary string to be displayed on your customer’s credit card statement. The statement description may not include <>”’ characters, and will appear on your customer’s statement in capital letters. Non-ASCII characters are automatically stripped. While most banks display this information consistently, some may display it incorrectly or not at all.
  • subscription (ForeignKey to Subscription) – Subscription. The subscription that this invoice was prepared for, if any.
  • subscription_proration_date (StripeDateTimeField) – Subscription proration date. Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • subtotal (StripeDecimalCurrencyAmountField) – Subtotal. Only set for upcoming invoices that preview prorations. The time used to calculate prorations.
  • tax (StripeDecimalCurrencyAmountField) – Tax. 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) – Tax percent. This percentage of the subtotal has been added to the total amount of the invoice, including invoice line items and discounts. This field is inherited from the subscription’s tax_percent field, but can be changed before the invoice is paid. This field defaults to null.
  • total (StripeDecimalCurrencyAmountField) – Total after discount.
  • webhooks_delivered_at (StripeDateTimeField) – Webhooks delivered at. The time at which webhooks for this invoice were successfully delivered (if the invoice had no webhooks to deliver, this will match date). Invoice payment is delayed until webhooks are delivered, or until all webhook delivery attempts have been exhausted.
  • 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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

UsageRecord

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

Usage records allow you to continually report usage and metrics to Stripe for metered billing of plans.

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • quantity (PositiveIntegerField) – Quantity. The quantity of the plan to which the customer should be subscribed.
  • subscription_item (ForeignKey to SubscriptionItem) – Subscription item. The subscription item this usage record contains data for.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Connect

Account

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

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • business_logo (ForeignKey to FileUpload) – Business logo
  • business_name (CharField) – Business name. The publicly visible name of the business
  • business_primary_color (CharField) – Business primary color. A CSS hex color value representing the primary branding color for this account
  • business_url (CharField) – Business url. The publicly visible website of the business
  • charges_enabled (BooleanField) – Charges enabled. Whether the account can create live charges
  • country (CharField) – Country. The country of the account
  • debit_negative_balances (NullBooleanField) – Debit negative balances. A Boolean indicating if Stripe should try to reclaim negative balances from an attached bank account.
  • decline_charge_on (JSONField) – Decline charge on. Account-level settings to automatically decline certain types of charges regardless of the decision of the card issuer
  • default_currency (StripeCurrencyCodeField) – Default currency. The currency this account has chosen to use as the default
  • details_submitted (BooleanField) – Details submitted. Whether account details have been submitted. Standard accounts cannot receive payouts before this is true.
  • display_name (CharField) – Display name. The display name for this account. This is used on the Stripe Dashboard to differentiate between accounts.
  • email (CharField) – Email. The primary user’s email address.
  • legal_entity (JSONField) – Legal entity. Information about the legal entity itself, including about the associated account representative
  • payout_schedule (JSONField) – Payout schedule. Details on when funds from charges are available, and when they are paid out to an external account.
  • payout_statement_descriptor (CharField) – Payout statement descriptor. The text that appears on the bank account statement for payouts.
  • payouts_enabled (BooleanField) – Payouts enabled. Whether Stripe can send payouts to this account
  • product_description (CharField) – Product description. Internal-only description of the product sold or service provided by the business. It’s used by Stripe for risk and underwriting purposes.
  • statement_descriptor (CharField) – Statement descriptor. The default text that appears on credit card statements when a charge is made directly on the account
  • support_email (CharField) – Support email. A publicly shareable support email address for the business
  • support_phone (CharField) – Support phone. A publicly shareable support phone number for the business
  • support_url (CharField) – Support url. A publicly shareable URL that provides support for this account
  • timezone (CharField) – Timezone. The timezone used in the Stripe Dashboard for this account.
  • type (StripeEnumField) – Type. The Stripe account type.
  • tos_acceptance (JSONField) – Tos acceptance. Details on the acceptance of the Stripe Services Agreement
  • verification (JSONField) – Verification. 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. Defaults to djstripe_settings.STRIPE_SECRET_KEY.

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Application Fee

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

When you collect a transaction fee on top of a charge made for your user (using Connect), an ApplicationFee is created in your account.

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeQuantumCurrencyAmountField) – Amount. Amount earned.
  • amount_refunded (StripeQuantumCurrencyAmountField) – Amount refunded. Amount refunded (can be less than the amount attribute on the fee if a partial refund was issued)
  • balance_transaction (ForeignKey to BalanceTransaction) – Balance transaction. Balance transaction that describes the impact on your account balance.
  • charge (ForeignKey to Charge) – Charge. The charge that the application fee was taken from.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • refunded (BooleanField) – Refunded. Whether the fee has been fully refunded. If the fee is only partially refunded, this attribute will still be false.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Country Spec

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

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

Parameters:
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • id (CharField) – Id
  • default_currency (StripeCurrencyCodeField) – Default currency. The default currency for this country. This applies to both payment methods and bank accounts.
  • supported_bank_account_currencies (JSONField) – Supported bank account currencies. Currencies that can be accepted in the specific country (for transfers).
  • supported_payment_currencies (JSONField) – Supported payment currencies. Currencies that can be accepted in the specified country (for payments).
  • supported_payment_methods (JSONField) – Supported payment methods. Payment methods available in the specified country.
  • supported_transfer_countries (JSONField) – Supported transfer countries. Countries that can accept transfers from the specified country.
  • verification_fields (JSONField) – Verification fields. Lists the types of verification data needed to keep an account open.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

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.

Stripe documentation: https://stripe.com/docs/api/python#transfers

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeDecimalCurrencyAmountField) – Amount. The amount transferred
  • amount_reversed (StripeDecimalCurrencyAmountField) – Amount reversed. The amount reversed (can be less than the amount attribute on the transfer if a partial reversal was issued).
  • balance_transaction (ForeignKey to BalanceTransaction) – Balance transaction. Balance transaction that describes the impact on your account balance.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • destination (StripeIdField) – Destination. ID of the bank account, card, or Stripe account the transfer was sent to.
  • destination_payment (StripeIdField) – Destination payment. If the destination is a Stripe account, this will be the ID of the payment that the destination account received for the transfer.
  • reversed (BooleanField) – Reversed. Whether or not the transfer has been fully reversed. If the transfer is only partially reversed, this attribute will still be false.
  • source_transaction (StripeIdField) – Source transaction. ID of the charge (or other transaction) that was used to fund the transfer. If null, the transfer was funded from the available balance.
  • source_type (StripeEnumField) – Source type. The source balance from which this transfer came.
  • transfer_group (CharField) – Transfer group. A string that identifies this transaction as part of a group.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Transfer Reversal

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

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • amount (StripeQuantumCurrencyAmountField) – Amount. Amount, in cents.
  • balance_transaction (ForeignKey to BalanceTransaction) – Balance transaction. Balance transaction that describes the impact on your account balance.
  • currency (StripeCurrencyCodeField) – Currency. Three-letter ISO currency code
  • transfer (ForeignKey to Transfer) – Transfer. The transfer that was reversed.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Fraud

TODO

Orders

TODO

Sigma

ScheduledQueryRun

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

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

Parameters:
  • djstripe_id (BigAutoField) – Id
  • id (StripeIdField) – Id
  • livemode (NullBooleanField) – Livemode. Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.
  • created (StripeDateTimeField) – Created. The datetime this object was created in stripe.
  • metadata (JSONField) – Metadata. A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.
  • description (TextField) – Description. A description of this object.
  • djstripe_created (DateTimeField) – Djstripe created
  • djstripe_updated (DateTimeField) – Djstripe updated
  • data_load_time (StripeDateTimeField) – Data load time. When the query was run, Sigma contained a snapshot of your Stripe data at this time.
  • error (JSONField) – Error. If the query run was not succeesful, contains information about the failure.
  • file (ForeignKey to FileUpload) – File. The file object representing the results of the query.
  • result_available_until (StripeDateTimeField) – Result available until. Time at which the result expires and is no longer available for download.
  • sql (TextField) – Sql. SQL for the query.
  • status (StripeEnumField) – Status. The query’s execution status.
  • title (TextField) – Title. Title of the query.
classmethod api_list(api_key='', **kwargs)

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

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

See Stripe documentation for accepted kwargs for each object.

Returns:an iterator over all items in the query
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 sync_from_stripe_data(data, field_name=None)

Syncs this object from the stripe data provided.

Foreign keys will also be retrieved and synced recursively.

Parameters:data (dict) – stripe object

Webhooks

WebhookEventTrigger

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

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

Webhook Events are initially UNTRUSTED, as it is possible for any web entity to post any data to our webhook url. Data posted may be valid Stripe information, garbage, or even malicious. The ‘valid’ flag in this model monitors this.

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