View Source Stripe.Subscription (Striped v0.5.0) (generated)
Subscriptions allow you to charge a customer on a recurring basis.
Related guide: Creating Subscriptions.
Link to this section Summary
Types
Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
Configuration for the bank transfer funding type, if the funding_type is set to bank_transfer.
Configuration for eu_bank_transfer funding type.
Additional fields for Financial Connections Session creation
Additional fields for Mandate creation
Payment-method-specific configuration to provide to invoices created by the subscription.
Payment settings to pass to invoices created by the subscription.
Data used to generate a new Price object inline.
The recurring components of a price such as interval and interval_count.
The subscription type.
If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges.
Functions
Cancels a customer’s subscription immediately. The customer will not be charged again for the subscription.
Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.
Removes the currently applied discount on a subscription.
By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.
Retrieves the subscription with the given ID.
Search for subscriptions you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
Updates an existing subscription on a customer to match the specified parameters. When changing plans or quantities, we will optionally prorate the price we charge next month to make up for any price changes. To preview how the proration will be calculated, use the upcoming invoice endpoint.
Link to this section Types
@type acss_debit() :: %{ optional(:mandate_options) => mandate_options(), optional(:verification_method) => :automatic | :instant | :microdeposits }
@type add_invoice_items() :: %{ optional(:price) => binary(), optional(:price_data) => price_data(), optional(:quantity) => integer(), optional(:tax_rates) => [binary()] | binary() }
@type automatic_tax() :: %{optional(:enabled) => boolean()}
Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.
@type bancontact() :: %{optional(:preferred_language) => :de | :en | :fr | :nl}
@type bank_transfer() :: %{ optional(:eu_bank_transfer) => eu_bank_transfer(), optional(:type) => binary() }
Configuration for the bank transfer funding type, if the funding_type is set to bank_transfer.
@type card() :: %{ optional(:mandate_options) => mandate_options(), optional(:network) => :amex | :cartes_bancaires | :diners | :discover | :interac | :jcb | :mastercard | :unionpay | :unknown | :visa, optional(:request_three_d_secure) => :any | :automatic }
@type customer_balance() :: %{ optional(:bank_transfer) => bank_transfer(), optional(:funding_type) => binary() }
@type eu_bank_transfer() :: %{optional(:country) => binary()}
Configuration for eu_bank_transfer funding type.
@type financial_connections() :: %{
optional(:permissions) => [
:balances | :ownership | :payment_method | :transactions
]
}
Additional fields for Financial Connections Session creation
@type items() :: %{ optional(:billing_thresholds) => billing_thresholds() | binary(), optional(:metadata) => %{optional(binary()) => binary()}, optional(:plan) => binary(), optional(:price) => binary(), optional(:price_data) => price_data(), optional(:quantity) => integer(), optional(:tax_rates) => [binary()] | binary() }
@type mandate_options() :: %{optional(:transaction_type) => :business | :personal}
Additional fields for Mandate creation
@type pause_collection() :: %{ optional(:behavior) => :keep_as_draft | :mark_uncollectible | :void, optional(:resumes_at) => integer() }
@type payment_method_options() :: %{ optional(:acss_debit) => acss_debit() | binary(), optional(:bancontact) => bancontact() | binary(), optional(:card) => card() | binary(), optional(:customer_balance) => customer_balance() | binary(), optional(:konbini) => map() | binary(), optional(:us_bank_account) => us_bank_account() | binary() }
Payment-method-specific configuration to provide to invoices created by the subscription.
@type payment_settings() :: %{ optional(:payment_method_options) => payment_method_options(), optional(:payment_method_types) => [ :ach_credit_transfer | :ach_debit | :acss_debit | :au_becs_debit | :bacs_debit | :bancontact | :boleto | :card | :customer_balance | :fpx | :giropay | :grabpay | :ideal | :konbini | :link | :paynow | :promptpay | :sepa_credit_transfer | :sepa_debit | :sofort | :us_bank_account | :wechat_pay ] | binary(), optional(:save_default_payment_method) => :off | :on_subscription }
Payment settings to pass to invoices created by the subscription.
@type pending_invoice_item_interval() :: %{ optional(:interval) => :day | :month | :week | :year, optional(:interval_count) => integer() }
@type price_data() :: %{ optional(:currency) => binary(), optional(:product) => binary(), optional(:recurring) => recurring(), optional(:tax_behavior) => :exclusive | :inclusive | :unspecified, optional(:unit_amount) => integer(), optional(:unit_amount_decimal) => binary() }
Data used to generate a new Price object inline.
@type recurring() :: %{ optional(:interval) => :day | :month | :week | :year, optional(:interval_count) => integer() }
The recurring components of a price such as interval and interval_count.
@type t() :: %Stripe.Subscription{ application: (binary() | term() | term()) | nil, application_fee_percent: term() | nil, automatic_tax: term(), billing_cycle_anchor: integer(), billing_thresholds: term() | nil, cancel_at: integer() | nil, cancel_at_period_end: boolean(), canceled_at: integer() | nil, collection_method: binary(), created: integer(), currency: binary(), current_period_end: integer(), current_period_start: integer(), customer: binary() | Stripe.Customer.t() | Stripe.DeletedCustomer.t(), days_until_due: integer() | nil, default_payment_method: (binary() | Stripe.PaymentMethod.t()) | nil, default_source: (binary() | Stripe.PaymentSource.t()) | nil, default_tax_rates: term() | nil, description: binary() | nil, discount: term() | nil, ended_at: integer() | nil, id: binary(), items: term(), latest_invoice: (binary() | Stripe.Invoice.t()) | nil, livemode: boolean(), metadata: term(), next_pending_invoice_item_invoice: integer() | nil, object: binary(), on_behalf_of: (binary() | Stripe.Account.t()) | nil, pause_collection: term() | nil, payment_settings: term() | nil, pending_invoice_item_interval: term() | nil, pending_setup_intent: (binary() | Stripe.SetupIntent.t()) | nil, pending_update: term() | nil, schedule: (binary() | Stripe.SubscriptionSchedule.t()) | nil, start_date: integer(), status: binary(), test_clock: (binary() | Stripe.TestHelpers.TestClock.t()) | nil, transfer_data: term() | nil, trial_end: integer() | nil, trial_start: integer() | nil }
The subscription type.
application_fee_percentA non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the application owner's Stripe account.livemodeHas the valuetrueif the object exists in live mode or the valuefalseif the object exists in test mode.collection_methodEithercharge_automatically, orsend_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 asactive.default_payment_methodID of the default payment method for the subscription. It must belong to the customer associated with the subscription. This takes precedence overdefault_source. If neither are set, invoices will use the customer's invoice_settings.default_payment_method or default_source.metadataSet 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.descriptionThe 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.pending_setup_intentYou 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.discountDescribes the current discount applied to this subscription, if there is one. When billing, a discount applied to a subscription overrides a discount applied on a customer-wide basis.start_dateDate when the subscription was first created. The date might differ from thecreateddate due to backdating.on_behalf_ofThe account (if any) the charge was made on behalf of for charges associated with this subscription. See the Connect documentation for details.pause_collectionIf specified, payment collection for this subscription will be paused.customerID of the customer who owns the subscription.ended_atIf the subscription has ended, the date the subscription ended.days_until_dueNumber of days a customer has to pay invoices generated by this subscription. This value will benullfor subscriptions wherecollection_method=charge_automatically.payment_settingsPayment settings passed on to invoices created by the subscription.applicationID of the Connect Application that created the subscription.pending_invoice_item_intervalSpecifies 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.billing_thresholdsDefine thresholds at which an invoice will be sent, and the subscription advanced to a new billing periodnext_pending_invoice_item_invoiceSpecifies the approximate timestamp on which any pending invoice items will be billed according to the schedule provided atpending_invoice_item_interval.default_sourceID of the default payment source for the subscription. It must belong to the customer associated with the subscription and be in a chargeable state. Ifdefault_payment_methodis also set,default_payment_methodwill take precedence. If neither are set, invoices will use the customer's invoice_settings.default_payment_method or default_source.cancel_at_period_endIf the subscription has been canceled with theat_period_endflag set totrue,cancel_at_period_endon the subscription will be true. You can use this attribute to determine whether a subscription that has a status of active is scheduled to be canceled at the end of the current period.objectString representing the object's type. Objects of the same type share the same value.billing_cycle_anchorDetermines the date of the first full invoice, and, for plans withmonthoryearintervals, the day of the month for subsequent invoices. The timestamp is in UTC format.test_clockID of the test clock this subscription belongs to.automatic_taxscheduleThe schedule attached to the subscriptioncanceled_atIf the subscription has been canceled, the date of that cancellation. If the subscription was canceled withcancel_at_period_end,canceled_atwill 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.current_period_endEnd of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created.latest_invoiceThe most recent invoice this subscription has generated.currencyThree-letter ISO currency code, in lowercase. Must be a supported currency.createdTime at which the object was created. Measured in seconds since the Unix epoch.trial_endIf the subscription has a trial, the end of that trial.cancel_atA date in the future at which the subscription will automatically get canceledtrial_startIf the subscription has a trial, the beginning of that trial.current_period_startStart of the current period that the subscription has been invoiced for.statusPossible values areincomplete,incomplete_expired,trialing,active,past_due,canceled, orunpaid.
For collection_method=charge_automatically a subscription moves into incomplete if the initial payment attempt fails. A subscription in this state can only have metadata and default_source updated. Once the first invoice is paid, the subscription moves into an active state. If the first invoice is not paid within 23 hours, the subscription transitions to incomplete_expired. This is a terminal state, 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.
If subscription collection_method=charge_automatically it becomes past_due when payment to renew it fails and canceled or unpaid (depending on your subscriptions settings) when Stripe has exhausted all payment retry attempts.
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.
itemsList of subscription items, each with an attached price.transfer_dataThe 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.idUnique identifier for the object.pending_updateIf specified, pending updates that will be applied to the subscription once thelatest_invoicehas been paid.default_tax_ratesThe tax rates that will apply to any subscription item that does not havetax_ratesset. Invoices created will have theirdefault_tax_ratespopulated from the subscription.
@type transfer_data() :: %{ optional(:amount_percent) => number(), optional(:destination) => binary() }
If specified, the funds from the subscription's invoices will be transferred to the destination and the ID of the resulting transfers will be found on the resulting charges.
@type us_bank_account() :: %{ optional(:financial_connections) => financial_connections(), optional(:verification_method) => :automatic | :instant | :microdeposits }
Link to this section Functions
cancel(client, subscription_exposed_id, params \\ %{}, opts \\ [])
View Source@spec cancel( client :: Stripe.t(), subscription_exposed_id :: binary(), params :: %{ optional(:expand) => [binary()], optional(:invoice_now) => boolean(), optional(:prorate) => boolean() }, opts :: Keyword.t() ) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Cancels a customer’s subscription immediately. 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 the end of the period, 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, upon subscription cancellation, Stripe will stop automatic collection of all finalized invoices for the customer. This is intended to prevent unexpected payment attempts after the customer has canceled a subscription. However, you can resume automatic collection of the invoices manually after subscription cancellation to have us proceed. Or, you could check for unpaid invoices before allowing the customer to cancel the subscription at all.
Details
- Method:
delete - Path:
/v1/subscriptions/{subscription_exposed_id}
@spec create( client :: Stripe.t(), params :: %{ optional(:add_invoice_items) => [add_invoice_items()], optional(:application_fee_percent) => number(), optional(:automatic_tax) => automatic_tax(), optional(:backdate_start_date) => integer(), optional(:billing_cycle_anchor) => integer(), optional(:billing_thresholds) => billing_thresholds() | binary(), optional(:cancel_at) => integer(), optional(:cancel_at_period_end) => boolean(), optional(:collection_method) => :charge_automatically | :send_invoice, optional(:coupon) => binary(), optional(:currency) => binary(), optional(:customer) => binary(), optional(:days_until_due) => integer(), optional(:default_payment_method) => binary(), optional(:default_source) => binary(), optional(:default_tax_rates) => [binary()] | binary(), optional(:description) => binary(), optional(:expand) => [binary()], optional(:items) => [items()], optional(:metadata) => %{optional(binary()) => binary()} | binary(), optional(:off_session) => boolean(), optional(:on_behalf_of) => binary() | binary(), optional(:payment_behavior) => :allow_incomplete | :default_incomplete | :error_if_incomplete | :pending_if_incomplete, optional(:payment_settings) => payment_settings(), optional(:pending_invoice_item_interval) => pending_invoice_item_interval() | binary(), optional(:promotion_code) => binary(), optional(:proration_behavior) => :always_invoice | :create_prorations | :none, optional(:transfer_data) => transfer_data(), optional(:trial_end) => :now | integer(), optional(:trial_from_plan) => boolean(), optional(:trial_period_days) => integer() }, opts :: Keyword.t() ) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Creates a new subscription on an existing customer. Each customer can have up to 500 active or scheduled subscriptions.
When you create a subscription with collection_method=charge_automatically, the first invoice is finalized as part of the request.The payment_behavior parameter determines the exact behavior of the initial payment.
To start subscriptions where the first invoice always begins in a draft status, use subscription schedules instead.Schedules provide the flexibility to model more complex billing configurations that change over time.
Details
- Method:
post - Path:
/v1/subscriptions
@spec delete_discount( client :: Stripe.t(), subscription_exposed_id :: binary(), opts :: Keyword.t() ) :: {:ok, Stripe.DeletedDiscount.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Removes the currently applied discount on a subscription.
Details
- Method:
delete - Path:
/v1/subscriptions/{subscription_exposed_id}/discount
@spec list( client :: Stripe.t(), params :: %{ optional(:collection_method) => :charge_automatically | :send_invoice, optional(:created) => created() | integer(), optional(:current_period_end) => current_period_end() | integer(), optional(:current_period_start) => current_period_start() | integer(), optional(:customer) => binary(), optional(:ending_before) => binary(), optional(:expand) => [binary()], optional(:limit) => integer(), optional(:plan) => binary(), optional(:price) => binary(), optional(:starting_after) => binary(), optional(:status) => :active | :all | :canceled | :ended | :incomplete | :incomplete_expired | :past_due | :trialing | :unpaid, optional(:test_clock) => binary() }, opts :: Keyword.t() ) :: {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
By default, returns a list of subscriptions that have not been canceled. In order to list canceled subscriptions, specify status=canceled.
Details
- Method:
get - Path:
/v1/subscriptions
retrieve(client, subscription_exposed_id, params \\ %{}, opts \\ [])
View Source@spec retrieve( client :: Stripe.t(), subscription_exposed_id :: binary(), params :: %{optional(:expand) => [binary()]}, opts :: Keyword.t() ) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Retrieves the subscription with the given ID.
Details
- Method:
get - Path:
/v1/subscriptions/{subscription_exposed_id}
@spec search( client :: Stripe.t(), params :: %{ optional(:expand) => [binary()], optional(:limit) => integer(), optional(:page) => binary(), optional(:query) => binary() }, opts :: Keyword.t() ) :: {:ok, Stripe.SearchResult.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Search for subscriptions you’ve previously created using Stripe’s Search Query Language.Don’t use search in read-after-write flows where strict consistency is necessary. Under normal operating conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up to an hour behind during outages. Search functionality is not available to merchants in India.
Details
- Method:
get - Path:
/v1/subscriptions/search
update(client, subscription_exposed_id, params \\ %{}, opts \\ [])
View Source@spec update( client :: Stripe.t(), subscription_exposed_id :: binary(), params :: %{ optional(:add_invoice_items) => [add_invoice_items()], optional(:application_fee_percent) => number(), optional(:automatic_tax) => automatic_tax(), optional(:billing_cycle_anchor) => :now | :unchanged, optional(:billing_thresholds) => billing_thresholds() | binary(), optional(:cancel_at) => integer() | binary(), optional(:cancel_at_period_end) => boolean(), optional(:collection_method) => :charge_automatically | :send_invoice, optional(:coupon) => binary(), optional(:days_until_due) => integer(), optional(:default_payment_method) => binary(), optional(:default_source) => binary(), optional(:default_tax_rates) => [binary()] | binary(), optional(:description) => binary(), optional(:expand) => [binary()], optional(:items) => [items()], optional(:metadata) => %{optional(binary()) => binary()} | binary(), optional(:off_session) => boolean(), optional(:on_behalf_of) => binary() | binary(), optional(:pause_collection) => pause_collection() | binary(), optional(:payment_behavior) => :allow_incomplete | :default_incomplete | :error_if_incomplete | :pending_if_incomplete, optional(:payment_settings) => payment_settings(), optional(:pending_invoice_item_interval) => pending_invoice_item_interval() | binary(), optional(:promotion_code) => binary(), optional(:proration_behavior) => :always_invoice | :create_prorations | :none, optional(:proration_date) => integer(), optional(:transfer_data) => transfer_data() | binary(), optional(:trial_end) => :now | integer(), optional(:trial_from_plan) => boolean() }, opts :: Keyword.t() ) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Updates an existing subscription on a customer to match the specified parameters. When changing plans or quantities, we will optionally prorate the price we charge next month to make up for any price changes. To preview how the proration will be calculated, use the upcoming invoice endpoint.
Details
- Method:
post - Path:
/v1/subscriptions/{subscription_exposed_id}