# Retrieve Allowed Plans and Addons
Using the function, fetchAllowedPlanConfig
, following functionalities can be performed:
Fetch applicable addons
Automatically attach addons based on selected plans
Quantity meta support
Note
fetchAllowedPlanConfig
does not override mandatory addons. So, mandatory addons has to be included as part of the output JSON.
# Usage and invocation
This function will be invoked to get the list of plans and addons combination for a particular subscription. Only the plans and addons present in the list will be shown to the customer while changing the subscription. You can write your business specific logic in this function to restrict the plan list and addon list for your customers.
Let's take an example. For users on the Platinum plan you can provide the plans and addons from a premium group to choose from during upgrade. Whereas for users on the Gold plan, you can provide the plans and addons from a basic group to choose from, during downgrade.
# Instructions for writing the function
- It should be written in javascript.
- It should be executable in Node.js v6.0 environment.
- Some default resources are passed to this function by Chargebee. You can use these resources to write your business logic. The resource formats are similar to the resource output generated from the Node.js client library.
- You can also use Chargebee’s Node.js client library (if already configured with API key and secret key) for retrieving and using additional resources.
- Return a JavaScript object that matches the JSON schema given below.
# Parameters
# Output parameters
You can use these additional parameters to pass data to Chargebee. It is then displayed on portal for the user to access.
use_existing_addons
: Settrue
to carryover addons from the current subscription to the changed subscription.allowed_addons
: List of applicable addons for the plan.addons
: List of addons to be auto-attached when a customer moves from one plan to another.meta_data
: This supplies data for the quantity drop-down associated with a plan or addon.
# Sample Code
- js
# Sample Output
- json
# Expected JSON schema for the output
- json