Introducing the Better Auth Chargebee plugin: Use it to handle subscriptions, billing, and auth seamlessly.
Chargebeechargebee API

Manage payment sources

Idempotency Supported

This API generates a hosted page URL to add new or update existing payment sources for the customer.

Use one of the following methods to open the hosted page:

  • In-app modal: Use Chargebee.js openCheckout() to open the hosted page in a modal popup in your website or application.
  • Standalone page: Redirect the customer to the hosted page url.

Do not embed the hosted page in your own iframe.

Sample Request

Sample Result[JSON]

URL Format

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

Input Parameters

business_entity_id
optional, string, max chars=50
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.
customer
Parameters for customer
pass parameters as customer[<param name>]
card
Parameters for card
pass parameters as card[<param name>]

Returns

Hosted page object
Resource object representing hosted_page