# Retrieve Subscription Change Timeline

Using the fucntion, fetchChangeSubscriptionOptions, you can change subscription immediately or end-of-term based on custom code logic.

# Usage and invocation

You can implement your business logic on cases of subscription change that need to happen immediately and at the end of term, and finally return a value for each scenario.

  • If the changes need to take effect immediately, end-of-term should be set to false.
  • If the changes need to take effect at the term end, end-of-term should be set to true.

Let's take an example. For downgrades, you can choose to make the change during the end of the term. Whereas for upgrades, you can choose to make the change immediately.

# 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

subscription
Object
User's existing subscription details.
subscription_changes
Object
User's newly selected plan or addon details for the updated subscription.
customer
Object
Parameters for customer.
item_prices
Object
Details of current plan and addon price points.
callback
Object View properties
Callback that can be passed during the payment process. Usage is limited based on value returned from the redirected page.
logger
Object

Helps log debug information for your custom code. To emit a log entry, call logger.debug('key', 'value') in your custom code. The logs appear in Chargebee Billing on the Custom Codes page at https://YOUR_SUBDOMAIN.chargebee.com/custom_codes, under the Execution section, after you execute the custom code.

# Sample code

  • js

# Sample Output

  • json

# Expected JSON schema for the output

  • json

TIP

If you are still using Product Catalog 1.0 (opens new window), click here to learn more about retrieve subscription change timeline.