ChargebeeAPI

Portal sessions

Customer Portal lets your customers to manage their account and billing themselves. Chargebee supports Single Sign-on (SSO) to access the customer portal. If you already have your own authentication for your website, it allows your authenticated customers to access their portal without having to login again.

Note: You can instead allow your customers to access the portal via login page provided by Chargebee. Read more.

Please follow the below steps for supporting portal access via SSO:

  1. To enable the "Allow access to customer portal via API", click Settings > Configure Chargebee > Customer Facing Essentials > Checkout and Self Serve Portal > Portal.
  2. Provide a link in your website/application which your authenticated customers can use to access the portal (For example, {your_website_url}/portal_link).
  3. Handle the link request in your server code and create a portal session for the customer by calling Chargebee's "Create a portal session" API
  4. Forward the user to the access URL present in the "Portal Session" resource returned by the above API call.

Notes about access URL:

  • The access URL should be accessed by the customer within one hour from the time it was created.
  • Once accessed, the session is valid until the user logs out from the portal UI or logout API is called from your application for this session.
  • Once accessed, the access url cannot be reused. Hence do not persist this URL. Whenever you need to provide access to the portal, you need to create a new portal session.

Sample Portal sessionJSON

API Index URL

https://[site].chargebee.com/api/v2/portal_sessions

Portal sessions attributes

id
required, string, max chars=70

Unique identifier for the portal session.

token
required, string, max chars=70

Unique pre-authenticated portal session token to access customer portal directly.

access_url
required, string, max chars=550

Unique URL for accessing the customer portal. Once accessed, this cannot be reused.

redirect_url
optional, string, max chars=250

URL to redirect when the user logs out from the portal.

status
required, enumerated string, default=created

Indicates the current status of the portal session.

Possible Enum Values
created

Indicates that the portal session is just created and not yet accessed by the user.

logged_in

Indicates that the portal session URL has been accessed by the user and the session is active.

logged_out

Indicates that the portal session is logged out either by user or via API.

not_yet_activated

Indicates that the portal session is created and not yet activated for the customer to allow access to your website. This is applicable when you use Chargebee's authentication for your website

activated

Indicates that the portal session is activated for the customer to allow access to your website. This is applicable when you use Chargebee's authentication for your website.

created_at
required, timestamp(UTC) in seconds

Timestamp indicating when this portal session was generated.

expires_at
optional, timestamp(UTC) in seconds

Specifies when the portal session URL expires. After this time, it is no longer accessible. The expiration time is set to 1 hour after the portal session is created.

customer_id
required, string, max chars=50

Identifier of the customer.

login_at
optional, timestamp(UTC) in seconds

Timestamp indicating when this portal session URL was accessed by the user.

logout_at
optional, timestamp(UTC) in seconds

Timestamp indicating when this portal session was logged out either by user or via API.

login_ipaddress
optional, string, max chars=50

IP Address from which the portal session URL was accessed.

logout_ipaddress
optional, string, max chars=50

IP Address from which the portal session was logged out either by user or via API.

linked_customers

The list of customers for this session