thunderbird_accounts.subscription.models

Classes

PaddleId(*args[, db_collation])

Holds a paddle id with some sensible defaults, but is otherwise just a CharField

Plan(*args, **kwargs)

A paddle product This will correspond with permissions/plans

Price(*args, **kwargs)

Paddle price object.

Product(uuid, created_at, updated_at, ...)

Subscription(*args, **kwargs)

A paddle subscription object

SubscriptionItem(*args, **kwargs)

An item from a subscription, a subscription should really only have one of these unless we add additional purchasable/subscribable items like addons.

Transaction(uuid, created_at, updated_at, ...)

class thunderbird_accounts.subscription.models.PaddleId(*args, db_collation=None, **kwargs)[source]

Bases: CharField

Holds a paddle id with some sensible defaults, but is otherwise just a CharField

__init__(*args, db_collation=None, **kwargs)[source]
class thunderbird_accounts.subscription.models.Product(uuid, created_at, updated_at, paddle_id, name, description, product_type, status, webhook_updated_at)[source]

Bases: BaseModel

Parameters:
  • uuid (UUIDField) – Primary key: Uuid

  • created_at (DateTimeField) – Created at

  • updated_at (DateTimeField) – Updated at

  • paddle_id (PaddleId) – Paddle id

  • name (CharField) – Name

  • description (TextField) – Description

  • product_type (CharField) – Product type. Is this a catalog product (standard) or a custom product?

  • status (CharField) – Status. Is this product active or archived (cannot be used.)

  • webhook_updated_at (DateTimeField) – Webhook updated at. date when this model was last updated by a paddle webhook.

Reverse relationships:

Parameters:
  • price (Reverse ForeignKey from Price) – All prices of this product (related name of product)

  • plan (Reverse OneToOneField from Plan) – The plan of this product (related name of product)

  • subscriptionitem (Reverse ForeignKey from SubscriptionItem) – All subscription items of this product (related name of product)

class TypeValues(*values)[source]

Bases: TextChoices

class StatusValues(*values)[source]

Bases: TextChoices

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class thunderbird_accounts.subscription.models.Price(*args, **kwargs)[source]

Bases: BaseModel

Paddle price object. A product can have multiple of these.

Parameters:
  • uuid (UUIDField) – Primary key: Uuid

  • created_at (DateTimeField) – Created at

  • updated_at (DateTimeField) – Updated at

  • paddle_id (PaddleId) – Paddle id

  • paddle_product_id (PaddleId) – Paddle product id

  • name (CharField) – Name

  • amount (CharField) – Amount. Amount in lowest denomination for currency. e.g. 10 USD = 1000 (cents).

  • currency (CharField) – Currency. Three letter ISO 4217 currency code.

  • price_type (CharField) – Price type. Is this a one-off price?

  • status (CharField) – Status. Is this price active or archived (cannot be used.)

  • billing_cycle_frequency (CharField) – Billing cycle frequency. Amount of time in a billing cycle.

  • billing_cycle_interval (CharField) – Billing cycle interval. The unit of time in a billing cycle.

  • webhook_updated_at (DateTimeField) – Webhook updated at. date when this model was last updated by a paddle webhook.

Relationship fields:

Parameters:

product (ForeignKey to Product) – Product (related name: price)

Reverse relationships:

Parameters:

subscriptionitem (Reverse ForeignKey from SubscriptionItem) – All subscription items of this price (related name of price)

class TypeValues(*values)[source]

Bases: TextChoices

class IntervalValues(*values)[source]

Bases: TextChoices

class StatusValues(*values)[source]

Bases: TextChoices

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

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

Bases: BaseModel

A paddle product This will correspond with permissions/plans

For now a plan has access to all clients

Parameters:
  • uuid (UUIDField) – Primary key: Uuid

  • created_at (DateTimeField) – Created at

  • updated_at (DateTimeField) – Updated at

  • name (CharField) – Name

  • visible_on_subscription_page (BooleanField) – Visible on subscription page. Is this plan visible on the subscription page?

  • mail_address_count (IntegerField) – Mail address count. Amount of mail addresses a user can create.

  • mail_domain_count (IntegerField) – Mail domain count. Amount of custom domains a user can have.

  • mail_storage_gb (IntegerField) – Mail storage gb. Amount of mail storage a user has access to (in GB).

  • send_storage_gb (IntegerField) – Send storage gb. Amount of send storage a user has access to (in GB).

