You are viewing the documentation for Chargebee API V2. If you're using the older version (V1), click here.

Hosted pages are the easiest and most secure way to integrate chargebee with your website. By using hosted pages, you can avoid the sensitive card information passing through your server and be compliant with most of the PCI DSS requirements.

When you request for a hosted page, a secure and unique URL will be returned which you could either embed or redirect depending upon the embed parameter value that you had passed.

Specifying "embed" parameter as true allows you to embed the "hosted page" in an iframe in your own website. This helps you provide the best experience to your user as they do not have to leave your website to provide card information. There are a few limitations:

  • Your site URL must be embedded with HTTPS.
  • Set the appropriate height and width for the iframe to avoid scrolling.

To use the hosted pages, you must configure Redirect URL in the Chargebee web interface under Hosted Pages Settings > Configuration. The configured redirect URL will be called with the following parameters after user had submitted the page.

  • id - unique identifier of the hosted page resource
  • state - succeeded, failed or cancelled

After the Redirect URL is called by Chargebee with the above parameters, the details of the hosted page can be fetched using Retrieve a hosted page API. The content attribute will have the details about the customer, subscription, card and invoice based on the type of the hosted page.

Checkout New Subscription:

  • Customer - The details about the new customer created.
  • Subscription - The details about the new subscription created.
  • Card - The details about the card provided while subscribing.
  • Invoice - The details about the invoice, if one is generated.

Checkout Existing Subscription:

  • Customer - The updated details of the customer.
  • Subscription - The updated details of the subscription.
  • Card - The details about the card provided while subscribing.
  • Invoice - The details about the invoice, if one is generated.

Update Payment Method:

  • Customer - The details about the customer for whom the card was updated.
  • Card - The details about the updated card. It will be present only if the type of payment method is card.

When an embedded hosted page is cancelled by your end user, the content attribute will have the unmodified details of customer, subscription and card resources.

Sample hosted page [ JSON ]

{ "created_at": 1517505996, "embed": true, "expires_at": 1517509596, "id": "__test__znukwBn17fojRqcSm5uZtxxn99WgF5gcu", "object": "hosted_page", "resource_version": 1517505996000, "state": "created", "type": "checkout_new", "updated_at": 1517505996, "url": "https://yourapp.chargebee.com/pages/v2/__test__znukwBn17fojRqcSm5uZtxxn99WgF5gcu/checkout" }
id
optional, string, max chars=70
Unique identifier generated for each hosted page requested.
type
optional, enumerated string
Type of the requested hosted page.
Possible values are
checkout_newCheckout new Subscription.checkout_existingCheckout existing Subscription.update_payment_methodUpdate Payment Method for a Customer.
manage_payment_sourcesManage Payments for a customer.collect_nowCollect Unpaid Invoices for a Customer.extend_subscriptionTo extend a Subscription period.checkout_giftCheckout a gift subscription.claim_giftClaim a gift subscription.checkout_one_timeCheckout one time.pre_cancelThis hosted page is used to help retain customers when they attempt to cancel their account or subscription.
Show all values[+]
url
optional, string, max chars=250
Unique URL for the hosted page that will be included in your website.
state
optional, enumerated string, default=created
Indicating the current state of the hosted page resource.
Possible values are
createdIndicates the hosted page is just created.requestedIndicates the hosted page is requested by the website.succeededIndicates the hosted page is successfully submitted by the user and response is sent to the return url.cancelledIndicates the page is cancelled by the end user after requesting it.acknowledgedIndicates the succeeded hosted page is acknowledged.
pass_thru_content
optional, string, max chars=2048
You can pass through any content specific to the hosted page request and get it back after user had submitted the hosted page.
embed
boolean, default=true
If true then hosted page formatted to be shown in iframe. If false, it is formatted to be shown as a separate page.

Note : For in-app checkout, default is false.
created_at
optional, timestamp(UTC) in seconds
Indicates when this hosted page url is generated.
expires_at
optional, timestamp(UTC) in seconds
Indicates when this hosted page url will expire. After this, the hosted page cannot be accessed.
content
jsonobject
This attribute will be returned only during retrieve hosted page API call and also the retrieved hosted page resource state should be either in "succeeded" or "cancelled" state.
If hosted page state is "succeeded", then the subscription, customer, card & invoice(optional) resources during checkout can be obtained.
If hosted page is state is "cancelled", then it will be empty i.e no information about checkout.
updated_at
optional, timestamp(UTC) in seconds
Timestamp indicating when this hosted page was last updated.
resource_version
optional, long
The version number of this resource. For every change made to the resource, resource_version is updated with a new timestamp in milliseconds.
checkout_info
optional, jsonobject
Customer Info (email, first name and last name) given in the checkout page used for tracking abandoned carts.
Learn more.
business_entity_id
optional, string, max chars=50
The ID of the business entity created for the site. For Product Catalog 1.0, all the site data is tied to this business entity.
Note

Multiple Business Entities is a feature available only on Product Catalog 2.0.


Hosted page to accept card details from the subscriber and create a new subscription. This is similar to our server to server API Create a Subscription.

When the redirect URL is notified of the result, we would advise you to retrieve the subscription and verify the details.

Related Tutorials

Notes

As mentioned before this behavior is very similar to the create subscription API call. All the web hook events will be fired only after the submission of payment details by the customer and successful creation of subscription.

Any errors related to the payment form that is submitted is handled as a response within the form so that the user is kept informed about the reason for failure to take corrective action.

Sample Request
# checkout a new subscription with customer details.
curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_new \
     -u {site_api_key}:\
     -d customer[email]="john@user.com" \
     -d customer[first_name]="John" \
     -d customer[last_name]="Doe" \
     -d customer[locale]="fr-CA" \
     -d customer[phone]="+1-949-999-9999" \
     -d subscription[plan_id]="no_trial" \
     -d billing_address[first_name]="John" \
     -d billing_address[last_name]="Doe" \
     -d billing_address[line1]="PO Box 9999" \
     -d billing_address[city]="Walnut" \
     -d billing_address[state]="California" \
     -d billing_address[zip]="91789" \
     -d billing_address[country]="US"
copy

Sample Response [ JSON ]

URL Format POST

https://{site}.chargebee.com/api/v2/hosted_pages/checkout_new
billing_cycles
optional, integer, min=0
Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
mandatory_addons_to_remove[0..n]
optional, list of string
List of addons IDs that are mandatory to the plan and has to be removed from the subscription.
terms_to_charge
optional, integer, min=1
The number of subscription billing cycles (including the first one) to invoice in advance.
billing_alignment_mode
optional, enumerated string
Override the billing alignment mode for Calendar Billing. Only applicable when using Calendar Billing. The default value is that which has been configured for the site.
Possible values are
immediateSubscription period will be aligned with the configured billing date immediately, with credits or charges raised accordingly..delayedSubscription period will be aligned with the configured billing date at the next renewal.
coupon_ids[0..n]
optional, list of string
List of coupons to be applied to this subscription. You can provide coupon ids or coupon codes.
redirect_url
optional, string, max chars=250
The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL. Although the customer will be redirected to the redirect_url after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as subscription_created or invoice_generated to verify a successful checkout.

Note :
  • Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
    Eg : http://yoursite.com?id=<hosted_page_id>&state=succeeded
  • This parameter is not applicable for iframe messaging.
cancel_url
optional, string, max chars=250
The customers will be redirected to this URL upon canceling checkout. The hosted page id and state will be passed as parameters to this URL.

Note :
  • Cancel URL configured in Settings > Hosted Pages Settings would be overriden by this cancel URL.
    Eg : http://yoursite.com?id=<hosted_page_id>&state=cancelled
  • This parameter is not applicable for iframe messaging and in-app checkout.
pass_thru_content
optional, string, max chars=2048
You can pass through any content specific to the hosted page request and get it back after user had submitted the hosted page.
embed
optional, boolean, default=true
If true then hosted page formatted to be shown in iframe. If false, it is formatted to be shown as a separate page.

Note : For in-app checkout, default is false.
iframe_messaging
optional, boolean, default=false
If true then iframe will communicate with the parent window. Applicable only for embedded(iframe) hosted pages. If you're using iframe_messaging you need to implement onSuccess & onCancel callbacks.

Note : This parameter is not applicable for in-app checkout.
allow_offline_payment_methods
optional, boolean
Allow the customer to select an offline payment method during checkout. The choice of payment methods can be configured via the Chargebee UI.
+
subscription
Parameters for subscription
pass parameters as subscription[<param name>]
subscription[id]
optional, string, max chars=50
A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
subscription[plan_id]
required, string, max chars=100
Identifier of the plan for this subscription.
subscription[plan_quantity]
optional, integer, default=1, min=1
Plan quantity for this subscription.
subscription[plan_quantity_in_decimal]
optional, string, max chars=33
The decimal representation of the quantity of the plan purchased. Can be provided for quantity-based plans and only when multi-decimal pricing is enabled.
subscription[plan_unit_price]
optional, in cents, min=0
Amount that will override the Plan's default price. The unit depends on the type of currency.
subscription[plan_unit_price_in_decimal]
optional, string, max chars=33
When price overriding is enabled for the site, the price or per-unit price of the plan can be set here. The value set for the plan is used by default. Provide the value as a decimal string in major units of the currency. Can be provided only when multi-decimal pricing is enabled.
subscription[setup_fee]
optional, in cents, min=0
Amount that will override the default setup fee. The unit depends on the type of currency.
subscription[trial_end]
optional, timestamp(UTC) in seconds
The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
subscription[start_date]
optional, timestamp(UTC) in seconds
The date/time at which the subscription is to start. If not provided, the subscription starts immediately. You can provide a value in the past as well. This is called backdating the subscription creation and is done when the subscription has already been provisioned but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
  • Backdating is enabled for subscription creation operations.
  • The current day of the month does not exceed the limit set in Chargebee for backdating such operations. This day is typically the day of the month by which the accounting for the previous month must be closed.
  • The date is not more than duration X into the past, where X is the billing period of the plan. For example, if the period of the plan in the subscription is 2 months and today is 14th April, start_date cannot be earlier than 14th February.
