API Reference Chargebee
object init
This function is used to initialize Chargebee with your site, domain name and publishable key (opens new window) . The 'chargebee instance' object returned as result of initialization can be used to create the components.
Syntax Chargebee. init ( options) ;
1
Parameters options
Object Required Hide properties domain
String Required if custom domain is enabled
Your custom domain.
Eg: https://billing.yourdomain.com
publishableKey
String Required Your publishable API key.
The unique ID of the
business entity under whose
context the cart object or the
drop-in script should work.
If not provided, the
default business entity defined for the site is considered.
Note: This parameter is applicable only when multiple business entities have been created for the site. Multiple Business Entities is currently in early access. Contact eap@chargebee.com to join the Early Adopter Program and enable this feature.
Return value Chargebee
instance object
Example var cbInstance = Chargebee. init ( {
site : "site-name" ,
domain : "https://mybilling.acme.com"
publishableKey : "test__"
} )
1 2 3 4 5
getInstance
This function will return 'chargebee instance' object.
Syntax Chargebee. getInstance ( ) ;
1
Return value Chargebee instance object
Error will be thrown if instance is not created.
Chargebee
instance object Chargebee instance object is used to create components instance.
components
Creates a Components
object which is used to create payment components.
Syntax cbInstance. components ( options) ;
1
Parameters options
Object Required Hide properties style
Object Hide properties Interactive components color 1
Interactive components color 2
Interactive components color 3
Borders and separators color 1
Borders and separators color 2
Borders and separators color 3
Functional color for surface
Functional color for accent indicator
Functional color for accent track
Functional color for accent contrast
Gray for interactive components 1
Gray for interactive components 2
Gray for interactive components 3
Gray for borders and separators 1
Gray for borders and separators 2
Gray for borders and separators 3
Gray for accessible text 1
Gray for accessible text 2
Gray color for accent indicator
Gray color for accent track
Gray color for accent contrast
Solid panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
colorPanelTranslucent
String Translucent panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
Form component backgrounds, such as text fields, checkboxes, select, etc.
Your custom font for <Heading> components
Your custom font for <Code> components
Your custom font for <Strong> components
Your custom font for <Em> components
Your custom font for <Quote> components
Font weight for light text
Font weight for regular text
Font weight for medium text
Font weight for bold text
Radius base variable, used for multiplying.
A variable used to calculate a fully rounded radius.
A variable used to calculate radius of a thumb element.
The rules option is a map of CSS-like selectors to CSS properties, allowing granular customization of individual components.
Locale code in ISO 639-1 format (en, fr). By default, `en` will be used
Return value A Components
instance.
Example Components
class create
Creates a UI component to collect sensitive information from your customers.
Syntax const component = components. create ( componentType, options, callbacks)
1
Parameters payment
componentType
string Required options
Object Required Hide properties style
Object Hide properties Interactive components color 1
Interactive components color 2
Interactive components color 3
Borders and separators color 1
Borders and separators color 2
Borders and separators color 3
Functional color for surface
Functional color for accent indicator
Functional color for accent track
Functional color for accent contrast
Gray for interactive components 1
Gray for interactive components 2
Gray for interactive components 3
Gray for borders and separators 1
Gray for borders and separators 2
Gray for borders and separators 3
Gray for accessible text 1
Gray for accessible text 2
Gray color for accent indicator
Gray color for accent track
Gray color for accent contrast
Solid panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
colorPanelTranslucent
String Translucent panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
Form component backgrounds, such as text fields, checkboxes, select, etc.
Your custom font for <Heading> components
Your custom font for <Code> components
Your custom font for <Strong> components
Your custom font for <Em> components
Your custom font for <Quote> components
Font weight for light text
Font weight for regular text
Font weight for medium text
Font weight for bold text
Radius base variable, used for multiplying.
A variable used to calculate a fully rounded radius.
A variable used to calculate radius of a thumb element.
The rules option is a map of CSS-like selectors to CSS properties, allowing granular customization of individual components.
Locale code in ISO 639-1 format (en, fr). By default, `en` will be used
layout
Object Hide properties type
tab | accordion Required defaultItemsToShow
number Specifies the number of payment methods to display in the UI. Any additional payment methods appear under an expandable menu.
paymentMethods
Object Hide properties Sort order of the payment methods displayed on the payment component.
Example: sortOrder: ["card", "google_pay", "apple_pay"]
See PaymentIntent.payment_method_type
for the list of supported values.
List of payment methods supported by the payment component.
Example: allowed: ["card", "google_pay", "apple_pay"]
See also :
See PaymentIntent.payment_method_type
for the list of supported values.
options
Object Hide properties card
Object Hide properties List of logos of card provider.
Example: options: { card: { logos: ["mastercard", "amex", "visa"] } }
paymentIntent
Object Hide properties form
Object Hide properties customer
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> email
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> payment
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> email
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> billingAddress
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine1
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine2
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine3
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> city
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> state
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> stateCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> countryCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> zip
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> shippingAddress
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine1
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine2
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine3
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> city
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> state
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> stateCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> countryCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> zip
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> context
Object Hide properties cart
Object Hide properties
Allowed Values:
plan
addon
charge
customer
Object Hide properties payment
Object Hide properties billingAddress
Object Hide properties First name associated with the address
Last name associated with the address
Phone number associated with the shipping address
Address line 1 (eg. number, street, etc).
Address line 2 (eg. suite, apt #, etc.).
Address line 3 (eg. suite, apt #, etc).
2 letter code for US states or equivalent
shippingAddress
Object Hide properties First name associated with the address
Last name associated with the address
Phone number associated with the shipping address
Address line 1 (eg. number, street, etc).
Address line 2 (eg. suite, apt #, etc.).
Address line 3 (eg. suite, apt #, etc).
2 letter code for US states or equivalent
callbacks
Object Hide properties onSuccess(paymentIntent, extra)
function PaymentIntent
Object Hide properties
Allowed Values:
authorized
gateway_account_id
string payment_method_type
string
Allowed Values:
google_pay
apple_pay
paypal_express_checkout
card
created_at
Unix timestamp modified_at
Unix timestamp updated_at
Unix timestamp onPaymentMethodChange(paymentMethod)
function Return PaymentComponent
Example componentType
string Required
Allowed Values:
payment-button
options
Object Required Hide properties style
Object Hide properties Interactive components color 1
Interactive components color 2
Interactive components color 3
Borders and separators color 1
Borders and separators color 2
Borders and separators color 3
Functional color for surface
Functional color for accent indicator
Functional color for accent track
Functional color for accent contrast
Gray for interactive components 1
Gray for interactive components 2
Gray for interactive components 3
Gray for borders and separators 1
Gray for borders and separators 2
Gray for borders and separators 3
Gray for accessible text 1
Gray for accessible text 2
Gray color for accent indicator
Gray color for accent track
Gray color for accent contrast
Solid panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
colorPanelTranslucent
String Translucent panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
Form component backgrounds, such as text fields, checkboxes, select, etc.
Your custom font for <Heading> components
Your custom font for <Code> components
Your custom font for <Strong> components
Your custom font for <Em> components
Your custom font for <Quote> components
Font weight for light text
Font weight for regular text
Font weight for medium text
Font weight for bold text
Radius base variable, used for multiplying.
A variable used to calculate a fully rounded radius.
A variable used to calculate radius of a thumb element.
The rules option is a map of CSS-like selectors to CSS properties, allowing granular customization of individual components.
Locale code in ISO 639-1 format (en, fr). By default, `en` will be used
paymentMethods
Object Hide properties options
Object Hide properties card
Object Hide properties The text appearing on payment button when card is selected
google_pay
Object Hide properties Color of the Google Pay button.
Allowed Values:
default
black
white
Type of the Google Pay button.
Allowed Values:
long
short
book
buy
checkout
donate
order
pay
plain
subscribe
Button size options.
Allowed Values:
static
fill
Locale options for the Google Pay Button.
paypal_express_checkout
Object callbacks
Object Hide properties Return PaymentButtonComponent
Example Payment Component mount
Inserts the payment UI component into the DOM.
Syntax await paymentComponent. mount ( target) ;
1
Parameters target
string | HTMLElement Required DOM element or a CSS selector where the component should be mounted.
Return A promise that resolves to true if the component was successfully mounted, or false if an error occurred
update
Updates the payment component options using a shallow merge and remounts the component.
Syntax paymentComponent. update ( options)
1
Parameters options
Object Hide properties style
Object Hide properties Interactive components color 1
Interactive components color 2
Interactive components color 3
Borders and separators color 1
Borders and separators color 2
Borders and separators color 3
Functional color for surface
Functional color for accent indicator
Functional color for accent track
Functional color for accent contrast
Gray for interactive components 1
Gray for interactive components 2
Gray for interactive components 3
Gray for borders and separators 1
Gray for borders and separators 2
Gray for borders and separators 3
Gray for accessible text 1
Gray for accessible text 2
Gray color for accent indicator
Gray color for accent track
Gray color for accent contrast
Solid panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
colorPanelTranslucent
String Translucent panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
Form component backgrounds, such as text fields, checkboxes, select, etc.
Your custom font for <Heading> components
Your custom font for <Code> components
Your custom font for <Strong> components
Your custom font for <Em> components
Your custom font for <Quote> components
Font weight for light text
Font weight for regular text
Font weight for medium text
Font weight for bold text
Radius base variable, used for multiplying.
A variable used to calculate a fully rounded radius.
A variable used to calculate radius of a thumb element.
The rules option is a map of CSS-like selectors to CSS properties, allowing granular customization of individual components.
Locale code in ISO 639-1 format (en, fr). By default, `en` will be used
paymentIntent
Object Hide properties paymentMethods
Object Hide properties Sort order of the payment methods displayed on the payment component.
Example: sortOrder: ["card", "google_pay", "apple_pay"]
See PaymentIntent.payment_method_type
for the list of supported values.
List of payment methods supported by the payment component.
Example: allowed: ["card", "google_pay", "apple_pay"]
See also :
See PaymentIntent.payment_method_type
for the list of supported values.
options
Object Hide properties card
Object Hide properties List of logos of card provider.
Example: options: { card: { logos: ["mastercard", "amex", "visa"] } }
layout
Object Hide properties type
tab | accordion Required defaultItemsToShow
number Specifies the number of payment methods to display in the UI. Any additional payment methods appear under an expandable menu.
form
Object Hide properties customer
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> email
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> payment
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> email
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> billingAddress
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine1
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine2
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine3
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> city
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> state
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> stateCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> countryCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> zip
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> shippingAddress
Object Hide properties firstName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> lastName
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> phone
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine1
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine2
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> addressLine3
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> city
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> state
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> stateCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> countryCode
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> zip
Object Hide properties
Allowed Values:
Object
'default'
'never'
allowedValues
Array<Object> context
Object Hide properties cart
Object Hide properties
Allowed Values:
plan
addon
charge
customer
Object Hide properties payment
Object Hide properties billingAddress
Object Hide properties First name associated with the address
Last name associated with the address
Phone number associated with the shipping address
Address line 1 (eg. number, street, etc).
Address line 2 (eg. suite, apt #, etc.).
Address line 3 (eg. suite, apt #, etc).
2 letter code for US states or equivalent
shippingAddress
Object Hide properties First name associated with the address
Last name associated with the address
Phone number associated with the shipping address
Address line 1 (eg. number, street, etc).
Address line 2 (eg. suite, apt #, etc.).
Address line 3 (eg. suite, apt #, etc).
2 letter code for US states or equivalent
Return NA
validate
Verifies that the submitted payment details are valid and ready for processing.
Syntax const isValid = await paymentComponent. validate ( )
1
Return Promise<boolean>
confirm
Initiates the payment authorization process. Once the user completes the payment, the function calls the onSuccess
callback along with authorized paymentIntent
, which can be used to create subscriptions and invoices.
Syntax await paymentComponent. confirm ( )
1
Return NA
close
Removes the mounted component from the DOM and triggers the onClose
callback of the payment component if defined.
Syntax paymentComponent. close ( )
1
Return NA
The Payment Button Component is a dynamic prebuilt UI button that submits the payment form when clicked.
mount
Inserts the payment button UI component into the DOM.
Syntax await paymentButtonComponent. mount ( target) ;
1
Parameters target
string | HTMLElement Required DOM element or a CSS selector where the component should be mounted.
Return A promise that resolves to true if the component was successfully mounted, or false if an error occurred
update
Updates the payment button component options using a shallow merge and remounts the component.
Syntax paymentButtonComponent. update ( options)
1
Parameters options
Object Hide properties style
Object Hide properties Interactive components color 1
Interactive components color 2
Interactive components color 3
Borders and separators color 1
Borders and separators color 2
Borders and separators color 3
Functional color for surface
Functional color for accent indicator
Functional color for accent track
Functional color for accent contrast
Gray for interactive components 1
Gray for interactive components 2
Gray for interactive components 3
Gray for borders and separators 1
Gray for borders and separators 2
Gray for borders and separators 3
Gray for accessible text 1
Gray for accessible text 2
Gray color for accent indicator
Gray color for accent track
Gray color for accent contrast
Solid panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
colorPanelTranslucent
String Translucent panel backgrounds, such as cards, tables, popovers, dropdown menus, etc.
Form component backgrounds, such as text fields, checkboxes, select, etc.
Your custom font for <Heading> components
Your custom font for <Code> components
Your custom font for <Strong> components
Your custom font for <Em> components
Your custom font for <Quote> components
Font weight for light text
Font weight for regular text
Font weight for medium text
Font weight for bold text
Radius base variable, used for multiplying.
A variable used to calculate a fully rounded radius.
A variable used to calculate radius of a thumb element.
The rules option is a map of CSS-like selectors to CSS properties, allowing granular customization of individual components.
Locale code in ISO 639-1 format (en, fr). By default, `en` will be used
paymentMethods
Object Hide properties options
Object Hide properties card
Object Hide properties The text appearing on payment button when card is selected
google_pay
Object Hide properties Color of the Google Pay button.
Allowed Values:
default
black
white
Type of the Google Pay button.
Allowed Values:
long
short
book
buy
checkout
donate
order
pay
plain
subscribe
Button size options.
Allowed Values:
static
fill
Locale options for the Google Pay Button.
paypal_express_checkout
Object Return NA
close
Removes the mounted payment button component from the DOM and triggers the onClose
callback of the payment button component if defined.
Syntax paymentButtonComponent. close ( )
1
Return NA
PaymentIntent
Allowed Values:
consumed
in_progress
inited
expired
authorized
gateway_account_id
string payment_method_type
string
Allowed Values:
google_pay
apple_pay
paypal_express_checkout
card
created_at
Unix timestamp modified_at
Unix timestamp updated_at
Unix timestamp PaymentMethods supported payment methods card
google_pay
apple_pay
paypal_express_checkout
Locale code language es
Spanish en
English fr
French de
German it
Italian pt
Portuguese