Reference¶
django_stripe.common¶
Abstract model for storing Stripe objects.
- class django_stripe.common.models.AbstractStripeModel(*args, **kwargs)
An abstract base class for storing Stripe-related objects in the database.
This model provides a standardized schema for storing information from Stripe objects, including their unique identifier, mode, data, and timestamps. It is intended to be inherited by other models which interact with various Stripe objects such as charges, payments, or accounts.
- stripe_id
Unique identifier for the Stripe object.
- livemode
Indicates whether the object was created within Stripe’s live mode.
- data
Stores the complete JSON representation of the Stripe object.
- created_at
Timestamp indicating when the object was first created.
- updated_at
Timestamp indicating when the object was last updated.
- connect_account_id
The Stripe Connect account ID this object is associated with, if any. # noqa B950
The class is abstract and should not be instantiated directly.
- process_data(event)
Updates the model’s data based on a Stripe webhook payload.
This method is designed to handle the data from a webhook event, updating the model’s fields accordingly.
- Parameters:
event (stripe.Event) – The Stripe event object containing the webhook data.
- Return type:
None
No return value; the instance is updated and saved to the database.
- retrieve_data_from_stripe()
Retrieves the latest data from Stripe for a specific object ID and updates the model.
This method directly interacts with the Stripe API to fetch the latest data for a specific object, updating the model’s data field and saving the changes.
- Raises:
ValueError – If stripe_sdk_name is not defined in the subclass.
- Returns:
The JSON data retrieved from the Stripe API as a dictionary.
- Return type:
json
django_stripe.account¶
- class django_stripe.account.models.Account(*args, **kwargs)¶
A model for storing Stripe Account objects. Inherits all fields and methods from AbstractStripeModel.
django_stripe.charge¶
- class django_stripe.charge.models.Charge(*args, **kwargs)¶
A model for storing Stripe Charge objects. Inherits all fields and methods from AbstractStripeModel.
django_stripe.checkout_session¶
- class django_stripe.checkout_session.models.CheckoutSession(*args, **kwargs)¶
A model for storing Stripe CheckoutSession objects. Inherits all fields and methods from AbstractStripeModel.
django_stripe.payment_intent¶
- class django_stripe.payment_intent.models.PaymentIntent(*args, **kwargs)¶
A model for storing Stripe PaymentIntent objects. Inherits all fields and methods from AbstractStripeModel.