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:
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.
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 Existing Subscription:
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.
{
"created_at": 1517506797,
"embed": true,
"expires_at": 1517510397,
"id": "__test__KfW0lW3V4e8fhHtugBdLaUcuJL60OycPv",
"object": "hosted_page",
"state": "created",
"type": "checkout_new",
"url": "https://yourapp.chargebee.com/pages/v2/__test__KfW0lW3V4e8fhHtugBdLaUcuJL60OycPv/checkout"
}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.
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.
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.
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.
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=&state=succeeded
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
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.
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.
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.
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.
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=&state=succeeded
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
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.
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.
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:
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=&state=succeeded
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
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.
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.
This operation is only supported by the 2Checkout payment gateway.
This operation is only supported by the 2Checkout payment gateway.
This API is used to retrieve a hosted page. You will get the URL from the API response.