# 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.
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.
loader
Object
Used to log debugging information only while testing (function should be in draft mode) using the Chargebee test site.

# 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.