Create a Chargebee hosted page to accept payment details from a customer and checkout charge-items and one-time charges.
The following steps describe how best to use this API:
- Call this endpoint, providing item prices, charges, coupons and a host of other details such as billing and shipping addresses of the customer, to be prefilled on the checkout page. You may also provide
pass_thru_contentcontaining information and IDs from your systems that must be associated with the checkout page. - Send the customer to the Checkout
urlreceived in the response. - Once they complete checkout, the set of charge-items and one-time charges are automatically invoiced against the respective
customerrecord in Chargebee, and they are redirected to theredirect_urlwith theidandstateattributes passed as query string parameters. - Retrieve the hosted page at this stage to get the invoice details.
Customer resource lookup and creation
When customer[id] is provided for this operation, it is looked up by Chargebee, and if found, the hosted_page is created for it. If not found, a new customer resource is created with an autogenarated ID, and the hosted_page is created.
Multiple business entities
If multiple business entities are created for the site, the customer resource lookup and creation happen within the context of the business entity specified in this API call. If no business entity is specified, the customer resource lookup is performed within the site context , and if not found, the resource is created for the default business entity of the site.
Sample Request
Sample Result[JSON]
URL Format
Input Parameters
Sets the context for this operation to the business entity specified. Applicable only when multiple business entities have been created for the site. When this parameter is provided, the operation is able to read/write data associated only to the business entity specified. When not provided, the operation can read/write data for the entire site.
Note
An alternative way of passing this parameter is by means of a custom HTTP header.
The unique ID of the brand this hosted page should be linked to. Applicable only when multiple brands have been created for the site. Resources created through the hosted page, such as the customer and the subscription, are linked to the same brand. An alternative way of passing this parameter is by means of the chargebee-brand-id custom HTTP header; when both are provided, they must specify the same brand.
Default behavior
- When not provided, the brand of the customer or subscription referenced in the request is used, or the default brand defined for the site when the request references neither.
Specifies the UI layout for the hosted page. This overrides the layout configured in Chargebee Billing.
Renders the hosted page in an in-app layout.
Renders the hosted page in a full-page layout.
A note for this particular invoice. This, and all other notes for the invoice are displayed on the PDF invoice sent to the customer.
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.
Note :
- Although the customer will be redirected to the
redirect_urlafter 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 such as user closing the tab, or exiting the browser, and so on. If there is any synchronization that you are doing after the redirection, you will have to have a backup. Chargebee recommends listening to appropriate webhooks such assubscription_createdorinvoice_generatedto verify a successful checkout. - Redirect URL configured in Settings > Hosted Pages Settings would be overriden by this redirect URL.
- Eg : http://yoursite.com?id=**&state=succeeded
- This parameter is not applicable for iframe messaging.
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=&state=cancelled
- This parameter is not applicable for iframe messaging and in-app checkout.
This attribute allows you to store custom information with the hosted_page object. You can use it to associate specific data with a hosted page session.
For example, you can store the ID of the marketing campaign that initiated the user session. After a successful checkout, when the customer is redirected, you can retrieve the hosted page ID from the redirect URL's query parameters. Using this ID, you can fetch the hosted page and perform actions related to the success of the marketing campaign.
Returns
Resource object representing hosted_page