# `Stripe.Resources.Subscription`
[🔗](https://github.com/jeffhuen/tiger_stripe/blob/main/lib/stripe/resources/subscription.ex#L2)

Subscription

Subscriptions allow you to charge a customer on a recurring basis.

Related guide: [Creating subscriptions](https://docs.stripe.com/billing/subscriptions/creating)

# `t`

```elixir
@type t() :: %Stripe.Resources.Subscription{
  application: map(),
  application_fee_percent: float(),
  automatic_tax: map(),
  billing_cycle_anchor: integer(),
  billing_cycle_anchor_config: map(),
  billing_mode: map(),
  billing_thresholds: map(),
  cancel_at: integer(),
  cancel_at_period_end: boolean(),
  canceled_at: integer(),
  cancellation_details: map(),
  collection_method: String.t(),
  created: integer(),
  currency: String.t(),
  customer: map(),
  customer_account: String.t(),
  days_until_due: integer(),
  default_payment_method: String.t() | map(),
  default_source: String.t() | map(),
  default_tax_rates: [String.t() | map()] | nil,
  description: String.t(),
  discounts: [String.t() | map()],
  ended_at: integer(),
  id: String.t(),
  invoice_settings: map(),
  items: map(),
  latest_invoice: String.t() | map(),
  livemode: boolean(),
  metadata: map(),
  next_pending_invoice_item_invoice: integer(),
  object: String.t(),
  on_behalf_of: String.t() | map(),
  pause_collection: map(),
  payment_settings: map(),
  pending_invoice_item_interval: map(),
  pending_setup_intent: String.t() | map(),
  pending_update: map(),
  schedule: String.t() | map(),
  start_date: integer(),
  status: String.t(),
  test_clock: String.t() | map(),
  transfer_data: map(),
  trial_end: integer(),
  trial_settings: map(),
  trial_start: integer()
}
```

* `application` - ID of the Connect Application that created the subscription. Nullable. Expandable.
* `application_fee_percent` - A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account. Nullable.
* `automatic_tax` - Expandable.
* `billing_cycle_anchor` - The reference point that aligns future [billing cycle](https://docs.stripe.com/subscriptions/billing-cycle) dates. It sets the day of week for `week` intervals, the day of month for `month` and `year` intervals, and the month of year for `year` intervals. The timestamp is in UTC format. Format: Unix timestamp.
* `billing_cycle_anchor_config` - The fixed values used to calculate the `billing_cycle_anchor`. Nullable. Expandable.
* `billing_mode` - Expandable.
* `billing_thresholds` - Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period Nullable. Expandable.
* `cancel_at` - A date in the future at which the subscription will automatically get canceled Format: Unix timestamp. Nullable.
* `cancel_at_period_end` - Whether this subscription will (if `status=active`) or did (if `status=canceled`) cancel at the end of the current billing period.
* `canceled_at` - If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with `cancel_at_period_end`, `canceled_at` will reflect the time of the most recent update request, not the end of the subscription period when the subscription is automatically moved to a canceled state. Format: Unix timestamp. Nullable.
* `cancellation_details` - Details about why this subscription was cancelled Nullable. Expandable.
* `collection_method` - Either `charge_automatically`, or `send_invoice`. When charging automatically, Stripe will attempt to pay this subscription at the end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`. Possible values: `charge_automatically`, `send_invoice`.
* `created` - Time at which the object was created. Measured in seconds since the Unix epoch. Format: Unix timestamp.
* `currency` - Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies). Format: ISO 4217 currency code.
* `customer` - ID of the customer who owns the subscription. Expandable.
* `customer_account` - ID of the account representing the customer who owns the subscription. Max length: 5000. Nullable.
* `days_until_due` - Number of days a customer has to pay invoices generated by this subscription. This value will be `null` for subscriptions where `collection_method=charge_automatically`. Nullable.
* `default_payment_method` - ID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence over `default_source`. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://docs.stripe.com/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://docs.stripe.com/api/customers/object#customer_object-default_source). Nullable. Expandable.
* `default_source` - ID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. If `default_payment_method` is also set, `default_payment_method` will take precedence. If neither are set, invoices will use the customer's [invoice_settings.default_payment_method](https://docs.stripe.com/api/customers/object#customer_object-invoice_settings-default_payment_method) or [default_source](https://docs.stripe.com/api/customers/object#customer_object-default_source). Nullable. Expandable.
* `default_tax_rates` - The tax rates that will apply to any subscription item that does not have `tax_rates` set. Invoices created will have their `default_tax_rates` populated from the subscription. Nullable. Expandable.
* `description` - The subscription's description, meant to be displayable to the customer. Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs. Max length: 500. Nullable.
* `discounts` - The discounts applied to the subscription. Subscription item discounts are applied before subscription discounts. Use `expand[]=discounts` to expand each discount. Expandable.
* `ended_at` - If the subscription has ended, the date the subscription ended. Format: Unix timestamp. Nullable.
* `id` - Unique identifier for the object. Max length: 5000.
* `invoice_settings` - Expandable.
* `items` - List of subscription items, each with an attached price. Expandable.
* `latest_invoice` - The most recent invoice this subscription has generated over its lifecycle (for example, when it cycles or is updated). Nullable. Expandable.
* `livemode` - Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
* `metadata` - Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
* `next_pending_invoice_item_invoice` - Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at `pending_invoice_item_interval`. Format: Unix timestamp. Nullable.
* `object` - String representing the object's type. Objects of the same type share the same value. Possible values: `subscription`.
* `on_behalf_of` - The account (if any) the charge was made on behalf of for charges associated with this subscription. See the [Connect documentation](https://docs.stripe.com/connect/subscriptions#on-behalf-of) for details. Nullable. Expandable.
* `pause_collection` - If specified, payment collection for this subscription will be paused. Note that the subscription status will be unchanged and will not be updated to `paused`. Learn more about [pausing collection](https://docs.stripe.com/billing/subscriptions/pause-payment). Nullable. Expandable.
* `payment_settings` - Payment settings passed on to invoices created by the subscription. Nullable. Expandable.
* `pending_invoice_item_interval` - Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling [Create an invoice](https://docs.stripe.com/api#create_invoice) for the given subscription at the specified interval. Nullable. Expandable.
* `pending_setup_intent` - You can use this [SetupIntent](https://docs.stripe.com/api/setup_intents) to collect user authentication when creating a subscription without immediate payment or updating a subscription's payment method, allowing you to optimize for off-session payments. Learn more in the [SCA Migration Guide](https://docs.stripe.com/billing/migration/strong-customer-authentication#scenario-2). Nullable. Expandable.
* `pending_update` - If specified, [pending updates](https://docs.stripe.com/billing/subscriptions/pending-updates) that will be applied to the subscription once the `latest_invoice` has been paid. Nullable. Expandable.
* `schedule` - The schedule attached to the subscription Nullable. Expandable.
* `start_date` - Date when the subscription was first created. The date might differ from the `created` date due to backdating. Format: Unix timestamp.
* `status` - Possible values are `incomplete`, `incomplete_expired`, `trialing`, `active`, `past_due`, `canceled`, `unpaid`, or `paused`. 

For `collection_method=charge_automatically` a subscription moves into `incomplete` if the initial payment attempt fails. A subscription in this status can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an `active` status. If the first invoice is not paid within 23 hours, the subscription transitions to `incomplete_expired`. This is a terminal status, the open invoice will be voided and no further invoices will be generated. 

A subscription that is currently in a trial period is `trialing` and moves to `active` when the trial period is over. 

A subscription can only enter a `paused` status [when a trial ends without a payment method](https://docs.stripe.com/billing/subscriptions/trials#create-free-trials-without-payment). A `paused` subscription doesn't generate invoices and can be resumed after your customer adds their payment method. The `paused` status is different from [pausing collection](https://docs.stripe.com/billing/subscriptions/pause-payment), which still generates invoices and leaves the subscription's status unchanged. 

If subscription `collection_method=charge_automatically`, it becomes `past_due` when payment is required but cannot be paid (due to failed payment or awaiting additional user actions). Once Stripe has exhausted all payment retry attempts, the subscription will become `canceled` or `unpaid` (depending on your subscriptions settings). 

If subscription `collection_method=send_invoice` it becomes `past_due` when its invoice is not paid by the due date, and `canceled` or `unpaid` if it is still not paid by an additional deadline after that. 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). After receiving updated payment information from a customer, you may choose to reopen and pay their closed invoices. Possible values: `active`, `canceled`, `incomplete`, `incomplete_expired`, `past_due`, `paused`, `trialing`, `unpaid`.
* `test_clock` - ID of the test clock this subscription belongs to. Nullable. Expandable.
* `transfer_data` - The account (if any) the subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices. Nullable. Expandable.
* `trial_end` - If the subscription has a trial, the end of that trial. Format: Unix timestamp. Nullable.
* `trial_settings` - Settings related to subscription trials. Nullable. Expandable.
* `trial_start` - If the subscription has a trial, the beginning of that trial. Format: Unix timestamp. Nullable.

# `expandable_fields`

# `object_name`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
