Plans

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.

The Plan object

Attributes

  • idstring

    Unique identifier for the object.

  • activeboolean

    Whether the plan can be used for new purchases.

  • amountnullable integer

    The unit amount in cents to be charged, represented as a whole integer if possible. Only set if billing_scheme=per_unit.

  • currencyenum

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

  • intervalenum

    The frequency at which a subscription is billed. One of day, week, month or year.

  • metadatanullable hash

    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.

  • nicknamenullable string

    A brief description of the plan, hidden from customers.

  • productnullable stringExpandable

    The product whose pricing this plan determines.

More attributes

  • objectstring

  • aggregate_usagenullable enum

  • amount_decimalnullable decimal string

  • billing_schemeenum

  • createdtimestamp

  • interval_countinteger

  • livemodeboolean

  • meternullable stringPreview feature

  • tiersnullable array of hashesExpandable

  • tiers_modenullable enum

  • transform_usagenullable hash

  • trial_period_daysnullable integer

  • usage_typeenum

The Plan object
{
"id": "plan_NjpIbv3g3ZibnD",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1200,
"amount_decimal": "1200",
"billing_scheme": "per_unit",
"created": 1681851647,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"product": "prod_NjpI7DbZx6AlWQ",
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
}

Create a plan

You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.

Parameters

  • currencyenumRequired

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

  • intervalenumRequired

    Specifies billing frequency. Either day, week, month or year.

    Possible enum values
    day
    month
    week
    year
  • producthashRequired

    The product whose pricing the created plan will represent. This can either be the ID of an existing product, or a dictionary containing fields used to create a service product.

  • activeboolean

    Whether the plan is currently available for new subscriptions. Defaults to true.

  • amountintegerRequired unless billing_scheme=tiered

    A positive integer in cents (or 0 for a free plan) representing how much to charge on a recurring basis.

  • metadatahash

    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 to metadata.

  • nicknamestring

    A brief description of the plan, hidden from customers.

More parameters

  • aggregate_usageenum

  • amount_decimalstring

  • billing_schemeenum

  • idstring

  • interval_countinteger

  • meterstringPreview feature

  • tiersarray of hashesRequired if billing_scheme=tiered

  • tiers_modeenumRequired if billing_scheme=tiered

  • transform_usagehash

  • trial_period_daysinteger

  • usage_typeenum

Returns

Returns the plan object.

POST /v1/plans
Stripe.api_key = 'sk_test_4eC39Hq...arjtT1zdp7dcsk_test_4eC39HqLyjWDarjtT1zdp7dc'
Stripe::Plan.create({
amount: 1200,
currency: 'usd',
interval: 'month',
product: 'prod_NjpI7DbZx6AlWQ',
})
Response
{
"id": "plan_NjpIbv3g3ZibnD",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1200,
"amount_decimal": "1200",
"billing_scheme": "per_unit",
"created": 1681851647,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"product": "prod_NjpI7DbZx6AlWQ",
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
}

Update a plan

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.

Parameters

  • activeboolean

    Whether the plan is currently available for new subscriptions.

  • metadatahash

    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 to metadata.

  • nicknamestring

    A brief description of the plan, hidden from customers.

More parameters

  • productstring

  • trial_period_daysinteger

Returns

The updated plan object is returned upon success. Otherwise, this call raises an error.

POST /v1/plans/:id
Stripe.api_key = 'sk_test_4eC39Hq...arjtT1zdp7dcsk_test_4eC39HqLyjWDarjtT1zdp7dc'
Stripe::Plan.update('plan_NjpIbv3g3ZibnD', {metadata: {order_id: '6735'}})
Response
{
"id": "plan_NjpIbv3g3ZibnD",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1200,
"amount_decimal": "1200",
"billing_scheme": "per_unit",
"created": 1681851647,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
"order_id": "6735"
},
"nickname": null,
"product": "prod_NjpI7DbZx6AlWQ",
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
}

Retrieve a plan

Retrieves the plan with the given ID.

Parameters

No parameters.

Returns

Returns a plan if a valid plan ID was provided. Raises an error otherwise.

GET /v1/plans/:id
Stripe.api_key = 'sk_test_4eC39Hq...arjtT1zdp7dcsk_test_4eC39HqLyjWDarjtT1zdp7dc'
Stripe::Plan.retrieve('plan_NjpIbv3g3ZibnD')
Response
{
"id": "plan_NjpIbv3g3ZibnD",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 1200,
"amount_decimal": "1200",
"billing_scheme": "per_unit",
"created": 1681851647,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {},
"nickname": null,
"product": "prod_NjpI7DbZx6AlWQ",
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
}
Stripe Shell
Test mode
Welcome to the Stripe Shell! Stripe Shell is a browser-based shell with the Stripe CLI pre-installed. Log in to your Stripe account and press Control + Backtick (`) on your keyboard to start managing your Stripe resources in test mode. - View supported Stripe commands: - Find webhook events: - Listen for webhook events: - Call Stripe APIs: stripe [api resource] [operation] (e.g., )
The Stripe Shell is best experienced on desktop.
$