Portal via API

Integrating portal via API allows you to reuse your app's authentication to open the self-serve portal. This improves your end user experience as they need not sign in again.

Call Flow

You need to have an HTTPS end point at your end, that will use chargebee portal session api and return a portal session object as a response. Server side changes

Then use chargebee.js to open the self-serve portal Client side changes

Integration Steps

Importing the .js script to your application

Copy and paste the below script in your HTML page. You only need to do this once, per page.

<script src="https://js.chargebee.com/v2/chargebee.js"></script>

Intializing a Chargebee instance

Inside your javascript code, initialize chargebee instance once the page is loaded. This instance is used further to open self-serve portal.

  • jQuery
  • vue

Passing portal session object to chargebee instance

Create a function that will return a promise and pass it to setPortalSession method of chargebee instance. This promise should resolve a portal session object.

  • jQuery
  • vue

Opening the Self-Serve Portal

  • es6
  • es5
In mobile browsers, we open the customer portal in a new window. So, please make sure you open the checkout as a result of an user action or else the browser will block the new window creation.

Please check the API reference to know more about supported callback functions.

Logging out from portal

After your end customers access our self-serve portal, we will maintain the session for one hour. If you want to end this session, please call logout() method of chargebee instance.


End point that returns a portal page object.

Create an HTTP end point at your server. This end point should return a portal session object as a response.

  • ruby
  • java
  • python
  • php
  • .net

The portal session response JSON should look like this:

  "id": "portal_XpbGElGQgEHspHB",
  "token": "cuqdrWacuITd2cabvf97KJD73SpNcd7BICB",
  "access_url": "https://yourapp.chargebeeportal.com/portal/access/cuqdrWacuITd2cabvf97KJD73SpNcd7BICB",
  "status": "created",
  "created_at": 1515494835,
  "expires_at": 1515498435,
  "object": "portal_session",
  "customer_id": "XpbGEt7QgEHsnL7O"
Please make sure the HTTP response has the content type "application/json"

Managing customer payment sources