.
subscription[auto_collection]
optional, enumerated string
Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
Possible values are
onWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.offAutomatic collection of charges will not be made for this subscription. Use this for offline payments.
subscription[offline_payment_method]
optional, enumerated string
The preferred offline payment method for the subscription.
Possible values are
no_preferenceNo Preference.cashCash.checkCheck.bank_transferBank Transfer.ach_creditACH Credit.sepa_creditSEPA Credit.
subscription[invoice_notes]
optional, string, max chars=2000
A customer-facing note added to all invoices associated with this subscription. This note is one among all the notes displayed on the invoice PDF.
subscription[affiliate_token]
optional, string, max chars=250
A unique tracking token.
subscription[contract_term_billing_cycle_on_renewal]
optional, integer, min=1, max=100
Number of billing cycles the new contract term should run for, on contract renewal. The default value is the same as billing_cycles or a custom value depending on the site configuration.
+
customer
Parameters for customer
pass parameters as customer[<param name>]
customer[id]
optional, string, max chars=50
The unique ID of the customer for which this hosted_page should be created. When not provided, a new customer is created with the ID set to the value provided for subscription[id]. If subscription[id] is unavailable, then the customer ID is autogenerated.
customer[email]
optional, string, max chars=70
Email of the customer. Configured email notifications will be sent to this email.
customer[first_name]
optional, string, max chars=150
First name of the customer. If not provided it will be got from contact information entered in the hosted page .
customer[last_name]
optional, string, max chars=150
Last name of the customer. If not provided it will be got from contact information entered in the hosted page .
customer[company]
optional, string, max chars=250
Company name of the customer.
customer[taxability]
optional, enumerated string, default=taxable
Specifies if the customer is liable for tax.
Possible values are
taxableComputes tax for the customer based on the site configuration. In some cases, depending on the region, shipping_address is needed. If not provided, then billing_address is used to compute tax. If that’s not available either, the tax is taken as zero.exempt
  • Customer is exempted from tax. When using Chargebee’s native Taxes feature or when using the TaxJar integration, no other action is needed.
  • However, when using our Avalara integration, optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
.
customer[locale]
optional, string, max chars=50
Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
customer[phone]
optional, string, max chars=50
Phone number of the customer.
customer[vat_number]
optional, string, max chars=20
The VAT/tax registration number for the customer. For customers with billing_address country as XI (which is United Kingdom - Northern Ireland), the first two characters of the full VAT number can be overridden by setting vat_number_prefix.
customer[vat_number_prefix]
optional, string, max chars=10
An overridden value for the first two characters of the full VAT number. Only applicable specifically for customers with billing_address country as XI (which is United Kingdom - Northern Ireland).

When you have enabled EU VAT in 2021 or have manually enabled the Brexit configuration, you have the option of setting billing_address country as XI. That’s the code for United Kingdom - Northern Ireland. The first two characters of the VAT number in such a case is XI by default. However, if the VAT number was registered in UK, the value should be GB. Set vat_number_prefix to GB for such cases.
customer[consolidated_invoicing]
optional, boolean

Indicates whether invoices raised on the same day for the customer are consolidated. When provided, this overrides the default configuration at the site-level. This parameter can be provided only when Consolidated Invoicing is enabled.

Note:

Any invoices raised when a subscription activates from in_trial or future status, are not consolidated by default. Contact Support to enable consolidation for such invoices.

.
+
card
Parameters for card
pass parameters as card[<param name>]
card[gateway_account_id]
optional, string, max chars=50
The gateway account in which this payment source is stored.
+
billing_address
Parameters for billing_address
pass parameters as billing_address[<param name>]
billing_address[first_name]
optional, string, max chars=150
The first name of the billing contact.
billing_address[last_name]
optional, string, max chars=150
The last name of the billing contact.
billing_address[email]
optional, string, max chars=70
The email address.
billing_address[company]
optional, string, max chars=250
The company name.
billing_address[phone]
optional, string, max chars=50
The phone number.
billing_address[line1]
optional, string, max chars=150
Address line 1.
billing_address[line2]
optional, string, max chars=150
Address line 2.
billing_address[line3]
optional, string, max chars=150
Address line 3.
billing_address[city]
optional, string, max chars=50
The name of the city.
billing_address[state_code]
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
billing_address[state]
optional, string, max chars=50
The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.
billing_address[zip]
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
billing_address[country]
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

.
billing_address[validation_status]
optional, enumerated string, default=not_validated
The address verification status.
Possible values are
not_validatedAddress is not yet validated.validAddress was validated successfully.partially_validThe address is valid for taxability but has not been validated for shipping.invalidAddress is invalid.
+
shipping_address
Parameters for shipping_address
pass parameters as shipping_address[<param name>]
shipping_address[first_name]
optional, string, max chars=150
The first name of the contact.
shipping_address[last_name]
optional, string, max chars=150
The last name of the contact.
shipping_address[email]
optional, string, max chars=70
The email address.
shipping_address[company]
optional, string, max chars=250
The company name.
shipping_address[phone]
optional, string, max chars=50
The phone number.
shipping_address[line1]
optional, string, max chars=150
Address line 1.
shipping_address[line2]
optional, string, max chars=150
Address line 2.
shipping_address[line3]
optional, string, max chars=150
Address line 3.
shipping_address[city]
optional, string, max chars=50
The name of the city.
shipping_address[state_code]
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
shipping_address[state]
optional, string, max chars=50
The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.
shipping_address[zip]
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
shipping_address[country]
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

