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.
Core Resources
Classes
        
djstripe.models.core.BalanceTransaction        
    A single transaction that updates the Stripe balance.
Stripe documentation: https://stripe.com/docs/api#balance_transaction_object
djstripe.models.core.BalanceTransaction.amount
    
djstripe.models.core.BalanceTransaction.available_on
    
djstripe.models.core.BalanceTransaction.currency
    
djstripe.models.core.BalanceTransaction.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.BalanceTransaction.exchange_rate
    
djstripe.models.core.BalanceTransaction.fee
    
djstripe.models.core.BalanceTransaction.fee_details
    
djstripe.models.core.BalanceTransaction.net
    
djstripe.models.core.BalanceTransaction.reporting_category
    
djstripe.models.core.BalanceTransaction.source
    
djstripe.models.core.BalanceTransaction.status
    
djstripe.models.core.BalanceTransaction.type
    
        
djstripe.models.core.BalanceTransaction.DoesNotExist        
    
        
djstripe.models.core.BalanceTransaction.MultipleObjectsReturned        
    
        
djstripe.models.core.BalanceTransaction.stripe_class        
    Methods
djstripe.models.core.BalanceTransaction.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return f"{self.human_readable_amount} ({enums.BalanceTransactionStatus.humanize(self.status)})"
djstripe.models.core.BalanceTransaction.get_next_by_available_on(self, *, field=<djstripe.fields.StripeDateTimeField: available_on>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_previous_by_available_on(self, *, field=<djstripe.fields.StripeDateTimeField: available_on>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_reporting_category_display(self, *, field=<djstripe.fields.StripeEnumField: reporting_category>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_source_class(self)
    Source code in djstripe/models/core.py
          def get_source_class(self):
    try:
        return apps.get_model("djstripe", self.type)
    except LookupError:
        raise
djstripe.models.core.BalanceTransaction.get_source_instance(self)
    Source code in djstripe/models/core.py
          def get_source_instance(self):
    return self.get_source_class().objects.get(id=self.source)
djstripe.models.core.BalanceTransaction.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.BalanceTransaction.get_stripe_dashboard_url(self)
    Get the stripe dashboard url for this object.
Source code in djstripe/models/core.py
          def get_stripe_dashboard_url(self):
    return self.get_source_instance().get_stripe_dashboard_url()
djstripe.models.core.BalanceTransaction.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.core.Charge        
    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?lang=python#charges
djstripe.models.core.Charge.amount
    
djstripe.models.core.Charge.amount_captured
    
djstripe.models.core.Charge.amount_refunded
    
djstripe.models.core.Charge.application
    
djstripe.models.core.Charge.application_fee
    
djstripe.models.core.Charge.application_fee_amount
    
djstripe.models.core.Charge.balance_transaction
    
djstripe.models.core.Charge.billing_details
    
djstripe.models.core.Charge.calculated_statement_descriptor
    
djstripe.models.core.Charge.captured
    
djstripe.models.core.Charge.currency
    
djstripe.models.core.Charge.customer
    
djstripe.models.core.Charge.dispute
    
djstripe.models.core.Charge.disputed
    
djstripe.models.core.Charge.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Charge.expand_fields: List[str]
    
djstripe.models.core.Charge.failure_code
    
djstripe.models.core.Charge.failure_message
    
djstripe.models.core.Charge.fee
  
      property
      readonly
  
    
djstripe.models.core.Charge.fraud_details
    
djstripe.models.core.Charge.fraudulent: bool
  
      property
      readonly
  
    
djstripe.models.core.Charge.human_readable_status: str
  
      property
      readonly
  
    
djstripe.models.core.Charge.invoice
    
djstripe.models.core.Charge.objects
    
djstripe.models.core.Charge.on_behalf_of
    
djstripe.models.core.Charge.outcome
    
djstripe.models.core.Charge.paid
    
djstripe.models.core.Charge.payment_intent
    
djstripe.models.core.Charge.payment_method
    
djstripe.models.core.Charge.payment_method_details
    
djstripe.models.core.Charge.receipt_email
    
djstripe.models.core.Charge.receipt_number
    
djstripe.models.core.Charge.receipt_url
    
djstripe.models.core.Charge.refunded
    
djstripe.models.core.Charge.shipping
    
djstripe.models.core.Charge.source
    
djstripe.models.core.Charge.source_transfer
    
djstripe.models.core.Charge.statement_descriptor
    
djstripe.models.core.Charge.statement_descriptor_suffix
    
djstripe.models.core.Charge.status
    
djstripe.models.core.Charge.stripe_dashboard_item_name
    
djstripe.models.core.Charge.transfer
    
djstripe.models.core.Charge.transfer_data
    
djstripe.models.core.Charge.transfer_group
    
        
djstripe.models.core.Charge.DoesNotExist        
    
        
djstripe.models.core.Charge.MultipleObjectsReturned        
    
        
djstripe.models.core.Charge.stripe_class        
    djstripe.models.core.Charge.stripe_class.OBJECT_NAME
djstripe.models.core.Charge.stripe_class.capture(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def capture(self, idempotency_key=None, **params):
    url = self.instance_url() + "/capture"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.Charge.stripe_class.close_dispute(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def close_dispute(self, idempotency_key=None, **params):
    requestor = api_requestor.APIRequestor(
        self.api_key,
        api_version=self.stripe_version,
        account=self.stripe_account,
    )
    url = self.instance_url() + "/dispute/close"
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request("post", url, params, headers)
    self.refresh_from({"dispute": response}, api_key, True)
    return self.dispute
djstripe.models.core.Charge.stripe_class.mark_as_fraudulent(self, idempotency_key=None)
Source code in djstripe/models/core.py
          def mark_as_fraudulent(self, idempotency_key=None):
    params = {"fraud_details": {"user_report": "fraudulent"}}
    url = self.instance_url()
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.Charge.stripe_class.mark_as_safe(self, idempotency_key=None)
Source code in djstripe/models/core.py
          def mark_as_safe(self, idempotency_key=None):
    params = {"fraud_details": {"user_report": "safe"}}
    url = self.instance_url()
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.Charge.stripe_class.refund(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def refund(self, idempotency_key=None, **params):
    url = self.instance_url() + "/refund"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.Charge.stripe_class.update_dispute(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def update_dispute(self, idempotency_key=None, **params):
    requestor = api_requestor.APIRequestor(
        self.api_key,
        api_version=self.stripe_version,
        account=self.stripe_account,
    )
    url = self.instance_url() + "/dispute"
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request("post", url, params, headers)
    self.refresh_from({"dispute": response}, api_key, True)
    return self.dispute
Methods
djstripe.models.core.Charge.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    amount = self.human_readable_amount
    status = self.human_readable_status
    return "{amount} ({status})".format(amount=amount, status=status)
djstripe.models.core.Charge.capture(self, **kwargs)
    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
Source code in djstripe/models/core.py
          def capture(self, **kwargs) -> "Charge":
    """
    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
    """
    captured_charge = self.api_retrieve().capture(**kwargs)
    return self.__class__.sync_from_stripe_data(captured_charge)
djstripe.models.core.Charge.get_failure_code_display(self, *, field=<djstripe.fields.StripeEnumField: failure_code>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Charge.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Charge.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Charge.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Charge.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Charge.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Charge.refund(self, amount=None, reason=None)
    Initiate a refund. Returns the charge object.
:param amount: A positive decimal amount representing how much of this charge
    to refund. If amount is not provided, then this will be a full refund.
    Can only refund up to the unrefunded amount remaining of the charge.
:param 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.
Source code in djstripe/models/core.py
          def refund(self, amount: Decimal = None, reason: str = None) -> "Charge":
    """
    Initiate a refund. Returns the charge object.
    :param amount: A positive decimal amount representing how much of this charge
        to refund. If amount is not provided, then this will be a full refund.
        Can only refund up to the unrefunded amount remaining of the charge.
    :param 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.
    """
    charge_obj = self.api_retrieve().refund(
        amount=self._calculate_refund_amount(amount=amount), reason=reason
    )
    return self.__class__.sync_from_stripe_data(charge_obj)
        
djstripe.models.core.Customer        
    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?lang=python#customers
Attributes
djstripe.models.core.Customer.active_subscriptions
  
      property
      readonly
  
    Returns active subscriptions (subscriptions with an active status that end in the future).
djstripe.models.core.Customer.address
    
djstripe.models.core.Customer.balance
    
djstripe.models.core.Customer.coupon
    
djstripe.models.core.Customer.coupon_end
    
djstripe.models.core.Customer.coupon_start
    
djstripe.models.core.Customer.credits
  
      property
      readonly
  
    The customer is considered to have credits if their balance is below 0.
djstripe.models.core.Customer.currency
    
djstripe.models.core.Customer.customer_payment_methods
  
      property
      readonly
  
    An iterable of all of the customer's payment methods (sources, then legacy cards)
djstripe.models.core.Customer.date_purged
    
djstripe.models.core.Customer.default_payment_method
    
djstripe.models.core.Customer.default_source
    
djstripe.models.core.Customer.deleted
    
djstripe.models.core.Customer.delinquent
    
djstripe.models.core.Customer.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Customer.email
    
djstripe.models.core.Customer.expand_fields: List[str]
    
djstripe.models.core.Customer.invoice_prefix
    
djstripe.models.core.Customer.invoice_settings
    
djstripe.models.core.Customer.name
    
djstripe.models.core.Customer.pending_charges
  
      property
      readonly
  
    The customer is considered to have pending charges if their balance is above 0.
djstripe.models.core.Customer.phone
    
djstripe.models.core.Customer.preferred_locales
    
djstripe.models.core.Customer.shipping
    
djstripe.models.core.Customer.stripe_dashboard_item_name
    
djstripe.models.core.Customer.subscriber
    
djstripe.models.core.Customer.subscription
  
      property
      readonly
  
    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.
djstripe.models.core.Customer.tax_exempt
    
djstripe.models.core.Customer.valid_subscriptions
  
      property
      readonly
  
    Returns this customer's valid subscriptions (subscriptions that aren't canceled or incomplete_expired).
        
djstripe.models.core.Customer.DoesNotExist        
    
        
djstripe.models.core.Customer.MultipleObjectsReturned        
    
        
djstripe.models.core.Customer.stripe_class        
    djstripe.models.core.Customer.stripe_class.OBJECT_NAME
djstripe.models.core.Customer.stripe_class.balance_transactions_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.core.Customer.stripe_class.balance_transactions_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/core.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.core.Customer.stripe_class.create_balance_transaction(id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.core.Customer.stripe_class.create_source(id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.core.Customer.stripe_class.create_tax_id(id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.core.Customer.stripe_class.delete_discount(self, **params)
Source code in djstripe/models/core.py
          def delete_discount(self, **params):
    requestor = api_requestor.APIRequestor(
        self.api_key,
        api_version=self.stripe_version,
        account=self.stripe_account,
    )
    url = self.instance_url() + "/discount"
    _, api_key = requestor.request("delete", url, params)
    self.refresh_from({"discount": None}, api_key, True)
djstripe.models.core.Customer.stripe_class.delete_source(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def delete_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "delete", url, **params
    )
djstripe.models.core.Customer.stripe_class.delete_tax_id(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def delete_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "delete", url, **params
    )
djstripe.models.core.Customer.stripe_class.list_balance_transactions(id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.core.Customer.stripe_class.list_payment_methods(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def list_payment_methods(self, idempotency_key=None, **params):
    url = self.instance_url() + "/payment_methods"
    headers = util.populate_headers(idempotency_key)
    resp = self.request("get", url, params, headers)
    stripe_object = util.convert_to_stripe_object(resp)
    stripe_object._retrieve_params = params
    return stripe_object
djstripe.models.core.Customer.stripe_class.list_sources(id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.core.Customer.stripe_class.list_tax_ids(id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.core.Customer.stripe_class.modify_balance_transaction(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.core.Customer.stripe_class.modify_source(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.core.Customer.stripe_class.retrieve_balance_transaction(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.core.Customer.stripe_class.retrieve_source(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.core.Customer.stripe_class.retrieve_tax_id(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.core.Customer.stripe_class.sources_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.core.Customer.stripe_class.sources_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/core.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.core.Customer.stripe_class.tax_ids_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.core.Customer.stripe_class.tax_ids_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/core.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
Methods
djstripe.models.core.Customer.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    if self.subscriber:
        return str(self.subscriber)
    return self.name or self.description or self.id
djstripe.models.core.Customer.add_card(self, source, set_default=True)
    Adds a card to this customer's account.
:param source: 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. :type source: string, dict :param set_default: Whether or not to set the source as the customer's default source :type set_default: boolean
Source code in djstripe/models/core.py
          def add_card(self, source, set_default=True):
    """
    Adds a card to this customer's account.
    :param source: 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.
    :type source: string, dict
    :param set_default: Whether or not to set the source as the customer's
        default source
    :type set_default: boolean
    """
    from .payment_methods import DjstripePaymentMethod
    stripe_customer = self.api_retrieve()
    new_stripe_payment_method = stripe_customer.sources.create(source=source)
    if set_default:
        stripe_customer.default_source = new_stripe_payment_method["id"]
        stripe_customer.save()
    new_payment_method = DjstripePaymentMethod.from_stripe_object(
        new_stripe_payment_method
    )
    # Change the default source
    if set_default:
        self.default_source = new_payment_method
        self.save()
    return new_payment_method.resolve()
djstripe.models.core.Customer.add_coupon(self, coupon, idempotency_key=None)
    Add a coupon to a Customer.
The coupon can be a Coupon object, or a valid Stripe Coupon ID.
Source code in djstripe/models/core.py
          def add_coupon(self, coupon, idempotency_key=None):
    """
    Add a coupon to a Customer.
    The coupon can be a Coupon object, or a valid Stripe Coupon ID.
    """
    if isinstance(coupon, StripeModel):
        coupon = coupon.id
    stripe_customer = self.api_retrieve()
    stripe_customer["coupon"] = coupon
    stripe_customer.save(idempotency_key=idempotency_key)
    return self.__class__.sync_from_stripe_data(stripe_customer)
djstripe.models.core.Customer.add_invoice_item(self, amount, currency, description=None, discountable=None, invoice=None, metadata=None, subscription=None)
    Adds an arbitrary charge or credit to the customer's upcoming invoice. Different than creating a charge. Charges are separate bills that get processed immediately. Invoice items are appended to the customer's next invoice. This is extremely useful when adding surcharges to subscriptions.
:param amount: The amount to charge.
:type amount: Decimal. Precision is 2; anything more will be ignored.
:param currency: 3-letter ISO code for currency
:type currency: string
:param description: An arbitrary string.
:type description: string
:param discountable: Controls whether discounts apply to this invoice item.
    Defaults to False for prorations or negative invoice items,
    and True for all other invoice items.
:type discountable: boolean
:param invoice: 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.
:type invoice: Invoice or string (invoice ID)
:param metadata: A set of key/value pairs useful for storing
    additional information.
:type metadata: dict
:param subscription: 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.
:type subscription: Subscription or string (subscription ID)
.. Notes:
.. if you're using Customer.add_invoice_item() instead of
.. Customer.add_invoice_item(), invoice and subscriptions
.. can only be strings
Source code in djstripe/models/core.py
          def add_invoice_item(
    self,
    amount,
    currency,
    description=None,
    discountable=None,
    invoice=None,
    metadata=None,
    subscription=None,
):
    """
    Adds an arbitrary charge or credit to the customer's upcoming invoice.
    Different than creating a charge. Charges are separate bills that get
    processed immediately. Invoice items are appended to the customer's next
    invoice. This is extremely useful when adding surcharges to subscriptions.
    :param amount: The amount to charge.
    :type amount: Decimal. Precision is 2; anything more will be ignored.
    :param currency: 3-letter ISO code for currency
    :type currency: string
    :param description: An arbitrary string.
    :type description: string
    :param discountable: Controls whether discounts apply to this invoice item.
        Defaults to False for prorations or negative invoice items,
        and True for all other invoice items.
    :type discountable: boolean
    :param invoice: 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.
    :type invoice: Invoice or string (invoice ID)
    :param metadata: A set of key/value pairs useful for storing
        additional information.
    :type metadata: dict
    :param subscription: 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.
    :type subscription: Subscription or string (subscription ID)
    .. Notes:
    .. if you're using ``Customer.add_invoice_item()`` instead of
    .. ``Customer.add_invoice_item()``, ``invoice`` and ``subscriptions``
    .. can only be strings
    """
    from .billing import InvoiceItem
    if not isinstance(amount, Decimal):
        raise ValueError("You must supply a decimal value representing dollars.")
    # Convert Invoice to id
    if invoice is not None and isinstance(invoice, StripeModel):
        invoice = invoice.id
    # Convert Subscription to id
    if subscription is not None and isinstance(subscription, StripeModel):
        subscription = subscription.id
    stripe_invoiceitem = InvoiceItem._api_create(
        amount=int(amount * 100),  # Convert dollars into cents
        currency=currency,
        customer=self.id,
        description=description,
        discountable=discountable,
        invoice=invoice,
        metadata=metadata,
        subscription=subscription,
    )
    return InvoiceItem.sync_from_stripe_data(stripe_invoiceitem)
djstripe.models.core.Customer.add_payment_method(self, payment_method, set_default=True)
    Adds an already existing payment method to this customer's account
:param payment_method: PaymentMethod to be attached to the customer :type payment_method: str, PaymentMethod :param set_default: If true, this will be set as the default_payment_method :type set_default: bool :rtype: PaymentMethod
Source code in djstripe/models/core.py
          def add_payment_method(self, payment_method, set_default=True):
    """
    Adds an already existing payment method to this customer's account
    :param payment_method: PaymentMethod to be attached to the customer
    :type payment_method: str, PaymentMethod
    :param set_default: If true, this will be set as the default_payment_method
    :type set_default: bool
    :rtype: PaymentMethod
    """
    from .payment_methods import PaymentMethod
    stripe_customer = self.api_retrieve()
    payment_method = PaymentMethod.attach(payment_method, stripe_customer)
    if set_default:
        stripe_customer["invoice_settings"][
            "default_payment_method"
        ] = payment_method.id
        stripe_customer.save()
        # Refresh self from the stripe customer, this should have two effects:
        # 1) sets self.default_payment_method (we rely on logic in
        # Customer._manipulate_stripe_object_hook to do this)
        # 2) updates self.invoice_settings.default_payment_methods
        self.sync_from_stripe_data(stripe_customer)
        self.refresh_from_db()
    return payment_method
djstripe.models.core.Customer.can_charge(self)
    Determines if this customer is able to be charged.
Source code in djstripe/models/core.py
          def can_charge(self):
    """Determines if this customer is able to be charged."""
    return (
        self.has_valid_source() or self.default_payment_method is not None
    ) and self.date_purged is None
djstripe.models.core.Customer.charge(self, amount, *, application_fee=None, source=None, **kwargs)
    Creates a charge for this customer.
:param amount: The amount to charge. :type amount: Decimal. Precision is 2; anything more will be ignored. :param 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. :type source: string, Source
Source code in djstripe/models/core.py
          def charge(
    self,
    amount: Decimal,
    *,
    application_fee: Decimal = None,
    source: Union[str, StripeModel] = None,
    **kwargs,
) -> Charge:
    """
    Creates a charge for this customer.
    :param amount: The amount to charge.
    :type amount: Decimal. Precision is 2; anything more will be ignored.
    :param 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.
    :type source: string, Source
    """
    if not isinstance(amount, Decimal):
        raise ValueError("You must supply a decimal value representing dollars.")
    # Convert Source to id
    if source and isinstance(source, StripeModel):
        source = source.id
    stripe_charge = Charge._api_create(
        customer=self.id,
        amount=int(amount * 100),  # Convert dollars into cents
        application_fee=int(application_fee * 100)
        if application_fee
        else None,  # Convert dollars into cents
        source=source,
        **kwargs,
    )
    return Charge.sync_from_stripe_data(stripe_charge)
djstripe.models.core.Customer.create(subscriber, idempotency_key=None, stripe_account=None)
  
      classmethod
  
    Source code in djstripe/models/core.py
          @classmethod
def create(cls, subscriber, idempotency_key=None, stripe_account=None):
    metadata = {}
    subscriber_key = djstripe_settings.SUBSCRIBER_CUSTOMER_KEY
    if subscriber_key not in ("", None):
        metadata[subscriber_key] = subscriber.pk
    stripe_customer = cls._api_create(
        email=subscriber.email,
        idempotency_key=idempotency_key,
        metadata=metadata,
        stripe_account=stripe_account,
    )
    customer, created = Customer.objects.get_or_create(
        id=stripe_customer["id"],
        defaults={
            "subscriber": subscriber,
            "livemode": stripe_customer["livemode"],
            "balance": stripe_customer.get("balance", 0),
            "delinquent": stripe_customer.get("delinquent", False),
        },
    )
    return customer
djstripe.models.core.Customer.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Customer.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Customer.get_or_create(subscriber, livemode=False, stripe_account=None)
  
      classmethod
  
    Get or create a dj-stripe customer.
:param subscriber: The subscriber model instance for which to get or create a customer. :type subscriber: User
:param livemode: Whether to get the subscriber in live or test mode. :type livemode: bool
Source code in djstripe/models/core.py
          @classmethod
def get_or_create(
    cls,
    subscriber,
    livemode=djstripe_settings.STRIPE_LIVE_MODE,
    stripe_account=None,
):
    """
    Get or create a dj-stripe customer.
    :param subscriber: The subscriber model instance for which to get or
        create a customer.
    :type subscriber: User
    :param livemode: Whether to get the subscriber in live or test mode.
    :type livemode: bool
    """
    try:
        return Customer.objects.get(subscriber=subscriber, livemode=livemode), False
    except Customer.DoesNotExist:
        action = "create:{}".format(subscriber.pk)
        idempotency_key = djstripe_settings.get_idempotency_key(
            "customer", action, livemode
        )
        return (
            cls.create(
                subscriber,
                idempotency_key=idempotency_key,
                stripe_account=stripe_account,
            ),
            True,
        )
djstripe.models.core.Customer.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Customer.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Customer.get_tax_exempt_display(self, *, field=<djstripe.fields.StripeEnumField: tax_exempt>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Customer.has_any_active_subscription(self)
    Checks to see if this customer has an active subscription to any plan.
:returns: True if there exists an active subscription, False otherwise.
Source code in djstripe/models/core.py
          def has_any_active_subscription(self):
    """
    Checks to see if this customer has an active subscription to any plan.
    :returns: True if there exists an active subscription, False otherwise.
    """
    return len(self._get_valid_subscriptions()) != 0
djstripe.models.core.Customer.has_valid_source(self)
    Check whether the customer has a valid payment source.
Source code in djstripe/models/core.py
          def has_valid_source(self):
    """Check whether the customer has a valid payment source."""
    return self.default_source is not None
djstripe.models.core.Customer.is_subscribed_to(self, product)
    Checks to see if this customer has an active subscription to the given product.
:param product: The product for which to check for an active subscription. :type product: Product or string (product ID)
:returns: True if there exists an active subscription, False otherwise.
Source code in djstripe/models/core.py
          def is_subscribed_to(self, product: Union[Product, str]) -> bool:
    """
    Checks to see if this customer has an active subscription to the given product.
    :param product: The product for which to check for an active subscription.
    :type product: Product or string (product ID)
    :returns: True if there exists an active subscription, False otherwise.
    """
    if isinstance(product, StripeModel):
        product = product.id
    for subscription in self._get_valid_subscriptions():
        for item in subscription.items.all():
            if item.price and item.price.product.id == product:
                return True
    return False
djstripe.models.core.Customer.purge(self)
    Customers are soft deleted as deleted customers are still accessible by the Stripe API and sync for all RelatedModels would fail
Source code in djstripe/models/core.py
          def purge(self):
    """Customers are soft deleted as deleted customers are still accessible by the
    Stripe API and sync for all RelatedModels would fail"""
    try:
        self._api_delete()
    except InvalidRequestError as exc:
        if "No such customer:" in str(exc):
            # The exception was thrown because the stripe customer was already
            # deleted on the stripe side, ignore the exception
            pass
        else:
            # The exception was raised for another reason, re-raise it
            raise
    # toggle the deleted flag on Customer to indicate it has been
    # deleted upstream in Stripe
    self.deleted = True
    if self.subscriber:
        # Delete the idempotency key used by Customer.create()
        # So re-creating a customer for this subscriber before the key expires
        # doesn't return the older Customer data
        idempotency_key_action = "customer:create:{}".format(self.subscriber.pk)
        IdempotencyKey.objects.filter(action=idempotency_key_action).delete()
    self.subscriber = None
    # Remove sources
    self.default_source = None
    for source in self.legacy_cards.all():
        source.remove()
    for source in self.sources.all():
        source.detach()
    self.date_purged = timezone.now()
    self.save()
djstripe.models.core.Customer.retry_unpaid_invoices(self)
    Attempt to retry collecting payment on the customer's unpaid invoices.
Source code in djstripe/models/core.py
          def retry_unpaid_invoices(self):
    """Attempt to retry collecting payment on the customer's unpaid invoices."""
    self._sync_invoices()
    for invoice in self.invoices.filter(auto_advance=True).exclude(status="paid"):
        try:
            invoice.retry()  # Always retry unpaid invoices
        except InvalidRequestError as exc:
            if str(exc) != "Invoice is already paid":
                raise
djstripe.models.core.Customer.send_invoice(self)
    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).
Source code in djstripe/models/core.py
          def send_invoice(self):
    """
    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).
    """
    from .billing import Invoice
    try:
        invoice = Invoice._api_create(customer=self.id)
        invoice.pay()
        return True
    except InvalidRequestError:  # TODO: Check this for a more
        #                           specific error message.
        return False  # There was nothing to invoice
djstripe.models.core.Customer.subscribe(self, *, items=None, price=None, plan=None, **kwargs)
    Subscribes this customer to all the prices or plans in the items dict (Recommended).
:param items: A list of up to 20 subscription items, each with an attached price :type list: :param items: A dictionary of Plan (or Plan ID) or Price (or Price ID) :type dict: The price or plan to which to subscribe the customer.
:param price: The price to which to subscribe the customer. :type price: Price or string (price ID)
:param plan: The plan to which to subscribe the customer. :type plan: Plan or string (plan ID)
Source code in djstripe/models/core.py
          def subscribe(self, *, items=None, price=None, plan=None, **kwargs):
    """
    Subscribes this customer to all the prices or plans in the items dict (Recommended).
    :param items: A list of up to 20 subscription items, each with an attached price
    :type list:
        :param items: A dictionary of Plan (or Plan ID) or Price (or Price ID)
        :type dict:  The price or plan to which to subscribe the customer.
    :param price: The price to which to subscribe the customer.
    :type price: Price or string (price ID)
    :param plan: The plan to which to subscribe the customer.
    :type plan: Plan or string (plan ID)
    """
    from .billing import Subscription
    products_lst = []
    if (items and price) or (items and plan) or (price and plan):
        raise TypeError("Please define only one of items, price or plan arguments.")
    if items:
        for item in items:
            price = item.get("price", "")
            plan = item.get("plan", "")
            price, kwargs = self._sanitise_price(price, plan, **kwargs)
            # todo override Subscription.sync_from_stripe_data to attach all subscriptions to the customer using bulk updates
            stripe_subscription = Subscription._api_create(
                items=[item], customer=self.id, **kwargs
            )
            Subscription.sync_from_stripe_data(stripe_subscription)
            # get associated product
            product_name = Price.objects.get(id=price).product.name
            # keep count of products subscribed to
            products_lst.append(product_name)
    else:
        warnings.warn(
            "The Customer.subscribe() method will not be accepting price (or price id)"
            " or plan (or plan id) arguments and support will be removed in dj-stripe 2.5+."
            " Please default to using the items dictionary which will allow you to subscribe"
            " the given customer to one or more than one plan in one go.",
            DeprecationWarning,
        )
        price, kwargs = self._sanitise_price(price, plan, **kwargs)
        stripe_subscription = Subscription._api_create(
            items=[{"price": price}], customer=self.id, **kwargs
        )
        Subscription.sync_from_stripe_data(stripe_subscription)
        # get associated product
        product_name = Price.objects.get(id=price).product.name
        # keep count of products subscribed to
        products_lst.append(product_name)
    return f"Subscribed {self} to {' and '.join(products_lst)}"
djstripe.models.core.Customer.upcoming_invoice(self, **kwargs)
    Gets the upcoming preview invoice (singular) for this customer.
See Invoice.upcoming() <#djstripe.Invoice.upcoming>__.
The customer argument to the upcoming() call is automatically set
 by this method.
Source code in djstripe/models/core.py
          def upcoming_invoice(self, **kwargs):
    """Gets the upcoming preview invoice (singular) for this customer.
    See `Invoice.upcoming() <#djstripe.Invoice.upcoming>`__.
    The ``customer`` argument to the ``upcoming()`` call is automatically set
     by this method.
    """
    from .billing import Invoice
    kwargs["customer"] = self
    return Invoice.upcoming(**kwargs)
        
djstripe.models.core.Dispute        
    A dispute occurs when a customer questions your charge with their card issuer. When this happens, you're given the opportunity to respond to the dispute with evidence that shows that the charge is legitimate
Stripe documentation: https://stripe.com/docs/api#disputes
djstripe.models.core.Dispute.amount
    
djstripe.models.core.Dispute.balance_transaction
    
djstripe.models.core.Dispute.balance_transactions
    
djstripe.models.core.Dispute.charge
    
djstripe.models.core.Dispute.currency
    
djstripe.models.core.Dispute.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Dispute.evidence
    
djstripe.models.core.Dispute.evidence_details
    
djstripe.models.core.Dispute.is_charge_refundable
    
djstripe.models.core.Dispute.payment_intent
    
djstripe.models.core.Dispute.reason
    
djstripe.models.core.Dispute.status
    
djstripe.models.core.Dispute.stripe_dashboard_item_name
    
        
djstripe.models.core.Dispute.DoesNotExist        
    
        
djstripe.models.core.Dispute.MultipleObjectsReturned        
    
        
djstripe.models.core.Dispute.stripe_class        
    djstripe.models.core.Dispute.stripe_class.OBJECT_NAME
djstripe.models.core.Dispute.stripe_class.close(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def close(self, idempotency_key=None, **params):
    url = self.instance_url() + "/close"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.Dispute.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return f"{self.human_readable_amount} ({enums.DisputeStatus.humanize(self.status)}) "
djstripe.models.core.Dispute.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Dispute.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Dispute.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Dispute.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Dispute.get_reason_display(self, *, field=<djstripe.fields.StripeEnumField: reason>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Dispute.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.core.Event        
    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
djstripe.models.core.Event.api_version
    
djstripe.models.core.Event.customer
  
      property
      readonly
  
    
djstripe.models.core.Event.data
    
djstripe.models.core.Event.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Event.idempotency_key
    
djstripe.models.core.Event.request_id
    
djstripe.models.core.Event.stripe_dashboard_item_name
    
djstripe.models.core.Event.type
    
        
djstripe.models.core.Event.DoesNotExist        
    
        
djstripe.models.core.Event.MultipleObjectsReturned        
    
        
djstripe.models.core.Event.stripe_class        
    Methods
djstripe.models.core.Event.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return f"type={self.type}, id={self.id}"
djstripe.models.core.Event.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Event.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Event.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Event.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Event.invoke_webhook_handlers(self)
    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).
Source code in djstripe/models/core.py
          def invoke_webhook_handlers(self):
    """
    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).
    """
    webhooks.call_handlers(event=self)
    signal = WEBHOOK_SIGNALS.get(self.type)
    if signal:
        return signal.send(sender=Event, event=self)
djstripe.models.core.Event.process(data)
  
      classmethod
  
    Source code in djstripe/models/core.py
          @classmethod
def process(cls, data):
    qs = cls.objects.filter(id=data["id"])
    if qs.exists():
        return qs.first()
    # Rollback any DB operations in the case of failure so
    # we will retry creating and processing the event the
    # next time the webhook fires.
    with transaction.atomic():
        # process the event and create an Event Object
        ret = cls._create_from_stripe_object(data)
        ret.invoke_webhook_handlers()
        return ret
        
djstripe.models.core.File        
    Stripe documentation: https://stripe.com/docs/api/files
djstripe.models.core.File.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.File.filename
    
djstripe.models.core.File.purpose
    
djstripe.models.core.File.size
    
djstripe.models.core.File.type
    
djstripe.models.core.File.url
    
        
djstripe.models.core.File.DoesNotExist        
    
        
djstripe.models.core.File.MultipleObjectsReturned        
    
        
djstripe.models.core.File.stripe_class        
    djstripe.models.core.File.stripe_class.OBJECT_NAME
djstripe.models.core.File.stripe_class.OBJECT_NAME_ALT
djstripe.models.core.File.stripe_class.class_url()
  
      classmethod
  
Source code in djstripe/models/core.py
          @classmethod
def class_url(cls):
    return "/v1/files"
djstripe.models.core.File.stripe_class.create(api_key=None, api_version=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          @classmethod
def create(
    # 'api_version' is deprecated, please use 'stripe_version'
    cls,
    api_key=None,
    api_version=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    version = api_version or stripe_version
    requestor = api_requestor.APIRequestor(
        api_key,
        api_base=stripe.upload_api_base,
        api_version=version,
        account=stripe_account,
    )
    url = cls.class_url()
    supplied_headers = {"Content-Type": "multipart/form-data"}
    response, api_key = requestor.request(
        "post", url, params=params, headers=supplied_headers
    )
    return util.convert_to_stripe_object(
        response, api_key, version, stripe_account
    )
Methods
djstripe.models.core.File.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return f"{self.filename}, {enums.FilePurpose.humanize(self.purpose)}"
djstripe.models.core.File.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.File.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.File.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.File.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.File.get_purpose_display(self, *, field=<djstripe.fields.StripeEnumField: purpose>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.File.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.File.is_valid_object(data)
  
      classmethod
  
    Returns whether the data is a valid object for the class
Source code in djstripe/models/core.py
          @classmethod
def is_valid_object(cls, data):
    return "object" in data and data["object"] in ("file", "file_upload")
        
djstripe.models.core.FileLink        
    Stripe documentation: https://stripe.com/docs/api/file_links
djstripe.models.core.FileLink.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.FileLink.expires_at
    
djstripe.models.core.FileLink.file
    
djstripe.models.core.FileLink.url
    
        
djstripe.models.core.FileLink.DoesNotExist        
    
        
djstripe.models.core.FileLink.MultipleObjectsReturned        
    
        
djstripe.models.core.FileLink.stripe_class        
    
djstripe.models.core.FileLink.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return f"{self.file.filename}, {self.url}"
djstripe.models.core.FileLink.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileLink.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileLink.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileLink.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.core.FileUpload        
    Stripe documentation: https://stripe.com/docs/api/files
djstripe.models.core.FileUpload.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.FileUpload.filename
    
djstripe.models.core.FileUpload.purpose
    
djstripe.models.core.FileUpload.size
    
djstripe.models.core.FileUpload.type
    
djstripe.models.core.FileUpload.url
    
        
djstripe.models.core.FileUpload.DoesNotExist        
    
        
djstripe.models.core.FileUpload.MultipleObjectsReturned        
    
        
djstripe.models.core.FileUpload.stripe_class        
    djstripe.models.core.FileUpload.stripe_class.OBJECT_NAME
djstripe.models.core.FileUpload.stripe_class.OBJECT_NAME_ALT
djstripe.models.core.FileUpload.stripe_class.class_url()
  
      classmethod
  
Source code in djstripe/models/core.py
          @classmethod
def class_url(cls):
    return "/v1/files"
djstripe.models.core.FileUpload.stripe_class.create(api_key=None, api_version=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/core.py
          @classmethod
def create(
    # 'api_version' is deprecated, please use 'stripe_version'
    cls,
    api_key=None,
    api_version=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    version = api_version or stripe_version
    requestor = api_requestor.APIRequestor(
        api_key,
        api_base=stripe.upload_api_base,
        api_version=version,
        account=stripe_account,
    )
    url = cls.class_url()
    supplied_headers = {"Content-Type": "multipart/form-data"}
    response, api_key = requestor.request(
        "post", url, params=params, headers=supplied_headers
    )
    return util.convert_to_stripe_object(
        response, api_key, version, stripe_account
    )
Methods
djstripe.models.core.FileUpload.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return f"{self.filename}, {enums.FilePurpose.humanize(self.purpose)}"
djstripe.models.core.FileUpload.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileUpload.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileUpload.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileUpload.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileUpload.get_purpose_display(self, *, field=<djstripe.fields.StripeEnumField: purpose>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileUpload.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.FileUpload.is_valid_object(data)
  
      classmethod
  
    Returns whether the data is a valid object for the class
Source code in djstripe/models/core.py
          @classmethod
def is_valid_object(cls, data):
    return "object" in data and data["object"] in ("file", "file_upload")
        
djstripe.models.core.Mandate        
    https://stripe.com/docs/api/mandates
djstripe.models.core.Mandate.customer_acceptance
    
djstripe.models.core.Mandate.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Mandate.multi_use
    
djstripe.models.core.Mandate.payment_method
    
djstripe.models.core.Mandate.payment_method_details
    
djstripe.models.core.Mandate.single_use
    
djstripe.models.core.Mandate.status
    
djstripe.models.core.Mandate.type
    
        
djstripe.models.core.Mandate.DoesNotExist        
    
        
djstripe.models.core.Mandate.MultipleObjectsReturned        
    
        
djstripe.models.core.Mandate.stripe_class        
    
djstripe.models.core.Mandate.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Mandate.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Mandate.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Mandate.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Mandate.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Mandate.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.core.PaymentIntent        
    Stripe documentation: https://stripe.com/docs/api#payment_intents
djstripe.models.core.PaymentIntent.amount
    
djstripe.models.core.PaymentIntent.amount_capturable
    
djstripe.models.core.PaymentIntent.amount_received
    
djstripe.models.core.PaymentIntent.canceled_at
    
djstripe.models.core.PaymentIntent.cancellation_reason
    
djstripe.models.core.PaymentIntent.capture_method
    
djstripe.models.core.PaymentIntent.client_secret
    
djstripe.models.core.PaymentIntent.confirmation_method
    
djstripe.models.core.PaymentIntent.currency
    
djstripe.models.core.PaymentIntent.customer
    
djstripe.models.core.PaymentIntent.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.PaymentIntent.last_payment_error
    
djstripe.models.core.PaymentIntent.next_action
    
djstripe.models.core.PaymentIntent.on_behalf_of
    
djstripe.models.core.PaymentIntent.payment_method
    
djstripe.models.core.PaymentIntent.payment_method_types
    
djstripe.models.core.PaymentIntent.receipt_email
    
djstripe.models.core.PaymentIntent.setup_future_usage
    
djstripe.models.core.PaymentIntent.shipping
    
djstripe.models.core.PaymentIntent.statement_descriptor
    
djstripe.models.core.PaymentIntent.status
    
djstripe.models.core.PaymentIntent.stripe_dashboard_item_name
    
djstripe.models.core.PaymentIntent.transfer_data
    
djstripe.models.core.PaymentIntent.transfer_group
    
        
djstripe.models.core.PaymentIntent.DoesNotExist        
    
        
djstripe.models.core.PaymentIntent.MultipleObjectsReturned        
    
        
djstripe.models.core.PaymentIntent.stripe_class        
    djstripe.models.core.PaymentIntent.stripe_class.OBJECT_NAME
djstripe.models.core.PaymentIntent.stripe_class.cancel(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def cancel(self, idempotency_key=None, **params):
    url = self.instance_url() + "/cancel"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.PaymentIntent.stripe_class.capture(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def capture(self, idempotency_key=None, **params):
    url = self.instance_url() + "/capture"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.PaymentIntent.stripe_class.confirm(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def confirm(self, idempotency_key=None, **params):
    url = self.instance_url() + "/confirm"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
Methods
djstripe.models.core.PaymentIntent.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    account = self.on_behalf_of
    customer = self.customer
    if account and customer:
        return (
            f"{self.human_readable_amount} ({enums.PaymentIntentStatus.humanize(self.status)}) "
            f"for {account} "
            f"by {customer}"
        )
    if account:
        return f"{self.human_readable_amount} for {account}. {enums.PaymentIntentStatus.humanize(self.status)}"
    if customer:
        return f"{self.human_readable_amount} by {customer}. {enums.PaymentIntentStatus.humanize(self.status)}"
    return f"{self.human_readable_amount} ({enums.PaymentIntentStatus.humanize(self.status)})"
djstripe.models.core.PaymentIntent.get_cancellation_reason_display(self, *, field=<djstripe.fields.StripeEnumField: cancellation_reason>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_capture_method_display(self, *, field=<djstripe.fields.StripeEnumField: capture_method>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_confirmation_method_display(self, *, field=<djstripe.fields.StripeEnumField: confirmation_method>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_setup_future_usage_display(self, *, field=<djstripe.fields.StripeEnumField: setup_future_usage>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.PaymentIntent.update(self, api_key=None, **kwargs)
    Call the stripe API's modify operation for this model
:param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string
Source code in djstripe/models/core.py
          def update(self, api_key=None, **kwargs):
    """
    Call the stripe API's modify operation for this model
    :param api_key: The api key to use for this request.
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    """
    api_key = api_key or self.default_api_key
    response = self.api_retrieve(api_key=api_key)
    return response.modify(response.stripe_id, api_key=api_key, **kwargs)
        
djstripe.models.core.Payout        
    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
djstripe.models.core.Payout.amount
    
djstripe.models.core.Payout.arrival_date
    
djstripe.models.core.Payout.automatic
    
djstripe.models.core.Payout.balance_transaction
    
djstripe.models.core.Payout.currency
    
djstripe.models.core.Payout.destination
    
djstripe.models.core.Payout.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Payout.expand_fields: List[str]
    
djstripe.models.core.Payout.failure_balance_transaction
    
djstripe.models.core.Payout.failure_code
    
djstripe.models.core.Payout.failure_message
    
djstripe.models.core.Payout.method
    
djstripe.models.core.Payout.source_type
    
djstripe.models.core.Payout.statement_descriptor
    
djstripe.models.core.Payout.status
    
djstripe.models.core.Payout.stripe_dashboard_item_name
    
djstripe.models.core.Payout.type
    
        
djstripe.models.core.Payout.DoesNotExist        
    
        
djstripe.models.core.Payout.MultipleObjectsReturned        
    
        
djstripe.models.core.Payout.stripe_class        
    djstripe.models.core.Payout.stripe_class.OBJECT_NAME
djstripe.models.core.Payout.stripe_class.cancel(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def cancel(self, idempotency_key=None, **params):
    url = self.instance_url() + "/cancel"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.Payout.stripe_class.reverse(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def reverse(self, idempotency_key=None, **params):
    url = self.instance_url() + "/reverse"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.Payout.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return f"{self.amount} ({enums.PayoutStatus.humanize(self.status)})"
djstripe.models.core.Payout.get_failure_code_display(self, *, field=<djstripe.fields.StripeEnumField: failure_code>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_method_display(self, *, field=<djstripe.fields.StripeEnumField: method>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_next_by_arrival_date(self, *, field=<djstripe.fields.StripeDateTimeField: arrival_date>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_previous_by_arrival_date(self, *, field=<djstripe.fields.StripeDateTimeField: arrival_date>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_source_type_display(self, *, field=<djstripe.fields.StripeEnumField: source_type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Payout.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.core.Price        
    Prices define the unit cost, currency, and (optional) billing cycle for both recurring and one-time purchases of products.
Price and Plan objects are the same, but use a different representation. Creating a recurring Price in Stripe also makes a Plan available, and vice versa. This is not the case for a Price with interval=one_time.
Price objects are a more recent API representation, support more features and its usage is encouraged instead of Plan objects.
Stripe documentation: - https://stripe.com/docs/api/prices - https://stripe.com/docs/billing/prices-guide
djstripe.models.core.Price.active
    
djstripe.models.core.Price.billing_scheme
    
djstripe.models.core.Price.currency
    
djstripe.models.core.Price.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Price.expand_fields: List[str]
    
djstripe.models.core.Price.human_readable_price
  
      property
      readonly
  
    
djstripe.models.core.Price.lookup_key
    
djstripe.models.core.Price.nickname
    
djstripe.models.core.Price.product
    
djstripe.models.core.Price.recurring
    
djstripe.models.core.Price.stripe_dashboard_item_name
    
djstripe.models.core.Price.tiers
    
djstripe.models.core.Price.tiers_mode
    
djstripe.models.core.Price.transform_quantity
    
djstripe.models.core.Price.type
    
djstripe.models.core.Price.unit_amount
    
djstripe.models.core.Price.unit_amount_decimal
    
        
djstripe.models.core.Price.DoesNotExist        
    
        
djstripe.models.core.Price.MultipleObjectsReturned        
    
        
djstripe.models.core.Price.stripe_class        
    Methods
djstripe.models.core.Price.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    from .billing import Subscription
    subscriptions = Subscription.objects.filter(plan__id=self.id).count()
    if self.recurring:
        return f"{self.human_readable_price} for {self.product.name} ({subscriptions} subscriptions)"
    return f"{self.human_readable_price} for {self.product.name}"
djstripe.models.core.Price.create(**kwargs)
  
      classmethod
  
    Source code in djstripe/models/core.py
          @classmethod
def create(cls, **kwargs):
    # A few minor things are changed in the api-version of the create call
    api_kwargs = dict(kwargs)
    api_kwargs["unit_amount"] = int(api_kwargs["unit_amount"] * 100)
    if isinstance(api_kwargs.get("product"), StripeModel):
        api_kwargs["product"] = api_kwargs["product"].id
    stripe_price = cls._api_create(**api_kwargs)
    price = cls.sync_from_stripe_data(stripe_price)
    return price
djstripe.models.core.Price.get_billing_scheme_display(self, *, field=<djstripe.fields.StripeEnumField: billing_scheme>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Price.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Price.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Price.get_or_create(**kwargs)
  
      classmethod
  
    Get or create a Price.
Source code in djstripe/models/core.py
          @classmethod
def get_or_create(cls, **kwargs):
    """Get or create a Price."""
    try:
        return Price.objects.get(id=kwargs["id"]), False
    except Price.DoesNotExist:
        return cls.create(**kwargs), True
djstripe.models.core.Price.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Price.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Price.get_tiers_mode_display(self, *, field=<djstripe.fields.StripeEnumField: tiers_mode>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Price.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.core.Product        
    Stripe documentation: - https://stripe.com/docs/api#products
djstripe.models.core.Product.active
    
djstripe.models.core.Product.attributes
    
djstripe.models.core.Product.caption
    
djstripe.models.core.Product.deactivate_on
    
djstripe.models.core.Product.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Product.images
    
djstripe.models.core.Product.name
    
djstripe.models.core.Product.package_dimensions
    
djstripe.models.core.Product.shippable
    
djstripe.models.core.Product.statement_descriptor
    
djstripe.models.core.Product.stripe_dashboard_item_name
    
djstripe.models.core.Product.type
    
djstripe.models.core.Product.unit_label
    
djstripe.models.core.Product.url
    
        
djstripe.models.core.Product.DoesNotExist        
    
        
djstripe.models.core.Product.MultipleObjectsReturned        
    
        
djstripe.models.core.Product.stripe_class        
    
djstripe.models.core.Product.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    # 1 product can have 1 or more than 1 related price
    price_qs = Price.objects.filter(product__id=self.id)
    price_count = price_qs.count()
    if price_count > 1:
        return f"{self.name} ({price_count} prices)"
    elif price_count == 1:
        return f"{self.name} ({price_qs[0].human_readable_price})"
    else:
        return self.name
djstripe.models.core.Product.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Product.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Product.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Product.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Product.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.core.Refund        
    Stripe documentation: https://stripe.com/docs/api#refund_object
djstripe.models.core.Refund.amount
    
djstripe.models.core.Refund.balance_transaction
    
djstripe.models.core.Refund.charge
    
djstripe.models.core.Refund.currency
    
djstripe.models.core.Refund.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.Refund.failure_balance_transaction
    
djstripe.models.core.Refund.failure_reason
    
djstripe.models.core.Refund.reason
    
djstripe.models.core.Refund.receipt_number
    
djstripe.models.core.Refund.status
    
        
djstripe.models.core.Refund.DoesNotExist        
    
        
djstripe.models.core.Refund.MultipleObjectsReturned        
    
        
djstripe.models.core.Refund.stripe_class        
    Methods
djstripe.models.core.Refund.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    return (
        f"{self.human_readable_amount} ({enums.RefundStatus.humanize(self.status)})"
    )
djstripe.models.core.Refund.get_failure_reason_display(self, *, field=<djstripe.fields.StripeEnumField: failure_reason>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Refund.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Refund.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Refund.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Refund.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Refund.get_reason_display(self, *, field=<djstripe.fields.StripeEnumField: reason>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Refund.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.Refund.get_stripe_dashboard_url(self)
    Get the stripe dashboard url for this object.
Source code in djstripe/models/core.py
          def get_stripe_dashboard_url(self):
    return self.charge.get_stripe_dashboard_url()
        
djstripe.models.core.SetupIntent        
    A SetupIntent guides you through the process of setting up a customer's payment credentials for future payments. For example, you could use a SetupIntent to set up your customer's card without immediately collecting a payment. Later, you can use PaymentIntents to drive the payment flow.
NOTE: You should not maintain long-lived, unconfirmed SetupIntents. For security purposes, SetupIntents older than 24 hours may no longer be valid.
Stripe documentation: https://stripe.com/docs/api#setup_intents
djstripe.models.core.SetupIntent.application
    
djstripe.models.core.SetupIntent.cancellation_reason
    
djstripe.models.core.SetupIntent.client_secret
    
djstripe.models.core.SetupIntent.customer
    
djstripe.models.core.SetupIntent.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.core.SetupIntent.last_setup_error
    
djstripe.models.core.SetupIntent.next_action
    
djstripe.models.core.SetupIntent.on_behalf_of
    
djstripe.models.core.SetupIntent.payment_method
    
djstripe.models.core.SetupIntent.payment_method_types
    
djstripe.models.core.SetupIntent.status
    
djstripe.models.core.SetupIntent.usage
    
        
djstripe.models.core.SetupIntent.DoesNotExist        
    
        
djstripe.models.core.SetupIntent.MultipleObjectsReturned        
    
        
djstripe.models.core.SetupIntent.stripe_class        
    djstripe.models.core.SetupIntent.stripe_class.OBJECT_NAME
djstripe.models.core.SetupIntent.stripe_class.cancel(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def cancel(self, idempotency_key=None, **params):
    url = self.instance_url() + "/cancel"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.SetupIntent.stripe_class.confirm(self, idempotency_key=None, **params)
Source code in djstripe/models/core.py
          def confirm(self, idempotency_key=None, **params):
    url = self.instance_url() + "/confirm"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.core.SetupIntent.__str__(self)
  
      special
  
    Source code in djstripe/models/core.py
          def __str__(self):
    account = self.on_behalf_of
    customer = self.customer
    if account and customer:
        return (
            f"{self.payment_method} ({enums.SetupIntentStatus.humanize(self.status)}) "
            f"for {account} "
            f"by {customer}"
        )
    if account:
        return f"{self.payment_method} for {account}. {enums.SetupIntentStatus.humanize(self.status)}"
    if customer:
        return f"{self.payment_method} by {customer}. {enums.SetupIntentStatus.humanize(self.status)}"
    return (
        f"{self.payment_method} ({enums.SetupIntentStatus.humanize(self.status)})"
    )
djstripe.models.core.SetupIntent.get_cancellation_reason_display(self, *, field=<djstripe.fields.StripeEnumField: cancellation_reason>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.SetupIntent.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.SetupIntent.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.SetupIntent.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.SetupIntent.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.SetupIntent.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.core.SetupIntent.get_usage_display(self, *, field=<djstripe.fields.StripeEnumField: usage>)
    Source code in djstripe/models/core.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
Payment Methods
Classes
        
djstripe.models.payment_methods.BankAccount        
    BankAccount(djstripe_created, djstripe_updated, djstripe_id, id, djstripe_owner_account, livemode, created, metadata, description, account, account_holder_name, account_holder_type, bank_name, country, currency, customer, default_for_currency, fingerprint, last4, routing_number, status)
djstripe.models.payment_methods.BankAccount.account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.BankAccount.account_holder_name
    
djstripe.models.payment_methods.BankAccount.account_holder_type
    
djstripe.models.payment_methods.BankAccount.bank_name
    
djstripe.models.payment_methods.BankAccount.country
    
djstripe.models.payment_methods.BankAccount.currency
    
djstripe.models.payment_methods.BankAccount.customer: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.BankAccount.default_for_currency
    
djstripe.models.payment_methods.BankAccount.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.BankAccount.fingerprint
    
djstripe.models.payment_methods.BankAccount.human_readable_status
  
      property
      readonly
  
    
djstripe.models.payment_methods.BankAccount.last4
    
djstripe.models.payment_methods.BankAccount.routing_number
    
djstripe.models.payment_methods.BankAccount.status
    
        
djstripe.models.payment_methods.BankAccount.DoesNotExist        
    
        
djstripe.models.payment_methods.BankAccount.MultipleObjectsReturned        
    
        
djstripe.models.payment_methods.BankAccount.stripe_class        
    djstripe.models.payment_methods.BankAccount.stripe_class.OBJECT_NAME
djstripe.models.payment_methods.BankAccount.stripe_class.instance_url(self)
Source code in djstripe/models/payment_methods.py
          def instance_url(self):
    token = util.utf8(self.id)
    extn = quote_plus(token)
    if hasattr(self, "customer"):
        customer = util.utf8(self.customer)
        base = Customer.class_url()
        owner_extn = quote_plus(customer)
        class_base = "sources"
    elif hasattr(self, "account"):
        account = util.utf8(self.account)
        base = Account.class_url()
        owner_extn = quote_plus(account)
        class_base = "external_accounts"
    else:
        raise error.InvalidRequestError(
            "Could not determine whether bank_account_id %s is "
            "attached to a customer or an account." % token,
            "id",
        )
    return "%s/%s/%s/%s" % (base, owner_extn, class_base, extn)
djstripe.models.payment_methods.BankAccount.stripe_class.modify(sid, **params)
  
      classmethod
  
Source code in djstripe/models/payment_methods.py
          @classmethod
def modify(cls, sid, **params):
    raise NotImplementedError(
        "Can't modify a bank account without a customer or account ID. "
        "Call save on customer.sources.retrieve('bank_account_id') or "
        "account.external_accounts.retrieve('bank_account_id') instead."
    )
djstripe.models.payment_methods.BankAccount.stripe_class.retrieve(id, api_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/payment_methods.py
          @classmethod
def retrieve(
    cls,
    id,
    api_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    raise NotImplementedError(
        "Can't retrieve a bank account without a customer or account ID. "
        "Use customer.sources.retrieve('bank_account_id') or "
        "account.external_accounts.retrieve('bank_account_id') instead."
    )
Methods
djstripe.models.payment_methods.BankAccount.__str__(self)
  
      special
  
    Source code in djstripe/models/payment_methods.py
          def __str__(self):
    default = False
    # prefer to show it by customer format if present
    if self.customer:
        default_source = self.customer.default_source
        default_payment_method = self.customer.default_payment_method
        if (default_payment_method and self.id == default_payment_method.id) or (
            default_source and self.id == default_source.id
        ):
            # current card is the default payment method or source
            default = True
        customer_template = f"{self.bank_name} {self.routing_number} ({self.human_readable_status}) {'Default' if default else ''} {self.currency}"
        return customer_template
    elif self.account:
        default = getattr(self, "default_for_currency", False)
        account_template = f"{self.bank_name} {self.currency} {'Default' if default else ''} {self.routing_number} {self.last4}"
        return account_template
djstripe.models.payment_methods.BankAccount.api_retrieve(self, **kwargs)
    Call the stripe API's retrieve operation for this model.
:param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string :param stripe_account: The optional connected account for which this request is being made. :type stripe_account: string
Source code in djstripe/models/payment_methods.py
          def api_retrieve(self, **kwargs):
    if not self.customer and not self.account:
        raise NotImplementedError(
            "Can't retrieve a bank account without a customer or account object."
        )
    return super().api_retrieve(**kwargs)
djstripe.models.payment_methods.BankAccount.get_account_holder_type_display(self, *, field=<djstripe.fields.StripeEnumField: account_holder_type>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.BankAccount.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.BankAccount.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.BankAccount.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.BankAccount.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.BankAccount.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.payment_methods.Card        
    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?lang=python#cards
djstripe.models.payment_methods.Card.account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.Card.address_city
    
djstripe.models.payment_methods.Card.address_country
    
djstripe.models.payment_methods.Card.address_line1
    
djstripe.models.payment_methods.Card.address_line1_check
    
djstripe.models.payment_methods.Card.address_line2
    
djstripe.models.payment_methods.Card.address_state
    
djstripe.models.payment_methods.Card.address_zip
    
djstripe.models.payment_methods.Card.address_zip_check
    
djstripe.models.payment_methods.Card.brand
    
djstripe.models.payment_methods.Card.country
    
djstripe.models.payment_methods.Card.customer: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.Card.cvc_check
    
djstripe.models.payment_methods.Card.default_for_currency
    
djstripe.models.payment_methods.Card.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.Card.dynamic_last4
    
djstripe.models.payment_methods.Card.exp_month
    
djstripe.models.payment_methods.Card.exp_year
    
djstripe.models.payment_methods.Card.fingerprint
    
djstripe.models.payment_methods.Card.funding
    
djstripe.models.payment_methods.Card.last4
    
djstripe.models.payment_methods.Card.name
    
djstripe.models.payment_methods.Card.tokenization_method
    
        
djstripe.models.payment_methods.Card.DoesNotExist        
    
        
djstripe.models.payment_methods.Card.MultipleObjectsReturned        
    
        
djstripe.models.payment_methods.Card.stripe_class        
    djstripe.models.payment_methods.Card.stripe_class.OBJECT_NAME
djstripe.models.payment_methods.Card.stripe_class.instance_url(self)
Source code in djstripe/models/payment_methods.py
          def instance_url(self):
    token = util.utf8(self.id)
    extn = quote_plus(token)
    if hasattr(self, "customer"):
        customer = util.utf8(self.customer)
        base = Customer.class_url()
        owner_extn = quote_plus(customer)
        class_base = "sources"
    elif hasattr(self, "recipient"):
        recipient = util.utf8(self.recipient)
        base = Recipient.class_url()
        owner_extn = quote_plus(recipient)
        class_base = "cards"
    elif hasattr(self, "account"):
        account = util.utf8(self.account)
        base = Account.class_url()
        owner_extn = quote_plus(account)
        class_base = "external_accounts"
    else:
        raise error.InvalidRequestError(
            "Could not determine whether card_id %s is "
            "attached to a customer, recipient, or "
            "account." % token,
            "id",
        )
    return "%s/%s/%s/%s" % (base, owner_extn, class_base, extn)
djstripe.models.payment_methods.Card.stripe_class.modify(sid, **params)
  
      classmethod
  
Source code in djstripe/models/payment_methods.py
          @classmethod
def modify(cls, sid, **params):
    raise NotImplementedError(
        "Can't modify a card without a customer, recipient or account "
        "ID. Call save on customer.sources.retrieve('card_id'), "
        "recipient.cards.retrieve('card_id'), or "
        "account.external_accounts.retrieve('card_id') instead."
    )
djstripe.models.payment_methods.Card.stripe_class.retrieve(id, api_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/payment_methods.py
          @classmethod
def retrieve(
    cls,
    id,
    api_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    raise NotImplementedError(
        "Can't retrieve a card without a customer, recipient or account "
        "ID. Use customer.sources.retrieve('card_id'), "
        "recipient.cards.retrieve('card_id'), or "
        "account.external_accounts.retrieve('card_id') instead."
    )
Methods
djstripe.models.payment_methods.Card.__str__(self)
  
      special
  
    Source code in djstripe/models/payment_methods.py
          def __str__(self):
    default = False
    # prefer to show it by customer format if present
    if self.customer:
        default_source = self.customer.default_source
        default_payment_method = self.customer.default_payment_method
        if (default_payment_method and self.id == default_payment_method.id) or (
            default_source and self.id == default_source.id
        ):
            # current card is the default payment method or source
            default = True
        customer_template = f"{enums.CardBrand.humanize(self.brand)} {self.last4} {'Default' if default else ''} Expires {self.exp_month} {self.exp_year}"
        return customer_template
    elif self.account:
        default = getattr(self, "default_for_currency", False)
        account_template = f"{enums.CardBrand.humanize(self.brand)} {self.account.default_currency} {'Default' if default else ''} {self.last4}"
        return account_template
djstripe.models.payment_methods.Card.create_token(number, exp_month, exp_year, cvc, api_key='sk_test_XXXXXXXXXXXXXXXXXXXXXXXXX', **kwargs)
  
      classmethod
  
    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?lang=python#create_card_token)
:param number: The card number without any separators (no spaces) :param exp_month: The card's expiration month. (two digits) :param exp_year: The card's expiration year. (four digits) :param cvc: Card security code. :param api_key: The API key to use
Source code in djstripe/models/payment_methods.py
          @classmethod
def create_token(
    cls,
    number: str,
    exp_month: int,
    exp_year: int,
    cvc: str,
    api_key: str = djstripe_settings.STRIPE_SECRET_KEY,
    **kwargs,
) -> stripe.Token:
    """
    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?lang=python#create_card_token)
    :param number: The card number without any separators (no spaces)
    :param exp_month: The card's expiration month. (two digits)
    :param exp_year: The card's expiration year. (four digits)
    :param cvc: Card security code.
    :param api_key: The API key to use
    """
    card = {
        "number": number,
        "exp_month": exp_month,
        "exp_year": exp_year,
        "cvc": cvc,
    }
    card.update(kwargs)
    return stripe.Token.create(api_key=api_key, card=card)
djstripe.models.payment_methods.Card.get_address_line1_check_display(self, *, field=<djstripe.fields.StripeEnumField: address_line1_check>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_address_zip_check_display(self, *, field=<djstripe.fields.StripeEnumField: address_zip_check>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_brand_display(self, *, field=<djstripe.fields.StripeEnumField: brand>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_cvc_check_display(self, *, field=<djstripe.fields.StripeEnumField: cvc_check>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_funding_display(self, *, field=<djstripe.fields.StripeEnumField: funding>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Card.get_tokenization_method_display(self, *, field=<djstripe.fields.StripeEnumField: tokenization_method>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.payment_methods.PaymentMethod        
    Stripe documentation: https://stripe.com/docs/api#payment_methods
djstripe.models.payment_methods.PaymentMethod.acss_debit
    
djstripe.models.payment_methods.PaymentMethod.afterpay_clearpay
    
djstripe.models.payment_methods.PaymentMethod.alipay
    
djstripe.models.payment_methods.PaymentMethod.au_becs_debit
    
djstripe.models.payment_methods.PaymentMethod.bacs_debit
    
djstripe.models.payment_methods.PaymentMethod.bancontact
    
djstripe.models.payment_methods.PaymentMethod.billing_details
    
djstripe.models.payment_methods.PaymentMethod.boleto
    
djstripe.models.payment_methods.PaymentMethod.card
    
djstripe.models.payment_methods.PaymentMethod.card_present
    
djstripe.models.payment_methods.PaymentMethod.customer
    
djstripe.models.payment_methods.PaymentMethod.description
    
djstripe.models.payment_methods.PaymentMethod.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.PaymentMethod.eps
    
djstripe.models.payment_methods.PaymentMethod.fpx
    
djstripe.models.payment_methods.PaymentMethod.giropay
    
djstripe.models.payment_methods.PaymentMethod.grabpay
    
djstripe.models.payment_methods.PaymentMethod.ideal
    
djstripe.models.payment_methods.PaymentMethod.interac_present
    
djstripe.models.payment_methods.PaymentMethod.oxxo
    
djstripe.models.payment_methods.PaymentMethod.p24
    
djstripe.models.payment_methods.PaymentMethod.sepa_debit
    
djstripe.models.payment_methods.PaymentMethod.sofort
    
djstripe.models.payment_methods.PaymentMethod.type
    
djstripe.models.payment_methods.PaymentMethod.wechat_pay
    
        
djstripe.models.payment_methods.PaymentMethod.DoesNotExist        
    
        
djstripe.models.payment_methods.PaymentMethod.MultipleObjectsReturned        
    
        
djstripe.models.payment_methods.PaymentMethod.stripe_class        
    djstripe.models.payment_methods.PaymentMethod.stripe_class.OBJECT_NAME
djstripe.models.payment_methods.PaymentMethod.stripe_class._cls_attach(sid, **params)
  
      classmethod
      private
  
Source code in djstripe/models/payment_methods.py
          def custom_method_request(cls, sid, **params):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(util.utf8(sid)),
        http_path,
    )
    obj = cls._static_request(http_verb, url, **params)
    # For list objects, we have to attach the parameters so that they
    # can be referenced in auto-pagination and ensure consistency.
    if "object" in obj and obj.object == "list":
        obj._retrieve_params = params
    return obj
djstripe.models.payment_methods.PaymentMethod.stripe_class._cls_detach(sid, **params)
  
      classmethod
      private
  
Source code in djstripe/models/payment_methods.py
          def custom_method_request(cls, sid, **params):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(util.utf8(sid)),
        http_path,
    )
    obj = cls._static_request(http_verb, url, **params)
    # For list objects, we have to attach the parameters so that they
    # can be referenced in auto-pagination and ensure consistency.
    if "object" in obj and obj.object == "list":
        obj._retrieve_params = params
    return obj
djstripe.models.payment_methods.PaymentMethod.stripe_class.attach(self, idempotency_key=None, **params)
Source code in djstripe/models/payment_methods.py
          def attach(self, idempotency_key=None, **params):
    url = self.instance_url() + "/attach"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.payment_methods.PaymentMethod.stripe_class.detach(self, idempotency_key=None, **params)
Source code in djstripe/models/payment_methods.py
          def detach(self, idempotency_key=None, **params):
    url = self.instance_url() + "/detach"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
Methods
djstripe.models.payment_methods.PaymentMethod.__str__(self)
  
      special
  
    Source code in djstripe/models/payment_methods.py
          def __str__(self):
    if self.customer:
        return f"{enums.PaymentMethodType.humanize(self.type)} for {self.customer}"
    return f"{enums.PaymentMethodType.humanize(self.type)} is not associated with any customer"
djstripe.models.payment_methods.PaymentMethod._attach_objects_hook(self, cls, data, current_ids=None)
  
      private
  
    Gets called by this object's create and sync methods just before save. Use this to populate fields before the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict :param current_ids: stripe ids of objects that are currently being processed :type current_ids: set
Source code in djstripe/models/payment_methods.py
          def _attach_objects_hook(self, cls, data, current_ids=None):
    customer = None
    # "customer" key could be like "cus_6lsBvm5rJ0zyHc" or {"id": "cus_6lsBvm5rJ0zyHc"}
    customer_id = cls._id_from_data(data.get("customer"))
    if current_ids is None or customer_id not in current_ids:
        customer = cls._stripe_object_to_customer(
            target_cls=Customer, data=data, current_ids=current_ids
        )
    if customer:
        self.customer = customer
    else:
        self.customer = None
djstripe.models.payment_methods.PaymentMethod.attach(payment_method, customer, api_key='sk_test_XXXXXXXXXXXXXXXXXXXXXXXXX')
  
      classmethod
  
    Attach a payment method to a customer
Source code in djstripe/models/payment_methods.py
          @classmethod
def attach(
    cls,
    payment_method: Union[str, "PaymentMethod"],
    customer: Union[str, Customer],
    api_key: str = djstripe_settings.STRIPE_SECRET_KEY,
) -> "PaymentMethod":
    """
    Attach a payment method to a customer
    """
    if isinstance(payment_method, StripeModel):
        payment_method = payment_method.id
    if isinstance(customer, StripeModel):
        customer = customer.id
    extra_kwargs = {}
    if not isinstance(payment_method, stripe.PaymentMethod):
        # send api_key if we're not passing in a Stripe object
        # avoids "Received unknown parameter: api_key" since api uses the
        # key cached in the Stripe object
        extra_kwargs = {"api_key": api_key}
    stripe_payment_method = stripe.PaymentMethod.attach(
        payment_method, customer=customer, **extra_kwargs
    )
    return cls.sync_from_stripe_data(stripe_payment_method)
djstripe.models.payment_methods.PaymentMethod.detach(self)
    Detach the payment method from its customer.
:return: Returns true if the payment method was newly detached, false if it was already detached :rtype: bool
Source code in djstripe/models/payment_methods.py
          def detach(self):
    """
    Detach the payment method from its customer.
    :return: Returns true if the payment method was newly detached, \
             false if it was already detached
    :rtype: bool
    """
    # Find customers that use this
    customers = Customer.objects.filter(default_payment_method=self).all()
    changed = True
    # special handling is needed for legacy "card"-type PaymentMethods,
    # since detaching them deletes them within Stripe.
    # see https://github.com/dj-stripe/dj-stripe/pull/967
    is_legacy_card = self.id.startswith("card_")
    try:
        self.sync_from_stripe_data(self.api_retrieve().detach())
        # resync customer to update .default_payment_method and
        # .invoice_settings.default_payment_method
        for customer in customers:
            Customer.sync_from_stripe_data(customer.api_retrieve())
    except (InvalidRequestError,):
        # The source was already detached. Resyncing.
        if self.pk and not is_legacy_card:
            self.sync_from_stripe_data(self.api_retrieve())
        changed = False
    if self.pk:
        if is_legacy_card:
            self.delete()
        else:
            self.refresh_from_db()
    return changed
djstripe.models.payment_methods.PaymentMethod.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.PaymentMethod.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.PaymentMethod.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.PaymentMethod.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.PaymentMethod.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.payment_methods.Source        
    Stripe documentation: https://stripe.com/docs/api#sources
djstripe.models.payment_methods.Source.amount
    
djstripe.models.payment_methods.Source.client_secret
    
djstripe.models.payment_methods.Source.code_verification
    
djstripe.models.payment_methods.Source.currency
    
djstripe.models.payment_methods.Source.customer
    
djstripe.models.payment_methods.Source.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.payment_methods.Source.flow
    
djstripe.models.payment_methods.Source.owner
    
djstripe.models.payment_methods.Source.receiver
    
djstripe.models.payment_methods.Source.redirect
    
djstripe.models.payment_methods.Source.source_data
    
djstripe.models.payment_methods.Source.statement_descriptor
    
djstripe.models.payment_methods.Source.status
    
djstripe.models.payment_methods.Source.stripe_dashboard_item_name
    
djstripe.models.payment_methods.Source.type
    
djstripe.models.payment_methods.Source.usage
    Classes
        
djstripe.models.payment_methods.Source.DoesNotExist        
    
        
djstripe.models.payment_methods.Source.MultipleObjectsReturned        
    
        
djstripe.models.payment_methods.Source.stripe_class        
    djstripe.models.payment_methods.Source.stripe_class.OBJECT_NAME
Methods
djstripe.models.payment_methods.Source.stripe_class.detach(self, idempotency_key=None, **params)
Source code in djstripe/models/payment_methods.py
          def detach(self, idempotency_key=None, **params):
    token = util.utf8(self.id)
    if hasattr(self, "customer") and self.customer:
        extn = quote_plus(token)
        customer = util.utf8(self.customer)
        base = Customer.class_url()
        owner_extn = quote_plus(customer)
        url = "%s/%s/sources/%s" % (base, owner_extn, extn)
        headers = util.populate_headers(idempotency_key)
        self.refresh_from(self.request("delete", url, params, headers))
        return self
    else:
        raise error.InvalidRequestError(
            "Source %s does not appear to be currently attached "
            "to a customer object." % token,
            "id",
        )
djstripe.models.payment_methods.Source.stripe_class.list_source_transactions(id, **params)
  
      classmethod
  
Source code in djstripe/models/payment_methods.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.payment_methods.Source.stripe_class.source_transactions(self, **params)
source_transactions is deprecated, use Source.list_source_transactions instead.
Source code in djstripe/models/payment_methods.py
          def source_transactions(self, **params):
    """source_transactions is deprecated, use Source.list_source_transactions instead."""
    return self.request(
        "get", self.instance_url() + "/source_transactions", params
    )
djstripe.models.payment_methods.Source.stripe_class.source_transactions_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/payment_methods.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.payment_methods.Source.stripe_class.source_transactions_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/payment_methods.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
Methods
djstripe.models.payment_methods.Source._attach_objects_hook(self, cls, data, current_ids=None)
  
      private
  
    Gets called by this object's create and sync methods just before save. Use this to populate fields before the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict :param current_ids: stripe ids of objects that are currently being processed :type current_ids: set
Source code in djstripe/models/payment_methods.py
          def _attach_objects_hook(self, cls, data, current_ids=None):
    customer = None
    # "customer" key could be like "cus_6lsBvm5rJ0zyHc" or {"id": "cus_6lsBvm5rJ0zyHc"}
    customer_id = cls._id_from_data(data.get("customer"))
    if current_ids is None or customer_id not in current_ids:
        customer = cls._stripe_object_to_customer(
            target_cls=Customer, data=data, current_ids=current_ids
        )
    if customer:
        self.customer = customer
    else:
        self.customer = None
djstripe.models.payment_methods.Source._manipulate_stripe_object_hook(data)
  
      classmethod
      private
  
    Gets called by this object's stripe object conversion method just before conversion. Use this to populate custom fields in a StripeModel from stripe data.
Source code in djstripe/models/payment_methods.py
          @classmethod
def _manipulate_stripe_object_hook(cls, data):
    # The source_data dict is an alias of all the source types
    data["source_data"] = data[data["type"]]
    return data
djstripe.models.payment_methods.Source.detach(self)
    Detach the source from its customer.
Source code in djstripe/models/payment_methods.py
          def detach(self) -> bool:
    """
    Detach the source from its customer.
    """
    # First, wipe default source on all customers that use this.
    Customer.objects.filter(default_source=self.id).update(default_source=None)
    try:
        # TODO - we could use the return value of sync_from_stripe_data
        #  or call its internals - self._sync/_attach_objects_hook etc here
        #  to update `self` at this point?
        self.sync_from_stripe_data(self.api_retrieve().detach())
        return True
    except (InvalidRequestError, NotImplementedError):
        # The source was already detached. Resyncing.
        # NotImplementedError is an artifact of stripe-python<2.0
        # https://github.com/stripe/stripe-python/issues/376
        self.sync_from_stripe_data(self.api_retrieve())
        return False
djstripe.models.payment_methods.Source.get_flow_display(self, *, field=<djstripe.fields.StripeEnumField: flow>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.get_usage_display(self, *, field=<djstripe.fields.StripeEnumField: usage>)
    Source code in djstripe/models/payment_methods.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.payment_methods.Source.str_parts(self)
    Extend this to add information to the string representation of the object
Source code in djstripe/models/payment_methods.py
          def str_parts(self):
    return [
        f"type={self.type}",
        f"status={self.status}",
        f"customer={self.customer}",
        f"usage={self.usage}",
    ] + super().str_parts()
Billing
Classes
        
djstripe.models.billing.Coupon        
    A coupon contains information about a percent-off or amount-off discount you might want to apply to a customer. Coupons may be applied to invoices or orders. Coupons do not work with conventional one-off charges.
Stripe documentation: https://stripe.com/docs/api/coupons
djstripe.models.billing.Coupon.amount_off
    
djstripe.models.billing.Coupon.currency
    
djstripe.models.billing.Coupon.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.Coupon.duration
    
djstripe.models.billing.Coupon.duration_in_months
    
djstripe.models.billing.Coupon.human_readable
  
      property
      readonly
  
    
djstripe.models.billing.Coupon.human_readable_amount
  
      property
      readonly
  
    
djstripe.models.billing.Coupon.max_redemptions
    
djstripe.models.billing.Coupon.name
    
djstripe.models.billing.Coupon.percent_off
    
djstripe.models.billing.Coupon.redeem_by
    
djstripe.models.billing.Coupon.stripe_dashboard_item_name
    
djstripe.models.billing.Coupon.times_redeemed
    
        
djstripe.models.billing.Coupon.DoesNotExist        
    
        
djstripe.models.billing.Coupon.MultipleObjectsReturned        
    
        
djstripe.models.billing.Coupon.stripe_class        
    
djstripe.models.billing.Coupon.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    if self.name:
        return self.name
    return self.human_readable
djstripe.models.billing.Coupon.get_duration_display(self, *, field=<djstripe.fields.StripeEnumField: duration>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Coupon.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Coupon.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Coupon.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Coupon.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.Invoice        
    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?lang=python#invoices
djstripe.models.billing.Invoice.charge
    
djstripe.models.billing.Invoice.customer
    
djstripe.models.billing.Invoice.default_payment_method
    
djstripe.models.billing.Invoice.default_source
    
djstripe.models.billing.Invoice.default_tax_rates
    
djstripe.models.billing.Invoice.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.Invoice.payment_intent
    
djstripe.models.billing.Invoice.subscription
    
        
djstripe.models.billing.Invoice.DoesNotExist        
    
        
djstripe.models.billing.Invoice.MultipleObjectsReturned        
    Methods
djstripe.models.billing.Invoice._attach_objects_post_save_hook(self, cls, data, pending_relations=None)
  
      private
  
    Gets called by this object's create and sync methods just after save. Use this to populate fields after the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict
Source code in djstripe/models/billing.py
          def _attach_objects_post_save_hook(self, cls, data, pending_relations=None):
    super()._attach_objects_post_save_hook(
        cls, data, pending_relations=pending_relations
    )
    self.default_tax_rates.set(
        cls._stripe_object_to_default_tax_rates(target_cls=TaxRate, data=data)
    )
    cls._stripe_object_set_total_tax_amounts(
        target_cls=DjstripeInvoiceTotalTaxAmount, data=data, instance=self
    )
djstripe.models.billing.Invoice.get_billing_reason_display(self, *, field=<djstripe.fields.StripeEnumField: billing_reason>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_collection_method_display(self, *, field=<djstripe.fields.StripeEnumField: collection_method>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_customer_tax_exempt_display(self, *, field=<djstripe.fields.StripeEnumField: customer_tax_exempt>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_next_by_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: period_end>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_next_by_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: period_start>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_previous_by_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: period_end>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_previous_by_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: period_start>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Invoice.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.InvoiceItem        
    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?lang=python#invoiceitems
djstripe.models.billing.InvoiceItem.amount
    
djstripe.models.billing.InvoiceItem.currency
    
djstripe.models.billing.InvoiceItem.customer
    
djstripe.models.billing.InvoiceItem.date
    
djstripe.models.billing.InvoiceItem.discountable
    
djstripe.models.billing.InvoiceItem.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.InvoiceItem.invoice
    
djstripe.models.billing.InvoiceItem.period
    
djstripe.models.billing.InvoiceItem.period_end
    
djstripe.models.billing.InvoiceItem.period_start
    
djstripe.models.billing.InvoiceItem.plan
    
djstripe.models.billing.InvoiceItem.price
    
djstripe.models.billing.InvoiceItem.proration
    
djstripe.models.billing.InvoiceItem.quantity
    
djstripe.models.billing.InvoiceItem.subscription
    
djstripe.models.billing.InvoiceItem.tax_rates
    
djstripe.models.billing.InvoiceItem.unit_amount
    
djstripe.models.billing.InvoiceItem.unit_amount_decimal
    
        
djstripe.models.billing.InvoiceItem.DoesNotExist        
    
        
djstripe.models.billing.InvoiceItem.MultipleObjectsReturned        
    
        
djstripe.models.billing.InvoiceItem.stripe_class        
    Methods
djstripe.models.billing.InvoiceItem.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    return self.description
djstripe.models.billing.InvoiceItem._attach_objects_post_save_hook(self, cls, data, pending_relations=None)
  
      private
  
    Gets called by this object's create and sync methods just after save. Use this to populate fields after the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict
Source code in djstripe/models/billing.py
          def _attach_objects_post_save_hook(self, cls, data, pending_relations=None):
    super()._attach_objects_post_save_hook(
        cls, data, pending_relations=pending_relations
    )
    if self.pk:
        # only call .set() on saved instance (ie don't on items of UpcomingInvoice)
        self.tax_rates.set(
            cls._stripe_object_to_tax_rates(target_cls=TaxRate, data=data)
        )
djstripe.models.billing.InvoiceItem._manipulate_stripe_object_hook(data)
  
      classmethod
      private
  
    Gets called by this object's stripe object conversion method just before conversion. Use this to populate custom fields in a StripeModel from stripe data.
Source code in djstripe/models/billing.py
          @classmethod
def _manipulate_stripe_object_hook(cls, data):
    data["period_start"] = data["period"]["start"]
    data["period_end"] = data["period"]["end"]
    return data
djstripe.models.billing.InvoiceItem.api_retrieve(self, *args, **kwargs)
    Call the stripe API's retrieve operation for this model.
:param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string :param stripe_account: The optional connected account for which this request is being made. :type stripe_account: string
Source code in djstripe/models/billing.py
          def api_retrieve(self, *args, **kwargs):
    if "-il_" in self.id:
        warnings.warn(
            f"Attempting to retrieve InvoiceItem with id={self.id!r}"
            " will most likely fail. "
            "Run manage.py djstripe_update_invoiceitem_ids if this is a problem."
        )
    return super().api_retrieve(*args, **kwargs)
djstripe.models.billing.InvoiceItem.get_next_by_date(self, *, field=<djstripe.fields.StripeDateTimeField: date>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_next_by_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: period_end>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_next_by_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: period_start>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_previous_by_date(self, *, field=<djstripe.fields.StripeDateTimeField: date>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_previous_by_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: period_end>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_previous_by_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: period_start>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.InvoiceItem.get_stripe_dashboard_url(self)
    Get the stripe dashboard url for this object.
Source code in djstripe/models/billing.py
          def get_stripe_dashboard_url(self):
    return self.invoice.get_stripe_dashboard_url()
djstripe.models.billing.InvoiceItem.is_valid_object(data)
  
      classmethod
  
    Returns whether the data is a valid object for the class
Source code in djstripe/models/billing.py
          @classmethod
def is_valid_object(cls, data):
    return "object" in data and data["object"] in ("invoiceitem", "line_item")
        
djstripe.models.billing.Plan        
    A subscription plan contains the pricing information for different products and feature levels on your site.
Stripe documentation: https://stripe.com/docs/api/plans
NOTE: The Stripe Plans API has been deprecated in favor of the Prices API. You may want to upgrade to use the Price model instead of the Plan model.
djstripe.models.billing.Plan.active
    
djstripe.models.billing.Plan.aggregate_usage
    
djstripe.models.billing.Plan.amount
    
djstripe.models.billing.Plan.amount_decimal
    
djstripe.models.billing.Plan.amount_in_cents
  
      property
      readonly
  
    
djstripe.models.billing.Plan.billing_scheme
    
djstripe.models.billing.Plan.currency
    
djstripe.models.billing.Plan.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.Plan.expand_fields: List[str]
    
djstripe.models.billing.Plan.human_readable_price
  
      property
      readonly
  
    
djstripe.models.billing.Plan.interval
    
djstripe.models.billing.Plan.interval_count
    
djstripe.models.billing.Plan.nickname
    
djstripe.models.billing.Plan.product
    
djstripe.models.billing.Plan.stripe_dashboard_item_name
    
djstripe.models.billing.Plan.tiers
    
djstripe.models.billing.Plan.tiers_mode
    
djstripe.models.billing.Plan.transform_usage
    
djstripe.models.billing.Plan.trial_period_days
    
djstripe.models.billing.Plan.usage_type
    
        
djstripe.models.billing.Plan.DoesNotExist        
    
        
djstripe.models.billing.Plan.MultipleObjectsReturned        
    
        
djstripe.models.billing.Plan.stripe_class        
    Methods
djstripe.models.billing.Plan.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    from .billing import Subscription
    subscriptions = Subscription.objects.filter(plan__id=self.id).count()
    if self.product and self.product.name:
        return f"{self.human_readable_price} for {self.product.name} ({subscriptions} subscriptions)"
    return f"{self.human_readable_price} ({subscriptions} subscriptions)"
djstripe.models.billing.Plan.create(**kwargs)
  
      classmethod
  
    Source code in djstripe/models/billing.py
          @classmethod
def create(cls, **kwargs):
    # A few minor things are changed in the api-version of the create call
    api_kwargs = dict(kwargs)
    api_kwargs["amount"] = int(api_kwargs["amount"] * 100)
    if isinstance(api_kwargs.get("product"), StripeModel):
        api_kwargs["product"] = api_kwargs["product"].id
    stripe_plan = cls._api_create(**api_kwargs)
    plan = cls.sync_from_stripe_data(stripe_plan)
    return plan
djstripe.models.billing.Plan.get_aggregate_usage_display(self, *, field=<djstripe.fields.StripeEnumField: aggregate_usage>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_billing_scheme_display(self, *, field=<djstripe.fields.StripeEnumField: billing_scheme>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_interval_display(self, *, field=<djstripe.fields.StripeEnumField: interval>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_or_create(**kwargs)
  
      classmethod
  
    Get or create a Plan.
Source code in djstripe/models/billing.py
          @classmethod
def get_or_create(cls, **kwargs):
    """Get or create a Plan."""
    try:
        return Plan.objects.get(id=kwargs["id"]), False
    except Plan.DoesNotExist:
        return cls.create(**kwargs), True
djstripe.models.billing.Plan.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_tiers_mode_display(self, *, field=<djstripe.fields.StripeEnumField: tiers_mode>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Plan.get_usage_type_display(self, *, field=<djstripe.fields.StripeEnumField: usage_type>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.Subscription        
    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?lang=python#subscriptions
djstripe.models.billing.Subscription.application_fee_percent
    
djstripe.models.billing.Subscription.billing_cycle_anchor
    
djstripe.models.billing.Subscription.billing_thresholds
    
djstripe.models.billing.Subscription.cancel_at
    
djstripe.models.billing.Subscription.cancel_at_period_end
    
djstripe.models.billing.Subscription.canceled_at
    
djstripe.models.billing.Subscription.collection_method
    
djstripe.models.billing.Subscription.current_period_end
    
djstripe.models.billing.Subscription.current_period_start
    
djstripe.models.billing.Subscription.customer
    
djstripe.models.billing.Subscription.days_until_due
    
djstripe.models.billing.Subscription.default_payment_method
    
djstripe.models.billing.Subscription.default_source
    
djstripe.models.billing.Subscription.default_tax_rates
    
djstripe.models.billing.Subscription.discount
    
djstripe.models.billing.Subscription.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.Subscription.ended_at
    
djstripe.models.billing.Subscription.latest_invoice
    
djstripe.models.billing.Subscription.next_pending_invoice_item_invoice
    
djstripe.models.billing.Subscription.objects
    
djstripe.models.billing.Subscription.pending_invoice_item_interval
    
djstripe.models.billing.Subscription.pending_setup_intent
    
djstripe.models.billing.Subscription.pending_update
    
djstripe.models.billing.Subscription.plan
    
djstripe.models.billing.Subscription.quantity
    
djstripe.models.billing.Subscription.schedule
    
djstripe.models.billing.Subscription.start_date
    
djstripe.models.billing.Subscription.status
    
djstripe.models.billing.Subscription.stripe_dashboard_item_name
    
djstripe.models.billing.Subscription.trial_end
    
djstripe.models.billing.Subscription.trial_start
    
        
djstripe.models.billing.Subscription.DoesNotExist        
    
        
djstripe.models.billing.Subscription.MultipleObjectsReturned        
    
        
djstripe.models.billing.Subscription.stripe_class        
    djstripe.models.billing.Subscription.stripe_class.OBJECT_NAME
djstripe.models.billing.Subscription.stripe_class._cls_delete_discount(sid, **params)
  
      classmethod
      private
  
Source code in djstripe/models/billing.py
          def custom_method_request(cls, sid, **params):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(util.utf8(sid)),
        http_path,
    )
    obj = cls._static_request(http_verb, url, **params)
    # For list objects, we have to attach the parameters so that they
    # can be referenced in auto-pagination and ensure consistency.
    if "object" in obj and obj.object == "list":
        obj._retrieve_params = params
    return obj
djstripe.models.billing.Subscription.stripe_class.delete_discount(self, **params)
Source code in djstripe/models/billing.py
          def delete_discount(self, **params):
    requestor = api_requestor.APIRequestor(
        self.api_key,
        api_version=self.stripe_version,
        account=self.stripe_account,
    )
    url = self.instance_url() + "/discount"
    _, api_key = requestor.request("delete", url, params)
    self.refresh_from({"discount": None}, api_key, True)
Methods
djstripe.models.billing.Subscription.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    subscriptions_lst = self.customer._get_valid_subscriptions()
    products_lst = [
        subscription.plan.product.name
        for subscription in subscriptions_lst
        if subscription and subscription.plan
    ]
    return f"{self.customer} on {' and '.join(products_lst)}"
djstripe.models.billing.Subscription._attach_objects_post_save_hook(self, cls, data, pending_relations=None)
  
      private
  
    Gets called by this object's create and sync methods just after save. Use this to populate fields after the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict
Source code in djstripe/models/billing.py
          def _attach_objects_post_save_hook(self, cls, data, pending_relations=None):
    super()._attach_objects_post_save_hook(
        cls, data, pending_relations=pending_relations
    )
    cls._stripe_object_to_subscription_items(
        target_cls=SubscriptionItem, data=data, subscription=self
    )
    self.default_tax_rates.set(
        cls._stripe_object_to_default_tax_rates(target_cls=TaxRate, data=data)
    )
djstripe.models.billing.Subscription.cancel(self, at_period_end=True)
    Cancels this subscription. If you set the at_period_end parameter to true, the subscription will remain active until the end of the period, at which point it will be canceled and not renewed. By default, the subscription is terminated immediately. In either case, the customer will not be charged again for the subscription. Note, however, that any pending invoice items that you've created will still be charged for at the end of the period unless manually deleted. If you've set the subscription to cancel at period end, any pending prorations will also be left in place and collected at the end of the period, but if the subscription is set to cancel immediately, pending prorations will be removed.
By default, all unpaid invoices for the customer will be closed upon subscription cancellation. We do this in order to prevent unexpected payment retries once the customer has canceled a subscription. However, you can reopen the invoices manually after subscription cancellation to have us proceed with automatic retries, or you could even re-attempt payment yourself on all unpaid invoices before allowing the customer to cancel the subscription at all.
:param at_period_end: A flag that if set to true will delay the cancellation of the subscription until the end of the current period. Default is False. :type at_period_end: boolean
.. important:: If a subscription is canceled during a trial period,         the at_period_end flag will be overridden to False so that the trial ends         immediately and the customer's card isn't charged.
Source code in djstripe/models/billing.py
          def cancel(self, at_period_end=djstripe_settings.CANCELLATION_AT_PERIOD_END):
    """
    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.
    :param at_period_end: A flag that if set to true will delay the cancellation \
        of the subscription until the end of the current period. Default is False.
    :type at_period_end: boolean
    .. important:: If a subscription is canceled during a trial period, \
    the ``at_period_end`` flag will be overridden to False so that the trial ends \
    immediately and the customer's card isn't charged.
    """
    # If plan has trial days and customer cancels before
    # trial period ends, then end subscription now,
    # i.e. at_period_end=False
    if self.trial_end and self.trial_end > timezone.now():
        at_period_end = False
    if at_period_end:
        stripe_subscription = self._api_update(cancel_at_period_end=True)
    else:
        try:
            stripe_subscription = self._api_delete()
        except InvalidRequestError as exc:
            if "No such subscription:" in str(exc):
                # cancel() works by deleting the subscription. The object still
                # exists in Stripe however, and can still be retrieved.
                # If the subscription was already canceled (status=canceled),
                # that api_retrieve() call will fail with "No such subscription".
                # However, this may also happen if the subscription legitimately
                # does not exist, in which case the following line will re-raise.
                stripe_subscription = self.api_retrieve()
            else:
                raise
    return Subscription.sync_from_stripe_data(stripe_subscription)
djstripe.models.billing.Subscription.extend(self, delta)
    Extends this subscription by the provided delta.
:param delta: The timedelta by which to extend this subscription. :type delta: timedelta
Source code in djstripe/models/billing.py
          def extend(self, delta):
    """
    Extends this subscription by the provided delta.
    :param delta: The timedelta by which to extend this subscription.
    :type delta: timedelta
    """
    if delta.total_seconds() < 0:
        raise ValueError("delta must be a positive timedelta.")
    if self.trial_end is not None and self.trial_end > timezone.now():
        period_end = self.trial_end
    else:
        period_end = self.current_period_end
    period_end += delta
    return self.update(proration_behavior="none", trial_end=period_end)
djstripe.models.billing.Subscription.get_collection_method_display(self, *, field=<djstripe.fields.StripeEnumField: collection_method>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_next_by_current_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: current_period_end>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_next_by_current_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: current_period_start>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_previous_by_current_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: current_period_end>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_previous_by_current_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: current_period_start>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.Subscription.is_period_current(self)
    Returns True if this subscription's period is current, false otherwise.
Source code in djstripe/models/billing.py
          def is_period_current(self):
    """
    Returns True if this subscription's period is current, false otherwise.
    """
    return self.current_period_end > timezone.now() or (
        self.trial_end and self.trial_end > timezone.now()
    )
djstripe.models.billing.Subscription.is_status_current(self)
    Returns True if this subscription's status is current (active or trialing), false otherwise.
Source code in djstripe/models/billing.py
          def is_status_current(self):
    """
    Returns True if this subscription's status is current (active or trialing),
    false otherwise.
    """
    return self.status in ["trialing", "active"]
djstripe.models.billing.Subscription.is_status_temporarily_current(self)
    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.
Source code in djstripe/models/billing.py
          def is_status_temporarily_current(self):
    """
    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.
    """
    return (
        self.canceled_at
        and self.cancel_at_period_end
        and timezone.now() < self.current_period_end
    )
djstripe.models.billing.Subscription.is_valid(self)
    Returns True if this subscription's status and period are current, false otherwise.
Source code in djstripe/models/billing.py
          def is_valid(self):
    """
    Returns True if this subscription's status and period are current,
    false otherwise.
    """
    if not self.is_status_current():
        return False
    if not self.is_period_current():
        return False
    return True
djstripe.models.billing.Subscription.reactivate(self)
    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/billing/subscriptions/cancel)
.. warning:: Reactivating a fully canceled Subscription will fail silently. Be sure to check the returned Subscription's status.
Source code in djstripe/models/billing.py
          def reactivate(self):
    """
    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/billing/subscriptions/cancel)
    .. warning:: Reactivating a fully canceled Subscription will fail silently. \
    Be sure to check the returned Subscription's status.
    """
    stripe_subscription = self.api_retrieve()
    stripe_subscription.plan = self.plan.id
    stripe_subscription.cancel_at_period_end = False
    return Subscription.sync_from_stripe_data(stripe_subscription.save())
djstripe.models.billing.Subscription.update(self, plan=None, prorate=None, **kwargs)
    See Customer.subscribe() <#djstripe.models.Customer.subscribe>__
:param plan: The plan to which to subscribe the customer. :type plan: Plan or string (plan ID)
.. 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).
Source code in djstripe/models/billing.py
          def update(
    self,
    plan: Union[StripeModel, str] = None,
    prorate: bool = None,
    **kwargs,
):
    """
    See `Customer.subscribe() <#djstripe.models.Customer.subscribe>`__
    :param plan: The plan to which to subscribe the customer.
    :type plan: Plan or string (plan ID)
    .. 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).
    """
    # Convert Plan to id
    if plan is not None and isinstance(plan, StripeModel):
        plan = plan.id
    if "proration_behavior" not in kwargs:
        if prorate is not None:
            warnings.warn(
                "The `prorate` parameter to Subscription.update() is deprecated "
                "by Stripe. Use `proration_behavior` instead.\n"
                "Read more: "
                "https://stripe.com/docs/billing/subscriptions/prorations"
            )
        else:
            prorate = djstripe_settings.PRORATION_POLICY
        if prorate:
            kwargs.setdefault("proration_behavior", "create_prorations")
        else:
            kwargs.setdefault("proration_behavior", "none")
    stripe_subscription = self._api_update(plan=plan, **kwargs)
    return Subscription.sync_from_stripe_data(stripe_subscription)
        
djstripe.models.billing.SubscriptionItem        
    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
djstripe.models.billing.SubscriptionItem.billing_thresholds
    
djstripe.models.billing.SubscriptionItem.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.SubscriptionItem.plan
    
djstripe.models.billing.SubscriptionItem.price
    
djstripe.models.billing.SubscriptionItem.quantity
    
djstripe.models.billing.SubscriptionItem.subscription
    
djstripe.models.billing.SubscriptionItem.tax_rates
    Classes
        
djstripe.models.billing.SubscriptionItem.DoesNotExist        
    
        
djstripe.models.billing.SubscriptionItem.MultipleObjectsReturned        
    
        
djstripe.models.billing.SubscriptionItem.stripe_class        
    djstripe.models.billing.SubscriptionItem.stripe_class.OBJECT_NAME
Methods
djstripe.models.billing.SubscriptionItem.stripe_class.create_usage_record(id, **params)
  
      classmethod
  
Source code in djstripe/models/billing.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.billing.SubscriptionItem.stripe_class.list_usage_record_summaries(id, **params)
  
      classmethod
  
Source code in djstripe/models/billing.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.billing.SubscriptionItem.stripe_class.usage_record_summaries(self, **params)
usage_record_summaries is deprecated, use SubscriptionItem.list_usage_record_summaries instead.
Source code in djstripe/models/billing.py
          def usage_record_summaries(self, **params):
    """usage_record_summaries is deprecated, use SubscriptionItem.list_usage_record_summaries instead."""
    return self.request(
        "get", self.instance_url() + "/usage_record_summaries", params
    )
djstripe.models.billing.SubscriptionItem.stripe_class.usage_record_summarys_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/billing.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.billing.SubscriptionItem.stripe_class.usage_record_summarys_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/billing.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.billing.SubscriptionItem.stripe_class.usage_records_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/billing.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.billing.SubscriptionItem.stripe_class.usage_records_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/billing.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
Methods
djstripe.models.billing.SubscriptionItem._attach_objects_post_save_hook(self, cls, data, pending_relations=None)
  
      private
  
    Gets called by this object's create and sync methods just after save. Use this to populate fields after the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict
Source code in djstripe/models/billing.py
          def _attach_objects_post_save_hook(self, cls, data, pending_relations=None):
    super()._attach_objects_post_save_hook(
        cls, data, pending_relations=pending_relations
    )
    self.tax_rates.set(
        cls._stripe_object_to_tax_rates(target_cls=TaxRate, data=data)
    )
djstripe.models.billing.SubscriptionItem.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionItem.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionItem.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionItem.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.SubscriptionSchedule        
    Subscription schedules allow you to create and manage the lifecycle of a subscription by predefining expected changes.
Stripe documentation: https://stripe.com/docs/api/subscription_schedules
djstripe.models.billing.SubscriptionSchedule.billing_thresholds
    
djstripe.models.billing.SubscriptionSchedule.canceled_at
    
djstripe.models.billing.SubscriptionSchedule.completed_at
    
djstripe.models.billing.SubscriptionSchedule.current_phase
    
djstripe.models.billing.SubscriptionSchedule.customer
    
djstripe.models.billing.SubscriptionSchedule.default_settings
    
djstripe.models.billing.SubscriptionSchedule.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.SubscriptionSchedule.end_behavior
    
djstripe.models.billing.SubscriptionSchedule.phases
    
djstripe.models.billing.SubscriptionSchedule.released_at
    
djstripe.models.billing.SubscriptionSchedule.released_subscription
    
djstripe.models.billing.SubscriptionSchedule.status
    
        
djstripe.models.billing.SubscriptionSchedule.DoesNotExist        
    
        
djstripe.models.billing.SubscriptionSchedule.MultipleObjectsReturned        
    
        
djstripe.models.billing.SubscriptionSchedule.stripe_class        
    djstripe.models.billing.SubscriptionSchedule.stripe_class.OBJECT_NAME
djstripe.models.billing.SubscriptionSchedule.stripe_class._cls_cancel(sid, **params)
  
      classmethod
      private
  
Source code in djstripe/models/billing.py
          def custom_method_request(cls, sid, **params):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(util.utf8(sid)),
        http_path,
    )
    obj = cls._static_request(http_verb, url, **params)
    # For list objects, we have to attach the parameters so that they
    # can be referenced in auto-pagination and ensure consistency.
    if "object" in obj and obj.object == "list":
        obj._retrieve_params = params
    return obj
djstripe.models.billing.SubscriptionSchedule.stripe_class._cls_release(sid, **params)
  
      classmethod
      private
  
Source code in djstripe/models/billing.py
          def custom_method_request(cls, sid, **params):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(util.utf8(sid)),
        http_path,
    )
    obj = cls._static_request(http_verb, url, **params)
    # For list objects, we have to attach the parameters so that they
    # can be referenced in auto-pagination and ensure consistency.
    if "object" in obj and obj.object == "list":
        obj._retrieve_params = params
    return obj
djstripe.models.billing.SubscriptionSchedule.stripe_class.cancel(self, idempotency_key=None, **params)
Source code in djstripe/models/billing.py
          def cancel(self, idempotency_key=None, **params):
    url = self.instance_url() + "/cancel"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.billing.SubscriptionSchedule.stripe_class.release(self, idempotency_key=None, **params)
Source code in djstripe/models/billing.py
          def release(self, idempotency_key=None, **params):
    url = self.instance_url() + "/release"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.billing.SubscriptionSchedule.get_end_behavior_display(self, *, field=<djstripe.fields.StripeEnumField: end_behavior>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionSchedule.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionSchedule.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionSchedule.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionSchedule.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.SubscriptionSchedule.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.TaxId        
    Add one or multiple tax IDs to a customer. A customer's tax IDs are displayed on invoices and credit notes issued for the customer.
Stripe documentation: https://stripe.com/docs/api/customer_tax_ids
djstripe.models.billing.TaxId.country
    
djstripe.models.billing.TaxId.customer
    
djstripe.models.billing.TaxId.description
    
djstripe.models.billing.TaxId.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.TaxId.metadata
    
djstripe.models.billing.TaxId.type
    
djstripe.models.billing.TaxId.value
    
djstripe.models.billing.TaxId.verification
    
        
djstripe.models.billing.TaxId.DoesNotExist        
    
        
djstripe.models.billing.TaxId.MultipleObjectsReturned        
    
        
djstripe.models.billing.TaxId.stripe_class        
    djstripe.models.billing.TaxId.stripe_class.OBJECT_NAME
djstripe.models.billing.TaxId.stripe_class.instance_url(self)
Source code in djstripe/models/billing.py
          def instance_url(self):
    token = util.utf8(self.id)
    customer = util.utf8(self.customer)
    base = Customer.class_url()
    cust_extn = quote_plus(customer)
    extn = quote_plus(token)
    return "%s/%s/tax_ids/%s" % (base, cust_extn, extn)
djstripe.models.billing.TaxId.stripe_class.retrieve(id, api_key=None, **params)
  
      classmethod
  
Source code in djstripe/models/billing.py
          @classmethod
def retrieve(cls, id, api_key=None, **params):
    raise NotImplementedError(
        "Can't retrieve a tax id without a customer ID. Use customer.retrieve_tax_id('tax_id')"
    )
Methods
djstripe.models.billing.TaxId.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    return f"{enums.TaxIdType.humanize(self.type)} {self.value} ({self.verification.get('status')})"
djstripe.models.billing.TaxId._api_create(api_key='sk_test_XXXXXXXXXXXXXXXXXXXXXXXXX', **kwargs)
  
      classmethod
      private
  
    Call the stripe API's create operation for this model.
:param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string
Source code in djstripe/models/billing.py
          @classmethod
def _api_create(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):
    """
    Call the stripe API's create operation for this model.
    :param api_key: The api key to use for this request. \
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    """
    if not kwargs.get("id"):
        raise KeyError("Customer Object ID is missing")
    try:
        Customer.objects.get(id=kwargs["id"])
    except Customer.DoesNotExist:
        raise
    return stripe.Customer.create_tax_id(api_key=api_key, **kwargs)
djstripe.models.billing.TaxId.api_list(api_key='sk_test_XXXXXXXXXXXXXXXXXXXXXXXXX', **kwargs)
  
      classmethod
  
    Call the stripe API's list operation for this model. :param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string See Stripe documentation for accepted kwargs for each object. :returns: an iterator over all items in the query
Source code in djstripe/models/billing.py
          @classmethod
def api_list(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):
    """
    Call the stripe API's list operation for this model.
    :param api_key: The api key to use for this request. \
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    See Stripe documentation for accepted kwargs for each object.
    :returns: an iterator over all items in the query
    """
    return stripe.Customer.list_tax_ids(
        api_key=api_key, **kwargs
    ).auto_paging_iter()
djstripe.models.billing.TaxId.api_retrieve(self, api_key=None, stripe_account=None)
    Call the stripe API's retrieve operation for this model. :param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string :param stripe_account: The optional connected account for which this request is being made. :type stripe_account: string
Source code in djstripe/models/billing.py
          def api_retrieve(self, api_key=None, stripe_account=None):
    """
    Call the stripe API's retrieve operation for this model.
    :param api_key: The api key to use for this request. \
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    :param stripe_account: The optional connected account \
        for which this request is being made.
    :type stripe_account: string
    """
    nested_id = self.id
    id = self.customer.id
    # Prefer passed in stripe_account if set.
    if not stripe_account:
        stripe_account = self._get_stripe_account_id(api_key)
    return stripe.Customer.retrieve_tax_id(
        id=id,
        nested_id=nested_id,
        api_key=api_key or self.default_api_key,
        expand=self.expand_fields,
        stripe_account=stripe_account,
    )
djstripe.models.billing.TaxId.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.TaxId.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.TaxId.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.TaxId.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.TaxId.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.TaxRate        
    Tax rates can be applied to invoices and subscriptions to collect tax.
Stripe documentation: https://stripe.com/docs/api/tax_rates
djstripe.models.billing.TaxRate.active
    
djstripe.models.billing.TaxRate.display_name
    
djstripe.models.billing.TaxRate.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.TaxRate.inclusive
    
djstripe.models.billing.TaxRate.jurisdiction
    
djstripe.models.billing.TaxRate.percentage
    
        
djstripe.models.billing.TaxRate.DoesNotExist        
    
        
djstripe.models.billing.TaxRate.MultipleObjectsReturned        
    
        
djstripe.models.billing.TaxRate.stripe_class        
    
djstripe.models.billing.TaxRate.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    return f"{self.display_name} – {self.jurisdiction} at {self.percentage}%"
djstripe.models.billing.TaxRate.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.TaxRate.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.TaxRate.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.TaxRate.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.UpcomingInvoice        
    The preview of an upcoming invoice - does not exist in the Django database.
See BaseInvoice.upcoming()
Logically it should be set abstract, but that doesn't quite work since we do actually want to instantiate the model and use relations.
Attributes
djstripe.models.billing.UpcomingInvoice.charge
    
djstripe.models.billing.UpcomingInvoice.customer
    
djstripe.models.billing.UpcomingInvoice.default_payment_method
    
djstripe.models.billing.UpcomingInvoice.default_source
    
djstripe.models.billing.UpcomingInvoice.default_tax_rates
  
      property
      readonly
  
    Gets the default tax rates associated with this upcoming invoice. :return:
djstripe.models.billing.UpcomingInvoice.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.UpcomingInvoice.id
  
      property
      writable
  
    
djstripe.models.billing.UpcomingInvoice.invoiceitems
  
      property
      readonly
  
    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.
djstripe.models.billing.UpcomingInvoice.payment_intent
    
djstripe.models.billing.UpcomingInvoice.subscription
    
djstripe.models.billing.UpcomingInvoice.total_tax_amounts
  
      property
      readonly
  
    Gets the total tax amounts associated with this upcoming invoice. :return:
        
djstripe.models.billing.UpcomingInvoice.DoesNotExist        
    
        
djstripe.models.billing.UpcomingInvoice.MultipleObjectsReturned        
    Methods
djstripe.models.billing.UpcomingInvoice.__init__(self, *args, **kwargs)
  
      special
  
    Source code in djstripe/models/billing.py
          def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self._invoiceitems = []
    self._default_tax_rates = []
    self._total_tax_amounts = []
djstripe.models.billing.UpcomingInvoice._attach_objects_hook(self, cls, data, current_ids=None)
  
      private
  
    Gets called by this object's create and sync methods just before save. Use this to populate fields before the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict :param current_ids: stripe ids of objects that are currently being processed :type current_ids: set
Source code in djstripe/models/billing.py
          def _attach_objects_hook(self, cls, data, current_ids=None):
    super()._attach_objects_hook(cls, data, current_ids=current_ids)
    self._invoiceitems = cls._stripe_object_to_invoice_items(
        target_cls=InvoiceItem, data=data, invoice=self
    )
djstripe.models.billing.UpcomingInvoice._attach_objects_post_save_hook(self, cls, data, pending_relations=None)
  
      private
  
    Gets called by this object's create and sync methods just after save. Use this to populate fields after the model is saved.
:param cls: The target class for the instantiated object. :param data: The data dictionary received from the Stripe API. :type data: dict
Source code in djstripe/models/billing.py
          def _attach_objects_post_save_hook(self, cls, data, pending_relations=None):
    super()._attach_objects_post_save_hook(
        cls, data, pending_relations=pending_relations
    )
    self._default_tax_rates = cls._stripe_object_to_default_tax_rates(
        target_cls=TaxRate, data=data
    )
    total_tax_amounts = []
    for tax_amount_data in data.get("total_tax_amounts", []):
        tax_rate_id = tax_amount_data["tax_rate"]
        if not isinstance(tax_rate_id, str):
            tax_rate_id = tax_rate_id["tax_rate"]
        tax_rate = TaxRate._get_or_retrieve(id=tax_rate_id)
        tax_amount = DjstripeUpcomingInvoiceTotalTaxAmount(
            invoice=self,
            amount=tax_amount_data["amount"],
            inclusive=tax_amount_data["inclusive"],
            tax_rate=tax_rate,
        )
        total_tax_amounts.append(tax_amount)
    self._total_tax_amounts = total_tax_amounts
djstripe.models.billing.UpcomingInvoice.get_billing_reason_display(self, *, field=<djstripe.fields.StripeEnumField: billing_reason>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_collection_method_display(self, *, field=<djstripe.fields.StripeEnumField: collection_method>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_customer_tax_exempt_display(self, *, field=<djstripe.fields.StripeEnumField: customer_tax_exempt>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_next_by_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: period_end>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_next_by_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: period_start>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_previous_by_period_end(self, *, field=<djstripe.fields.StripeDateTimeField: period_end>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_previous_by_period_start(self, *, field=<djstripe.fields.StripeDateTimeField: period_start>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UpcomingInvoice.get_stripe_dashboard_url(self)
    Get the stripe dashboard url for this object.
Source code in djstripe/models/billing.py
          def get_stripe_dashboard_url(self):
    return ""
djstripe.models.billing.UpcomingInvoice.save(self, *args, **kwargs)
    Save the current instance. Override this in a subclass if you want to control the saving process.
The 'force_insert' and 'force_update' parameters can be used to insist that the "save" must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.
Source code in djstripe/models/billing.py
          def save(self, *args, **kwargs):
    return  # noop
        
djstripe.models.billing.UsageRecord        
    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
djstripe.models.billing.UsageRecord.action
    
djstripe.models.billing.UsageRecord.description
    
djstripe.models.billing.UsageRecord.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.UsageRecord.metadata
    
djstripe.models.billing.UsageRecord.quantity
    
djstripe.models.billing.UsageRecord.subscription_item
    
djstripe.models.billing.UsageRecord.timestamp
    
        
djstripe.models.billing.UsageRecord.DoesNotExist        
    
        
djstripe.models.billing.UsageRecord.MultipleObjectsReturned        
    
        
djstripe.models.billing.UsageRecord.stripe_class        
    djstripe.models.billing.UsageRecord.stripe_class.OBJECT_NAME
djstripe.models.billing.UsageRecord.stripe_class.create(api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/billing.py
          @classmethod
def create(
    cls,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    if "subscription_item" not in params:
        raise ValueError("Params must have a subscription_item key")
    subscription_item = params.pop("subscription_item")
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    url = "/v1/subscription_items/%s/usage_records" % subscription_item
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request("post", url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
Methods
djstripe.models.billing.UsageRecord.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    return f"Usage for {self.subscription_item} ({self.action}) is {self.quantity}"
djstripe.models.billing.UsageRecord._api_create(api_key='sk_test_XXXXXXXXXXXXXXXXXXXXXXXXX', **kwargs)
  
      classmethod
      private
  
    Call the stripe API's create operation for this model.
:param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string
Source code in djstripe/models/billing.py
          @classmethod
def _api_create(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):
    """
    Call the stripe API's create operation for this model.
    :param api_key: The api key to use for this request. \
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    """
    if not kwargs.get("id"):
        raise KeyError("SubscriptionItem Object ID is missing")
    try:
        SubscriptionItem.objects.get(id=kwargs["id"])
    except SubscriptionItem.DoesNotExist:
        raise
    usage_stripe_data = stripe.SubscriptionItem.create_usage_record(
        api_key=api_key, **kwargs
    )
    # ! Hack: there is no way to retrieve a UsageRecord object from Stripe,
    # ! which is why we create and sync it right here
    cls.sync_from_stripe_data(usage_stripe_data)
    return usage_stripe_data
djstripe.models.billing.UsageRecord.create(**kwargs)
  
      classmethod
  
    A wrapper around _api_create() to allow one to create and sync UsageRecord Objects
Source code in djstripe/models/billing.py
          @classmethod
def create(cls, **kwargs):
    """
    A wrapper around _api_create() to allow one to create and sync UsageRecord Objects
    """
    return cls._api_create(**kwargs)
djstripe.models.billing.UsageRecord.get_action_display(self, *, field=<djstripe.fields.StripeEnumField: action>)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UsageRecord.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UsageRecord.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UsageRecord.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UsageRecord.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.billing.UsageRecordSummary        
    Usage record summaries provides usage information that’s been summarized from multiple usage records and over a subscription billing period (e.g., 15 usage records in the month of September). Since new usage records can still be added, the returned summary information for the subscription item’s ID should be seen as unstable until the subscription billing period ends.
Stripe documentation: https://stripe.com/docs/api/usage_records/subscription_item_summary_list
djstripe.models.billing.UsageRecordSummary.description
    
djstripe.models.billing.UsageRecordSummary.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.billing.UsageRecordSummary.invoice
    
djstripe.models.billing.UsageRecordSummary.metadata
    
djstripe.models.billing.UsageRecordSummary.period
    
djstripe.models.billing.UsageRecordSummary.period_end
    
djstripe.models.billing.UsageRecordSummary.period_start
    
djstripe.models.billing.UsageRecordSummary.subscription_item
    
djstripe.models.billing.UsageRecordSummary.total_usage
    
        
djstripe.models.billing.UsageRecordSummary.DoesNotExist        
    
        
djstripe.models.billing.UsageRecordSummary.MultipleObjectsReturned        
    
        
djstripe.models.billing.UsageRecordSummary.stripe_class        
    Methods
djstripe.models.billing.UsageRecordSummary.__str__(self)
  
      special
  
    Source code in djstripe/models/billing.py
          def __str__(self):
    return f"Usage Summary for {self.subscription_item} ({self.invoice}) is {self.total_usage}"
djstripe.models.billing.UsageRecordSummary._manipulate_stripe_object_hook(data)
  
      classmethod
      private
  
    Gets called by this object's stripe object conversion method just before conversion. Use this to populate custom fields in a StripeModel from stripe data.
Source code in djstripe/models/billing.py
          @classmethod
def _manipulate_stripe_object_hook(cls, data):
    data["period_start"] = data["period"]["start"]
    data["period_end"] = data["period"]["end"]
    return data
djstripe.models.billing.UsageRecordSummary.api_list(api_key='sk_test_XXXXXXXXXXXXXXXXXXXXXXXXX', **kwargs)
  
      classmethod
  
    Call the stripe API's list operation for this model.
:param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string
See Stripe documentation for accepted kwargs for each object.
:returns: an iterator over all items in the query
Source code in djstripe/models/billing.py
          @classmethod
def api_list(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):
    """
    Call the stripe API's list operation for this model.
    :param api_key: The api key to use for this request. \
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    See Stripe documentation for accepted kwargs for each object.
    :returns: an iterator over all items in the query
    """
    if not kwargs.get("id"):
        raise KeyError("SubscriptionItem Object ID is missing")
    try:
        SubscriptionItem.objects.get(id=kwargs["id"])
    except SubscriptionItem.DoesNotExist:
        raise
    return stripe.SubscriptionItem.list_usage_record_summaries(
        api_key=api_key, **kwargs
    ).auto_paging_iter()
djstripe.models.billing.UsageRecordSummary.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UsageRecordSummary.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UsageRecordSummary.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.billing.UsageRecordSummary.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/billing.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
Connect
Classes
        
djstripe.models.account.Account        
    Stripe documentation: https://stripe.com/docs/api/accounts
Attributes
djstripe.models.account.Account.branding_icon
  
      property
      readonly
  
    
djstripe.models.account.Account.branding_logo
  
      property
      readonly
  
    
djstripe.models.account.Account.business_profile
    
djstripe.models.account.Account.business_type
    
djstripe.models.account.Account.business_url: str
  
      property
      readonly
  
    The business’s publicly available website.
djstripe.models.account.Account.charges_enabled
    
djstripe.models.account.Account.company
    
djstripe.models.account.Account.country
    
djstripe.models.account.Account.default_api_key: str
  
      property
      readonly
  
    
djstripe.models.account.Account.default_currency
    
djstripe.models.account.Account.details_submitted
    
djstripe.models.account.Account.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.account.Account.email
    
djstripe.models.account.Account.individual
    
djstripe.models.account.Account.payouts_enabled
    
djstripe.models.account.Account.product_description
    
djstripe.models.account.Account.requirements
    
djstripe.models.account.Account.settings
    
djstripe.models.account.Account.tos_acceptance
    
djstripe.models.account.Account.type
    
        
djstripe.models.account.Account.DoesNotExist        
    
        
djstripe.models.account.Account.MultipleObjectsReturned        
    
        
djstripe.models.account.Account.stripe_class        
    djstripe.models.account.Account.stripe_class.OBJECT_NAME
djstripe.models.account.Account.stripe_class.capabilitys_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.account.Account.stripe_class.capabilitys_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.account.Account.stripe_class.create_external_account(id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.account.Account.stripe_class.create_login_link(id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.account.Account.stripe_class.create_person(id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.account.Account.stripe_class.deauthorize(self, **params)
Source code in djstripe/models/account.py
          def deauthorize(self, **params):
    params["stripe_user_id"] = self.id
    return oauth.OAuth.deauthorize(**params)
djstripe.models.account.Account.stripe_class.delete_external_account(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def delete_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "delete", url, **params
    )
djstripe.models.account.Account.stripe_class.delete_person(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def delete_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "delete", url, **params
    )
djstripe.models.account.Account.stripe_class.external_accounts_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.account.Account.stripe_class.external_accounts_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.account.Account.stripe_class.instance_url(self)
Source code in djstripe/models/account.py
          def instance_url(self):
    return self._build_instance_url(self.get("id"))
djstripe.models.account.Account.stripe_class.list_capabilities(id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.account.Account.stripe_class.list_external_accounts(id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.account.Account.stripe_class.list_persons(id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.account.Account.stripe_class.login_links_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.account.Account.stripe_class.login_links_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.account.Account.stripe_class.modify(id=None, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          @classmethod
def modify(cls, id=None, **params):
    url = cls._build_instance_url(id)
    return cls._static_request("post", url, **params)
djstripe.models.account.Account.stripe_class.modify_capability(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.account.Account.stripe_class.modify_external_account(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.account.Account.stripe_class.modify_person(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.account.Account.stripe_class.persons(self, **params)
Source code in djstripe/models/account.py
          def persons(self, **params):
    return self.request("get", self.instance_url() + "/persons", params)
djstripe.models.account.Account.stripe_class.persons_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.account.Account.stripe_class.persons_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/account.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.account.Account.stripe_class.reject(self, idempotency_key=None, **params)
Source code in djstripe/models/account.py
          def reject(self, idempotency_key=None, **params):
    url = self.instance_url() + "/reject"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.account.Account.stripe_class.retrieve(id=None, api_key=None, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          @classmethod
def retrieve(cls, id=None, api_key=None, **params):
    instance = cls(id, api_key, **params)
    instance.refresh()
    return instance
djstripe.models.account.Account.stripe_class.retrieve_capability(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.account.Account.stripe_class.retrieve_external_account(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.account.Account.stripe_class.retrieve_person(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/account.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.account.Account.stripe_class.serialize(self, previous)
Source code in djstripe/models/account.py
          def serialize(self, previous):
    params = super(Account, self).serialize(previous)
    previous = previous or self._previous or {}
    for k, v in six.iteritems(self):
        if (
            k == "individual"
            and isinstance(v, stripe.api_resources.Person)
            and k not in params
        ):
            params[k] = v.serialize(previous.get(k, None))
    return params
djstripe.models.account.Account.__str__(self)
  
      special
  
    Source code in djstripe/models/account.py
          def __str__(self):
    settings = self.settings or {}
    business_profile = self.business_profile or {}
    return (
        settings.get("dashboard", {}).get("display_name")
        or business_profile.get("name")
        or super().__str__()
    )
djstripe.models.account.Account.get_business_type_display(self, *, field=<djstripe.fields.StripeEnumField: business_type>)
    Source code in djstripe/models/account.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.account.Account.get_default_account()
  
      classmethod
  
    Source code in djstripe/models/account.py
          @classmethod
def get_default_account(cls):
    # As of API version 2020-03-02, there is no permission that can allow
    # restricted keys to call GET /v1/account
    if djstripe_settings.STRIPE_SECRET_KEY.startswith("rk_"):
        return None
    account_data = cls.stripe_class.retrieve(
        api_key=djstripe_settings.STRIPE_SECRET_KEY
    )
    return cls._get_or_create_from_stripe_object(account_data)[0]
djstripe.models.account.Account.get_default_api_key(self)
    Source code in djstripe/models/account.py
          def get_default_api_key(self) -> str:
    api_key = APIKey.objects.filter(
        djstripe_owner_account=self, type=APIKeyType.secret
    ).first()
    if api_key:
        return api_key.secret
    return djstripe_settings.get_default_api_key(self.livemode)
djstripe.models.account.Account.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/account.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.account.Account.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/account.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.account.Account.get_or_retrieve_for_api_key(api_key)
  
      classmethod
  
    Source code in djstripe/models/account.py
          @classmethod
def get_or_retrieve_for_api_key(cls, api_key: str):
    with transaction.atomic():
        apikey_instance, _ = APIKey.objects.get_or_create_by_api_key(api_key)
        if not apikey_instance.djstripe_owner_account:
            apikey_instance.refresh_account()
        return apikey_instance.djstripe_owner_account
djstripe.models.account.Account.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/account.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.account.Account.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/account.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.account.Account.get_type_display(self, *, field=<djstripe.fields.StripeEnumField: type>)
    Source code in djstripe/models/account.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
Classes
        
djstripe.models.connect.ApplicationFee        
    When you collect a transaction fee on top of a charge made for your user (using Connect), an ApplicationFee is created in your account.
Please note the model field charge exists on the Stripe Connected Account while the application_fee modelfield on Charge model exists on the Platform Account!
Stripe documentation: https://stripe.com/docs/api#application_fees
djstripe.models.connect.ApplicationFee.account
    
djstripe.models.connect.ApplicationFee.amount
    
djstripe.models.connect.ApplicationFee.amount_refunded
    
djstripe.models.connect.ApplicationFee.balance_transaction
    
djstripe.models.connect.ApplicationFee.charge
    
djstripe.models.connect.ApplicationFee.currency
    
djstripe.models.connect.ApplicationFee.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.connect.ApplicationFee.refunded
    
        
djstripe.models.connect.ApplicationFee.DoesNotExist        
    
        
djstripe.models.connect.ApplicationFee.MultipleObjectsReturned        
    
        
djstripe.models.connect.ApplicationFee.stripe_class        
    djstripe.models.connect.ApplicationFee.stripe_class.OBJECT_NAME
djstripe.models.connect.ApplicationFee.stripe_class.create_refund(id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.connect.ApplicationFee.stripe_class.list_refunds(id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.connect.ApplicationFee.stripe_class.modify_refund(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.connect.ApplicationFee.stripe_class.refund(self, idempotency_key=None, **params)
Source code in djstripe/models/connect.py
          def refund(self, idempotency_key=None, **params):
    headers = util.populate_headers(idempotency_key)
    url = self.instance_url() + "/refund"
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.connect.ApplicationFee.stripe_class.refunds_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.connect.ApplicationFee.stripe_class.refunds_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.connect.ApplicationFee.stripe_class.retrieve_refund(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.connect.ApplicationFee.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.ApplicationFee.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.ApplicationFee.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.ApplicationFee.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.connect.ApplicationFeeRefund        
    ApplicationFeeRefund objects allow you to refund an ApplicationFee that has previously been created but not yet refunded. Funds will be refunded to the Stripe account from which the fee was originally collected.
Stripe documentation: https://stripe.com/docs/api#fee_refunds
djstripe.models.connect.ApplicationFeeRefund.amount
    
djstripe.models.connect.ApplicationFeeRefund.balance_transaction
    
djstripe.models.connect.ApplicationFeeRefund.currency
    
djstripe.models.connect.ApplicationFeeRefund.description
    
djstripe.models.connect.ApplicationFeeRefund.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.connect.ApplicationFeeRefund.fee
    
        
djstripe.models.connect.ApplicationFeeRefund.DoesNotExist        
    
        
djstripe.models.connect.ApplicationFeeRefund.MultipleObjectsReturned        
    
djstripe.models.connect.ApplicationFeeRefund.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.ApplicationFeeRefund.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.ApplicationFeeRefund.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.ApplicationFeeRefund.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.connect.CountrySpec        
    Stripe documentation: https://stripe.com/docs/api#country_specs
djstripe.models.connect.CountrySpec.default_currency
    
djstripe.models.connect.CountrySpec.id
    
djstripe.models.connect.CountrySpec.supported_bank_account_currencies
    
djstripe.models.connect.CountrySpec.supported_payment_currencies
    
djstripe.models.connect.CountrySpec.supported_payment_methods
    
djstripe.models.connect.CountrySpec.supported_transfer_countries
    
djstripe.models.connect.CountrySpec.verification_fields
    
        
djstripe.models.connect.CountrySpec.DoesNotExist        
    
        
djstripe.models.connect.CountrySpec.MultipleObjectsReturned        
    
        
djstripe.models.connect.CountrySpec.stripe_class        
    Methods
djstripe.models.connect.CountrySpec.api_retrieve(self, api_key=None, stripe_account=None)
    Source code in djstripe/models/connect.py
          def api_retrieve(self, api_key: str = None, stripe_account=None):
    if api_key is None:
        api_key = djstripe_settings.get_default_api_key(livemode=None)
    return self.stripe_class.retrieve(
        id=self.id,
        api_key=api_key,
        stripe_account=stripe_account,
    )
djstripe.models.connect.CountrySpec.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.CountrySpec.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.CountrySpec.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.CountrySpec.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.CountrySpec.sync_from_stripe_data(data)
  
      classmethod
  
    Syncs this object from the stripe data provided.
Foreign keys will also be retrieved and synced recursively.
:param data: stripe object :type data: dict :rtype: cls
Source code in djstripe/models/connect.py
          @classmethod
def sync_from_stripe_data(cls, data) -> "CountrySpec":
    """
    Syncs this object from the stripe data provided.
    Foreign keys will also be retrieved and synced recursively.
    :param data: stripe object
    :type data: dict
    :rtype: cls
    """
    data_id = data["id"]
    supported_fields = (
        "default_currency",
        "supported_bank_account_currencies",
        "supported_payment_currencies",
        "supported_payment_methods",
        "supported_transfer_countries",
        "verification_fields",
    )
    instance, created = cls.objects.get_or_create(
        id=data_id,
        defaults={k: data[k] for k in supported_fields},
    )
    return instance
        
djstripe.models.connect.Transfer        
    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?lang=python#transfers
djstripe.models.connect.Transfer.amount
    
djstripe.models.connect.Transfer.amount_reversed
    
djstripe.models.connect.Transfer.balance_transaction
    
djstripe.models.connect.Transfer.currency
    
djstripe.models.connect.Transfer.destination
    
djstripe.models.connect.Transfer.destination_payment
    
djstripe.models.connect.Transfer.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.connect.Transfer.expand_fields: List[str]
    
djstripe.models.connect.Transfer.fee
  
      property
      readonly
  
    
djstripe.models.connect.Transfer.objects
    
djstripe.models.connect.Transfer.reversed
    
djstripe.models.connect.Transfer.source_transaction
    
djstripe.models.connect.Transfer.source_type
    
djstripe.models.connect.Transfer.stripe_dashboard_item_name
    
djstripe.models.connect.Transfer.transfer_group
    
        
djstripe.models.connect.Transfer.DoesNotExist        
    
        
djstripe.models.connect.Transfer.MultipleObjectsReturned        
    
        
djstripe.models.connect.Transfer.stripe_class        
    djstripe.models.connect.Transfer.stripe_class.OBJECT_NAME
djstripe.models.connect.Transfer.stripe_class.cancel(self, idempotency_key=None, **params)
Source code in djstripe/models/connect.py
          def cancel(self, idempotency_key=None, **params):
    url = self.instance_url() + "/cancel"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.connect.Transfer.stripe_class.create_reversal(id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.connect.Transfer.stripe_class.list_reversals(id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.connect.Transfer.stripe_class.modify_reversal(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.connect.Transfer.stripe_class.retrieve_reversal(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.connect.Transfer.stripe_class.reversals_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.connect.Transfer.stripe_class.reversals_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
djstripe.models.connect.Transfer.__str__(self)
  
      special
  
    Source code in djstripe/models/connect.py
          def __str__(self):
    if self.reversed:
        # Complete Reversal
        return f"{self.human_readable_amount} Reversed"
    elif self.amount_reversed:
        # Partial Reversal
        return f"{self.human_readable_amount} Partially Reversed"
    # No Reversal
    return f"{self.human_readable_amount}"
djstripe.models.connect.Transfer.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.Transfer.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.Transfer.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.Transfer.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.Transfer.get_source_type_display(self, *, field=<djstripe.fields.StripeEnumField: source_type>)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.connect.TransferReversal        
    Stripe documentation: https://stripe.com/docs/api#transfer_reversals
djstripe.models.connect.TransferReversal.amount
    
djstripe.models.connect.TransferReversal.balance_transaction
    
djstripe.models.connect.TransferReversal.currency
    
djstripe.models.connect.TransferReversal.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.connect.TransferReversal.expand_fields: List[str]
    
djstripe.models.connect.TransferReversal.transfer
    
        
djstripe.models.connect.TransferReversal.DoesNotExist        
    
        
djstripe.models.connect.TransferReversal.MultipleObjectsReturned        
    
        
djstripe.models.connect.TransferReversal.stripe_class        
    djstripe.models.connect.TransferReversal.stripe_class.OBJECT_NAME
djstripe.models.connect.TransferReversal.stripe_class.cancel(self, idempotency_key=None, **params)
Source code in djstripe/models/connect.py
          def cancel(self, idempotency_key=None, **params):
    url = self.instance_url() + "/cancel"
    headers = util.populate_headers(idempotency_key)
    self.refresh_from(self.request("post", url, params, headers))
    return self
djstripe.models.connect.TransferReversal.stripe_class.create_reversal(id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def create_nested_resource(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.connect.TransferReversal.stripe_class.list_reversals(id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def list_nested_resources(cls, id, **params):
    url = getattr(cls, resource_url_method)(id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.connect.TransferReversal.stripe_class.modify_reversal(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def modify_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "post", url, **params
    )
djstripe.models.connect.TransferReversal.stripe_class.retrieve_reversal(id, nested_id, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def retrieve_nested_resource(cls, id, nested_id, **params):
    url = getattr(cls, resource_url_method)(id, nested_id)
    return getattr(cls, resource_request_method)(
        "get", url, **params
    )
djstripe.models.connect.TransferReversal.stripe_class.reversals_request(method, url, api_key=None, idempotency_key=None, stripe_version=None, stripe_account=None, **params)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def nested_resource_request(
    cls,
    method,
    url,
    api_key=None,
    idempotency_key=None,
    stripe_version=None,
    stripe_account=None,
    **params
):
    requestor = api_requestor.APIRequestor(
        api_key, api_version=stripe_version, account=stripe_account
    )
    headers = util.populate_headers(idempotency_key)
    response, api_key = requestor.request(method, url, params, headers)
    return util.convert_to_stripe_object(
        response, api_key, stripe_version, stripe_account
    )
djstripe.models.connect.TransferReversal.stripe_class.reversals_url(id, nested_id=None)
  
      classmethod
  
Source code in djstripe/models/connect.py
          def nested_resource_url(cls, id, nested_id=None):
    url = "%s/%s/%s" % (
        cls.class_url(),
        quote_plus(id),
        quote_plus(path),
    )
    if nested_id is not None:
        url += "/%s" % quote_plus(nested_id)
    return url
Methods
djstripe.models.connect.TransferReversal.__str__(self)
  
      special
  
    Source code in djstripe/models/connect.py
          def __str__(self):
    return str(self.transfer)
djstripe.models.connect.TransferReversal.api_list(api_key='sk_test_XXXXXXXXXXXXXXXXXXXXXXXXX', **kwargs)
  
      classmethod
  
    Call the stripe API's list operation for this model. :param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string See Stripe documentation for accepted kwargs for each object. :returns: an iterator over all items in the query
Source code in djstripe/models/connect.py
          @classmethod
def api_list(cls, api_key=djstripe_settings.STRIPE_SECRET_KEY, **kwargs):
    """
    Call the stripe API's list operation for this model.
    :param api_key: The api key to use for this request. \
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    See Stripe documentation for accepted kwargs for each object.
    :returns: an iterator over all items in the query
    """
    return stripe.Transfer.list_reversals(
        api_key=api_key, **kwargs
    ).auto_paging_iter()
djstripe.models.connect.TransferReversal.api_retrieve(self, api_key=None, stripe_account=None)
    Call the stripe API's retrieve operation for this model. :param api_key: The api key to use for this request. Defaults to djstripe_settings.STRIPE_SECRET_KEY. :type api_key: string :param stripe_account: The optional connected account for which this request is being made. :type stripe_account: string
Source code in djstripe/models/connect.py
          def api_retrieve(self, api_key=None, stripe_account=None):
    """
    Call the stripe API's retrieve operation for this model.
    :param api_key: The api key to use for this request. \
        Defaults to djstripe_settings.STRIPE_SECRET_KEY.
    :type api_key: string
    :param stripe_account: The optional connected account \
        for which this request is being made.
    :type stripe_account: string
    """
    nested_id = self.id
    id = self.transfer.id
    # Prefer passed in stripe_account if set.
    if not stripe_account:
        stripe_account = self._get_stripe_account_id(api_key)
    return stripe.Transfer.retrieve_reversal(
        id=id,
        nested_id=nested_id,
        api_key=api_key or self.default_api_key,
        expand=self.expand_fields,
        stripe_account=stripe_account,
    )
djstripe.models.connect.TransferReversal.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.TransferReversal.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.TransferReversal.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.TransferReversal.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/connect.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.connect.TransferReversal.is_valid_object(data)
  
      classmethod
  
    Returns whether the data is a valid object for the class
Source code in djstripe/models/connect.py
          @classmethod
def is_valid_object(cls, data):
    """
    Returns whether the data is a valid object for the class
    """
    return "object" in data and data["object"] == "transfer_reversal"
Fraud
Orders
Sigma
Classes
        
djstripe.models.sigma.ScheduledQueryRun        
    Stripe documentation: https://stripe.com/docs/api#scheduled_queries
djstripe.models.sigma.ScheduledQueryRun.data_load_time
    
djstripe.models.sigma.ScheduledQueryRun.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.sigma.ScheduledQueryRun.error
    
djstripe.models.sigma.ScheduledQueryRun.file
    
djstripe.models.sigma.ScheduledQueryRun.result_available_until
    
djstripe.models.sigma.ScheduledQueryRun.sql
    
djstripe.models.sigma.ScheduledQueryRun.status
    
djstripe.models.sigma.ScheduledQueryRun.title
    
        
djstripe.models.sigma.ScheduledQueryRun.DoesNotExist        
    
        
djstripe.models.sigma.ScheduledQueryRun.MultipleObjectsReturned        
    
        
djstripe.models.sigma.ScheduledQueryRun.stripe_class        
    djstripe.models.sigma.ScheduledQueryRun.stripe_class.OBJECT_NAME
djstripe.models.sigma.ScheduledQueryRun.stripe_class.class_url()
  
      classmethod
  
Source code in djstripe/models/sigma.py
          @classmethod
def class_url(cls):
    return "/v1/sigma/scheduled_query_runs"
djstripe.models.sigma.ScheduledQueryRun.__str__(self)
  
      special
  
    Source code in djstripe/models/sigma.py
          def __str__(self):
    return f"{self.title or self.id} ({self.status})"
djstripe.models.sigma.ScheduledQueryRun.get_next_by_data_load_time(self, *, field=<djstripe.fields.StripeDateTimeField: data_load_time>, is_next=True, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_next_by_result_available_until(self, *, field=<djstripe.fields.StripeDateTimeField: result_available_until>, is_next=True, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_previous_by_data_load_time(self, *, field=<djstripe.fields.StripeDateTimeField: data_load_time>, is_next=False, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_previous_by_result_available_until(self, *, field=<djstripe.fields.StripeDateTimeField: result_available_until>, is_next=False, **kwargs)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.sigma.ScheduledQueryRun.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/sigma.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
Webhooks
Module for dj-stripe Webhook models
Classes
        
djstripe.models.webhooks.WebhookEndpoint        
    WebhookEndpoint(djstripe_created, djstripe_updated, djstripe_id, id, djstripe_owner_account, livemode, created, metadata, description, api_version, enabled_events, secret, status, url, application, djstripe_uuid)
djstripe.models.webhooks.WebhookEndpoint.api_version
    
djstripe.models.webhooks.WebhookEndpoint.application
    
djstripe.models.webhooks.WebhookEndpoint.djstripe_owner_account: Optional[djstripe.fields.StripeForeignKey]
    
djstripe.models.webhooks.WebhookEndpoint.djstripe_uuid
    
djstripe.models.webhooks.WebhookEndpoint.enabled_events
    
djstripe.models.webhooks.WebhookEndpoint.secret
    
djstripe.models.webhooks.WebhookEndpoint.status
    
djstripe.models.webhooks.WebhookEndpoint.url
    
        
djstripe.models.webhooks.WebhookEndpoint.DoesNotExist        
    
        
djstripe.models.webhooks.WebhookEndpoint.MultipleObjectsReturned        
    
        
djstripe.models.webhooks.WebhookEndpoint.stripe_class        
    
djstripe.models.webhooks.WebhookEndpoint.__str__(self)
  
      special
  
    Source code in djstripe/models/webhooks.py
          def __str__(self):
    return self.url or str(self.djstripe_uuid)
djstripe.models.webhooks.WebhookEndpoint.get_next_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=True, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEndpoint.get_next_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=True, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEndpoint.get_previous_by_djstripe_created(self, *, field=<django.db.models.fields.DateTimeField: djstripe_created>, is_next=False, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEndpoint.get_previous_by_djstripe_updated(self, *, field=<django.db.models.fields.DateTimeField: djstripe_updated>, is_next=False, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEndpoint.get_status_display(self, *, field=<djstripe.fields.StripeEnumField: status>)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
        
djstripe.models.webhooks.WebhookEventTrigger        
    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.
djstripe.models.webhooks.WebhookEventTrigger.body
    
djstripe.models.webhooks.WebhookEventTrigger.created
    
djstripe.models.webhooks.WebhookEventTrigger.djstripe_version
    
djstripe.models.webhooks.WebhookEventTrigger.event
    
djstripe.models.webhooks.WebhookEventTrigger.exception
    
djstripe.models.webhooks.WebhookEventTrigger.headers
    
djstripe.models.webhooks.WebhookEventTrigger.id
    
djstripe.models.webhooks.WebhookEventTrigger.is_test_event
  
      property
      readonly
  
    
djstripe.models.webhooks.WebhookEventTrigger.processed
    
djstripe.models.webhooks.WebhookEventTrigger.remote_ip
    
djstripe.models.webhooks.WebhookEventTrigger.stripe_trigger_account
    
djstripe.models.webhooks.WebhookEventTrigger.traceback
    
djstripe.models.webhooks.WebhookEventTrigger.updated
    
djstripe.models.webhooks.WebhookEventTrigger.valid
    
        
djstripe.models.webhooks.WebhookEventTrigger.DoesNotExist        
    
        
djstripe.models.webhooks.WebhookEventTrigger.MultipleObjectsReturned        
    Methods
djstripe.models.webhooks.WebhookEventTrigger.__str__(self)
  
      special
  
    Source code in djstripe/models/webhooks.py
          def __str__(self):
    return f"id={self.id}, valid={self.valid}, processed={self.processed}"
djstripe.models.webhooks.WebhookEventTrigger.from_request(request)
  
      classmethod
  
    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).
Source code in djstripe/models/webhooks.py
          @classmethod
def from_request(cls, request):
    """
    Create, validate and process a WebhookEventTrigger given a Django
    request object.
    The process is three-fold:
    1. Create a WebhookEventTrigger object from a Django request.
    2. Validate the WebhookEventTrigger as a Stripe event using the API.
    3. If valid, process it into an Event object (and child resource).
    """
    try:
        body = request.body.decode(request.encoding or "utf-8")
    except Exception:
        body = "(error decoding body)"
    ip = get_remote_ip(request)
    try:
        data = json.loads(body)
    except ValueError:
        data = {}
    obj = cls.objects.create(
        headers=dict(request.headers),
        body=body,
        remote_ip=ip,
        stripe_trigger_account=StripeModel._find_owner_account(data=data),
    )
    try:
        obj.valid = obj.validate()
        if obj.valid:
            if djstripe_settings.WEBHOOK_EVENT_CALLBACK:
                # If WEBHOOK_EVENT_CALLBACK, pass it for processing
                djstripe_settings.WEBHOOK_EVENT_CALLBACK(obj)
            else:
                # Process the item (do not save it, it'll get saved below)
                obj.process(save=False)
    except Exception as e:
        max_length = WebhookEventTrigger._meta.get_field("exception").max_length
        obj.exception = str(e)[:max_length]
        obj.traceback = format_exc()
        # Send the exception as the webhook_processing_error signal
        webhook_processing_error.send(
            sender=WebhookEventTrigger,
            exception=e,
            data=getattr(e, "http_body", ""),
        )
        # re-raise the exception so Django sees it
        raise e
    finally:
        obj.save()
    return obj
djstripe.models.webhooks.WebhookEventTrigger.get_next_by_created(self, *, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEventTrigger.get_next_by_updated(self, *, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEventTrigger.get_previous_by_created(self, *, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEventTrigger.get_previous_by_updated(self, *, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)
    Source code in djstripe/models/webhooks.py
          def _method(cls_or_self, /, *args, **keywords):
    keywords = {**self.keywords, **keywords}
    return self.func(cls_or_self, *self.args, *args, **keywords)
djstripe.models.webhooks.WebhookEventTrigger.process(self, save=True)
    Source code in djstripe/models/webhooks.py
          def process(self, save=True):
    # Reset traceback and exception in case of reprocessing
    self.exception = ""
    self.traceback = ""
    self.event = Event.process(self.json_body)
    self.processed = True
    if save:
        self.save()
    return self.event
djstripe.models.webhooks.WebhookEventTrigger.validate(self, api_key=None)
    The original contents of the Event message must be confirmed by refetching it and comparing the fetched data with the original data.
This function makes an API call to Stripe to redownload the Event data and returns whether or not it matches the WebhookEventTrigger data.
Source code in djstripe/models/webhooks.py
          def validate(self, api_key=None):
    """
    The original contents of the Event message must be confirmed by
    refetching it and comparing the fetched data with the original data.
    This function makes an API call to Stripe to redownload the Event data
    and returns whether or not it matches the WebhookEventTrigger data.
    """
    local_data = self.json_body
    if "id" not in local_data or "livemode" not in local_data:
        logger.error(
            '"id" not in json body or "livemode" not in json body(%s)', local_data
        )
        return False
    if self.is_test_event:
        logger.info("Test webhook received and discarded: {}".format(local_data))
        return False
    if djstripe_settings.WEBHOOK_VALIDATION is None:
        # validation disabled
        warnings.warn("WEBHOOK VALIDATION is disabled.")
        return True
    elif (
        djstripe_settings.WEBHOOK_VALIDATION == "verify_signature"
        and djstripe_settings.WEBHOOK_SECRET
    ):
        # HTTP headers are case-insensitive, but we store them as a dict.
        headers = CaseInsensitiveMapping(self.headers)
        try:
            stripe.WebhookSignature.verify_header(
                self.body,
                headers.get("stripe-signature"),
                djstripe_settings.WEBHOOK_SECRET,
                djstripe_settings.WEBHOOK_TOLERANCE,
            )
        except stripe.error.SignatureVerificationError:
            logger.exception("Failed to verify header")
            return False
        else:
            return True
    livemode = local_data["livemode"]
    api_key = api_key or djstripe_settings.get_default_api_key(livemode)
    # Retrieve the event using the api_version specified in itself
    with stripe_temporary_api_version(local_data["api_version"], validate=False):
        remote_data = Event.stripe_class.retrieve(
            id=local_data["id"], api_key=api_key
        )
    return local_data["data"] == remote_data["data"]
Functions
djstripe.models.webhooks.get_remote_ip(request)
    Given the HTTPRequest object return the IP Address of the client
:param request: client request :type request: HTTPRequest
:Returns: the client ip address
Source code in djstripe/models/webhooks.py
          def get_remote_ip(request):
    """Given the HTTPRequest object return the IP Address of the client
    :param request: client request
    :type request: HTTPRequest
    :Returns: the client ip address
    """
    # HTTP_X_FORWARDED_FOR is relevant for django running behind a proxy
    x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR")
    if x_forwarded_for:
        ip = x_forwarded_for.split(",")[0]
    else:
        ip = request.META.get("REMOTE_ADDR")
    if not ip:
        warnings.warn(
            "Could not determine remote IP (missing REMOTE_ADDR). "
            "This is likely an issue with your wsgi/server setup."
        )
        ip = "0.0.0.0"
    return ip