chargebee 2.46.0 → 2.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +51 -0
- package/lib/chargebee.js +48 -25
- package/lib/resources/api_endpoints.js +2147 -407
- package/package.json +1 -1
- package/types/core.d.ts +3 -3
- package/types/index.d.ts +4 -0
- package/types/resources/AttachedItem.d.ts +20 -205
- package/types/resources/Coupon.d.ts +2 -0
- package/types/resources/CreditNote.d.ts +119 -1216
- package/types/resources/DifferentialPrice.d.ts +20 -200
- package/types/resources/Invoice.d.ts +344 -2219
- package/types/resources/InvoiceEstimate.d.ts +9 -0
- package/types/resources/Item.d.ts +2 -0
- package/types/resources/ItemFamily.d.ts +2 -0
- package/types/resources/ItemPrice.d.ts +2 -0
- package/types/resources/Order.d.ts +184 -1073
- package/types/resources/PriceVariant.d.ts +24 -163
- package/types/resources/Purchase.d.ts +13 -258
- package/types/resources/Rule.d.ts +38 -0
- package/types/resources/Subscription.d.ts +2 -0
- package/types/resources/UsageEvent.d.ts +46 -0
|
@@ -3,115 +3,44 @@
|
|
|
3
3
|
declare module 'chargebee' {
|
|
4
4
|
export interface PriceVariant {
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @description The unique and immutable identifier of the price variant.
|
|
8
6
|
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
id:string;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @description A unique name of the price variant.
|
|
15
8
|
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
9
|
name:string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @description A unique display name for the price variant.
|
|
22
10
|
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
11
|
external_name?:string;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @description Description of the price variant.
|
|
29
12
|
|
|
30
|
-
*/
|
|
31
13
|
variant_group?:string;
|
|
14
|
+
|
|
32
15
|
description?:string;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @description Status of a price variant. \* active - Active price variant. This price variant can be attached to [item prices](https://apidocs.chargebee.com/docs/api/item_prices?lang=curl). \* deleted - Deleted price variant. The `id` and `name` of the deleted price variant can be reused. \* archived - Archived price variant. This price variant is no longer `active` and cannot be attached to new [item prices](https://apidocs.chargebee.com/docs/api/item_prices?lang=curl). Existing item prices that already have this price variant attached will continue to remain as is.
|
|
36
16
|
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
17
|
status?:'active' | 'archived' | 'deleted';
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @description Timestamp indicating when this price variant is created.
|
|
43
18
|
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
19
|
created_at:number;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @description The version number of this resource. For every change made to the resource, `resource_version` is updated with a new timestamp in milliseconds.
|
|
50
20
|
|
|
51
|
-
*/
|
|
52
|
-
|
|
53
21
|
resource_version?:number;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @description Timestamp indicating when this price variant was last updated.
|
|
57
22
|
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
23
|
updated_at?:number;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @description Timestamp indicating when this price variant was archived.
|
|
64
24
|
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
25
|
archived_at?:number;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* @description The list of price variant attribute values.
|
|
71
|
-
|
|
72
|
-
Attributes can be used to store additional information about the price variant. For example, for a price variant called 'Germany', the attributes can be 'Country':'Germany', 'City':'Berlin' and so on.
|
|
73
26
|
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
27
|
attributes?:PriceVariant.Attribute[];
|
|
77
28
|
|
|
78
29
|
business_entity_id?:string;
|
|
30
|
+
|
|
31
|
+
deleted:boolean;
|
|
32
|
+
|
|
79
33
|
}
|
|
80
34
|
export namespace PriceVariant {
|
|
81
35
|
export class PriceVariantResource {
|
|
82
|
-
/**
|
|
83
|
-
* @description This endpoint allows the creation of a new price variant that can be attached to [item prices](https://apidocs.chargebee.com/docs/api/item_prices?lang=curl).
|
|
84
|
-
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
36
|
create(input:CreateInputParam):ChargebeeRequest<CreateResponse>;
|
|
88
37
|
|
|
89
|
-
/**
|
|
90
|
-
* @description This endpoint retrieves the details of a specific price variant using its unique identifier.
|
|
91
|
-
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
38
|
retrieve(price_variant_id:string):ChargebeeRequest<RetrieveResponse>;
|
|
95
39
|
|
|
96
|
-
/**
|
|
97
|
-
* @description This endpoint modifies the details of an existing price variant.
|
|
98
|
-
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
40
|
update(price_variant_id:string, input:UpdateInputParam):ChargebeeRequest<UpdateResponse>;
|
|
102
41
|
|
|
103
|
-
/**
|
|
104
|
-
* @description Deletes the price variant. This is not allowed if price variant is attached to any [item price](https://apidocs.chargebee.com/docs/api/item_prices?lang=curl). Once deleted, the `id` and `name` of the price variant can be reused.
|
|
105
|
-
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
42
|
delete(price_variant_id:string):ChargebeeRequest<DeleteResponse>;
|
|
109
43
|
|
|
110
|
-
/**
|
|
111
|
-
* @description This endpoint is used to retrieve a list of price variants.
|
|
112
|
-
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
44
|
list(input?:ListInputParam):ChargebeeRequest<ListResponse>;
|
|
116
45
|
}
|
|
117
46
|
export interface CreateResponse {
|
|
@@ -119,45 +48,18 @@ Attributes can be used to store additional information about the price variant.
|
|
|
119
48
|
}
|
|
120
49
|
export interface CreateInputParam {
|
|
121
50
|
|
|
122
|
-
|
|
123
|
-
* @description The unique and immutable identifier of the price variant.
|
|
124
|
-
|
|
125
|
-
*/
|
|
51
|
+
attributes:{name:string,value:string}[];
|
|
126
52
|
|
|
127
53
|
id:string;
|
|
128
54
|
|
|
129
|
-
/**
|
|
130
|
-
* @description A unique name of the price variant.
|
|
131
|
-
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
55
|
name:string;
|
|
135
56
|
|
|
136
|
-
/**
|
|
137
|
-
* @description A unique display name for the price variant.
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
57
|
external_name?:string;
|
|
142
58
|
|
|
143
|
-
/**
|
|
144
|
-
* @description Description of the price variant.
|
|
145
|
-
|
|
146
|
-
*/
|
|
147
|
-
|
|
148
59
|
description?:string;
|
|
149
60
|
|
|
150
|
-
/**
|
|
151
|
-
* @description The list of price variant attribute values.
|
|
152
|
-
|
|
153
|
-
Attributes can be used to store additional information about the price variant. For example, for a price variant called 'Germany', the attributes can be 'Country':'Germany', 'City':'Berlin' and so on.
|
|
154
|
-
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
attributes:{name:string,value:string}[];
|
|
158
|
-
|
|
159
61
|
variant_group?:string;
|
|
160
|
-
|
|
62
|
+
|
|
161
63
|
business_entity_id?:string;
|
|
162
64
|
}
|
|
163
65
|
export interface RetrieveResponse {
|
|
@@ -169,137 +71,96 @@ Attributes can be used to store additional information about the price variant.
|
|
|
169
71
|
}
|
|
170
72
|
export interface UpdateInputParam {
|
|
171
73
|
|
|
172
|
-
|
|
173
|
-
* @description A unique name of the price variant.
|
|
174
|
-
|
|
175
|
-
*/
|
|
74
|
+
attributes:{name:string,value:string}[];
|
|
176
75
|
|
|
177
76
|
name?:string;
|
|
178
77
|
|
|
179
|
-
/**
|
|
180
|
-
* @description A unique display name for the price variant.
|
|
181
|
-
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
78
|
external_name?:string;
|
|
185
79
|
|
|
186
|
-
/**
|
|
187
|
-
* @description Description of the price variant.
|
|
188
|
-
|
|
189
|
-
*/
|
|
190
|
-
|
|
191
80
|
description?:string;
|
|
192
|
-
|
|
193
|
-
variant_group?:string;
|
|
194
81
|
|
|
195
|
-
|
|
196
|
-
* @description Status of a price variant. \* active - Active price variant. This price variant can be attached to [item prices](https://apidocs.chargebee.com/docs/api/item_prices?lang=curl). \* deleted - Deleted price variant. The `id` and `name` of the deleted price variant can be reused. \* archived - Archived price variant. This price variant is no longer `active` and cannot be attached to new [item prices](https://apidocs.chargebee.com/docs/api/item_prices?lang=curl). Existing item prices that already have this price variant attached will continue to remain as is.
|
|
197
|
-
|
|
198
|
-
*/
|
|
82
|
+
variant_group?:string;
|
|
199
83
|
|
|
200
84
|
status?:'active' | 'archived';
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* @description The list of price variant attribute values.
|
|
204
|
-
|
|
205
|
-
Attributes can be used to store additional information about the price variant. For example, for a price variant called 'Germany', the attributes can be 'Country':'Germany', 'City':'Berlin' and so on.
|
|
206
|
-
|
|
207
|
-
*/
|
|
208
|
-
|
|
209
|
-
attributes:{name:string,value:string}[];
|
|
210
85
|
}
|
|
211
86
|
export interface DeleteResponse {
|
|
212
87
|
price_variant:PriceVariant;
|
|
213
88
|
}
|
|
214
89
|
|
|
215
90
|
export interface ListResponse {
|
|
216
|
-
/**
|
|
217
|
-
* @description This endpoint is used to retrieve a list of price variants.
|
|
218
|
-
|
|
219
|
-
*/
|
|
220
|
-
|
|
221
91
|
list:{price_variant:PriceVariant}[];
|
|
222
92
|
|
|
223
|
-
/**
|
|
224
|
-
* @description This endpoint is used to retrieve a list of price variants.
|
|
225
|
-
|
|
226
|
-
*/
|
|
227
|
-
|
|
228
93
|
next_offset?:string;
|
|
229
94
|
}
|
|
230
95
|
export interface ListInputParam {
|
|
231
96
|
[key : string]: any;
|
|
232
97
|
/**
|
|
233
|
-
* @description
|
|
98
|
+
* @description The number of resources to be returned.
|
|
234
99
|
|
|
235
100
|
*/
|
|
236
101
|
|
|
237
102
|
limit?:number;
|
|
238
103
|
|
|
239
104
|
/**
|
|
240
|
-
* @description
|
|
105
|
+
* @description Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set \`offset\` to the value of \`next_offset\` obtained in the previous iteration of the API call.
|
|
241
106
|
|
|
242
107
|
*/
|
|
243
108
|
|
|
244
109
|
offset?:string;
|
|
245
110
|
|
|
246
111
|
/**
|
|
247
|
-
* @description
|
|
112
|
+
* @description Filter variant based on their [id](#).
|
|
248
113
|
|
|
249
114
|
*/
|
|
250
115
|
|
|
251
116
|
id?:{in?:string,is?:string,is_not?:string,not_in?:string,starts_with?:string};
|
|
252
117
|
|
|
253
118
|
/**
|
|
254
|
-
* @description
|
|
119
|
+
* @description Filter variant based on their `name`s.
|
|
255
120
|
|
|
256
121
|
*/
|
|
257
122
|
|
|
258
123
|
name?:{in?:string,is?:string,is_not?:string,not_in?:string,starts_with?:string};
|
|
259
124
|
|
|
260
125
|
/**
|
|
261
|
-
* @description
|
|
126
|
+
* @description Filter variant based on their `status`.
|
|
262
127
|
|
|
263
128
|
*/
|
|
264
129
|
|
|
265
130
|
status?:{in?:string,is?:'active' | 'archived',is_not?:'active' | 'archived',not_in?:string};
|
|
266
131
|
|
|
267
132
|
/**
|
|
268
|
-
* @description
|
|
133
|
+
* @description Filter product based on their `updated time`.
|
|
269
134
|
|
|
270
135
|
*/
|
|
271
136
|
|
|
272
137
|
updated_at?:{after?:string,before?:string,between?:string,on?:string};
|
|
273
138
|
|
|
274
139
|
/**
|
|
275
|
-
* @description
|
|
140
|
+
* @description Filter product based on their `created time`.
|
|
276
141
|
|
|
277
142
|
*/
|
|
278
143
|
|
|
279
144
|
created_at?:{after?:string,before?:string,between?:string,on?:string};
|
|
280
145
|
|
|
281
146
|
/**
|
|
282
|
-
* @description This
|
|
147
|
+
* @description The unique ID of the [business entity](/docs/api?prod_cat_ver=2#mbe) of this subscription. This is always the same as the [business entity](/docs/api/subscriptions?prod_cat_ver=2#subscription_customer_id) of the customer.
|
|
148
|
+
The ID of the business entity created for the site. For Product Catalog 1.0, all the site data is tied to this business entity.
|
|
149
|
+
**Note**
|
|
150
|
+
|
|
151
|
+
[Multiple Business Entities](/docs/api?prod_cat_ver=2#mbe) is a feature available only on Product Catalog 2.0.
|
|
283
152
|
|
|
284
153
|
*/
|
|
285
154
|
|
|
286
|
-
sort_by?:{asc?:'name' | 'id' | 'status' | 'created_at' | 'updated_at',desc?:'name' | 'id' | 'status' | 'created_at' | 'updated_at'};
|
|
287
|
-
|
|
288
155
|
business_entity_id?:{is?:string,is_present?:'true' | 'false'};
|
|
156
|
+
|
|
157
|
+
include_site_level_resources?:{is?:'true' | 'false'};
|
|
158
|
+
|
|
159
|
+
sort_by?:{asc?:'name' | 'id' | 'status' | 'created_at' | 'updated_at',desc?:'name' | 'id' | 'status' | 'created_at' | 'updated_at'};
|
|
289
160
|
}
|
|
290
161
|
export interface Attribute {
|
|
291
|
-
/**
|
|
292
|
-
* @description Attribute name
|
|
293
|
-
|
|
294
|
-
*/
|
|
295
|
-
|
|
296
162
|
name:string;
|
|
297
163
|
|
|
298
|
-
/**
|
|
299
|
-
* @description Attribute value
|
|
300
|
-
|
|
301
|
-
*/
|
|
302
|
-
|
|
303
164
|
value:string;
|
|
304
165
|
}
|
|
305
166
|
}
|
|
@@ -3,120 +3,24 @@
|
|
|
3
3
|
declare module 'chargebee' {
|
|
4
4
|
export interface Purchase {
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* @description The unique identifier of the purchase resource. This is always autogenerated.
|
|
8
6
|
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
7
|
id?:string;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @description The unique identifier of the [customer](https://apidocs.chargebee.com/docs/api/customers) that made this purchase.
|
|
15
8
|
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
9
|
customer_id:string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @description The time at which this purchase was created.
|
|
22
10
|
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
11
|
created_at?:number;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* @description The time at which the purchase was modified.
|
|
29
12
|
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
13
|
modified_at?:number;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @description The unique identifiers of the [subscriptions](https://apidocs.chargebee.com/docs/api/subscriptions) that are created as part of this purchase. These IDs remain even when the associated subscriptions have been deleted.
|
|
36
14
|
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
15
|
subscription_ids?:string[];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @description The unique identifier of the [invoice(s)](invoices) created immediately as part of this purchase.
|
|
43
16
|
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
17
|
invoice_ids?:string[];
|
|
18
|
+
|
|
47
19
|
}
|
|
48
20
|
export namespace Purchase {
|
|
49
21
|
export class PurchaseResource {
|
|
50
|
-
/**
|
|
51
|
-
* @description Creates a `purchase` resource. A purchase can contain one or more of the following:
|
|
52
|
-
|
|
53
|
-
* subscriptions (a [subscription](subscriptions) resource consists of item prices such that at least one of the item prices belongs to an [item](items) of `type` `plan`.)
|
|
54
|
-
* group of one-time charges (aka [charge item prices](item_prices#types))
|
|
55
|
-
|
|
56
|
-
When you call this API, the invoices for the subscription(s) and one-time charge(s) are created immediately and not left [unbilled](subscriptions?prod_cat_ver=2#create_subscription_for_items_invoice_immediately).
|
|
57
|
-
**Note**
|
|
58
|
-
|
|
59
|
-
Providing `shipping_addresses[]` is required when the [Orders feature](https://www.chargebee.com/docs/2.0/orders.html#configuration_step-1-configure-site-wide-settings) has been enabled.
|
|
60
|
-
|
|
61
|
-
### Specifying `purchase_item` groups {#groups}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
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.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
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:
|
|
68
|
-
|
|
69
|
-
* Subscription groups
|
|
70
|
-
* One-time charge groups
|
|
71
|
-
|
|
72
|
-
The following subsections describe the types of groups in detail.
|
|
73
|
-
**Note**
|
|
74
|
-
|
|
75
|
-
You can specify up to 10 groups,
|
|
76
|
-
|
|
77
|
-
* with a recommended subscription group of 5. To increase this limit to a maximum of 8, contact eap@chargebee.com.
|
|
78
|
-
* with a maximum of 10 one-time charge groups by default.
|
|
79
|
-
|
|
80
|
-
The total limit for group items for a single purchase is 60.
|
|
81
|
-
|
|
82
|
-
#### Subscription groups {#subscription}
|
|
83
|
-
|
|
84
|
-
To create a subscription, specify a *subscription group* . A subscription [group](#groups) is a group of item prices that contains exactly one item price of `type` `plan`. To create multiple subscriptions, provide multiple subscription groups.
|
|
85
|
-
**Note**
|
|
86
|
-
|
|
87
|
-
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.
|
|
88
|
-
|
|
89
|
-
#### Custom Fields {#custom-fields}
|
|
90
|
-
|
|
91
|
-
Purchase API supports custom fields of Subscriptions, use the following format to specify custom fields in Purchase API: **`subscription_info[custom_field]`**.
|
|
92
|
-
|
|
93
|
-
#### One-time charge groups {#one-time}
|
|
94
|
-
|
|
95
|
-
A one-time charge [group](#groups) 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.
|
|
96
|
-
**Note**
|
|
97
|
-
|
|
98
|
-
* 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.
|
|
99
|
-
* A charge item price can only be added to a single one-time charge group. However, it can be part of multiple [subscription groups](#subscription).
|
|
100
|
-
|
|
101
|
-
### Applying discounts {#discounts}
|
|
102
|
-
|
|
103
|
-
Discounts, both [manual discounts](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:
|
|
104
|
-
|
|
105
|
-
| | **`discounts[index][i]` is provided** | **`discounts[index][i]` is not provided** |
|
|
106
|
-
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
107
|
-
| **Coupons** | * The coupon is applied exclusively to the invoice for group `i`. * The coupon is applied exclusively to the invoice created immediately upon invoking this API. * If group `i` is a [subscription group](#subscription), then the coupon is applied to invoices for subscription renewals based on coupon attributes such as `duration_type` and `max_redemptions`. | * The coupon is applied to all the invoices immediately generated upon invoking this API. * The coupon is not applied to subsequent invoices, such as those generated upon subscription renewal. |
|
|
108
|
-
| **Manual discounts** | * The manual discount is applied exclusively to the invoice for group `i`. * The manual discount is applied exclusively to the invoice created immediately upon invoking this API. * The manual discount is not applied to subsequent invoices, such as those generated upon subscription renewal. | * The manual discount is applied to all the invoices immediately generated upon invoking this API. * The manual discount is not applied to subsequent invoices, such as those generated upon subscription renewal. |
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*/
|
|
112
|
-
|
|
113
22
|
create(input:CreateInputParam):ChargebeeRequest<CreateResponse>;
|
|
114
23
|
|
|
115
|
-
/**
|
|
116
|
-
* @description Returns an estimate for creating a `purchase` resource. The operation works exactly like [Create a purchase](purchases#create_a_purchase), except that only an [estimate](estimates) resource is returned without an actual `purchase` resource being created.
|
|
117
|
-
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
24
|
estimate(input:EstimateInputParam):ChargebeeRequest<EstimateResponse>;
|
|
121
25
|
}
|
|
122
26
|
export interface CreateResponse {
|
|
@@ -124,203 +28,54 @@ Discounts, both [manual discounts](discounts) and <coupons>, can be applie
|
|
|
124
28
|
}
|
|
125
29
|
export interface CreateInputParam {
|
|
126
30
|
|
|
127
|
-
|
|
128
|
-
* @description The unique identifier of the [customer](https://apidocs.chargebee.com/docs/api/customers) that made this purchase.
|
|
129
|
-
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
customer_id:string;
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @description Payment source attached to this purchase. If present, the customer's payment sources won't be used to collect any payment for this purchase.
|
|
136
|
-
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
payment_source_id?:string;
|
|
31
|
+
invoice_info?:{notes?:string,po_number?:string};
|
|
140
32
|
|
|
141
|
-
|
|
142
|
-
* @description Parameters for invoice_info
|
|
143
|
-
|
|
144
|
-
*/
|
|
33
|
+
payment_schedule?:{amount?:number,scheme_id?:string};
|
|
145
34
|
|
|
146
|
-
|
|
35
|
+
statement_descriptor?:{descriptor?:string};
|
|
147
36
|
|
|
148
|
-
|
|
149
|
-
* @description Parameters for purchase_items
|
|
150
|
-
|
|
151
|
-
*/
|
|
37
|
+
payment_intent?:{additional_information?:object,gateway_account_id?:string,gw_payment_method_id?:string,gw_token?:string,id?:string,payment_method_type?:'card' | 'ideal' | 'sofort' | 'bancontact' | 'google_pay' | 'dotpay' | 'giropay' | 'apple_pay' | 'upi' | 'netbanking_emandates' | 'paypal_express_checkout' | 'direct_debit' | 'boleto' | 'venmo' | 'amazon_payments' | 'pay_to' | 'faster_payments' | 'sepa_instant_transfer' | 'klarna_pay_now' | 'online_banking_poland',reference_id?:string};
|
|
152
38
|
|
|
153
39
|
purchase_items:{index:number,item_price_id:string,quantity?:number,quantity_in_decimal?:string,unit_amount?:number,unit_amount_in_decimal?:string}[];
|
|
154
40
|
|
|
155
|
-
/**
|
|
156
|
-
* @description Parameters for item_tiers
|
|
157
|
-
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
41
|
item_tiers:{ending_unit?:number,ending_unit_in_decimal?:string,index:number,item_price_id?:string,price?:number,price_in_decimal?:string,starting_unit?:number,starting_unit_in_decimal?:string}[];
|
|
161
42
|
|
|
162
|
-
/**
|
|
163
|
-
* @description Parameters for shipping_addresses
|
|
164
|
-
|
|
165
|
-
*/
|
|
166
|
-
|
|
167
43
|
shipping_addresses?:{city?:string,company?:string,country?:string,email?:string,first_name?:string,last_name?:string,line1?:string,line2?:string,line3?:string,phone?:string,state?:string,state_code?:string,validation_status?:ValidationStatus,zip?:string}[];
|
|
168
44
|
|
|
169
|
-
/**
|
|
170
|
-
* @description Parameters for discounts
|
|
171
|
-
|
|
172
|
-
*/
|
|
173
|
-
|
|
174
45
|
discounts?:{amount?:number,coupon_id?:string,included_in_mrr?:boolean,index?:number,percentage?:number}[];
|
|
175
46
|
|
|
176
|
-
/**
|
|
177
|
-
* @description Parameters for subscription_info
|
|
178
|
-
|
|
179
|
-
*/
|
|
180
|
-
|
|
181
47
|
subscription_info:{billing_cycles?:number,contract_term_billing_cycle_on_renewal?:number,index:number,meta_data?:object,subscription_id?:string}[];
|
|
182
48
|
|
|
183
|
-
|
|
184
|
-
* @description Creates a `purchase` resource. A purchase can contain one or more of the following:
|
|
185
|
-
|
|
186
|
-
* subscriptions (a [subscription](subscriptions) resource consists of item prices such that at least one of the item prices belongs to an [item](items) of `type` `plan`.)
|
|
187
|
-
* group of one-time charges (aka [charge item prices](item_prices#types))
|
|
188
|
-
|
|
189
|
-
When you call this API, the invoices for the subscription(s) and one-time charge(s) are created immediately and not left [unbilled](subscriptions?prod_cat_ver=2#create_subscription_for_items_invoice_immediately).
|
|
190
|
-
**Note**
|
|
191
|
-
|
|
192
|
-
Providing `shipping_addresses[]` is required when the [Orders feature](https://www.chargebee.com/docs/2.0/orders.html#configuration_step-1-configure-site-wide-settings) has been enabled.
|
|
193
|
-
|
|
194
|
-
### Specifying `purchase_item` groups {#groups}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
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.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
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:
|
|
201
|
-
|
|
202
|
-
* Subscription groups
|
|
203
|
-
* One-time charge groups
|
|
204
|
-
|
|
205
|
-
The following subsections describe the types of groups in detail.
|
|
206
|
-
**Note**
|
|
207
|
-
|
|
208
|
-
You can specify up to 10 groups,
|
|
209
|
-
|
|
210
|
-
* with a recommended subscription group of 5. To increase this limit to a maximum of 8, contact eap@chargebee.com.
|
|
211
|
-
* with a maximum of 10 one-time charge groups by default.
|
|
212
|
-
|
|
213
|
-
The total limit for group items for a single purchase is 60.
|
|
214
|
-
|
|
215
|
-
#### Subscription groups {#subscription}
|
|
216
|
-
|
|
217
|
-
To create a subscription, specify a *subscription group* . A subscription [group](#groups) is a group of item prices that contains exactly one item price of `type` `plan`. To create multiple subscriptions, provide multiple subscription groups.
|
|
218
|
-
**Note**
|
|
219
|
-
|
|
220
|
-
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.
|
|
221
|
-
|
|
222
|
-
#### Custom Fields {#custom-fields}
|
|
223
|
-
|
|
224
|
-
Purchase API supports custom fields of Subscriptions, use the following format to specify custom fields in Purchase API: **`subscription_info[custom_field]`**.
|
|
225
|
-
|
|
226
|
-
#### One-time charge groups {#one-time}
|
|
227
|
-
|
|
228
|
-
A one-time charge [group](#groups) 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.
|
|
229
|
-
**Note**
|
|
230
|
-
|
|
231
|
-
* 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.
|
|
232
|
-
* A charge item price can only be added to a single one-time charge group. However, it can be part of multiple [subscription groups](#subscription).
|
|
233
|
-
|
|
234
|
-
### Applying discounts {#discounts}
|
|
235
|
-
|
|
236
|
-
Discounts, both [manual discounts](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:
|
|
237
|
-
|
|
238
|
-
| | **`discounts[index][i]` is provided** | **`discounts[index][i]` is not provided** |
|
|
239
|
-
|----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
240
|
-
| **Coupons** | * The coupon is applied exclusively to the invoice for group `i`. * The coupon is applied exclusively to the invoice created immediately upon invoking this API. * If group `i` is a [subscription group](#subscription), then the coupon is applied to invoices for subscription renewals based on coupon attributes such as `duration_type` and `max_redemptions`. | * The coupon is applied to all the invoices immediately generated upon invoking this API. * The coupon is not applied to subsequent invoices, such as those generated upon subscription renewal. |
|
|
241
|
-
| **Manual discounts** | * The manual discount is applied exclusively to the invoice for group `i`. * The manual discount is applied exclusively to the invoice created immediately upon invoking this API. * The manual discount is not applied to subsequent invoices, such as those generated upon subscription renewal. | * The manual discount is applied to all the invoices immediately generated upon invoking this API. * The manual discount is not applied to subsequent invoices, such as those generated upon subscription renewal. |
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
*/
|
|
49
|
+
contract_terms:{action_at_term_end?:'renew' | 'evergreen' | 'cancel' | 'renew_once',cancellation_cutoff_period?:number,index:number}[];
|
|
245
50
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
51
|
+
customer_id:string;
|
|
52
|
+
|
|
53
|
+
payment_source_id?:string;
|
|
249
54
|
}
|
|
250
55
|
export interface EstimateResponse {
|
|
251
56
|
estimate:Estimate;
|
|
252
57
|
}
|
|
253
58
|
export interface EstimateInputParam {
|
|
254
59
|
|
|
255
|
-
/**
|
|
256
|
-
* @description Indicates the Client profile id for the customer. This is applicable only if you use [Chargebee's AvaTax for Communications](https://www.chargebee.com/docs/avatax-for-communication.html) integration.
|
|
257
|
-
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
client_profile_id?:string;
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* @description The unique identifier of the [customer](https://apidocs.chargebee.com/docs/api/customers) that made this purchase.
|
|
264
|
-
|
|
265
|
-
*/
|
|
266
|
-
|
|
267
|
-
customer_id?:string;
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* @description Parameters for customer
|
|
271
|
-
|
|
272
|
-
*/
|
|
273
|
-
|
|
274
60
|
customer?:{customer_type?:CustomerType,entity_code?:EntityCode,exempt_number?:string,exemption_details?:any[],registered_for_gst?:boolean,taxability?:Taxability,vat_number?:string,vat_number_prefix?:string};
|
|
275
61
|
|
|
276
|
-
/**
|
|
277
|
-
* @description Parameters for billing_address
|
|
278
|
-
|
|
279
|
-
*/
|
|
280
|
-
|
|
281
62
|
billing_address?:{city?:string,country?:string,line1?:string,line2?:string,line3?:string,state_code?:string,validation_status?:ValidationStatus,zip?:string};
|
|
282
63
|
|
|
283
|
-
/**
|
|
284
|
-
* @description Parameters for purchase_items
|
|
285
|
-
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
64
|
purchase_items:{index:number,item_price_id:string,quantity?:number,quantity_in_decimal?:string,unit_amount?:number,unit_amount_in_decimal?:string}[];
|
|
289
65
|
|
|
290
|
-
/**
|
|
291
|
-
* @description Parameters for item_tiers
|
|
292
|
-
|
|
293
|
-
*/
|
|
294
|
-
|
|
295
66
|
item_tiers:{ending_unit?:number,ending_unit_in_decimal?:string,index:number,item_price_id?:string,price?:number,price_in_decimal?:string,starting_unit?:number,starting_unit_in_decimal?:string}[];
|
|
296
67
|
|
|
297
|
-
/**
|
|
298
|
-
* @description Parameters for shipping_addresses
|
|
299
|
-
|
|
300
|
-
*/
|
|
301
|
-
|
|
302
68
|
shipping_addresses?:{city?:string,company?:string,country?:string,email?:string,first_name?:string,last_name?:string,line1?:string,line2?:string,line3?:string,phone?:string,state?:string,state_code?:string,validation_status?:ValidationStatus,zip?:string}[];
|
|
303
69
|
|
|
304
|
-
/**
|
|
305
|
-
* @description Parameters for discounts
|
|
306
|
-
|
|
307
|
-
*/
|
|
308
|
-
|
|
309
70
|
discounts?:{amount?:number,coupon_id?:string,included_in_mrr?:boolean,index?:number,percentage?:number}[];
|
|
310
71
|
|
|
311
|
-
/**
|
|
312
|
-
* @description Parameters for subscription_info
|
|
313
|
-
|
|
314
|
-
*/
|
|
315
|
-
|
|
316
72
|
subscription_info:{billing_cycles?:number,contract_term_billing_cycle_on_renewal?:number,index:number,subscription_id?:string}[];
|
|
317
73
|
|
|
318
|
-
|
|
319
|
-
* @description Returns an estimate for creating a `purchase` resource. The operation works exactly like [Create a purchase](purchases#create_a_purchase), except that only an [estimate](estimates) resource is returned without an actual `purchase` resource being created.
|
|
320
|
-
|
|
321
|
-
*/
|
|
74
|
+
contract_terms:{action_at_term_end?:'renew' | 'evergreen' | 'cancel' | 'renew_once',cancellation_cutoff_period?:number,index:number}[];
|
|
322
75
|
|
|
323
|
-
|
|
76
|
+
client_profile_id?:string;
|
|
77
|
+
|
|
78
|
+
customer_id?:string;
|
|
324
79
|
}
|
|
325
80
|
|
|
326
81
|
}
|