Portal Features 

The following sections capture the features offered by the Chargebee hosted portal.

Custom Codes 

Custom code is a feature enabled by Chargebee that allows you to implement custom business logic while the customer edits a subscription in the portal.

Let's look at an example. James runs a fitness app. He has three plans to which his users can subscribe, Elite, Pro, and Luxe. James needs to implement business logic in his system to display only upper-level plans when his user wants to change his subscription.

Say, if a user is subscribed to a Pro plan and is trying to change his subscription, the listed plans should be only Luxe and not Elite.

Custom code is a feature enabled by Chargebee that allows you to implement custom business logic while the customer performs certain actions in the portal.

The functions fetchChangeSubscriptionOptions  or fetchAllowedPlanConfig  enable you to use this feature.

Fetch Change Subscription Options 

Using this function, fetchChangeSubscriptionOptions, you can change subscriptions immediately or end-of-term based on custom code logic.

Implement your business logic on subscription change scenarios that need to happen with immediate effect or at the end of the subscription term, and finally return a value for each scenario.

  • If the changes need to take effect immediately, the 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.

Note

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.

Fetch Allowed Plan Config 

Using this function, fetchAllowedPlanConfig, the following functionalities can be performed:

  • Specify allowed addons.

  • Specify allowed addons for a particular plan.

  • Specify addons to be automatically attached to a plan when selected.

  • Specify quantity meta for a plan or addon.

This function gets the list of plans and addons combinations for a specific subscription. Only the plans and addons present in the list appear 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.

Note

Let's take an example. For users on the Platinum plan you can provide the plan items and addon items from a premium group to choose from during upgrade. Whereas for users on the Gold plan, you can provide the plan items and addon items from a basic group to choose from, during downgrade.

Learn more  about the implementation details of the functions.

Information
  • Contact support to enable the custom code feature.
  • Currently, this feature is supported in the customer portal in Edit Subscription using the functions.

Once the custom code is enabled by the support, you can access the same by navigating to https://{your-site-name}/custom_codes

The published version of your custom code will be available in the link above.

Click the Download code to download the same to make changes if needed.

To execute your custom codes, follow the below steps:

  1. Upload your file - Upload the file containing your business logic using this option.

  2. Pick an execution option - Pick an option to execute. Based on the coding, fetchChangeSubscriptionOptions  or fetchAllowedPlanConfig  or both populates in the dropdown.

  1. Enter the required input parameters. Sample input: ['sampleSubscriptionId']

  2. Click Run and validate your results.

  3. Click Publish.

Was this article helpful?
Loading…