Relationship fields:

Parameters:

product (OneToOneField to Product) – Product (related name: plan)

save(**kwargs)[source]

Override save to quickly check if the mail_storage_gb field has changed, if it has then ship off a task off to update each associated mail account. FIXME: This probably could be in a util function, I’m just worried we might not catch all updates.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

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

Bases: BaseModel

An item from a subscription, a subscription should really only have one of these unless we add additional purchasable/subscribable items like addons.

Parameters:
  • uuid (UUIDField) – Primary key: Uuid

  • created_at (DateTimeField) – Created at

  • updated_at (DateTimeField) – Updated at

  • quantity (IntegerField) – Quantity

  • paddle_price_id (PaddleId) – Paddle price id

  • paddle_product_id (PaddleId) – Paddle product id

  • paddle_subscription_id (PaddleId) – Paddle subscription id

Relationship fields:

Parameters:
  • subscription (ForeignKey to Subscription) – Subscription (related name: subscriptionitem)

  • price (ForeignKey to Price) – Price (related name: subscriptionitem)

  • product (ForeignKey to Product) – Product (related name: subscriptionitem)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class thunderbird_accounts.subscription.models.Subscription(*args, **kwargs)[source]

Bases: BaseModel

A paddle subscription object

Parameters:
  • uuid (UUIDField) – Primary key: Uuid

  • created_at (DateTimeField) – Created at

  • updated_at (DateTimeField) – Updated at

  • paddle_id (PaddleId) – Paddle id. The subscription paddle id.

  • paddle_customer_id (PaddleId) – Paddle customer id. The customer paddle id.

  • status (CharField) – Status. The current subscription status.

  • next_billed_at (DateTimeField) – Next billed at. date when the subscription is next schedule to be billed.

  • current_billing_period_starts_at (DateTimeField) – Current billing period starts at. date when the billing period starts.

  • current_billing_period_ends_at (DateTimeField) – Current billing period ends at. date when the billing period ends.

  • webhook_updated_at (DateTimeField) – Webhook updated at. date when this model was last updated by a paddle webhook.

Relationship fields:

Parameters:

user (ForeignKey to User) – User (related name: subscription)

Reverse relationships:

Parameters:
  • subscriptionitem (Reverse ForeignKey from SubscriptionItem) – All subscription items of this subscription (related name of subscription)

  • transaction (Reverse ForeignKey from Transaction) – All transactions of this subscription (related name of subscription)

class StatusValues(*values)[source]

Bases: TextChoices

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class thunderbird_accounts.subscription.models.Transaction(uuid, created_at, updated_at, paddle_id, paddle_invoice_id, paddle_subscription_id, invoice_number, total, tax, currency, status, transaction_origin, billed_at, revised_at, webhook_updated_at, subscription)[source]

Bases: BaseModel

Parameters:
  • uuid (UUIDField) – Primary key: Uuid

  • created_at (DateTimeField) – Created at

  • updated_at (DateTimeField) – Updated at

  • paddle_id (PaddleId) – Paddle id. The transaction paddle id.

  • paddle_invoice_id (PaddleId) – Paddle invoice id. The invoice paddle id,

  • paddle_subscription_id (PaddleId) – Paddle subscription id. The subscription paddle id.

  • invoice_number (CharField) – Invoice number. Invoice number for this transaction.

  • total (CharField) – Total. Total after discount and tax.

  • tax (CharField) – Tax. Total tax on the subtotal.

  • currency (CharField) – Currency. Three letter ISO 4217 currency code.

  • status (CharField) – Status. The current subscription status.

  • transaction_origin (CharField) – Transaction origin. where the transaction first start from.

  • billed_at (DateTimeField) – Billed at. date when the subscription is next schedule to be billed.

  • revised_at (DateTimeField) – Revised at. date when the subscription is next schedule to be billed.

  • webhook_updated_at (DateTimeField) – Webhook updated at. date when this model was last updated by a paddle webhook.

Relationship fields:

Parameters:

subscription (ForeignKey to Subscription) – Subscription (related name: transaction)

class StatusValues(*values)[source]

Bases: TextChoices

class OriginValues(*values)[source]

Bases: TextChoices

Values from https://developer.paddle.com/webhooks/transactions/transaction-created -> origin

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned