Parameters for subscription update.
Summary
Types
@type add_invoice_items() :: %{ optional(:discounts) => [add_invoice_items_discounts()] | nil, optional(:metadata) => %{required(String.t()) => String.t()} | nil, optional(:period) => add_invoice_items_period() | nil, optional(:price) => String.t() | nil, optional(:price_data) => add_invoice_items_price_data() | nil, optional(:quantity) => integer() | nil, optional(:tax_rates) => map() | nil, optional(String.t()) => term() }
discounts- The coupons to redeem into discounts for the item.metadata- 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value tometadata.period- The period associated with this invoice item. If not set,period.start.typedefaults tomax_item_period_startandperiod.end.typedefaults tomin_item_period_end.price- The ID of the price object. One ofpriceorprice_datais required. Max length: 5000.price_data- Data used to generate a new Price object inline. One ofpriceorprice_datais required.quantity- Quantity for this item. Defaults to 1.tax_rates- The tax rates which apply to the item. When set, thedefault_tax_ratesdo not apply to this item.
@type add_invoice_items_discounts() :: %{ optional(:coupon) => String.t() | nil, optional(:discount) => String.t() | nil, optional(:promotion_code) => String.t() | nil, optional(String.t()) => term() }
coupon- ID of the coupon to create a new discount for. Max length: 5000.discount- ID of an existing discount on the object (or one of its ancestors) to reuse. Max length: 5000.promotion_code- ID of the promotion code to create a new discount for. Max length: 5000.
@type add_invoice_items_period() :: %{ optional(:end) => add_invoice_items_period_end() | nil, optional(:start) => add_invoice_items_period_start() | nil, optional(String.t()) => term() }
end- End of the invoice item period.start- Start of the invoice item period.
@type add_invoice_items_period_end() :: %{ optional(:timestamp) => integer() | nil, optional(:type) => String.t() | nil, optional(String.t()) => term() }
timestamp- A precise Unix timestamp for the end of the invoice item period. Must be greater than or equal toperiod.start. Format: Unix timestamp.type- Select how to calculate the end of the invoice item period. Possible values:min_item_period_end,timestamp.
@type add_invoice_items_period_start() :: %{ optional(:timestamp) => integer() | nil, optional(:type) => String.t() | nil, optional(String.t()) => term() }
timestamp- A precise Unix timestamp for the start of the invoice item period. Must be less than or equal toperiod.end. Format: Unix timestamp.type- Select how to calculate the start of the invoice item period. Possible values:max_item_period_start,now,timestamp.
@type add_invoice_items_price_data() :: %{ optional(:currency) => String.t() | nil, optional(:product) => String.t() | nil, optional(:tax_behavior) => String.t() | nil, optional(:unit_amount) => integer() | nil, optional(:unit_amount_decimal) => String.t() | nil, optional(String.t()) => term() }
currency- Three-letter ISO currency code, in lowercase. Must be a supported currency. Format: ISO 4217 currency code.product- The ID of the Product that this Price will belong to. Max length: 5000.tax_behavior- Only required if a default tax behavior was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One ofinclusive,exclusive, orunspecified. Once specified as eitherinclusiveorexclusive, it cannot be changed. Possible values:exclusive,inclusive,unspecified.unit_amount- A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge or a negative integer representing the amount to credit to the customer.unit_amount_decimal- Same asunit_amount, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one ofunit_amountandunit_amount_decimalcan be set. Format: decimal string.
@type automatic_tax() :: %{ optional(:enabled) => boolean() | nil, optional(:liability) => automatic_tax_liability() | nil, optional(String.t()) => term() }
enabled- Enabled automatic tax calculation which will automatically compute tax rates on all invoices generated by the subscription.liability- The account that's liable for tax. If set, the business address and tax registrations required to perform the tax calculation are loaded from this account. The tax transaction is returned in the report of the connected account.
@type automatic_tax_liability() :: %{ optional(:account) => String.t() | nil, optional(:type) => String.t() | nil, optional(String.t()) => term() }
account- The connected account being referenced whentypeisaccount.type- Type of the account referenced in the request. Possible values:account,self.
@type cancellation_details() :: %{ optional(:comment) => map() | nil, optional(:feedback) => String.t() | nil, optional(String.t()) => term() }
comment- Additional comments about why the user canceled the subscription, if the subscription was canceled explicitly by the user.feedback- The customer submitted reason for why they canceled, if the subscription was canceled explicitly by the user. Possible values:customer_service,low_quality,missing_features,other,switched_service,too_complex,too_expensive,unused.
@type invoice_settings() :: %{ optional(:account_tax_ids) => map() | nil, optional(:issuer) => invoice_settings_issuer() | nil, optional(String.t()) => term() }
account_tax_ids- The account tax IDs associated with the subscription. Will be set on invoices generated by the subscription.issuer- The connected account that issues the invoice. The invoice is presented with the branding and support information of the specified account.
@type invoice_settings_issuer() :: %{ optional(:account) => String.t() | nil, optional(:type) => String.t() | nil, optional(String.t()) => term() }
account- The connected account being referenced whentypeisaccount.type- Type of the account referenced in the request. Possible values:account,self.
@type items() :: %{ optional(:billing_thresholds) => map() | nil, optional(:clear_usage) => boolean() | nil, optional(:deleted) => boolean() | nil, optional(:discounts) => map() | nil, optional(:id) => String.t() | nil, optional(:metadata) => map() | nil, optional(:plan) => String.t() | nil, optional(:price) => String.t() | nil, optional(:price_data) => items_price_data() | nil, optional(:quantity) => integer() | nil, optional(:tax_rates) => map() | nil, optional(String.t()) => term() }
billing_thresholds- Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. Pass an empty string to remove previously-defined thresholds.clear_usage- Delete all usage for a given subscription item. You must pass this when deleting a usage records subscription item.clear_usagehas no effect if the plan has a billing meter attached.deleted- A flag that, if set totrue, will delete the specified item.discounts- The coupons to redeem into discounts for the subscription item.id- Subscription item to update. Max length: 5000.metadata- 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value tometadata.plan- Plan ID for this item, as a string. Max length: 5000.price- The ID of the price object. One ofpriceorprice_datais required. When changing a subscription item's price,quantityis set to 1 unless aquantityparameter is provided. Max length: 5000.price_data- Data used to generate a new Price object inline. One ofpriceorprice_datais required.quantity- Quantity for this item.tax_rates- A list of Tax Rate ids. These Tax Rates will override thedefault_tax_rateson the Subscription. When updating, pass an empty string to remove previously-defined tax rates.
@type items_price_data() :: %{ optional(:currency) => String.t() | nil, optional(:product) => String.t() | nil, optional(:recurring) => items_price_data_recurring() | nil, optional(:tax_behavior) => String.t() | nil, optional(:unit_amount) => integer() | nil, optional(:unit_amount_decimal) => String.t() | nil, optional(String.t()) => term() }
currency- Three-letter ISO currency code, in lowercase. Must be a supported currency. Format: ISO 4217 currency code.product- The ID of the Product that this Price will belong to. Max length: 5000.recurring- The recurring components of a price such asintervalandinterval_count.tax_behavior- Only required if a default tax behavior was not provided in the Stripe Tax settings. Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One ofinclusive,exclusive, orunspecified. Once specified as eitherinclusiveorexclusive, it cannot be changed. Possible values:exclusive,inclusive,unspecified.unit_amount- A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge.unit_amount_decimal- Same asunit_amount, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one ofunit_amountandunit_amount_decimalcan be set. Format: decimal string.
@type items_price_data_recurring() :: %{ optional(:interval) => String.t() | nil, optional(:interval_count) => integer() | nil, optional(String.t()) => term() }
interval- Specifies billing frequency. Eitherday,week,monthoryear. Possible values:day,month,week,year.interval_count- The number of intervals between subscription billings. For example,interval=monthandinterval_count=3bills every 3 months. Maximum of three years interval allowed (3 years, 36 months, or 156 weeks).
@type payment_settings() :: %{ optional(:payment_method_options) => payment_settings_payment_method_options() | nil, optional(:payment_method_types) => map() | nil, optional(:save_default_payment_method) => String.t() | nil, optional(String.t()) => term() }
payment_method_options- Payment-method-specific configuration to provide to invoices created by the subscription.payment_method_types- The list of payment method types (e.g. card) to provide to the invoice’s PaymentIntent. If not set, Stripe attempts to automatically determine the types to use by looking at the invoice’s default payment method, the subscription’s default payment method, the customer’s default payment method, and your invoice template settings. Should not be specified with payment_method_configurationsave_default_payment_method- Configure whether Stripe updatessubscription.default_payment_methodwhen payment succeeds. Defaults tooffif unspecified. Possible values:off,on_subscription.
@type payment_settings_payment_method_options() :: %{ optional(:acss_debit) => map() | nil, optional(:bancontact) => map() | nil, optional(:card) => map() | nil, optional(:customer_balance) => map() | nil, optional(:konbini) => map() | nil, optional(:payto) => map() | nil, optional(:sepa_debit) => map() | nil, optional(:us_bank_account) => map() | nil, optional(String.t()) => term() }
acss_debit- This sub-hash contains details about the Canadian pre-authorized debit payment method options to pass to the invoice’s PaymentIntent.bancontact- This sub-hash contains details about the Bancontact payment method options to pass to the invoice’s PaymentIntent.card- This sub-hash contains details about the Card payment method options to pass to the invoice’s PaymentIntent.customer_balance- This sub-hash contains details about the Bank transfer payment method options to pass to the invoice’s PaymentIntent.konbini- This sub-hash contains details about the Konbini payment method options to pass to the invoice’s PaymentIntent.payto- This sub-hash contains details about the PayTo payment method options to pass to the invoice’s PaymentIntent.sepa_debit- This sub-hash contains details about the SEPA Direct Debit payment method options to pass to the invoice’s PaymentIntent.us_bank_account- This sub-hash contains details about the ACH direct debit payment method options to pass to the invoice’s PaymentIntent.
@type t() :: %Stripe.Params.SubscriptionUpdateParams{ add_invoice_items: [add_invoice_items()] | nil, application_fee_percent: map() | nil, automatic_tax: automatic_tax() | nil, billing_cycle_anchor: String.t() | nil, billing_thresholds: map() | nil, cancel_at: map() | nil, cancel_at_period_end: boolean() | nil, cancellation_details: cancellation_details() | nil, collection_method: String.t() | nil, days_until_due: integer() | nil, default_payment_method: String.t() | nil, default_source: map() | nil, default_tax_rates: map() | nil, description: map() | nil, discounts: map() | nil, expand: [String.t()] | nil, invoice_settings: invoice_settings() | nil, items: [items()] | nil, metadata: map() | nil, off_session: boolean() | nil, on_behalf_of: map() | nil, pause_collection: map() | nil, payment_behavior: String.t() | nil, payment_settings: payment_settings() | nil, pending_invoice_item_interval: map() | nil, proration_behavior: String.t() | nil, proration_date: integer() | nil, transfer_data: map() | nil, trial_end: map() | nil, trial_from_plan: boolean() | nil, trial_settings: trial_settings() | nil }
add_invoice_items- A list of prices and quantities that will generate invoice items appended to the next invoice for this subscription. You may pass up to 20 items.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. The request must be made by a platform account on a connected account in order to set an application fee percentage. For more information, see the application fees documentation.automatic_tax- Automatic tax settings for this subscription. We recommend you only include this parameter when the existing value is being changed.billing_cycle_anchor- Eithernoworunchanged. Setting the value tonowresets the subscription's billing cycle anchor to the current time (in UTC). For more information, see the billing cycle documentation. Possible values:now,unchanged. Max length: 5000.billing_thresholds- Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds.cancel_at- A timestamp at which the subscription should cancel. If set to a date before the current period ends, this will cause a proration if prorations have been enabled usingproration_behavior. If set during a future period, this will always cause a proration for that period.cancel_at_period_end- Indicate whether this subscription should cancel at the end of the current period (current_period_end). Defaults tofalse.cancellation_details- Details about why this subscription was cancelledcollection_method- Eithercharge_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. Defaults tocharge_automatically. Possible values:charge_automatically,send_invoice.days_until_due- Number of days a customer has to pay invoices generated by this subscription. Valid only for subscriptions wherecollection_methodis set tosend_invoice.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 overdefault_source. If neither are set, invoices will use the customer's invoice_settings.default_payment_method or default_source. Max length: 5000.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. 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.default_tax_rates- The tax rates that will apply to any subscription item that does not havetax_ratesset. Invoices created will have theirdefault_tax_ratespopulated from the subscription. Pass an empty string to remove previously-defined tax rates.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.discounts- The coupons to redeem into discounts for the subscription. If not specified or empty, inherits the discount from the subscription's customer.expand- Specifies which fields in the response should be expanded.invoice_settings- All invoices will be billed using the specified settings.items- A list of up to 20 subscription items, each with an attached price.metadata- 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. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value tometadata.off_session- Indicates if a customer is on or off-session while an invoice payment is attempted. Defaults tofalse(on-session).on_behalf_of- The account on behalf of which to charge, for each of the subscription's invoices.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 topaused. Learn more about pausing collection.payment_behavior- Useallow_incompleteto transition the subscription tostatus=past_dueif a payment is required but cannot be paid. This allows you to manage scenarios where additional user actions are needed to pay a subscription's invoice. For example, SCA regulation may require 3DS authentication to complete payment. See the SCA Migration Guide for Billing to learn more. This is the default behavior.
Use default_incomplete to transition the subscription to status=past_due when payment is required and await explicit confirmation of the invoice's payment intent. This allows simpler management of scenarios where additional user actions are needed to pay a subscription’s invoice. Such as failed payments, SCA regulation, or collecting a mandate for a bank debit payment method.
Use pending_if_incomplete to update the subscription using pending updates. When you use pending_if_incomplete you can only pass the parameters supported by pending updates.
Use error_if_incomplete if you want Stripe to return an HTTP 402 status code if a subscription's invoice cannot be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further user action is needed, this parameter does not update the subscription and returns an error instead. This was the default behavior for API versions prior to 2019-03-14. See the changelog to learn more. Possible values: allow_incomplete, default_incomplete, error_if_incomplete, pending_if_incomplete.
payment_settings- Payment settings to pass to invoices created by the subscription.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 for the given subscription at the specified interval.proration_behavior- Determines how to handle prorations when the billing cycle changes (e.g., when switching plans, resettingbilling_cycle_anchor=now, or starting a trial), or if an item'squantitychanges. The default value iscreate_prorations. Possible values:always_invoice,create_prorations,none.proration_date- If set, prorations will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same prorations that were previewed with the create preview endpoint.proration_datecan also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations. Format: Unix timestamp.transfer_data- 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. This will be unset if you POST an empty value.trial_end- Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. If set,trial_endwill override the default trial period of the plan the customer is being subscribed to. Thebilling_cycle_anchorwill be updated to thetrial_endvalue. The special valuenowcan be provided to end the customer's trial immediately. Can be at most two years frombilling_cycle_anchor.trial_from_plan- Indicates if a plan'strial_period_daysshould be applied to the subscription. Settingtrial_endper subscription is preferred, and this defaults tofalse. Setting this flag totruetogether withtrial_endis not allowed. See Using trial periods on subscriptions to learn more.trial_settings- Settings related to subscription trials.
@type trial_settings() :: %{ optional(:end_behavior) => trial_settings_end_behavior() | nil, optional(String.t()) => term() }
end_behavior- Defines how the subscription should behave when the user's free trial ends.
@type trial_settings_end_behavior() :: %{ optional(:missing_payment_method) => String.t() | nil, optional(String.t()) => term() }
missing_payment_method- Indicates how the subscription should change when the trial ends if the user did not provide a payment method. Possible values:cancel,create_invoice,pause.