ChargebeeAPI

Checkout existing subscription

Idempotency Supported

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.

Sample Request

URL Format

POST https://[site].chargebee.com/api/v1/hosted_pages/checkout_existing

Input Parameters

replace_addon_list
optional, boolean, default=false

Should be true if the existing addons should be replaced with the ones that are being passed.

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.

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=&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=&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.

subscription[0..n]
Parameters for subscription
pass parameters as subscription[<param name>]
card[0..n]
Parameters for card
pass parameters as card[<param name>]
addons[0..n]
Parameters for addons. Multiple addons can be passed by specifying unique indices.
pass parameters as addons[<param name>][<idx:0..n>]

Returns

hosted_pageHosted page object
Resource object representing hosted_page