.
shipping_address[validation_status]
optional, enumerated string, default=not_validated
The address verification status.
Possible values are
not_validatedAddress is not yet validated.validAddress was validated successfully.partially_validThe address is valid for taxability but has not been validated for shipping.invalidAddress is invalid.
+
contract_term
Parameters for contract_term
pass parameters as contract_term[<param name>]
contract_term[action_at_term_end]
optional, enumerated string, default=cancel
Action to be taken when the contract term completes.
Possible values are
renew
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    evergreenContract term completes and the subscription renews.cancelContract term completes and subscription is canceled.
    contract_term[cancellation_cutoff_period]
    optional, integer, default=0
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    pass parameters as addons[<param name>][<idx:0..n>]
    addons[id][0..n]
    optional, string, max chars=100
    Identifier of the addon. Multiple addons can be passed.
    addons[quantity][0..n]
    optional, integer, default=1, min=1
    Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
    addons[quantity_in_decimal][0..n]
    optional, string, max chars=33
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when multi-decimal pricing is enabled.
    addons[unit_price][0..n]
    optional, in cents, min=0

    The price or per-unit-price of the addon. The value depends on the type of currency.

    Note:

    For recurring addons, this is the final price or per-unit price for each billing period of the subscription, regardless of the addon period. For example, consider the following details:

    • The unit_price provided is $10
    • The addon billing period is 1 month.
    • The plan billing period is 3 months.
    • The addon is only billed for $10 on each subscription renewal.
    .
    addons[unit_price_in_decimal][0..n]
    optional, string, max chars=33
    When price overriding is enabled for the site, the price or per-unit price of the addon can be set here. The value set for the addon is used by default. However, the price provided here is considered as the price of the addon for an entire billing cycle of the subscription regardless of the value of the addon period. Provide the value as a decimal string in major units of the currency. Can be provided only when multi-decimal pricing is enabled.
    addons[billing_cycles][0..n]
    optional, integer, min=1
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
    +
    event_based_addons
    Parameters for event_based_addons. Multiple event_based_addons can be passed by specifying unique indices.
    pass parameters as event_based_addons[<param name>][<idx:0..n>]
    event_based_addons[id][0..n]
    optional, string, max chars=100
    A unique 'id' used to identify the addon.
    event_based_addons[quantity][0..n]
    optional, integer, min=0
    Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
    event_based_addons[unit_price][0..n]
    optional, in cents, min=0
    Amount that will override the Addon's default price. The unit depends on the type of currency.
    event_based_addons[quantity_in_decimal][0..n]
    optional, string, max chars=33
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when multi-decimal pricing is enabled.
    event_based_addons[unit_price_in_decimal][0..n]
    optional, string, max chars=33
    When price overriding is enabled for the site, the price or per-unit price of the addon can be set here. The value set for the addon is used by default. Provide the value as a decimal string in major units of the currency. Can be provided only when multi-decimal pricing is enabled.
    event_based_addons[service_period_in_days][0..n]
    optional, integer, min=1, max=730
    Defines service period of the addon in days from the day of charge.
    event_based_addons[on_event][0..n]
    optional, enumerated string
    Event on which this addon will be charged.
    Possible values are
    subscription_creationAddon will be charged on subscription creation.subscription_trial_startAddon will be charged when the trial period starts.plan_activationAddon will be charged on plan activation.subscription_activationAddon will be charged on subscription activation.contract_terminationAddon will be charged on contract termination.
    event_based_addons[charge_once][0..n]
    optional, boolean, default=true
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
    event_based_addons[charge_on][0..n]
    optional, enumerated string
    Indicates when the non-recurring addon will be charged.
    Possible values are
    immediatelyCharges for the addon will be applied immediately.on_eventCharge for the addon will be applied on the occurrence of a specified event.
    always returned
    Resource object representing hosted_page.

    Create a Chargebee hosted page to accept payment from a customer and checkout non-recurring addons and one-time charges.

    The following steps describe how best to use this API:

    1. Call this endpoint, providing non-recurring addons, one-time charges, coupons and a host of other details such as billing and shipping addresses of the customer, to be prefilled on the checkout page.
    2. Send the customer to the Checkout url received in the response.
    3. Once they complete checkout, the non-recurring addons and one-time charges are automatically invoiced against the respective customer record in Chargebee, and they are redirected to the redirect_url with the id and state attributes passed as query string parameters.
    4. Retrieve the hosted page at this stage to get the invoice details.
    Sample Request
    # Creates a checkout with non-recurring addon
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_one_time \
         -u {site_api_key}:\
         -d customer[id]="__test__3Nl7Oe7SJWjx905b" \
         -d addons[id][0]="non_recurring_addon" \
         -d addons[unit_price][0]=2000 \
         -d addons[quantity][0]=2 \
         -d billing_address[first_name]="John" \
         -d billing_address[last_name]="Doe" \
         -d billing_address[line1]="PO Box 9999" \
         -d billing_address[city]="Walnut" \
         -d billing_address[state]="California" \
         -d billing_address[zip]="91789" \
         -d billing_address[country]="US" \
         -d shipping_address[first_name]="John" \
         -d shipping_address[last_name]="Mathew" \
         -d shipping_address[city]="Walnut" \
         -d shipping_address[state]="California" \
         -d shipping_address[zip]="91789" \
         -d shipping_address[country]="US"
    copy

    Sample Response [ JSON ]

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/checkout_one_time
    currency_code
    required if Multicurrency is enabled, string, max chars=3
    The currency code (ISO 4217 format) of the invoice amount.
    invoice_note
    optional, string, max chars=2000
    A note for this particular invoice. This, and all other notes for the invoice are displayed on the PDF invoice sent to the customer.
    coupon_ids[0..n]
    optional, list of string
    Identifier of the coupon as a List. Coupon Codes can also be passed.
    redirect_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL. Although the customer will be redirected to the redirect_url after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as subscription_created or invoice_generated to verify a successful checkout.

    Note :
    • Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=succeeded
    • This parameter is not applicable for iframe messaging.
    cancel_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon canceling checkout. The hosted page id and state will be passed as parameters to this URL.

    Note :
    • Cancel URL configured in Settings > Hosted Pages Settings would be overriden by this cancel URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=cancelled
    • This parameter is not applicable for iframe messaging and in-app checkout.
    pass_thru_content
    optional, string, max chars=2048
    You can pass through any content specific to the hosted page request and get it back after user had submitted the hosted page.
    embed
    optional, boolean, default=true
    If true then hosted page formatted to be shown in iframe. If false, it is formatted to be shown as a separate page.

    Note : For in-app checkout, default is false.
    iframe_messaging
    optional, boolean, default=false
    If true then iframe will communicate with the parent window. Applicable only for embedded(iframe) hosted pages. If you're using iframe_messaging you need to implement onSuccess & onCancel callbacks.

    Note : This parameter is not applicable for in-app checkout.
    +
    customer
    Parameters for customer
    pass parameters as customer[<param name>]
    customer[id]
    optional, string, max chars=50
    The unique ID of the customer for which this hosted_page should be created. When not provided, a new customer is created with the ID set to the value provided for subscription[id]. If subscription[id] is unavailable, then the customer ID is autogenerated.
    customer[email]
    optional, string, max chars=70
    Email of the customer. Configured email notifications will be sent to this email.
    customer[first_name]
    optional, string, max chars=150
    First name of the customer. If not provided it will be got from contact information entered in the hosted page .
    customer[last_name]
    optional, string, max chars=150
    Last name of the customer. If not provided it will be got from contact information entered in the hosted page .
    customer[company]
    optional, string, max chars=250
    Company name of the customer.
    customer[taxability]
    optional, enumerated string, default=taxable
    Specifies if the customer is liable for tax.
    Possible values are
    taxableComputes tax for the customer based on the site configuration. In some cases, depending on the region, shipping_address is needed. If not provided, then billing_address is used to compute tax. If that’s not available either, the tax is taken as zero.exempt
    • Customer is exempted from tax. When using Chargebee’s native Taxes feature or when using the TaxJar integration, no other action is needed.
    • However, when using our Avalara integration, optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
    .
    customer[locale]
    optional, string, max chars=50
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
    customer[phone]
    optional, string, max chars=50
    Phone number of the customer.
    customer[vat_number]
    optional, string, max chars=20
    The VAT/tax registration number for the customer. For customers with billing_address country as XI (which is United Kingdom - Northern Ireland), the first two characters of the full VAT number can be overridden by setting vat_number_prefix.
    customer[vat_number_prefix]
    optional, string, max chars=10
    An overridden value for the first two characters of the full VAT number. Only applicable specifically for customers with billing_address country as XI (which is United Kingdom - Northern Ireland).

    When you have enabled EU VAT in 2021 or have manually enabled the Brexit configuration, you have the option of setting billing_address country as XI. That’s the code for United Kingdom - Northern Ireland. The first two characters of the VAT number in such a case is XI by default. However, if the VAT number was registered in UK, the value should be GB. Set vat_number_prefix to GB for such cases.
    customer[consolidated_invoicing]
    optional, boolean

    Indicates whether invoices raised on the same day for the customer are consolidated. When provided, this overrides the default configuration at the site-level. This parameter can be provided only when Consolidated Invoicing is enabled.

    Note:

    Any invoices raised when a subscription activates from in_trial or future status, are not consolidated by default. Contact Support to enable consolidation for such invoices.

    .
    +
    invoice
    Parameters for invoice
    pass parameters as invoice[<param name>]
    invoice[po_number]
    optional, string, max chars=100
    Purchase Order Number for this invoice.
    +
    card
    Parameters for card
    pass parameters as card[<param name>]
    card[gateway_account_id]
    optional, string, max chars=50
    The gateway account in which this payment source is stored.
    +
    billing_address
    Parameters for billing_address
    pass parameters as billing_address[<param name>]
    billing_address[first_name]
    optional, string, max chars=150
    The first name of the billing contact.
    billing_address[last_name]
    optional, string, max chars=150
    The last name of the billing contact.
    billing_address[email]
    optional, string, max chars=70
    The email address.
    billing_address[company]
    optional, string, max chars=250
    The company name.
    billing_address[phone]
    optional, string, max chars=50
    The phone number.
    billing_address[line1]
    optional, string, max chars=150
    Address line 1.
    billing_address[line2]
    optional, string, max chars=150
    Address line 2.
    billing_address[line3]
    optional, string, max chars=150
    Address line 3.
    billing_address[city]
    optional, string, max chars=50
    The name of the city.
    billing_address[state_code]
    optional, string, max chars=50
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
    billing_address[state]
    optional, string, max chars=50
    The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.
    billing_address[zip]
    optional, string, max chars=20
    Zip or postal code. The number of characters is validated according to the rules specified here.
    billing_address[country]
    optional, string, max chars=50
    The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

    Note: If you enter an invalid country code, the system will return an error.

    Brexit

    If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

    .
    billing_address[validation_status]
    optional, enumerated string, default=not_validated
    The address verification status.
    Possible values are
    not_validatedAddress is not yet validated.validAddress was validated successfully.partially_validThe address is valid for taxability but has not been validated for shipping.invalidAddress is invalid.
    +
    shipping_address
    Parameters for shipping_address
    pass parameters as shipping_address[<param name>]
    shipping_address[first_name]
    optional, string, max chars=150
    The first name of the contact.
    shipping_address[last_name]
    optional, string, max chars=150
    The last name of the contact.
    shipping_address[email]
    optional, string, max chars=70
    The email address.
    shipping_address[company]
    optional, string, max chars=250
    The company name.
    shipping_address[phone]
    optional, string, max chars=50
    The phone number.
    shipping_address[line1]
    optional, string, max chars=150
    Address line 1.
    shipping_address[line2]
    optional, string, max chars=150
    Address line 2.
    shipping_address[line3]
    optional, string, max chars=150
    Address line 3.
    shipping_address[city]
    optional, string, max chars=50
    The name of the city.
    shipping_address[state_code]
    optional, string, max chars=50
    The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
    shipping_address[state]
    optional, string, max chars=50
    The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.
    shipping_address[zip]
    optional, string, max chars=20
    Zip or postal code. The number of characters is validated according to the rules specified here.
    shipping_address[country]
    optional, string, max chars=50
    The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

    Note: If you enter an invalid country code, the system will return an error.

    Brexit

    If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

    .
    shipping_address[validation_status]
    optional, enumerated string, default=not_validated
    The address verification status.
    Possible values are
    not_validatedAddress is not yet validated.validAddress was validated successfully.partially_validThe address is valid for taxability but has not been validated for shipping.invalidAddress is invalid.
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    pass parameters as addons[<param name>][<idx:0..n>]
    addons[id][0..n]
    optional, string, max chars=100
    Identifier of the addon. Multiple addons can be passed.
    addons[quantity][0..n]
    optional, integer, default=1, min=1
    Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
    addons[unit_price][0..n]
    optional, in cents, min=0

    The price or per-unit-price of the addon. The value depends on the type of currency.

    Note:

    For recurring addons, this is the final price or per-unit price for each billing period of the subscription, regardless of the addon period. For example, consider the following details:

    • The unit_price provided is $10
    • The addon billing period is 1 month.
    • The plan billing period is 3 months.
    • The addon is only billed for $10 on each subscription renewal.
    .
    addons[quantity_in_decimal][0..n]
    optional, string, max chars=33
    The decimal representation of the quantity of the non-recurring addon. Provide the value in major units of the currency. Must be provided when the addon is quantity-based. This parameter can only be passed when multi-decimal pricing is enabled.
    addons[unit_price_in_decimal][0..n]
    optional, string, max chars=33
    When price overriding is enabled for the site, the price or per-unit price of the non-recurring addon can be set here. The value set for the addon is used by default. Provide the value as a decimal string in major units of the currency. This parameter can only be passed when multi-decimal pricing is enabled.
    addons[date_from][0..n]
    optional, timestamp(UTC) in seconds
    The time when the service period for the addon starts.
    addons[date_to][0..n]
    optional, timestamp(UTC) in seconds
    The time when the service period for the addon ends.
    +
    charges
    Parameters for charges. Multiple charges can be passed by specifying unique indices.
    pass parameters as charges[<param name>][<idx:0..n>]
    charges[amount][0..n]
    optional, in cents, min=1
    The amount to be charged. The unit depends on the type of currency.
    charges[amount_in_decimal][0..n]
    optional, string, max chars=33
    The decimal representation of the amount for the one-time charge. Provide the value in major units of the currency. Can be provided only when multi-decimal pricing is enabled.
    charges[description][0..n]
    optional, string, max chars=250
    Description for this charge.
    charges[taxable][0..n]
    optional, boolean, default=true
    The amount to be charged is taxable or not.
    charges[tax_profile_id][0..n]
    optional, string, max chars=50
    Tax profile of the charge.
    charges[avalara_tax_code][0..n]
    optional, string, max chars=50
    The Avalara tax codes to which items are mapped to should be provided here. Applicable only if you use Chargebee's AvaTax for Sales integration.
    charges[hsn_code][0..n]
    optional, string, max chars=50
    The HSN code to which the item is mapped for calculating the customer’s tax in India. Applicable only when both of the following conditions are true: .
    charges[taxjar_product_code][0..n]
    optional, string, max chars=50
    The TaxJar product codes to which items are mapped to should be provided here. Applicable only if you use Chargebee's TaxJar integration.
    charges[avalara_sale_type][0..n]
    optional, enumerated string
    Indicates the type of sale carried out. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    Possible values are
    wholesaleTransaction is a sale to another company that will resell your product or service to another consumer.retailTransaction is a sale to an end user.consumedTransaction is for an item that is consumed directly.vendor_useTransaction is for an item that is subject to vendor use tax.
    charges[avalara_transaction_type][0..n]
    optional, integer
    Indicates the type of product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    charges[avalara_service_type][0..n]
    optional, integer
    Indicates the type of service for the product to be taxed. Values for this field can be taken from Avalara. This is applicable only if you use Chargebee’s AvaTax for Communications integration.
    charges[date_from][0..n]
    optional, timestamp(UTC) in seconds
    The time when the service period for the charge starts.
    charges[date_to][0..n]
    optional, timestamp(UTC) in seconds
    The time when the service period for the charge ends.
    always returned
    Resource object representing hosted_page.

    You can checkout an existing subscription(typically in the trial state) by passing in the plan, quantity and addon details(like Update a Subscription)

    When the redirect URL is notified of the result, we would advise you to retrieve the subscription and verify the details.

    Related Tutorial

    Notes

    As mentioned before this behavior is very similar to the update subscription API call. All the web hook events will be fired only after the submission of payment details by the customer and successful checkout of subscription.

    Any errors related to the payment form that is submitted is handled as a response within the form so that the user is kept informed about the reason for failure to take corrective action.

    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_existing \
         -u {site_api_key}:\
         -d subscription[id]="__test__KyVnHhSBWmCOu2tC" \
         -d subscription[plan_id]="sub_plan1"
    copy

    Sample Response [ JSON ]

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/checkout_existing
    replace_addon_list
    optional, boolean
    Should be true if the existing addons should be replaced with the ones that are being passed.
    mandatory_addons_to_remove[0..n]
    optional, list of string
    List of addons IDs that are mandatory to the plan and has to be removed from the subscription.
    invoice_date
    optional, timestamp(UTC) in seconds
    The document date displayed on the invoice PDF. The default value is the current date. Provide this value to backdate the invoice. Backdating an invoice is done for reasons such as booking revenue for a previous date or when the subscription is effective as of a past date. Moreover, if create_pending_invoices is set to true, and if the site is configured to set invoice dates to date of closing, then upon invoice closure, this date is changed to the invoice closing date. taxes and line_item_taxes are computed based on the tax configuration as of invoice_date. When passing this parameter, the following prerequisites must be met:
    • invoice_date must be in the past.
    • invoice_date is not more than one calendar month into the past. For example, if today is 13th January, then you cannot pass a value that is earlier than 13th December.
    • It is not earlier than changes_scheduled_at, reactivate_from, or trial_end.
    • invoice_immediately is true.
    .
    billing_cycles
    optional, integer, min=0
    The number of billing cycles the subscription runs before canceling. If not provided, then the billing cycles set for the plan is used.
    terms_to_charge
    optional, integer, min=1
    The number of subscription billing cycles to invoice in advance. If a new term is started for the subscription due to this API call, then terms_to_charge is inclusive of this new term. See description for the force_term_reset parameter to learn more about when a subscription term is reset.
    reactivate_from
    optional, timestamp(UTC) in seconds
    If the subscription status is cancelled and it is being reactivated via this operation, this is the date/time at which the subscription should be reactivated.
    Note: It is recommended not to pass this parameter along with changed_scheduled_at. reactivate_from can be backdated (set to a value in the past). Use backdating when the subscription has been reactivated already but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
    • Backdating must be enabled for subscription reactivation operations.
    • The current day of the month does not exceed the limit set in Chargebee for backdating subscription change. This limit is the day of the month by which the accounting for the previous month must be closed.
    • The date is on or after the last date/time any of the product catalog items of the subscription were changed.
    • The date is not more than duration X into the past where X is the billing period of the plan. For example, if the period of the plan in the subscription is 2 months and today is 14th April, changes_scheduled_at cannot be earlier than 14th February.
    .
    billing_alignment_mode
    optional, enumerated string
    Override the billing alignment mode chosen for the site for calendar billing. Only applicable when using calendar billing.
    Possible values are
    immediateSubscription period will be aligned with the configured billing date immediately, with credits or charges raised accordingly..delayedSubscription period will be aligned with the configured billing date at the next renewal.
    coupon_ids[0..n]
    optional, list of string
    List of coupons to be applied to this subscription. You can provide coupon ids or coupon codes.
    reactivate
    optional, boolean
    Applicable only for cancelled subscriptions. Once this is passed as true, cancelled subscription will become active; otherwise subscription changes will be made but the subscription state will remain cancelled. If not passed, subscription will be activated only if there is any change in subscription data.
    force_term_reset
    optional, boolean, default=false
    Applicable for 'Active' & 'Non Renewing' states alone. Generally, subscription's term will be reset (i.e current term is ended and a new term starts immediately) when a new plan having different billing frequency is specified in the input. For all the other cases, the subscription's term will remain intact. Now for this later scenario, if you want to force a term reset you can specify this param as 'true'.
    Note: Specifying this value as 'false' has no impact on the default behaviour.
    redirect_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL. Although the customer will be redirected to the redirect_url after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as subscription_created or invoice_generated to verify a successful checkout.

    Note :
    • Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=succeeded
    • This parameter is not applicable for iframe messaging.
    cancel_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon canceling checkout. The hosted page id and state will be passed as parameters to this URL.

    Note :
    • Cancel URL configured in Settings > Hosted Pages Settings would be overriden by this cancel URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=cancelled
    • This parameter is not applicable for iframe messaging and in-app checkout.
    pass_thru_content
    optional, string, max chars=2048
    You can pass through any content specific to the hosted page request and get it back after user had submitted the hosted page.
    embed
    optional, boolean, default=true
    If true then hosted page formatted to be shown in iframe. If false, it is formatted to be shown as a separate page.

    Note : For in-app checkout, default is false.
    iframe_messaging
    optional, boolean, default=false
    If true then iframe will communicate with the parent window. Applicable only for embedded(iframe) hosted pages. If you're using iframe_messaging you need to implement onSuccess & onCancel callbacks.

    Note : This parameter is not applicable for in-app checkout.
    allow_offline_payment_methods
    optional, boolean
    Allow the customer to select an offline payment method during checkout. The choice of payment methods can be configured via the Chargebee UI.
    +
    subscription
    Parameters for subscription
    pass parameters as subscription[<param name>]
    subscription[id]
    required, string, max chars=50
    A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
    subscription[plan_id]
    optional, string, max chars=100
    Identifier of the plan for this subscription.
    subscription[plan_quantity]
    optional, integer, min=1
    Represents the plan quantity for this subscription.
    subscription[plan_unit_price]
    optional, in cents, min=0
    Amount that will override the Plan's default price. The unit depends on the type of currency.
    subscription[setup_fee]
    optional, in cents, min=0
    Amount that will override the default setup fee. The unit depends on the type of currency.
    subscription[plan_quantity_in_decimal]
    optional, string, max chars=33
    The decimal representation of the quantity of the plan purchased. Can be provided for quantity-based plans and only when multi-decimal pricing is enabled.
    subscription[plan_unit_price_in_decimal]
    optional, string, max chars=33
    When price overriding is enabled for the site, the price or per-unit price of the plan can be set here. The value set for the plan is used by default. Provide the value as a decimal string in major units of the currency. Can be provided only when multi-decimal pricing is enabled.
    subscription[start_date]
    optional, timestamp(UTC) in seconds
    The new start date of a future subscription. Applicable only for future subscriptions.
    subscription[trial_end]
    optional, timestamp(UTC) in seconds
    The time at which the trial has ended or will end for the subscription. This is only allowed when the subscription status is future, in_trial, or cancelled. Also, the value must not be earlier than changes_scheduled_at or start_date. Note: This parameter can be backdated (set to a value in the past) only when the subscription is in cancelled or in_trial status. Do this to keep a record of when the trial ended in case it ended at some point in the past. When trial_end is backdated, the subscription immediately goes into active or non_renewing status.
    subscription[auto_collection]
    optional, enumerated string
    Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
    Possible values are
    onWhenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.offAutomatic collection of charges will not be made for this subscription. Use this for offline payments.
    subscription[offline_payment_method]
    optional, enumerated string
    The preferred offline payment method for the subscription.
    Possible values are
    no_preferenceNo Preference.cashCash.checkCheck.bank_transferBank Transfer.ach_creditACH Credit.sepa_creditSEPA Credit.
    subscription[invoice_notes]
    optional, string, max chars=2000
    A customer-facing note added to all invoices associated with this subscription. This note is one among all the notes displayed on the invoice PDF.
    subscription[contract_term_billing_cycle_on_renewal]
    optional, integer, min=1, max=100
    Number of billing cycles the new contract term should run for, on contract renewal. The default value is the same as billing_cycles or a custom value depending on the site configuration.
    +
    customer
    Parameters for customer
    pass parameters as customer[<param name>]
    customer[vat_number]
    optional, string, max chars=20
    The VAT/tax registration number for the customer. For customers with billing_address country as XI (which is United Kingdom - Northern Ireland), the first two characters of the full VAT number can be overridden by setting vat_number_prefix.
    customer[vat_number_prefix]
    optional, string, max chars=10
    An overridden value for the first two characters of the full VAT number. Only applicable specifically for customers with billing_address country as XI (which is United Kingdom - Northern Ireland).

    When you have enabled EU VAT in 2021 or have manually enabled the Brexit configuration, you have the option of setting billing_address country as XI. That’s the code for United Kingdom - Northern Ireland. The first two characters of the VAT number in such a case is XI by default. However, if the VAT number was registered in UK, the value should be GB. Set vat_number_prefix to GB for such cases.
    +
    card
    Parameters for card
    pass parameters as card[<param name>]
    card[gateway_account_id]
    optional, string, max chars=50
    The gateway account in which this payment source is stored.
    +
    contract_term
    Parameters for contract_term
    pass parameters as contract_term[<param name>]
    contract_term[action_at_term_end]
    optional, enumerated string, default=cancel
    Action to be taken when the contract term completes.
    Possible values are
    renew
  • Contract term completes and a new contract term is started for the number of billing cycles specified in contract_billing_cycle_on_renewal.
  • The action_at_term_end for the new contract term is set to renew.
  • .
    evergreenContract term completes and the subscription renews.cancelContract term completes and subscription is canceled.
    contract_term[cancellation_cutoff_period]
    optional, integer, default=0
    The number of days before contract_end, during which the customer is barred from canceling the contract term. The customer is allowed to cancel the contract term via the Self-Serve Portal only before this period. This allows you to have sufficient time for processing the contract term closure.
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    pass parameters as addons[<param name>][<idx:0..n>]
    addons[id][0..n]
    optional, string, max chars=100
    Identifier of the addon. Multiple addons can be passed.
    addons[quantity][0..n]
    optional, integer, min=1
    Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
    addons[unit_price][0..n]
    optional, in cents, min=0

    The price or per-unit-price of the addon. The value depends on the type of currency.

    Note:

    For recurring addons, this is the final price or per-unit price for each billing period of the subscription, regardless of the addon period. For example, consider the following details:

    • The unit_price provided is $10
    • The addon billing period is 1 month.
    • The plan billing period is 3 months.
    • The addon is only billed for $10 on each subscription renewal.
    .
    addons[billing_cycles][0..n]
    optional, integer, min=1
    Number of billing cycles the addon will be charged for. When not set, the addon is attached to the subscription for an indefinite number of billing cycles. While updating a subscription to a plan with a different billing period, set this parameter again or its value will be lost. And so, the addon will be attached indefinitely.
    addons[quantity_in_decimal][0..n]
    optional, string, max chars=33
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when multi-decimal pricing is enabled.
    addons[unit_price_in_decimal][0..n]
    optional, string, max chars=33
    When price overriding is enabled for the site, the price or per-unit price of the addon can be set here. The value set for the addon is used by default. However, the price provided here is considered as the price of the addon for an entire billing cycle of the subscription regardless of the value of the addon period. Provide the value as a decimal string in major units of the currency. Can be provided only when multi-decimal pricing is enabled.
    +
    event_based_addons
    Parameters for event_based_addons. Multiple event_based_addons can be passed by specifying unique indices.
    pass parameters as event_based_addons[<param name>][<idx:0..n>]
    event_based_addons[id][0..n]
    optional, string, max chars=100
    A unique 'id' used to identify the addon.
    event_based_addons[quantity][0..n]
    optional, integer, min=0
    Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
    event_based_addons[unit_price][0..n]
    optional, in cents, min=0
    Amount that will override the Addon's default price. The unit depends on the type of currency.
    event_based_addons[service_period_in_days][0..n]
    optional, integer, min=1, max=730
    Defines service period of the addon in days from the day of charge.
    event_based_addons[charge_on][0..n]
    optional, enumerated string
    Indicates when the non-recurring addon will be charged.
    Possible values are
    immediatelyCharges for the addon will be applied immediately.on_eventCharge for the addon will be applied on the occurrence of a specified event.
    event_based_addons[on_event][0..n]
    optional, enumerated string
    Event on which this addon will be charged.
    Possible values are
    subscription_creationAddon will be charged on subscription creation.subscription_trial_startAddon will be charged when the trial period starts.plan_activationAddon will be charged on plan activation.subscription_activationAddon will be charged on subscription activation.contract_terminationAddon will be charged on contract termination.
    event_based_addons[charge_once][0..n]
    optional, boolean
    If enabled, the addon will be charged only at the first occurrence of the event. Applicable only for non-recurring add-ons.
    event_based_addons[quantity_in_decimal][0..n]
    optional, string, max chars=33
    The decimal representation of the quantity of the addon. Can be provided for quantity-based addons and only when multi-decimal pricing is enabled.
    event_based_addons[unit_price_in_decimal][0..n]
    optional, string, max chars=33
    When price overriding is enabled for the site, the price or per-unit price of the addon can be set here. The value set for the addonis used by default. Provide the value as a decimal string in major units of the currency. Can be provided only when multi-decimal pricing is enabled.
    always returned
    Resource object representing hosted_page.

    Note: If you're using In-App Checkout , use Manage Payment Sources API to request your customers to update their payment method details or change their payment method.

    Using this API, you can request your customers to update their payment method details or change their payment method. This is used in scenarios like customers updating their payment methods before the end of trial or customers switching among payment methods.

    When this API is invoked, it returns a hosted page URL. When the customers are directed to this URL, they will be able to change/update their payment methods.

    Depending on the payment methods (Card, PayPal Express Checkout, Amazon Payments) that you offer your customers, they will find options to switch among the various methods of payment.

    Note:
    • If the card[gateway] parameter is passed, and the customer chooses Card as a payment method, then the card details are stored in the gateway which is passed. However, if the card[gateway] parameter is passed and the customer chooses PayPal Express Checkout/Amazon Payments as a payment method, the gateway passed will be ignored.
    • The option of embedding into an iframe is not supported for PayPal Express Checkout and Amazon Payments as customers are redirected to the respective website pages. Hence if you have PayPal Express Checkout/Amazon Payments configured and pass the parameter embed=true, this will result in an unsuccessful API request. Also, if you have all the three payment methods (Card, Paypal Express Checkout and Amazon Payments) configured and pass the parameter embed=true, the returned hosted page URL will show only Card Payment as a payment method.
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/update_payment_method \
         -u {site_api_key}:\
         -d customer[id]="__test__KyVnHhSBWmKhy2uX" \
         -d card[gateway_account_id]="gw___test__KyVnGlSBWmAIk2Ph"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/update_payment_method \
         -u {site_api_key}:\
         -d customer[id]="__test__KyVnHhSBWmKhy2uX" \
         -d card[gateway_account_id]="gw___test__KyVnGlSBWmAIk2Ph"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517506020, "embed": true, "expires_at": 1517592420, "id": "__test__Rvi8fL7SS0CURBeH2k0CgkPLH6MyU2Sy", "object": "hosted_page", "resource_version": 1517506020000, "state": "created", "type": "update_payment_method", "updated_at": 1517506020, "url": "https://yourapp.chargebee.com/pages/v2/__test__Rvi8fL7SS0CURBeH2k0CgkPLH6MyU2Sy/update_payment_method" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/update_payment_method
    redirect_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL. Although the customer will be redirected to the redirect_url after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as subscription_created or invoice_generated to verify a successful checkout.

    Note :
    • Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=succeeded
    • This parameter is not applicable for iframe messaging.
    cancel_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon canceling checkout. The hosted page id and state will be passed as parameters to this URL.

    Note :
    • Cancel URL configured in Settings > Hosted Pages Settings would be overriden by this cancel URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=cancelled
    • This parameter is not applicable for iframe messaging and in-app checkout.
    pass_thru_content
    optional, string, max chars=2048
    You can pass through any content specific to the hosted page request and get it back after user had submitted the hosted page.
    embed
    optional, boolean, default=true
    If true then hosted page formatted to be shown in iframe. If false, it is formatted to be shown as a separate page.

    Note : For in-app checkout, default is false.
    iframe_messaging
    optional, boolean, default=false
    If true then iframe will communicate with the parent window. Applicable only for embedded(iframe) hosted pages. If you're using iframe_messaging you need to implement onSuccess & onCancel callbacks.

    Note : This parameter is not applicable for in-app checkout.
    +
    customer
    Parameters for customer
    pass parameters as customer[<param name>]
    customer[id]
    required, string, max chars=50
    Identifier of the customer.
    +
    card
    Parameters for card
    pass parameters as card[<param name>]
    card[gateway_account_id]
    optional, string, max chars=50
    The gateway account in which this payment source is stored.
    always returned
    Resource object representing hosted_page.
    This API generates a hosted page URL to add new or update existing payment sources for the customer.
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/manage_payment_sources \
         -u {site_api_key}:\
         -d customer[id]="__test__KyVnHhSBWmJIX2uE" \
         -d card[gateway_account_id]="gw___test__KyVnGlSBWmAIk2Ph"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/manage_payment_sources \
         -u {site_api_key}:\
         -d customer[id]="__test__KyVnHhSBWmJIX2uE" \
         -d card[gateway_account_id]="gw___test__KyVnGlSBWmAIk2Ph"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517506015, "embed": false, "expires_at": 1517592415, "id": "__test__LycuLPCkhW3axOiXjHWkOOVl3ZE3yLLni", "object": "hosted_page", "resource_version": 1517506015000, "state": "created", "type": "manage_payment_sources", "updated_at": 1517506015, "url": "https://yourapp.chargebee.com/pages/v3/__test__LycuLPCkhW3axOiXjHWkOOVl3ZE3yLLni/" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/manage_payment_sources
    redirect_url
    optional, string, max chars=250
    URL to redirect after payment method is added.
    +
    customer
    Parameters for customer
    pass parameters as customer[<param name>]
    customer[id]
    required, string, max chars=50
    Identifier of the customer.
    +
    card
    Parameters for card
    pass parameters as card[<param name>]
    card[gateway_account_id]
    optional, string, max chars=50
    The gateway account in which this payment source is stored.
    always returned
    Resource object representing hosted_page.
    This API generates a hosted page URL to collect due payments for the customer.
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/collect_now \
         -u {site_api_key}:\
         -d customer[id]="__test__KyVnGlSBWmHH82Pw" \
         -d card[gateway_account_id]="gw___test__KyVnGlSBWmAIk2Ph"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/collect_now \
         -u {site_api_key}:\
         -d customer[id]="__test__KyVnGlSBWmHH82Pw" \
         -d card[gateway_account_id]="gw___test__KyVnGlSBWmAIk2Ph"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517506010, "embed": true, "expires_at": 1517592410, "id": "__test__4cq9mwW1cuoD085nSBLh0KUMKdphVO5cC", "object": "hosted_page", "resource_version": 1517506010000, "state": "created", "type": "collect_now", "updated_at": 1517506010, "url": "https://yourapp.chargebee.com/pages/v3/__test__4cq9mwW1cuoD085nSBLh0KUMKdphVO5cC/collect_now" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/collect_now
    redirect_url
    optional, string, max chars=250
    URL to redirect after invoices are paid.
    currency_code
    optional, string, max chars=3
    The currency code (ISO 4217 format) of the specified credit amount.
    +
    customer
    Parameters for customer
    pass parameters as customer[<param name>]
    customer[id]
    required, string, max chars=50
    Identifier of the customer.
    +
    card
    Parameters for card
    pass parameters as card[<param name>]
    card[gateway_account_id]
    optional, string, max chars=50
    The gateway account in which this payment source is stored.
    always returned
    Resource object representing hosted_page.
    This API generates a hosted page URL for the customer to accept a quote. If the hosted page URL has expired, a new URL will be generated automatically.

    Notes

    • Hosted page URL to accept a quote cannot be generated for one-time charges.
    • Customers with existing subscriptions can generate a quote for new subscriptions. However, Hosted page URL to accept a quote cannot be generated for new subscriptions in V1 and V2 hosted pages.
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/accept_quote \
         -X POST  \
         -u {site_api_key}:\
         -d quote[id]="1"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/accept_quote \
         -X POST  \
         -u {site_api_key}:\
         -d quote[id]="1"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517505980, "embed": true, "expires_at": 1517596199, "id": "__test__IKNpcdSoRFV0hFeci8SSkUbhZYjle2dKh", "object": "hosted_page", "resource_version": 1517505981000, "state": "created", "type": "checkout_existing", "updated_at": 1517505981, "url": "https://yourapp.chargebee.com/pages/v2/__test__IKNpcdSoRFV0hFeci8SSkUbhZYjle2dKh/checkout" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/accept_quote
    redirect_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL. Although the customer will be redirected to the redirect_url after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as subscription_created or invoice_generated to verify a successful checkout.

    Note :
    • Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=succeeded
    • This parameter is not applicable for iframe messaging.
    +
    quote
    Parameters for quote
    pass parameters as quote[<param name>]
    quote[id]
    required, string, max chars=50
    The quote number. Acts as a identifier for quote and typically generated sequentially.
    always returned
    Resource object representing hosted_page.
    This API generates a hosted page URL to extend the billing cycle of a subscription.
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/extend_subscription \
         -u {site_api_key}:\
         -d subscription[id]="__test__KyVnHhSBWmIgw2u6" \
         -d billing_cycle=2 \
         -d expiry=14
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/extend_subscription \
         -u {site_api_key}:\
         -d subscription[id]="__test__KyVnHhSBWmIgw2u6" \
         -d billing_cycle=2 \
         -d expiry=14

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517506012, "embed": true, "expires_at": 1518715612, "id": "__test__Bct8ySC6A1eV2GdMcdUl7dzovgyKhAz4M", "object": "hosted_page", "resource_version": 1517506012000, "state": "created", "type": "extend_subscription", "updated_at": 1517506012, "url": "https://yourapp.chargebee.com/pages/v3/__test__Bct8ySC6A1eV2GdMcdUl7dzovgyKhAz4M/" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/extend_subscription
    expiry
    optional, integer, min=1, max=500
    Expiry (in days) for the link generated. No expiry will be set if this is not specified.
    billing_cycle
    optional, integer, min=1
    Number of billing cycles to extend. If not specified, plan's billing cycle will be used.
    +
    subscription
    Parameters for subscription
    pass parameters as subscription[<param name>]
    subscription[id]
    required, string, max chars=50
    A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
    always returned
    Resource object representing hosted_page.

    Creates a hosted page for a customer (called the gifter) to gift a subscription to another customer (called the receiver).

    Gifter customer resource lookup and creation

    When gifter[customer_id] is provided, it is looked up in Chargebee when the gifter completes the hosted page checkout. If not found, a new customer resource is created with this ID.

    Gift receiver customer resource lookup and creation

    Once the gifter checks out using the hosted page returned by this endpoint, Chargebee checks if a customer resource with the receiver’s email address exists. The first such customer record is considered the receiver’s customer resource. A new customer resource is created for the receiver if none are found.

    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_gift \
         -u {site_api_key}:\
         -d subscription[plan_id]="GiftPlan$100"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/checkout_gift \
         -u {site_api_key}:\
         -d subscription[plan_id]="GiftPlan$100"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517505995, "embed": false, "expires_at": 1517509595, "id": "__gift___test__wZIbEJ1opH9ybmh2VbLVpejsaan5wM8U", "object": "hosted_page", "resource_version": 1517505995000, "state": "created", "type": "checkout_gift", "updated_at": 1517505995, "url": "https://yourapp.chargebee.com/pages/v3/__gift___test__wZIbEJ1opH9ybmh2VbLVpejsaan5wM8U/" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/checkout_gift
    redirect_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL. Although the customer will be redirected to the redirect_url after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as subscription_created or invoice_generated to verify a successful checkout.

    Note :
    • Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=succeeded
    • This parameter is not applicable for iframe messaging.
    +
    gifter
    Parameters for gifter
    pass parameters as gifter[<param name>]
    gifter[customer_id]
    optional, string, max chars=50
    Gifter customer id.
    gifter[locale]
    optional, string, max chars=50
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
    +
    subscription
    Parameters for subscription
    pass parameters as subscription[<param name>]
    subscription[plan_id]
    required, string, max chars=100
    Identifier of the plan for this subscription.
    subscription[plan_quantity]
    optional, integer, default=1, min=1
    Plan quantity for this subscription.
    subscription[plan_quantity_in_decimal]
    optional, string, max chars=33
    Plan Quantity for this subscription in Multi Decimal.
    subscription[coupon]
    optional, string, max chars=100
    Coupon for this subscription.
    +
    addons
    Parameters for addons. Multiple addons can be passed by specifying unique indices.
    pass parameters as addons[<param name>][<idx:0..n>]
    addons[id][0..n]
    optional, string, max chars=100
    Identifier of the addon. Multiple addons can be passed.
    addons[quantity][0..n]
    optional, integer, default=1, min=1
    Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
    addons[quantity_in_decimal][0..n]
    optional, string, max chars=33
    The decimal representation of the quantity of the addon. Returned for quantity-based plans when multi-decimal pricing is enabled.
    always returned
    Resource object representing hosted_page.
    This API generates a hosted page URL to claim a gifted subscription.
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/claim_gift \
         -u {site_api_key}:\
         -d gift[id]="__test__KyVnHhSBWmGdM2tv__test__21cdZvclBhOULyCT1SBUPDKjoXsuc3wdj"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/claim_gift \
         -u {site_api_key}:\
         -d gift[id]="__test__KyVnHhSBWmGdM2tv__test__21cdZvclBhOULyCT1SBUPDKjoXsuc3wdj"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517678804, "embed": false, "expires_at": 1517682404, "id": "__test__yRVH4Pr8siRXJEPsjeJXlcd8Aq1fDqVzd", "object": "hosted_page", "resource_version": 1517678804000, "state": "created", "type": "claim_gift", "updated_at": 1517678804, "url": "https://yourapp.chargebee.com/pages/v3/__test__yRVH4Pr8siRXJEPsjeJXlcd8Aq1fDqVzd/claim_gift" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/claim_gift
    redirect_url
    optional, string, max chars=250
    The customers will be redirected to this URL upon successful checkout. The hosted page id and state will be passed as parameters to this URL. Although the customer will be redirected to the redirect_url after successful checkout, we do not recommend relying on it for completing critical post-checkout actions. This is because redirection may not happen due to unforeseen reasons. Chargebee recommends listening to appropriate webhooks such as subscription_created or invoice_generated to verify a successful checkout.

    Note :
    • Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
      Eg : http://yoursite.com?id=<hosted_page_id>&state=succeeded
    • This parameter is not applicable for iframe messaging.
    +
    gift
    Parameters for gift
    pass parameters as gift[<param name>]
    gift[id]
    required, string, max chars=150
    Uniquely identifies a gift.
    +
    customer
    Parameters for customer
    pass parameters as customer[<param name>]
    customer[locale]
    optional, string, max chars=50
    Determines which region-specific language Chargebee uses to communicate with the customer. In the absence of the locale attribute, Chargebee will use your site's default language for customer communication.
    always returned
    Resource object representing hosted_page.

    This is applicable only for Direct Debit via SEPA, Bacs, Bg Autogiro, BECS (for both Australia and New Zealand) and PAD. For Direct Debit, the customer needs to accept an agreement that allows the merchant to debit their bank account. This agreement PDF allows you to easily display scheme-rules compliant Direct Debit mandates to your customers.

    This API retrieves the redirect link to the corresponding agreement for customers. The agreement PDF can be your “Thank You” page or sent by email to customers. Communicating this PDF to your customers is mandatory.

    Customer locale is used to generate the PDF in the required language. If a customer language is not supported, the PDF is generated in English. Checkout the list of languages supported by GoCardless.

    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/retrieve_agreement_pdf \
         -u {site_api_key}:\
         -d payment_source_id="pm___test__KyVnHhSBWmKRg2uT"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/retrieve_agreement_pdf \
         -u {site_api_key}:\
         -d payment_source_id="pm___test__KyVnHhSBWmKRg2uT"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517506018, "embed": false, "expires_at": 1520098018, "id": "__test__AUCK2LNxny5cXiA1JcdBQE9283e5McdvCC", "object": "hosted_page", "resource_version": 1517506018000, "state": "created", "type": "agreement_pfd", "updated_at": 1517506018, "url": "https://yourapp.chargebee.com/action_pages/__test__AUCK2LNxny5cXiA1JcdBQE9283e5McdvCC/agreement_pdf" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/retrieve_agreement_pdf
    payment_source_id
    required, string, max chars=40
    Payment source to be used for this payment.
    always returned
    Resource object representing hosted_page.
    When a hosted page is successfully completed by the user and processed by Chargebee, its state is automatically changed to succeeded. Acknowledging a hosted page confirms that you have moved the customer details from Chargebee into your system and are ready to fulfill it. This API is used to acknowledge the hosted page in succeeded state and change its state to acknowledged.

    Note: The hosted page status must be succeeded for this API call to be allowed.
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/__test__p541yXSwQO7jD2oRNFlBSvqU2s0oiWY0/acknowledge \
         -X POST  \
         -u {site_api_key}:
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/__test__p541yXSwQO7jD2oRNFlBSvqU2s0oiWY0/acknowledge \
         -X POST  \
         -u {site_api_key}:

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "content": { "card": { "card_type": "american_express", "customer_id": "__test__5SK0bLNFRFuFd5CuE", "expiry_month": 10, "expiry_year": 2020, "first_name": "Hello", "funding_type": "not_known", "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnTyRFuFcGgDu", "iin": "378282", "ip_address": "127.0.0.1", "last4": "0005", "last_name": "World", "masked_number": "***********0005", "object": "card", "payment_source_id": "pm___test__5SK0bLNFRFuFfTGuV", "status": "valid" }, "credit_notes": [ { "allocations": [ { "allocated_amount": 895, "allocated_at": 1517507562, "invoice_date": 1517507562, "invoice_id": "__demo_inv__2", "invoice_status": "paid" }, {..} ], "amount_allocated": 895, "amount_available": 0, "amount_refunded": 0, "base_currency_code": "USD", "currency_code": "USD", "customer_id": "__test__5SK0bLNFRFuFd5CuE", "date": 1517507562, "deleted": false, "exchange_rate": 1, "id": "__demo_cn__1", "line_item_discounts": [], "line_item_taxes": [], "line_items": [ { "amount": 895, "date_from": 1517507562, "date_to": 1519926753, "description": "No Trial - Prorated Credits for 01-Feb-2018 - 01-Mar-2018", "discount_amount": 0, "entity_id": "no_trial", "entity_type": "plan", "id": "li___test__5SK0bLNFRFuFfTvuY", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__5SK0bLNFRFuFd5CuE", "tax_amount": 0, "tax_exempt_reason": "tax_not_configured", "unit_amount": 895 }, {..} ], "linked_refunds": [], "object": "credit_note", "price_type": "tax_exclusive", "reason_code": "subscription_change", "reference_invoice_id": "__demo_inv__1", "refunded_at": 1517507562, "resource_version": 1517507562000, "round_off_amount": 0, "status": "refunded", "sub_total": 895, "subscription_id": "__test__5SK0bLNFRFuFd5CuE", "taxes": [], "total": 895, "type": "refundable", "updated_at": 1517507562 }, {..} ], "customer": { "allow_direct_debit": false, "auto_collection": "on", "billing_address": { "city": "Chennai", "country": "IN", "first_name": "Hello", "last_name": "World", "line1": "Wow", "line2": "Cool", "object": "billing_address", "phone": "122242222", "state": "Tamil Nadu", "state_code": "TN", "validation_status": "not_validated", "zip": "600041" }, "card_status": "valid", "created_at": 1517507553, "deleted": false, "email": "john@user.com", "excess_payments": 0, "first_name": "John", "id": "__test__5SK0bLNFRFuFd5CuE", "last_name": "Doe", "net_term_days": 0, "object": "customer", "payment_method": { "gateway": "chargebee", "gateway_account_id": "gw___test__KyVnTyRFuFcGgDu", "object": "payment_method", "reference_id": "tok___test__5SK0bLNFRFuFfTDuU", "status": "valid", "type": "card" }, "pii_cleared": "active", "preferred_currency_code": "USD", "primary_payment_source_id": "pm___test__5SK0bLNFRFuFfTGuV", "promotional_credits": 0, "refundable_credits": 0, "resource_version": 1517507562000, "taxability": "taxable", "unbilled_charges": 0, "updated_at": 1517507562 }, "invoice": { "adjustment_credit_notes": [], "amount_adjusted": 0, "amount_due": 0, "amount_paid": 605, "amount_to_collect": 0, "applied_credits": [ { "applied_amount": 895, "applied_at": 1517507562, "cn_date": 1517507562, "cn_id": "__demo_cn__1", "cn_reason_code": "subscription_change", "cn_status": "refunded" }, {..} ], "base_currency_code": "USD", "billing_address": { "city": "Chennai", "country": "IN", "first_name": "Hello", "last_name": "World", "line1": "Wow", "line2": "Cool", "object": "billing_address", "phone": "122242222", "state": "Tamil Nadu", "state_code": "TN", "validation_status": "not_validated", "zip": "600041" }, "credits_applied": 895, "currency_code": "USD", "customer_id": "__test__5SK0bLNFRFuFd5CuE", "date": 1517507562, "deleted": false, "due_date": 1517507562, "exchange_rate": 1, "first_invoice": false, "has_advance_charges": false, "id": "__demo_inv__2", "is_gifted": false, "issued_credit_notes": [], "line_items": [ { "amount": 1500, "date_from": 1517507562, "date_to": 1519926753, "description": "Plan1 - Prorated Charges", "discount_amount": 0, "entity_id": "plan1", "entity_type": "plan", "id": "li___test__5SK0bLNFRFuFfTpuW", "is_taxed": false, "item_level_discount_amount": 0, "object": "line_item", "pricing_model": "per_unit", "quantity": 1, "subscription_id": "__test__5SK0bLNFRFuFd5CuE", "tax_amount": 0, "tax_exempt_reason": "tax_not_configured", "unit_amount": 1500 }, {..} ], "linked_orders": [], "linked_payments": [ { "applied_amount": 605, "applied_at": 1517507562, "txn_amount": 605, "txn_date": 1517507562, "txn_id": "txn___test__5SK0bLNFRFuFfUeua", "txn_status": "success" }, {..} ], "net_term_days": 0, "object": "invoice", "paid_at": 1517507562, "price_type": "tax_exclusive", "recurring": true, "resource_version": 1517507562000, "round_off_amount": 0, "shipping_address": { "city": "Chennai", "country": "IN", "first_name": "Hello", "last_name": "World", "line1": "Wow", "line2": "Cool", "object": "shipping_address", "phone": "122242222", "state": "Tamil Nadu", "state_code": "TN", "validation_status": "not_validated", "zip": "600041" }, "status": "paid", "sub_total": 1500, "subscription_id": "__test__5SK0bLNFRFuFd5CuE", "tax": 0, "term_finalized": true, "total": 1500, "updated_at": 1517507562, "write_off_amount": 0 }, "subscription": { "activated_at": 1517507553, "billing_period": 1, "billing_period_unit": "month", "created_at": 1517507553, "currency_code": "USD", "current_term_end": 1519926753, "current_term_start": 1517507553, "customer_id": "__test__5SK0bLNFRFuFd5CuE", "deleted": false, "due_invoices_count": 0, "has_scheduled_changes": false, "id": "__test__5SK0bLNFRFuFd5CuE", "mrr": 0, "next_billing_at": 1519926753, "object": "subscription", "plan_amount": 1500, "plan_free_quantity": 0, "plan_id": "plan1", "plan_quantity": 1, "plan_unit_price": 1500, "resource_version": 1517507562000, "shipping_address": { "city": "Chennai", "country": "IN", "first_name": "Hello", "last_name": "World", "line1": "Wow", "line2": "Cool", "object": "shipping_address", "phone": "122242222", "state": "Tamil Nadu", "state_code": "TN", "validation_status": "not_validated", "zip": "600041" }, "started_at": 1517507553, "status": "active", "updated_at": 1517507562 } }, "created_at": 1517507553, "embed": false, "expires_at": 1517511153, "id": "__test__p541yXSwQO7jD2oRNFlBSvqU2s0oiWY0", "object": "hosted_page", "resource_version": 1517507577000, "state": "acknowledged", "type": "checkout_existing", "updated_at": 1517507577, "url": "https://yourapp.chargebee.com/pages/v2/__test__p541yXSwQO7jD2oRNFlBSvqU2s0oiWY0/checkout" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/{hosted_page_id}/acknowledge
    always returned
    Resource object representing hosted_page.

    Retrieves a hosted page resource.

    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/__test__Mgd44pMvDRJLhuy3KNs2j6qBRNbuGG9r \
         -u {site_api_key}:
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/__test__Mgd44pMvDRJLhuy3KNs2j6qBRNbuGG9r \
         -u {site_api_key}:

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "created_at": 1517506016, "embed": true, "expires_at": 1517509616, "id": "__test__Mgd44pMvDRJLhuy3KNs2j6qBRNbuGG9r", "object": "hosted_page", "resource_version": 1517506016000, "state": "created", "type": "checkout_existing", "updated_at": 1517506016, "url": "https://yourapp.chargebee.com/pages/v2/__test__Mgd44pMvDRJLhuy3KNs2j6qBRNbuGG9r/checkout" }}

    URL Format GET

    https://{site}.chargebee.com/api/v2/hosted_pages/{hosted_page_id}
    always returned
    Resource object representing hosted_page.

    This API retrieves the list of hosted page resources.

    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages \
         -G  \
         -u {site_api_key}:\
         --data-urlencode limit=2
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages \
         -G  \
         -u {site_api_key}:\
         --data-urlencode limit=2

    Sample Response [ JSON ]

    Show more...
    { "list": [ {"hosted_page": { "created_at": 1517678804, "embed": false, "expires_at": 1517682404, "id": "__test__yRVH4Pr8siRXJEPsjeJXlcd8Aq1fDqVzd", "object": "hosted_page", "resource_version": 1517678804000, "state": "created", "type": "claim_gift", "updated_at": 1517678804, "url": "https://yourapp.chargebee.com/pages/v3/__test__yRVH4Pr8siRXJEPsjeJXlcd8Aq1fDqVzd/claim_gift" }}, {..} ], "next_offset": "[\"1517506012000\",\"186000000018\"]" }

    URL Format GET

    https://{site}.chargebee.com/api/v2/hosted_pages
    limit
    optional, integer, default=10, min=1, max=100
    The number of resources to be returned.
    offset
    optional, string, max chars=1000
    Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set offset to the value of next_offset obtained in the previous iteration of the API call.
    Filter Params
    For operator usages, see the Pagination and Filtering section.
    id[<operator>]
    optional, string filter
    Unique identifier generated for each hosted page requested.
    Supported operators : is, is_not, starts_with, in, not_in

    Example id[is] = "Edi69nxpu6BeGBd9Fjcd0tqCSwb0sRcuKa"
    type[<operator>]
    optional, enumerated string filter
    Type of the requested hosted page. Possible values are : checkout_new, checkout_existing, update_payment_method, manage_payment_sources, collect_now, extend_subscription, checkout_gift, claim_gift, checkout_one_time, pre_cancel.
    Supported operators : is, is_not, in, not_in

    Example type[is_not] = "checkout_new"
    state[<operator>]
    optional, enumerated string filter
    Indicating the current state of the hosted page resource. Possible values are : created, requested, succeeded, cancelled, acknowledged.
    Supported operators : is, is_not, in, not_in

    Example state[is] = "succeeded"
    updated_at[<operator>]
    optional, timestamp(UTC) in seconds filter
    Timestamp indicating when this hosted page was last updated.
    Supported operators : after, before, on, between

    Example updated_at[before] = "1490784813"
    always returned
    Resource object representing hosted_page.
    next_offset
    optional, string, max chars=1000
    This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.
    Creates a hosted_page resource of type pre_cancel. Route canceling users to this page to provide them a retention experience and start saving revenue.

    The hosted page is created in accordance with the retention experience configured in the Brightback app, along with the data provided as input to this endpoint. Call the endpoint before your customer clicks the Cancel button, and when they do, route them to the url in the endpoint response.

    .
    Sample Request
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/pre_cancel \
         -X POST  \
         -u {site_api_key}:\
         -d subscription[id]="__test__KyVnHhSBWmCoF2tJ" \
         -d pass_thru_content="{custom :  {discount_percent: 10}}"
    copy
    curl  https://{site}.chargebee.com/api/v2/hosted_pages/pre_cancel \
         -X POST  \
         -u {site_api_key}:\
         -d subscription[id]="__test__KyVnHhSBWmCoF2tJ" \
         -d pass_thru_content="{custom :  {discount_percent: 10}}"

    Sample Response [ JSON ]

    Show more...
    {"hosted_page": { "id": "__dev__uxMMdSCbO8zweGryJDU37zfbdGxC3Gn9", "type": "pre_cancel", "url": "https://app.brightback.com/session/mVS0ecj6tswr3Ss", "state": "created", "pass_thru_content": "{custom : {discount_percentage: 10}}", "embed": false, "created_at": 1653382696, "expires_at": 1653386296, "object": "hosted_page" }}

    URL Format POST

    https://{site}.chargebee.com/api/v2/hosted_pages/pre_cancel
    pass_thru_content
    optional, string, max chars=2048

    Additional data to be passed to Brightback. Only the value of pass_thru_content.custom is sent to Brightback. It is sent as the value of the custom property. The fields provided in pass_thru_content.custom must be preconfigured in Brightback.

    Although only pass_thru_content.custom is sent to Brightback, all of pass_thru_content is stored by Chargebee and is retrievable as an attribute of the hosted_page.

    .
    cancel_url
    optional, string, max chars=250
    The customer is sent to this URL if they finally decide to cancel the subscription, despite the attempt to retain them.
    redirect_url
    optional, string, max chars=250
    The customer is sent to this URL upon successful retention. In other words, this is the page to which the customer is sent when they decide not to cancel the subscription.
    +
    subscription
    Parameters for subscription
    pass parameters as subscription[<param name>]
    subscription[id]
    required, string, max chars=50
    The unique ID of the subscription which the customer wants to cancel.
    always returned
    Resource object representing hosted_page.