Struct Subscription

Source
pub struct Subscription {
Show 41 fields pub application: Option<Expandable<Application>>, pub application_fee_percent: Option<f64>, pub automatic_tax: SubscriptionAutomaticTax, pub billing_cycle_anchor: Timestamp, pub billing_cycle_anchor_config: Option<SubscriptionsResourceBillingCycleAnchorConfig>, pub cancel_at: Option<Timestamp>, pub cancel_at_period_end: bool, pub canceled_at: Option<Timestamp>, pub cancellation_details: Option<CancellationDetails>, pub collection_method: SubscriptionCollectionMethod, pub created: Timestamp, pub currency: Currency, pub customer: Expandable<Customer>, pub days_until_due: Option<u32>, pub default_payment_method: Option<Expandable<PaymentMethod>>, pub default_source: Option<Expandable<PaymentSource>>, pub default_tax_rates: Option<Vec<TaxRate>>, pub description: Option<String>, pub discounts: Vec<Expandable<Discount>>, pub ended_at: Option<Timestamp>, pub id: SubscriptionId, pub invoice_settings: SubscriptionsResourceSubscriptionInvoiceSettings, pub items: List<SubscriptionItem>, pub latest_invoice: Option<Expandable<Invoice>>, pub livemode: bool, pub metadata: HashMap<String, String>, pub next_pending_invoice_item_invoice: Option<Timestamp>, pub on_behalf_of: Option<Expandable<Account>>, pub pause_collection: Option<SubscriptionsResourcePauseCollection>, pub payment_settings: Option<SubscriptionsResourcePaymentSettings>, pub pending_invoice_item_interval: Option<SubscriptionPendingInvoiceItemInterval>, pub pending_setup_intent: Option<Expandable<SetupIntent>>, pub pending_update: Option<SubscriptionsResourcePendingUpdate>, pub schedule: Option<Expandable<SubscriptionSchedule>>, pub start_date: Timestamp, pub status: SubscriptionStatus, pub test_clock: Option<Expandable<TestHelpersTestClock>>, pub transfer_data: Option<SubscriptionTransferData>, pub trial_end: Option<Timestamp>, pub trial_settings: Option<SubscriptionsTrialsResourceTrialSettings>, pub trial_start: Option<Timestamp>,
}
Expand description

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

Related guide: Creating subscriptions

For more details see <https://stripe.com/docs/api/subscriptions/object>.

Fields§

§application: Option<Expandable<Application>>

ID of the Connect Application that created the subscription.

§application_fee_percent: Option<f64>

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.

§automatic_tax: SubscriptionAutomaticTax§billing_cycle_anchor: Timestamp

The reference point that aligns future 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.

§billing_cycle_anchor_config: Option<SubscriptionsResourceBillingCycleAnchorConfig>

The fixed values used to calculate the billing_cycle_anchor.

§cancel_at: Option<Timestamp>

A date in the future at which the subscription will automatically get canceled

§cancel_at_period_end: bool

Whether this subscription will (if status=active) or did (if status=canceled) cancel at the end of the current billing period.

§canceled_at: Option<Timestamp>

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.

§cancellation_details: Option<CancellationDetails>

Details about why this subscription was cancelled

§collection_method: SubscriptionCollectionMethod

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.

§created: Timestamp

Time at which the object was created. Measured in seconds since the Unix epoch.

§currency: Currency

Three-letter ISO currency code, in lowercase. Must be a supported currency.

§customer: Expandable<Customer>

ID of the customer who owns the subscription.

§days_until_due: Option<u32>

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.

§default_payment_method: Option<Expandable<PaymentMethod>>

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 or default_source.

§default_source: Option<Expandable<PaymentSource>>

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 or default_source.

§default_tax_rates: Option<Vec<TaxRate>>

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.

§description: Option<String>

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.

§discounts: Vec<Expandable<Discount>>

The discounts applied to the subscription. Subscription item discounts are applied before subscription discounts. Use expand[]=discounts to expand each discount.

§ended_at: Option<Timestamp>

If the subscription has ended, the date the subscription ended.

§id: SubscriptionId

Unique identifier for the object.

§invoice_settings: SubscriptionsResourceSubscriptionInvoiceSettings§items: List<SubscriptionItem>

List of subscription items, each with an attached price.

§latest_invoice: Option<Expandable<Invoice>>

The most recent invoice this subscription has generated.

§livemode: bool

Has the value true if the object exists in live mode or the value false if the object exists in test mode.

§metadata: HashMap<String, String>

Set of key-value pairs 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: Option<Timestamp>

Specifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided at pending_invoice_item_interval.

§on_behalf_of: Option<Expandable<Account>>

The account (if any) the charge was made on behalf of for charges associated with this subscription. See the Connect documentation for details.

§pause_collection: Option<SubscriptionsResourcePauseCollection>

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.

§payment_settings: Option<SubscriptionsResourcePaymentSettings>

Payment settings passed on to invoices created by the subscription.

§pending_invoice_item_interval: Option<SubscriptionPendingInvoiceItemInterval>

Specifies an interval for how often to bill for any pending invoice items. It is analogous to calling Create an invoice for the given subscription at the specified interval.

§pending_setup_intent: Option<Expandable<SetupIntent>>

You can use this SetupIntent 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.

§pending_update: Option<SubscriptionsResourcePendingUpdate>

If specified, pending updates that will be applied to the subscription once the latest_invoice has been paid.

§schedule: Option<Expandable<SubscriptionSchedule>>

The schedule attached to the subscription

§start_date: Timestamp

Date when the subscription was first created. The date might differ from the created date due to backdating.

§status: SubscriptionStatus

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. 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, 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.

§test_clock: Option<Expandable<TestHelpersTestClock>>

ID of the test clock this subscription belongs to.

§transfer_data: Option<SubscriptionTransferData>

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.

§trial_end: Option<Timestamp>

If the subscription has a trial, the end of that trial.

§trial_settings: Option<SubscriptionsTrialsResourceTrialSettings>

Settings related to subscription trials.

§trial_start: Option<Timestamp>

If the subscription has a trial, the beginning of that trial.

Trait Implementations§

Source§

impl Clone for Subscription

Source§

fn clone(&self) -> Subscription

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Subscription

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deserialize for Subscription

Source§

fn begin(out: &mut Option<Self>) -> &mut dyn Visitor

The only correct implementation of this method is: Read more
Source§

impl FromValueOpt for Subscription

Source§

impl Object for Subscription

Source§

type Id = SubscriptionId

The canonical id type for this object.
Source§

fn id(&self) -> &Self::Id

The id of the object.
Source§

fn into_id(self) -> Self::Id

The owned id of the object.
Source§

impl ObjectDeser for Subscription

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.