Note: This operation optionally supports 3DS verification flow. To achieve the same, create the Payment Intent and pass it as input parameter to this API.
Creates a new subscription along with the customer. You can attach a plan, plan quantity, one or more addons and coupon while creating this subscription.
Future Subscriptions
If the start_date is specified, the subscription will be created in 'future' state (.ie, instead of starting immediately it will be scheduled to start at the specified 'start_date'). Besides if 'trial' is specified (plan configuration or specified explicitly using trial_end), the subscription will go into 'trial' state when it starts. Otherwise it will directly become 'active' when it starts.
Trial Period
If the plan has trial period or if the trial_end is specified explicitly, the subscription will be created in 'in_trial' state.
If the card details are passed, it is not charged until the end of the trial period. Incase you need to verify the card you could enable the 'card verification option' in the gateway settings.
Invoice
If the plan does not have a trial period and if any of the recurring items has charges, then a invoice would be raised immediately. If 'auto_collection' is turned 'on', then card attributes are mandatory and subscription will be created only if the payment was successful.
Card details
Passing card details to this API involves PCI liability at your end as sensitive card information passes through your servers. If you wish to avoid that, you can use one of the following integration methodologies if applicable
- If you are using Stripe gateway, you can use Stripe.js with your checkout form. Take a look at this Stripe tutorial for more details.
- If you are using Braintree gateway, you can use Braintree.js with your checkout form. Please refer this tutorial for more details.
- If you are using Authorize.Net gateway, you use Accept.js with your checkout form.
- In case you are using the Adyen gateway, you will have to use the Adyen's Client Side Encryption to encrypt sensitive cardholder data. Once the cardholder data is encrypted, pass the value in adyen.encrypted.data as temp token in this API. You can also use our Hosted Pages based integration.
Legacy behavior:
- For sites created before March 1st, 2014: On making this request, the
billing_addressandvat_numberof the customer are deleted and replaced by the values passed with this request. Ensure that you pass the billing address parameters and thevat_numberparameters each time you make this request, to avoid losing the same information at the customer-level. - For sites created on or after March 1st, 2014: This request does not alter the
billing_addressandvat_numberof the customer.
Related Tutorials
Sample Request
URL Format
Input Parameters
A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
The decimal representation of the quantity of the plan purchased. Can be provided for quantity-based plans and only when multi-decimal pricing is enabled.
Plan Unit Amount in Decimal for create subscription.
Amount that will override the default setup fee. The unit depends on the type of currency .
The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
Specifies the number of billing cycles for the subscription. The behavior of the subscription after the billing cycles have completed depends on whether the subscription is on a contract term or not.
- When the subscription is not on a contract term: if
billing_cyclesis not provided, then the billing cycles set for the plan is used. Moreover, once thebilling_cycleshave completed, the subscription cancels. - When the subscription is on a contract term: Providing
billing_cyclesis mandatory. Moreover, once thebilling_cycleshave completed, the behavior of the subscription is determined by thecontract_term[action_at_term_end]parameter.
List of addons IDs that are mandatory to the plan and has to be removed from the subscription.
The date/time at which the subscription is to start. If not provided, the subscription starts immediately. You can provide a value in the past as well. This is called backdating the subscription creation and is done when the subscription has already been provisioned but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
- Backdating is enabled for subscription creation operations.
- The current day of the month does not exceed the limit set in Chargebee for backdating such operations. This day is typically the day of the month by which the accounting for the previous month must be closed.
- 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,
start_datecannot be earlier than 14th February. .
Defines whether payments need to be collected automatically for this subscription. Overrides customer's auto-collection property.
Whenever an invoice is created for this subscription, an automatic charge will be attempted on the payment method available.
Automatic collection of charges will not be made for this subscription. Use this for offline payments.
The number of subscription billing cycles (including the first one) to invoice in advance .
Override the billing alignment mode for Calendar Billing. Only applicable when using Calendar Billing. The default value is that which has been configured for the site.
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.
The preferred offline payment method for the subscription.
No Preference
Cash
Check
Bank Transfer
ACH Credit
List of coupons to be applied to this subscription. You can provide coupon ids or coupon codes.
The Chargebee payment token generated by Chargebee JS.
Note:
The payment token created via Chargebee JS uses the gateway selected through Smart Routing.
Explicitly passing a gateway_id
in this API call will not override the gateway associated with the token.
A customer-facing note added to all invoices associated with this subscription. This note is one among all the notes displayed on the invoice PDF.
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 the 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.- It is not earlier than
start_date. - It is not more than one calendar month into the past. Eg. If today is 13th January, then you cannot pass a value that is earlier than 13th December.
invoice_immediatelyis true. .
A collection of key-value pairs that provides extra information about the subscription.
Note: There's a character limit of 65,535.
If there are charges raised immediately for the subscription, this parameter specifies whether those charges are to be invoiced immediately or added to unbilled charges. The default value is as per the site settings .
Note:
invoice_immediately
only affects charges that are raised at the time of execution of this API call. Any charges scheduled to be raised in the future are not affected by this parameter.
.
The period of time by which the first term of the subscription is to be extended free-of-charge. The value must be in multiples of free_period_unit.
The unit of time in multiples of which the free_period parameter is expressed. The value must be equal to or lower than the period_unit attribute of the plan chosen.
Charge based on day(s)
Charge based on week(s)
Charge based on month(s)
Charge based on year(s)
Number of billing cycles the new contract term should run for, on contract renewal. The default value is the same as billing_cycles
or a custom value depending on the site configuration
.
Applicable only when End-of-trial Action has been enabled for the site. Whenever the subscription has a trial period, this attribute (parameter) is returned (required) and specifies the operation to be carried out for the subscription once the trial ends.
This is the default value. The action configured for the site at the time when the trial ends, takes effect.
The action configured for the site at the time when the trial ends, takes effect.
The subscription activates and charges are raised for non-metered items.
The subscription cancels.
Indicates the Client profile id for the customer. This is applicable only if you use Chargebee's AvaTax for Communications integration.
The type of initiator to be used for the payment request triggered by this operation.
Pass this value to indicate that the request is initiated by the customer
Pass this value to indicate that the request is initiated by the merchant
Returns
Resource object representing subscription
Resource object representing customer
Resource object representing card
Resource object representing invoice
Resource object representing unbilled_charge