View Source Stripe.Plan (Striped v0.1.0)
You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
Plans define the base price, currency, and billing cycle for recurring purchases of products. Products help you track inventory or provisioning, and plans help you track pricing. Different physical goods or levels of service should be represented by products, and pricing options should be represented by plans. This approach lets you change prices without having to change your provisioning scheme.
For example, you might have a single "gold" product that has plans for $10/month, $100/year, €9/month, and €90/year.
Related guides: Set up a subscription and more about products and prices.
Link to this section Summary
Functions
You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.
Returns a list of your plans.
Retrieves the plan with the given ID.
Updates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan’s ID, amount, currency, or billing cycle.
Link to this section Types
@type t() :: %Stripe.Plan{ active: boolean(), aggregate_usage: binary() | nil, amount: integer() | nil, amount_decimal: binary() | nil, billing_scheme: binary(), created: integer(), currency: binary(), id: binary(), interval: binary(), interval_count: integer(), livemode: boolean(), metadata: term() | nil, nickname: binary() | nil, object: binary(), product: (binary() | Stripe.Product.t() | Stripe.DeletedProduct.t()) | nil, tiers: term(), tiers_mode: binary() | nil, transform_usage: term() | nil, trial_period_days: integer() | nil, usage_type: binary() }
The plan type.
activeWhether the plan can be used for new purchases.aggregate_usageSpecifies a usage aggregation strategy for plans ofusage_type=metered. Allowed values aresumfor summing up all usage during a period,last_during_periodfor using the last usage record reported within a period,last_everfor using the last usage record ever (across period bounds) ormaxwhich uses the usage record with the maximum reported usage during a period. Defaults tosum.amountThe unit amount in %s to be charged, represented as a whole integer if possible. Only set ifbilling_scheme=per_unit.amount_decimalThe unit amount in %s to be charged, represented as a decimal string with at most 12 decimal places. Only set ifbilling_scheme=per_unit.billing_schemeDescribes how to compute the price per period. Eitherper_unitortiered.per_unitindicates that the fixed amount (specified inamount) will be charged per unit inquantity(for plans withusage_type=licensed), or per unit of total usage (for plans withusage_type=metered).tieredindicates that the unit pricing will be computed using a tiering strategy as defined using thetiersandtiers_modeattributes.createdTime at which the object was created. Measured in seconds since the Unix epoch.currencyThree-letter ISO currency code, in lowercase. Must be a supported currency.idUnique identifier for the object.intervalThe frequency at which a subscription is billed. One ofday,week,monthoryear.interval_countThe number of intervals (specified in theintervalattribute) between subscription billings. For example,interval=monthandinterval_count=3bills every 3 months.livemodeHas the valuetrueif the object exists in live mode or the valuefalseif the object exists in test mode.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.nicknameA brief description of the plan, hidden from customers.objectString representing the object's type. Objects of the same type share the same value.productThe product whose pricing this plan determines.tiersEach element represents a pricing tier. This parameter requiresbilling_schemeto be set totiered. See also the documentation forbilling_scheme.tiers_modeDefines if the tiering price should begraduatedorvolumebased. Involume-based tiering, the maximum quantity within a period determines the per unit price. Ingraduatedtiering, pricing can change as the quantity grows.transform_usageApply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined withtiers.trial_period_daysDefault number of trial days when subscribing a customer to this plan usingtrial_from_plan=true.usage_typeConfigures how the quantity per period should be determined. Can be eithermeteredorlicensed.licensedautomatically bills thequantityset when adding it to a subscription.meteredaggregates the total usage based on usage records. Defaults tolicensed.
Link to this section Functions
@spec create(client :: term(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
Details
- Method:
post - Path:
/v1/plans
@spec delete(client :: term(), plan :: binary()) :: {:ok, Stripe.DeletedPlan.t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.
Details
- Method:
delete - Path:
/v1/plans/{plan}
@spec list(client :: term(), params :: map()) :: {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Returns a list of your plans.
Details
- Method:
get - Path:
/v1/plans
Query parameters
:activeboolean:createdany of:- object with (optional) properties:
gt: integergte: integerlt: integerlte: integer
- integer
- object with (optional) properties:
:ending_beforestring:expandarray of: string:limitinteger:productstring:starting_afterstring
@spec retrieve(client :: term(), plan :: binary(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Retrieves the plan with the given ID.
Details
- Method:
get - Path:
/v1/plans/{plan}
Query parameters
:expandarray of: string
@spec update(client :: term(), plan :: binary(), params :: map()) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}
Updates the specified plan by setting the values of the parameters passed. Any parameters not provided are left unchanged. By design, you cannot change a plan’s ID, amount, currency, or billing cycle.
Details
- Method:
post - Path:
/v1/plans/{plan}