Addon-item and charge-item prices are purchased with plan-item prices in subscriptions. You can automate this process by configuring certain addons and charges as “attached” to certain plans. This is done at the “item” level. In other words, addon- and charge-items can be attached to plan-items.
Once the attachment is defined, while creating or updating a subscription, the addon- or charge-item prices are selected automatically based on the plan-item price selected . Let’s look at the details:
Addons
Addons can be attached to plans as recommended, mandatory or optional.
When an addon is attached as recommended for a plan, the addon is suggested to be applied to subscriptions for the plan in Checkout and Self-Serve Portal. Alternatively, if you build your own payment pages or have a sales team, you can suggest recommended addons to your customers or salespeople on your website or CRM respectively
When an addon is attached as mandatory for a plan, the addon gets applied to subscriptions for the plan compulsorily, unless removed explicitly. If you do not pass an item price for a mandatory addon when including the plan in a subscription, an addon-item price is automatically applied as explained below.
Attaching an addon as optional neither marks it as recommended or mandatory but allows you a way to set a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.
How auto-selection of the addon-item price works
Once an addon has been attached as mandatory, the addon-item price to be applied to the plan-item price is selected based on the following rule: The addon-item price with the same currency as that of the plan-item price and the longest compatible period is selected.
Here's an example:
Consider a plan Standard Cloud Storage has an addon Extra Storage attached to it. Note that each of the two are items. Now consider that they have item prices with the following periods and currencies:
Item price for “Standard Cloud Storage” plan-item:
Standard Cloud Storage, 3 years, AUD.
Item prices for “Extra Storage” addon-item:
Extra Storage, 1 year, EUR.
Extra Storage, 1 year, USD.
Extra Storage, 1 year, AUD.
Extra Storage, 18 months, AUD.
Extra Storage, 2 years, AUD.
Extra Storage, 30 months, AUD.
For the plan-item price (Standard Cloud Storage, 3 years, AUD), the addon-item prices with matching currencies are the last 4 from the above list:
Extra Storage, 1 year, AUD.
Extra Storage, 18 months, AUD.
Extra Storage, 2 years, AUD.
Extra Storage, 30 months, AUD.
From among them, the last two have periods that are incompatible with the plan-item price period of 3 years. From the remaining 2 addon-item prices, the one with the longest period is of 18 months. So, “Extra Storage, 18 months, AUD” is selected for mandatory application to the plan item price.
Charges
Charges can also be attached to plans. When doing so, you specify the event at which the charge is to be applied to the subscription. For some events that can occur multiple times in a subscription lifetime, you can also set whether to apply the charge each time the event occurs or just once.
There may be multiple item prices for a given attached charge. The item price that matches the currency of the plan-item price is automatically selected for application.
Here’s an example:
Consider a plan Standard Cloud Storage has a charge named Implementation Fee attached to it. Now consider their item prices below, with the following periods and currencies:
Item price for “Standard Cloud Storage” plan-item:
Standard Cloud Storage, 3 years, AUD.
Item prices for “Implementation Fee” charge-item:
Implementation Fee, USD.
Implementation Fee, AUD.
Implementation Fee, EUR.
From among the charge-item prices above, the one compatible with the plan-item price is “Implementation Fee, AUD” since it has the same currency as the plan-item price.
string, max chars=100 The unique id for the attached item. Set to a random, immutable value automatically when the attached item is created.
parent_item_id
string, max chars=100 The id of the plan-item to which the item is attached.
item_id
string, max chars=100 The id of the item being attached.
type
enumerated string The type of attachment for the addon. Only applicable for addon-items.
Possible values are
recommendedThe addon is recommended to go with the plan-item when using Checkout or Portal.mandatoryThe addon is attached automatically to the subscription for the plan-item unless explicitly removed via API.optionalThe addon is neither mandatory, nor recommended. This allows you to attach an addon so you can specify a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.
status
optional, enumerated string The item state.
Possible values are
activeNew subscriptions can be created with the item.archivedNo new subscriptions allowed for the item.deletedNo subscriptions allowed for the item.
quantity
optional, integer, min=1 The default quantity of the addon to be attached when the quantity is not specified while creating/updating the subscription.
quantity_in_decimal
optional, string, max chars=33 The decimal representation of the quantity of the addon. Returned for quantity-based addons when multi-decimal pricing is enabled.
billing_cycles
optional, integer, min=1 The number of subscription billing cycles for which this item is attached when applied to a subscription. Applicable only for items of type addon. Requires addon billing cycles to be enabled for the site.
The value set explicitly for billing_cycles while applying the addon to a subscription takes precedence over this attribute. This attribute, in turn, has a higher precedence than the value set for the addon-item price.
charge_on_event
enumerated string Indicates when the item is charged. This attribute only applies to charge-items.
Possible values are
subscription_creationthe time of creation of the subscription.subscription_trial_startthe time when the trial period of the subscription begins.plan_activationsame as subscription activation, but also includes the case when the plan-item of the subscription is changed.subscription_activationthe moment a subscription enters an active or non-renewing state. Also includes reactivations of canceled subscriptions.contract_terminationwhen a contract term is terminated.on_demandItem can be charged on demand.
charge_once
boolean Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This attribute only applies to charge-items.
created_at
timestamp(UTC) in seconds The time at which this attached item was created.
resource_version
optional, long Version number of this resource. The resource_version is updated with a new timestamp in milliseconds for every change made to the resource. This attribute will be present only if the resource has been updated after 2016-09-28.
updated_at
optional, timestamp(UTC) in seconds The time at which this attached item was last updated.
channel
optional, enumerated string The subscription channel this object originated from and is maintained in.
Possible values are
webThe object was created (and is maintained) for the web channel directly in Chargebee via API or UI.app_storeThe object data is synchronized with data from in-app subscription(s) created in Apple App Store. Direct manipulation of this object via UI or API is disallowed.play_storeThe object data is synchronized with data from in-app subscription(s) created in Google Play Store. Direct manipulation of this object via UI or API is disallowed.
In-App Subscriptions is currently in early access. Contact eap@chargebee.com for more information.
required, string, max chars=100 The id of the addon or charge that is being attached to the plan-item.
type
optional, enumerated string The type of attachment for the addon. Only applicable for addon-items and is a required parameter as well for addon-items.
Possible values are
recommendedThe addon is recommended to go with the plan-item when using Checkout or Portal.mandatoryThe addon is attached automatically to the subscription for the plan-item unless explicitly removed via API.optionalThe addon is neither mandatory, nor recommended. This allows you to attach an addon so you can specify a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.
billing_cycles
optional, integer, min=1 The number of subscription billing cycles for which this item is attached when applied to a subscription. Applicable only for items of type addon. Requires addon billing cycles to be enabled for the site.
optional, integer, min=1 The default quantity of the addon to be attached when the quantity is not specified while creating/updating the subscription.
quantity_in_decimal
optional, string, max chars=33 The decimal representation of the quantity of the addon. Returned for quantity-based addons when multi-decimal pricing is enabled.
charge_on_event
optional, enumerated string Indicates when the item is charged. This parameter only applies to charge-items.
Possible values are
subscription_creationthe time of creation of the subscription.subscription_trial_startthe time when the trial period of the subscription begins.plan_activationsame as subscription activation, but also includes the case when the plan-item of the subscription is changed.subscription_activationthe moment a subscription enters an active or non-renewing state. Also includes reactivations of canceled subscriptions.contract_terminationwhen a contract term is terminated.on_demandItem can be charged on demand
charge_once
optional, boolean Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This parameter only applies to charge-items.
required, string, max chars=100 The id of the parent item in the attachment relationship.
type
optional, enumerated string The type of attachment for the addon. Only applicable for addon-items and is a required parameter as well for addon-items.
Possible values are
recommendedThe addon is recommended to go with the plan-item when using Checkout or Portal.mandatoryThe addon is attached automatically to the subscription for the plan-item unless explicitly removed via API.optionalThe addon is neither mandatory, nor recommended. This allows you to attach an addon so you can specify a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.
billing_cycles
optional, integer, min=1 The number of subscription billing cycles for which this item is attached when applied to a subscription. Applicable only for items of type addon. Requires addon billing cycles to be enabled for the site.
optional, integer, min=1 The default quantity of the addon to be attached when the quantity is not specified while creating/updating the subscription.
quantity_in_decimal
optional, string, max chars=33 The decimal representation of the quantity of the addon. Returned for quantity-based addons when multi-decimal pricing is enabled.
charge_on_event
optional, enumerated string Indicates when the item is charged. This parameter only applies to charge-items.
Possible values are
subscription_creationthe time of creation of the subscription.subscription_trial_startthe time when the trial period of the subscription begins.plan_activationsame as subscription activation, but also includes the case when the plan-item of the subscription is changed.subscription_activationthe moment a subscription enters an active or non-renewing state. Also includes reactivations of canceled subscriptions.contract_terminationwhen a contract term is terminated.on_demandItem can be charged on demand
charge_once
optional, boolean Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This parameter only applies to charge-items.
Returns a list of attached items satisfying all the conditions specified in the filter parameters below. The list is sorted by the date of creation in descending order (latest first).
optional, integer, default=10, min=1, max=100 The number of resources to be returned.
offset
optional, string, max chars=1000 Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set offset to the value of next_offset obtained in the previous iteration of the API call.
optional, string filter Filter attached items based on their id. Supported operators : is, is_not, starts_with, in, not_in
Example →id[is] = "bec0c324-adb6-44d3-ad4f-694f449be97c"
item_id[<operator>]
optional, string filter Filter attached items based on the item_id of the item being attached. Supported operators : is, is_not, starts_with, in, not_in
Example →item_id[is] = "basic"
type[<operator>]
optional, enumerated string filter Filter attached items based on the type of attached item. Possible values are : recommended, mandatory, optional. Possible values are : recommended, mandatory, optional. Supported operators : is, is_not, in, not_in
Example →type[is] = "mandatory"
item_type[<operator>]
optional, enumerated string filter To filter based on the type of of the attached item. Possible values are : addon, charge. Possible values are : plan, addon, charge. Supported operators : is, is_not, in, not_in
Example →item_type[is] = "plan"
charge_on_event[<operator>]
optional, enumerated string filter Indicates when the item is charged. This attribute only applies to charge-items. Possible values are : subscription_creation, subscription_trial_start, plan_activation, subscription_activation, contract_termination, on_demand. Supported operators : is, is_not, in, not_in
Example →charge_on_event[is] = "subscription_creation"
updated_at[<operator>]
optional, timestamp(UTC) in seconds filter Filter attached items based on when the attached items were last updated. Supported operators : after, before, on, between
always returned
Resource object representing attached_item
next_offset
optional, string, max chars=1000
This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.