Deprecated. The Purchase API is deprecated. It still works and existing integrations are unaffected, but it's no longer recommended for new integrations. Support for purchasing multiple plans in a single subscription is planned for the Subscriptions API.
Creates a purchase resource. A purchase can contain one or more of the following:
- subscriptions (a
subscriptionresource consists of item prices such that at least one of the item prices belongs to anitemoftypeplan.) - group of one-time charges (aka charge item prices)
When you call this API, the invoices for the subscription(s) and one-time charge(s) are created immediately and not left unbilled .
Note
Providing shipping_addresses[] is required when the Orders feature has been enabled.
Specifying purchase_item groups
When creating a purchase, you must specify the group or index to which each item price belongs. You can do this by setting the purchase_items[index] for each item price. Item prices with the same purchase_items[index] belong to the same group.
The grouping of item prices allows you to specify the discounts[] applicable for each group and indicate which item prices should be added to any subscriptions you want to create. Groups can be one of two types:
- Subscription groups
- One-time charge groups
The following subsections describe the types of groups in detail.
Note
You can specify up to 10 groups,
- with a recommended subscription group of 5. To increase this limit to a maximum of 8, contact eap@chargebee.com.
- with a maximum of 10 one-time charge groups by default.
The total limit for group items for a single purchase is 60.
Subscription groups
To create a subscription, specify a subscription group. A subscription group is a group of item prices that contains exactly one item price of type plan. To create multiple subscriptions, provide multiple subscription groups.
Note
A subscription group can have up to 20 non-plan item prices. To increase this limit to a maximum of 60, contact eap@chargebee.com.
Custom Fields
Purchase API supports custom fields of Subscriptions, use the following format to specify custom fields in Purchase API: subscription_info[custom_field].
One-time charge groups
A one-time charge group is a group of charge item prices (i.e. item prices belonging to items of type charge). Charge item prices can be added to subscription groups as well. The charges within and across each one-time group must be unique.
Note
- A one-time charge group can have up to 20 item prices. To increase this limit to a maximum of 60, contact eap@chargebee.com.
- A charge item price can only be added to a single one-time charge group. However, it can be part of multiple subscription groups.
Applying discounts
Discounts, both manual discounts and coupons, can be applied to groups by specifying the discounts[] array. The following table describes the method of application based on whether discounts[index][i] is provided:
discounts[index][i] is provided | discounts[index][i] is not provided | |
| Coupons |
|
|
| Manual discounts |
|
|
Sample Request
Sample Result[JSON]
URL Format
Input Parameters
Returns
Resource object representing purchase