# Chargebee library
These are the top level methods exposed by Chargebee.js.
# init
Within your JavaScript code, initialize chargebee once the page is loaded and get chargebee instance
object.
# Syntax
Chargebee.init(options)
# Parameters
# Return value
# Example
var cbInstance = Chargebee.init({
site: "site-name", // your test site
domain: "https://mybilling.acme.com" // this is an optional parameter.
})
2
3
4
# getPortalSections
This function returns an object with all the available sections in Chargebee customer portal. This section name can be used to forward a user to a particular section or open the section as an individual card.
# Syntax
Chargebee.getPortalSections();
# Return value
An object with all the available sections in Chargebee customer portal.
# Example
{
"SUBSCRIPTION_DETAILS": "sub_details",
"SUBSCRIPTION_CANCELLATION": "sub_cancel",
"EDIT_SUBSCRIPTION": "edit_subscription",
"VIEW_SCHEDULED_CHANGES": "scheduled_changes",
"ACCOUNT_DETAILS": "account_details",
"EDIT_ACCOUNT_DETAILS": "portal_edit_account",
"ADDRESS": "portal_address",
"EDIT_BILLING_ADDRESS": "portal_edit_billing_address",
"EDIT_SHIPPING_ADDRESS": "portal_edit_shipping_address",
"EDIT_SUBSCRIPTION_CUSTOM_FIELDS": "portal_edit_subscription_cf",
"PAYMENT_SOURCES": "portal_payment_methods",
"ADD_PAYMENT_SOURCE": "portal_add_payment_method",
"EDIT_PAYMENT_SOURCE": "portal_edit_payment_method",
"VIEW_PAYMENT_SOURCE": "portal_view_payment_method",
"CHOOSE_PAYMENT_METHOD_FOR_SUBSCRIPTION": "portal_choose_payment_method",
"BILLING_HISTORY": "portal_billing_history"
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# getInstance
This function will return 'chargebee instance' object created using init() function.
# Syntax
Chargebee.getInstance();
# Return value
chargebee instance object. Error will be thrown if instance is not created.
# registerAgain
Use this function to rebind listeners if a new element is inserted dynamically to the DOM. Used for drop-in script Checkout integration.
# Syntax
Chargebee.registerAgain();
# Return value
NA
# Example
const checkoutLink = document.createElement('a');
checkoutLink.href = "javascript:void(0)";
checkoutLink.dataset.cbType = "checkout";
checkoutLink.dataset.cbPlanId = "cbdemo_scale";
document.body.appendChild(checkoutLink);
Chargebee.registerAgain();
2
3
4
5
6
7