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.
Related Tutorial
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
Input Parameters
Should be true if the existing addons should be replaced with the ones that are being passed.
List of addons IDs that are mandatory to the plan and has to be removed from the subscription.
The document date displayed on the invoice PDF. The default value is the current date. Provide this value to backdate the invoice. Backdating an invoice is done for reasons such as booking revenue for a previous date or when the subscription is effective as of a past date. Moreover, if create_pending_invoices
is set to true
, and if the site is configured to set invoice dates to date of closing, then upon invoice closure, this date is changed to the invoice closing date. taxes and line_item_taxes are computed based on the tax configuration as of invoice_date.
When passing this parameter, the following prerequisites must be met:
invoice_datemust be in the past.invoice_dateis not more than one calendar month into the past. For example, if today is 13th January, then you cannot pass a value that is earlier than 13th December.- It is not earlier than
changes_scheduled_at,reactivate_from, ortrial_end. invoice_immediatelyistrue. .
The number of billing cycles the subscription runs before canceling. If not provided, then the billing cycles set for the plan is used.
The number of subscription billing cycles to invoice in advance.
If a new term is started for the subscription due to this API call, then terms_to_charge
is inclusive of this new term. See description for the force_term_reset
parameter to learn more about when a subscription term is reset.
If the subscription status
is cancelled
and it is being reactivated via this operation, this is the date/time at which the subscription should be reactivated.
Note:
It is recommended not to pass this parameter along with changed_scheduled_at.
reactivate_from
can be backdated (set to a value in the past). Use backdating when the subscription has been reactivated already but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
- Backdating must be enabled for subscription reactivation operations.
- The current day of the month does not exceed the limit set in Chargebee for backdating subscription change. This limit is the day of the month by which the accounting for the previous month must be closed.
- The date is on or after the last date/time any of the product catalog items of the subscription were changed.
- The date is not more than duration X into the past where X is the billing period of the plan. For example, if the period of the plan in the subscription is 2 months and today is 14th April,
changes_scheduled_atcannot be earlier than 14th February. .
Override the billing alignment mode chosen for the site for calendar billing. Only applicable when using calendar billing.
Subscription period will be aligned with the configured billing date immediately, with credits or charges raised accordingly..
Subscription period will be aligned with the configured billing date at the next renewal.
List of coupons to be applied to this subscription. You can provide coupon ids or coupon codes.
If true
then the existing coupon_ids
list for the subscription is replaced by the one provided. If false
then the provided coupon_ids
list gets added to the existing list.
Applicable only for cancelled subscriptions. Once this is passed as true, cancelled subscription will become active; otherwise subscription changes will be made but the subscription state will remain cancelled. If not passed, subscription will be activated only if there is any change in subscription data.
Note: This parameter is relevant only for subscriptions with status of active, non_renewing, or cancelled.
When you set this parameter to true, the subscription term resets to the date of the subscription change.
By default, if you change the plan to another with the same billing period, the subscription term remains unchanged. For example, if the subscription renews on the 28th of every month, it will continue to renew on the 28th after the change.
Note: If the new plan has a different billing period from the current plan, the subscription term resets automatically, regardless of the value of force_term_reset.
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.
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.
Allow the customer to select an offline payment method during checkout. The choice of payment methods can be configured via the Chargebee UI.
addons[<param name>][<idx:0..n>]