Class Plan

All Implemented Interfaces:
HasId, MetadataStore<Plan>, StripeActiveObject, StripeObjectInterface

public class Plan extends ApiResource implements HasId, MetadataStore<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.

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.

  • Constructor Details

    • Plan

      public Plan()
  • Method Details

    • getProduct

      public String getProduct()
      Get ID of expandable product object.
    • setProduct

      public void setProduct(String id)
    • getProductObject

      public Product getProductObject()
      Get expanded product.
    • setProductObject

      public void setProductObject(Product expandableObject)
    • create

      public static Plan create(Map<String,Object> params) throws StripeException
      You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
      Throws:
      StripeException
    • create

      public static Plan create(Map<String,Object> params, RequestOptions options) throws StripeException
      You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
      Throws:
      StripeException
    • create

      public static Plan create(PlanCreateParams params) throws StripeException
      You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
      Throws:
      StripeException
    • create

      public static Plan create(PlanCreateParams params, RequestOptions options) throws StripeException
      You can now model subscriptions more flexibly using the Prices API. It replaces the Plans API and is backwards compatible to simplify your migration.
      Throws:
      StripeException
    • delete

      public Plan delete() throws StripeException
      Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.
      Throws:
      StripeException
    • delete

      public Plan delete(RequestOptions options) throws StripeException
      Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.
      Throws:
      StripeException
    • delete

      public Plan delete(Map<String,Object> params) throws StripeException
      Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.
      Throws:
      StripeException
    • delete

      public Plan delete(Map<String,Object> params, RequestOptions options) throws StripeException
      Deleting plans means new subscribers can’t be added. Existing subscribers aren’t affected.
      Throws:
      StripeException
    • list

      public static PlanCollection list(Map<String,Object> params) throws StripeException
      Returns a list of your plans.
      Throws:
      StripeException
    • list

      public static PlanCollection list(Map<String,Object> params, RequestOptions options) throws StripeException
      Returns a list of your plans.
      Throws:
      StripeException
    • list

      public static PlanCollection list(PlanListParams params) throws StripeException
      Returns a list of your plans.
      Throws:
      StripeException
    • list

      public static PlanCollection list(PlanListParams params, RequestOptions options) throws StripeException
      Returns a list of your plans.
      Throws:
      StripeException
    • retrieve

      public static Plan retrieve(String plan) throws StripeException
      Retrieves the plan with the given ID.
      Throws:
      StripeException
    • retrieve

      public static Plan retrieve(String plan, RequestOptions options) throws StripeException
      Retrieves the plan with the given ID.
      Throws:
      StripeException
    • retrieve

      public static Plan retrieve(String plan, Map<String,Object> params, RequestOptions options) throws StripeException
      Retrieves the plan with the given ID.
      Throws:
      StripeException
    • retrieve

      public static Plan retrieve(String plan, PlanRetrieveParams params, RequestOptions options) throws StripeException
      Retrieves the plan with the given ID.
      Throws:
      StripeException
    • update

      public Plan update(Map<String,Object> params) throws StripeException
      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.
      Specified by:
      update in interface MetadataStore<Plan>
      Throws:
      StripeException
    • update

      public Plan update(Map<String,Object> params, RequestOptions options) throws StripeException
      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.
      Specified by:
      update in interface MetadataStore<Plan>
      Throws:
      StripeException
    • update

      public Plan update(PlanUpdateParams params) throws StripeException
      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.
      Throws:
      StripeException
    • update

      public Plan update(PlanUpdateParams params, RequestOptions options) throws StripeException
      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.
      Throws:
      StripeException
    • setResponseGetter

      public void setResponseGetter(StripeResponseGetter responseGetter)
      Description copied from interface: StripeActiveObject
      Method is used by the containing object or StripeResponseGetter implementations to set the StripeResponseGetter instance used to make further requests.
      Specified by:
      setResponseGetter in interface StripeActiveObject
      Overrides:
      setResponseGetter in class ApiResource
      Parameters:
      responseGetter - the StripeResponseGetter instance to use for making further requests.
    • getActive

      public Boolean getActive()
      Whether the plan can be used for new purchases.
    • getAggregateUsage

      public String getAggregateUsage()
      Specifies a usage aggregation strategy for plans of usage_type=metered. Allowed values are sum for summing up all usage during a period, last_during_period for using the last usage record reported within a period, last_ever for using the last usage record ever (across period bounds) or max which uses the usage record with the maximum reported usage during a period. Defaults to sum.

      One of last_during_period, last_ever, max, or sum.

    • getAmount

      public Long getAmount()
      The unit amount in cents (or local equivalent) to be charged, represented as a whole integer if possible. Only set if billing_scheme=per_unit.
    • getAmountDecimal

      public BigDecimal getAmountDecimal()
      The unit amount in cents (or local equivalent) to be charged, represented as a decimal string with at most 12 decimal places. Only set if billing_scheme=per_unit.
    • getBillingScheme

      public String getBillingScheme()
      Describes how to compute the price per period. Either per_unit or tiered. per_unit indicates that the fixed amount (specified in amount) will be charged per unit in quantity (for plans with usage_type=licensed), or per unit of total usage (for plans with usage_type=metered). tiered indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers and tiers_mode attributes.

      One of per_unit, or tiered.

    • getCreated

      public Long getCreated()
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • getCurrency

      public String getCurrency()
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • getDeleted

      public Boolean getDeleted()
      Always true for a deleted object.
    • getInterval

      public String getInterval()
      The frequency at which a subscription is billed. One of day, week, month or year.
    • getIntervalCount

      public Long getIntervalCount()
      The number of intervals (specified in the interval attribute) between subscription billings. For example, interval=month and interval_count=3 bills every 3 months.
    • getLivemode

      public Boolean getLivemode()
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • getMeter

      public String getMeter()
      The meter tracking the usage of a metered price.
    • getNickname

      public String getNickname()
      A brief description of the plan, hidden from customers.
    • getObject

      public String getObject()
      String representing the object's type. Objects of the same type share the same value.

      Equal to plan.

    • getTiers

      public List<Plan.Tier> getTiers()
      Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered. See also the documentation for billing_scheme.
    • getTiersMode

      public String getTiersMode()
      Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price. In graduated tiering, pricing can change as the quantity grows.

      One of graduated, or volume.

    • getTransformUsage

      public Plan.TransformUsage getTransformUsage()
      Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with tiers.
    • getTrialPeriodDays

      public Long getTrialPeriodDays()
      Default number of trial days when subscribing a customer to this plan using trial_from_plan=true.
    • getUsageType

      public String getUsageType()
      Configures how the quantity per period should be determined. Can be either metered or licensed. licensed automatically bills the quantity set when adding it to a subscription. metered aggregates the total usage based on usage records. Defaults to licensed.
    • setActive

      public void setActive(Boolean active)
      Whether the plan can be used for new purchases.
    • setAggregateUsage

      public void setAggregateUsage(String aggregateUsage)
      Specifies a usage aggregation strategy for plans of usage_type=metered. Allowed values are sum for summing up all usage during a period, last_during_period for using the last usage record reported within a period, last_ever for using the last usage record ever (across period bounds) or max which uses the usage record with the maximum reported usage during a period. Defaults to sum.

      One of last_during_period, last_ever, max, or sum.

    • setAmount

      public void setAmount(Long amount)
      The unit amount in cents (or local equivalent) to be charged, represented as a whole integer if possible. Only set if billing_scheme=per_unit.
    • setAmountDecimal

      public void setAmountDecimal(BigDecimal amountDecimal)
      The unit amount in cents (or local equivalent) to be charged, represented as a decimal string with at most 12 decimal places. Only set if billing_scheme=per_unit.
    • setBillingScheme

      public void setBillingScheme(String billingScheme)
      Describes how to compute the price per period. Either per_unit or tiered. per_unit indicates that the fixed amount (specified in amount) will be charged per unit in quantity (for plans with usage_type=licensed), or per unit of total usage (for plans with usage_type=metered). tiered indicates that the unit pricing will be computed using a tiering strategy as defined using the tiers and tiers_mode attributes.

      One of per_unit, or tiered.

    • setCreated

      public void setCreated(Long created)
      Time at which the object was created. Measured in seconds since the Unix epoch.
    • setCurrency

      public void setCurrency(String currency)
      Three-letter ISO currency code, in lowercase. Must be a supported currency.
    • setDeleted

      public void setDeleted(Boolean deleted)
      Always true for a deleted object.
    • setId

      public void setId(String id)
      Unique identifier for the object.
    • setInterval

      public void setInterval(String interval)
      The frequency at which a subscription is billed. One of day, week, month or year.
    • setIntervalCount

      public void setIntervalCount(Long intervalCount)
      The number of intervals (specified in the interval attribute) between subscription billings. For example, interval=month and interval_count=3 bills every 3 months.
    • setLivemode

      public void setLivemode(Boolean livemode)
      Has the value true if the object exists in live mode or the value false if the object exists in test mode.
    • setMetadata

      public void setMetadata(Map<String,String> 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.
    • setMeter

      public void setMeter(String meter)
      The meter tracking the usage of a metered price.
    • setNickname

      public void setNickname(String nickname)
      A brief description of the plan, hidden from customers.
    • setObject

      public void setObject(String object)
      String representing the object's type. Objects of the same type share the same value.

      Equal to plan.

    • setTiers

      public void setTiers(List<Plan.Tier> tiers)
      Each element represents a pricing tier. This parameter requires billing_scheme to be set to tiered. See also the documentation for billing_scheme.
    • setTiersMode

      public void setTiersMode(String tiersMode)
      Defines if the tiering price should be graduated or volume based. In volume-based tiering, the maximum quantity within a period determines the per unit price. In graduated tiering, pricing can change as the quantity grows.

      One of graduated, or volume.

    • setTransformUsage

      public void setTransformUsage(Plan.TransformUsage transformUsage)
      Apply a transformation to the reported usage or set quantity before computing the amount billed. Cannot be combined with tiers.
    • setTrialPeriodDays

      public void setTrialPeriodDays(Long trialPeriodDays)
      Default number of trial days when subscribing a customer to this plan using trial_from_plan=true.
    • setUsageType

      public void setUsageType(String usageType)
      Configures how the quantity per period should be determined. Can be either metered or licensed. licensed automatically bills the quantity set when adding it to a subscription. metered aggregates the total usage based on usage records. Defaults to licensed.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public String getId()
      Unique identifier for the object.
      Specified by:
      getId in interface HasId
    • getMetadata

      public Map<String,String> getMetadata()
      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.
      Specified by:
      getMetadata in interface MetadataStore<Plan>