ChargebeeAPI
Join the Chargebee Developers Discord — Connect, ask questions, and build faster.Join

Checkout one-time payments

Idempotency Supported

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

URL Format

POST https://[site].chargebee.com/api/v2/hosted_pages/checkout_one_time

Input Parameters

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
optional, string, max chars=100

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.

Note :

  • 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 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 as subscription_created or invoice_generated to 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.
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

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.

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>]
invoice
Parameters for invoice
pass parameters as invoice[<param name>]
card
Parameters for card
pass parameters as card[<param name>]
billing_address
Parameters for billing_address
pass parameters as billing_address[<param name>]
shipping_address
Parameters for shipping_address
pass parameters as shipping_address[<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>]
charges[0..n]
Parameters for charges. Multiple charges can be passed by specifying unique indices.
pass parameters as charges[<param name>][<idx:0..n>]

Returns

hosted_pageHosted page object
Resource object representing hosted_page