Parameters for subscription create.
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 billing_cycle_anchor_config() :: %{ optional(:day_of_month) => integer() | nil, optional(:hour) => integer() | nil, optional(:minute) => integer() | nil, optional(:month) => integer() | nil, optional(:second) => integer() | nil, optional(String.t()) => term() }
day_of_month- The day of the month the anchor should be. Ranges from 1 to 31.hour- The hour of the day the anchor should be. Ranges from 0 to 23.minute- The minute of the hour the anchor should be. Ranges from 0 to 59.month- The month to start full cycle periods. Ranges from 1 to 12.second- The second of the minute the anchor should be. Ranges from 0 to 59.
@type billing_mode() :: %{ optional(:flexible) => billing_mode_flexible() | nil, optional(:type) => String.t() | nil, optional(String.t()) => term() }
flexible- Configure behavior for flexible billing mode.type- Controls the calculation and orchestration of prorations and invoices for subscriptions. If no value is passed, the default isflexible. Possible values:classic,flexible.
@type billing_mode_flexible() :: %{ optional(:proration_discounts) => String.t() | nil, optional(String.t()) => term() }
proration_discounts- Controls how invoices and invoice items display proration amounts and discount amounts. Possible values:included,itemized.
@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(:discounts) => map() | nil, optional(:metadata) => %{required(String.t()) => String.t()} | 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.discounts- The coupons to redeem into discounts for the subscription 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.plan- Plan ID for this item, as a string. Max length: 5000.price- The ID of the price object. Max length: 5000.price_data- Data used to generate a new Price object inline.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.SubscriptionCreateParams{ add_invoice_items: [add_invoice_items()] | nil, application_fee_percent: map() | nil, automatic_tax: automatic_tax() | nil, backdate_start_date: integer() | nil, billing_cycle_anchor: integer() | nil, billing_cycle_anchor_config: billing_cycle_anchor_config() | nil, billing_mode: billing_mode() | nil, billing_thresholds: map() | nil, cancel_at: map() | nil, cancel_at_period_end: boolean() | nil, collection_method: String.t() | nil, currency: String.t() | nil, customer: String.t() | nil, customer_account: String.t() | nil, days_until_due: integer() | nil, default_payment_method: String.t() | nil, default_source: String.t() | nil, default_tax_rates: map() | nil, description: String.t() | 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, payment_behavior: String.t() | nil, payment_settings: payment_settings() | nil, pending_invoice_item_interval: map() | nil, proration_behavior: String.t() | nil, transfer_data: transfer_data() | nil, trial_end: map() | nil, trial_from_plan: boolean() | nil, trial_period_days: integer() | 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.backdate_start_date- A past timestamp to backdate the subscription's start date to. If set, the first invoice will contain line items for the timespan between the start date and the current time. Can be combined with trials and the billing cycle anchor. Format: Unix timestamp.billing_cycle_anchor- A future timestamp in UTC format to anchor the subscription's billing cycle. The anchor is the reference point that aligns future billing cycle dates. It sets the day of week forweekintervals, the day of month formonthandyearintervals, and the month of year foryearintervals. Format: Unix timestamp.billing_cycle_anchor_config- Mutually exclusive with billing_cycle_anchor and only valid with monthly and yearly price intervals. When provided, the billing_cycle_anchor is set to the next occurrence of the day_of_month at the hour, minute, and second UTC.billing_mode- Controls how prorations and invoices for subscriptions are calculated and orchestrated.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.collection_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.currency- Three-letter ISO currency code, in lowercase. Must be a supported currency. Format: ISO 4217 currency code.customer- The identifier of the customer to subscribe. Max length: 5000.customer_account- The identifier of the account representing the customer to subscribe. Max length: 5000.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. Max length: 5000.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.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.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.payment_behavior- Only applies to subscriptions withcollection_method=charge_automatically.
Use allow_incomplete to create Subscriptions with status=incomplete if the first invoice can't be paid. Creating Subscriptions with this status allows you to manage scenarios where additional customer 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 create Subscriptions with status=incomplete when the first invoice requires payment, otherwise start as active. Subscriptions transition to status=active when successfully confirming the PaymentIntent on the first invoice. This allows simpler management of scenarios where additional customer 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. If the PaymentIntent is not confirmed within 23 hours Subscriptions transition to status=incomplete_expired, which is a terminal state.
Use error_if_incomplete if you want Stripe to return an HTTP 402 status code if a subscription's first invoice can't be paid. For example, if a payment method requires 3DS authentication due to SCA regulation and further customer action is needed, this parameter doesn't create a 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.
pending_if_incomplete is only used with updates and cannot be passed when creating a Subscription.
Subscriptions with collection_method=send_invoice are automatically activated regardless of the first Invoice status. 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 resulting from thebilling_cycle_anchor. If no value is passed, the default iscreate_prorations. Possible values:always_invoice,create_prorations,none.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.trial_end- Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special valuenowcan be provided to end the customer's trial immediately. Can be at most two years frombilling_cycle_anchor. See Using trial periods on subscriptions to learn more.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_period_days- Integer representing the number of trial period days before the customer is charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. See Using trial periods on subscriptions to learn more.trial_settings- Settings related to subscription trials.
@type transfer_data() :: %{ optional(:amount_percent) => float() | nil, optional(:destination) => String.t() | nil, optional(String.t()) => term() }
amount_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 destination account. By default, the entire amount is transferred to the destination.destination- ID of an existing, connected Stripe account.
@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.