chargebee 3.21.1 → 3.22.1

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 CHANGED
@@ -1,3 +1,43 @@
1
+ ### v3.22.1 (2026-03-09)
2
+ * * *
3
+ ### Bug Fixes:
4
+ - Fixed GET requests incorrectly sending a request body. Parameters are now only serialized into the request body for non-GET requests.
5
+
6
+ ### Tests:
7
+ - GET list request — body must be empty.
8
+ - GET retrieve request — body must be empty.
9
+ - GET with params — params go into the query string, not the body.
10
+ - POST request — body is correctly populated with encoded params.
11
+
12
+ ### v3.22.0 (2026-03-02)
13
+ * * *
14
+ ### New Resources:
15
+ - [`UsageCharge`](https://apidocs.chargebee.com/docs/api/usage_charges) has been added.
16
+ - [`UsageSummary`](https://apidocs.chargebee.com/docs/api/usage_summaries) has been added.
17
+
18
+
19
+ ### New Attributes:
20
+ - [`free_period`](https://apidocs.chargebee.com/docs/api/quoted_subscriptions/quoted-subscription-object#free_period) has been added to [`QuotedSubscription`](https://apidocs.chargebee.com/docs/api/quoted_subscriptions).
21
+ - [`free_period_unit`](https://apidocs.chargebee.com/docs/api/quoted_subscriptions/quoted-subscription-object#free_period_unit) has been added to [`QuotedSubscription`](https://apidocs.chargebee.com/docs/api/quoted_subscriptions).
22
+
23
+
24
+ ### New Parameters:
25
+ - [`net_term_days`](https://apidocs.chargebee.com/docs/api/invoices/create-invoice-for-items-and-one-time-charges#net_term_days) has been added as request body parameter to [`create_invoice_for_items_and_one-time_charges`](https://apidocs.chargebee.com/docs/api/invoices/create-invoice-for-items-and-one-time-charges) in [`Invoice`](https://apidocs.chargebee.com/docs/api/invoices).
26
+ - [`contract_term`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions/create-pricing-page-for-existing-subscription#contract_term) has been added as request body parameter to [`create_pricing_page_for_existing_subscription`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions/create-pricing-page-for-existing-subscription) in [`PricingPageSession`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions).
27
+ - [`contract_term`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions/create-pricing-page-for-new-subscription#contract_term) has been added as request body parameter to [`create_pricing_page_for_new_subscription`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions/create-pricing-page-for-new-subscription) in [`PricingPageSession`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions).
28
+ - [`subscription.free_period`](https://apidocs.chargebee.com/docs/api/quotes/create-a-quote-for-a-new-subscription-items#subscription_free_period) has been added as request body parameter to [`create_a_quote_for_a_new_subscription_items`](https://apidocs.chargebee.com/docs/api/quotes/create-a-quote-for-a-new-subscription-items) in [`Quote`](https://apidocs.chargebee.com/docs/api/quotes).
29
+ - [`subscription.free_period_unit`](https://apidocs.chargebee.com/docs/api/quotes/create-a-quote-for-a-new-subscription-items#subscription_free_period_unit) has been added as request body parameter to [`create_a_quote_for_a_new_subscription_items`](https://apidocs.chargebee.com/docs/api/quotes/create-a-quote-for-a-new-subscription-items) in [`Quote`](https://apidocs.chargebee.com/docs/api/quotes).
30
+ - [`subscription.free_period`](https://apidocs.chargebee.com/docs/api/quotes/edit-create-subscription-quote-for-items#subscription_free_period) has been added as request body parameter to [`edit_create_subscription_quote_for_items`](https://apidocs.chargebee.com/docs/api/quotes/edit-create-subscription-quote-for-items) in [`Quote`](https://apidocs.chargebee.com/docs/api/quotes).
31
+ - [`subscription.free_period_unit`](https://apidocs.chargebee.com/docs/api/quotes/edit-create-subscription-quote-for-items#subscription_free_period_unit) has been added as request body parameter to [`edit_create_subscription_quote_for_items`](https://apidocs.chargebee.com/docs/api/quotes/edit-create-subscription-quote-for-items) in [`Quote`](https://apidocs.chargebee.com/docs/api/quotes).
32
+
33
+
34
+ ### New Enums:
35
+ - `month`, `week`, `day`, `hour`, and `minute` have been added as new values enum `WindowSize`.
36
+ - `cancel`, `renew_once`, `renew`, and `evergreen` have been added as new values to enum request body parameter `contract_term.action_at_term_end` in [`create_pricing_page_for_existing_subscription`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions/create-pricing-page-for-existing-subscription) of [`PricingPageSession`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions).
37
+ - `cancel`, `renew_once`, `renew`, and `evergreen` have been added as new values to enum request body parameter `contract_term.action_at_term_end` in [`create_pricing_page_for_new_subscription`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions/create-pricing-page-for-new-subscription) of [`PricingPageSession`](https://apidocs.chargebee.com/docs/api/pricing_page_sessions).
38
+
39
+
40
+
1
41
  ### v3.21.1 (2026-02-20)
2
42
  * * *
3
43
 
@@ -64,11 +64,14 @@ class RequestWrapper {
64
64
  requestParams = {};
65
65
  }
66
66
  const jsonKeys = this.apiCall.jsonKeys;
67
- const data = this.apiCall.isJsonRequest
68
- ? JSON.stringify(requestParams)
69
- : (0, util_js_1.encodeParams)(requestParams, undefined, undefined, undefined, jsonKeys);
67
+ let data = null;
68
+ if (this.apiCall.httpMethod !== 'GET') {
69
+ data = this.apiCall.isJsonRequest
70
+ ? JSON.stringify(requestParams)
71
+ : (0, util_js_1.encodeParams)(requestParams, undefined, undefined, undefined, jsonKeys);
72
+ }
70
73
  const requestHeaders = Object.assign({}, this.httpHeaders);
71
- if (data.length) {
74
+ if (data && data.length) {
72
75
  (0, util_js_1.extend)(true, requestHeaders, {
73
76
  'Content-Length': data.length,
74
77
  });
@@ -90,7 +93,7 @@ class RequestWrapper {
90
93
  const url = new URL(path, `${env.protocol}://${(0, util_js_1.getHost)(env, this.apiCall.subDomain)}${env.port ? `:${env.port}` : ''}`);
91
94
  const request = new Request(url, {
92
95
  method: this.apiCall.httpMethod,
93
- body: data ? data : undefined,
96
+ body: data || undefined,
94
97
  headers: this._createHeaders(requestHeaders),
95
98
  });
96
99
  const resp = await this.envArg.httpClient.makeApiRequest(request, env.timeout);
@@ -11,7 +11,7 @@ exports.Environment = {
11
11
  hostSuffix: '.chargebee.com',
12
12
  apiPath: '/api/v2',
13
13
  timeout: DEFAULT_TIME_OUT,
14
- clientVersion: 'v3.21.1',
14
+ clientVersion: 'v3.22.1',
15
15
  port: DEFAULT_PORT,
16
16
  timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
17
17
  exportWaitInMillis: DEFAULT_EXPORT_WAIT,
@@ -4872,6 +4872,32 @@ exports.Endpoints = {
4872
4872
  ],
4873
4873
  ['list', 'GET', '/webhook_endpoints', null, false, null, false, {}, {}],
4874
4874
  ],
4875
+ usageSummary: [
4876
+ [
4877
+ 'retrieveUsageSummaryForSubscription',
4878
+ 'GET',
4879
+ '/subscriptions',
4880
+ '/usage_summary',
4881
+ true,
4882
+ null,
4883
+ false,
4884
+ {},
4885
+ {},
4886
+ ],
4887
+ ],
4888
+ usageCharge: [
4889
+ [
4890
+ 'retrieveUsageChargesForSubscription',
4891
+ 'GET',
4892
+ '/subscriptions',
4893
+ '/usage_charges',
4894
+ true,
4895
+ null,
4896
+ false,
4897
+ {},
4898
+ {},
4899
+ ],
4900
+ ],
4875
4901
  impactedCustomer: [],
4876
4902
  subscriptionEntitlementsUpdatedDetail: [],
4877
4903
  subscriptionEntitlementsCreatedDetail: [],
@@ -61,11 +61,14 @@ export class RequestWrapper {
61
61
  requestParams = {};
62
62
  }
63
63
  const jsonKeys = this.apiCall.jsonKeys;
64
- const data = this.apiCall.isJsonRequest
65
- ? JSON.stringify(requestParams)
66
- : encodeParams(requestParams, undefined, undefined, undefined, jsonKeys);
64
+ let data = null;
65
+ if (this.apiCall.httpMethod !== 'GET') {
66
+ data = this.apiCall.isJsonRequest
67
+ ? JSON.stringify(requestParams)
68
+ : encodeParams(requestParams, undefined, undefined, undefined, jsonKeys);
69
+ }
67
70
  const requestHeaders = Object.assign({}, this.httpHeaders);
68
- if (data.length) {
71
+ if (data && data.length) {
69
72
  extend(true, requestHeaders, {
70
73
  'Content-Length': data.length,
71
74
  });
@@ -87,7 +90,7 @@ export class RequestWrapper {
87
90
  const url = new URL(path, `${env.protocol}://${getHost(env, this.apiCall.subDomain)}${env.port ? `:${env.port}` : ''}`);
88
91
  const request = new Request(url, {
89
92
  method: this.apiCall.httpMethod,
90
- body: data ? data : undefined,
93
+ body: data || undefined,
91
94
  headers: this._createHeaders(requestHeaders),
92
95
  });
93
96
  const resp = await this.envArg.httpClient.makeApiRequest(request, env.timeout);
@@ -8,7 +8,7 @@ export const Environment = {
8
8
  hostSuffix: '.chargebee.com',
9
9
  apiPath: '/api/v2',
10
10
  timeout: DEFAULT_TIME_OUT,
11
- clientVersion: 'v3.21.1',
11
+ clientVersion: 'v3.22.1',
12
12
  port: DEFAULT_PORT,
13
13
  timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
14
14
  exportWaitInMillis: DEFAULT_EXPORT_WAIT,
@@ -4869,6 +4869,32 @@ export const Endpoints = {
4869
4869
  ],
4870
4870
  ['list', 'GET', '/webhook_endpoints', null, false, null, false, {}, {}],
4871
4871
  ],
4872
+ usageSummary: [
4873
+ [
4874
+ 'retrieveUsageSummaryForSubscription',
4875
+ 'GET',
4876
+ '/subscriptions',
4877
+ '/usage_summary',
4878
+ true,
4879
+ null,
4880
+ false,
4881
+ {},
4882
+ {},
4883
+ ],
4884
+ ],
4885
+ usageCharge: [
4886
+ [
4887
+ 'retrieveUsageChargesForSubscription',
4888
+ 'GET',
4889
+ '/subscriptions',
4890
+ '/usage_charges',
4891
+ true,
4892
+ null,
4893
+ false,
4894
+ {},
4895
+ {},
4896
+ ],
4897
+ ],
4872
4898
  impactedCustomer: [],
4873
4899
  subscriptionEntitlementsUpdatedDetail: [],
4874
4900
  subscriptionEntitlementsCreatedDetail: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chargebee",
3
- "version": "3.21.1",
3
+ "version": "3.22.1",
4
4
  "description": "A library for integrating with Chargebee.",
5
5
  "scripts": {
6
6
  "prepack": "npm install && npm run build",
package/types/core.d.ts CHANGED
@@ -670,5 +670,6 @@ declare module 'chargebee' {
670
670
  | 'partially_valid'
671
671
  | 'invalid';
672
672
  type VoucherTypeEnum = 'boleto';
673
+ type WindowSizeEnum = 'month' | 'week' | 'day' | 'hour' | 'minute';
673
674
  type ChargeOnEnum = 'immediately' | 'on_event';
674
675
  }
package/types/index.d.ts CHANGED
@@ -94,8 +94,10 @@
94
94
  ///<reference path='./resources/Transaction.d.ts' />
95
95
  ///<reference path='./resources/UnbilledCharge.d.ts' />
96
96
  ///<reference path='./resources/Usage.d.ts' />
97
+ ///<reference path='./resources/UsageCharge.d.ts' />
97
98
  ///<reference path='./resources/UsageEvent.d.ts' />
98
99
  ///<reference path='./resources/UsageFile.d.ts' />
100
+ ///<reference path='./resources/UsageSummary.d.ts' />
99
101
  ///<reference path='./resources/VirtualBankAccount.d.ts' />
100
102
  ///<reference path='./resources/WebhookEndpoint.d.ts' />
101
103
  ///<reference path='./resources/Content.d.ts' />
@@ -238,8 +240,10 @@ declare module 'chargebee' {
238
240
  transaction: Transaction.TransactionResource;
239
241
  unbilledCharge: UnbilledCharge.UnbilledChargeResource;
240
242
  usage: Usage.UsageResource;
243
+ usageCharge: UsageCharge.UsageChargeResource;
241
244
  usageEvent: UsageEvent.UsageEventResource;
242
245
  usageFile: UsageFile.UsageFileResource;
246
+ usageSummary: UsageSummary.UsageSummaryResource;
243
247
  virtualBankAccount: VirtualBankAccount.VirtualBankAccountResource;
244
248
  webhookEndpoint: WebhookEndpoint.WebhookEndpointResource;
245
249
 
@@ -99,8 +99,10 @@ declare module 'chargebee' {
99
99
  transaction: Transaction;
100
100
  unbilled_charge: UnbilledCharge;
101
101
  usage: Usage;
102
+ usage_charge: UsageCharge;
102
103
  usage_event: UsageEvent;
103
104
  usage_file: UsageFile;
105
+ usage_summary: UsageSummary;
104
106
  virtual_bank_account: VirtualBankAccount;
105
107
  webhook_endpoint: WebhookEndpoint;
106
108
  }
@@ -907,6 +907,7 @@ declare module 'chargebee' {
907
907
  authorization_transaction_id?: string;
908
908
  payment_source_id?: string;
909
909
  auto_collection?: AutoCollectionEnum;
910
+ net_term_days?: number;
910
911
  invoice_date?: number;
911
912
  token_id?: string;
912
913
  replace_primary_payment_source?: boolean;
@@ -52,11 +52,11 @@ declare module 'chargebee' {
52
52
  }
53
53
 
54
54
  export interface AddItemEntitlementsResponse {
55
- item_entitlement: ItemEntitlement;
55
+ list: { item_entitlement: ItemEntitlement }[];
56
56
  }
57
57
 
58
58
  export interface UpsertOrRemoveItemEntitlementsForItemResponse {
59
- item_entitlement: ItemEntitlement;
59
+ list: { item_entitlement: ItemEntitlement }[];
60
60
  }
61
61
 
62
62
  // REQUEST PARAMS
@@ -43,6 +43,7 @@ declare module 'chargebee' {
43
43
  customer?: CustomerCreateForNewSubscriptionInputParam;
44
44
  billing_address?: BillingAddressCreateForNewSubscriptionInputParam;
45
45
  shipping_address?: ShippingAddressCreateForNewSubscriptionInputParam;
46
+ contract_term?: ContractTermCreateForNewSubscriptionInputParam;
46
47
  discounts?: DiscountsCreateForNewSubscriptionInputParam[];
47
48
  }
48
49
  export interface CreateForExistingSubscriptionInputParam {
@@ -50,6 +51,7 @@ declare module 'chargebee' {
50
51
  custom?: any;
51
52
  pricing_page?: PricingPageCreateForExistingSubscriptionInputParam;
52
53
  subscription?: SubscriptionCreateForExistingSubscriptionInputParam;
54
+ contract_term?: ContractTermCreateForExistingSubscriptionInputParam;
53
55
  discounts?: DiscountsCreateForExistingSubscriptionInputParam[];
54
56
  }
55
57
  export interface BillingAddressCreateForNewSubscriptionInputParam {
@@ -96,6 +98,10 @@ declare module 'chargebee' {
96
98
  country?: string;
97
99
  validation_status?: ValidationStatusEnum;
98
100
  }
101
+ export interface ContractTermCreateForNewSubscriptionInputParam {
102
+ action_at_term_end?: 'renew' | 'evergreen' | 'cancel' | 'renew_once';
103
+ cancellation_cutoff_period?: number;
104
+ }
99
105
  export interface SubscriptionCreateForNewSubscriptionInputParam {
100
106
  id?: string;
101
107
  }
@@ -115,6 +121,10 @@ declare module 'chargebee' {
115
121
  export interface PricingPageCreateForExistingSubscriptionInputParam {
116
122
  id?: string;
117
123
  }
124
+ export interface ContractTermCreateForExistingSubscriptionInputParam {
125
+ action_at_term_end?: 'renew' | 'evergreen' | 'cancel' | 'renew_once';
126
+ cancellation_cutoff_period?: number;
127
+ }
118
128
  export interface SubscriptionCreateForExistingSubscriptionInputParam {
119
129
  id: string;
120
130
  }
@@ -1120,6 +1120,8 @@ declare module 'chargebee' {
1120
1120
  start_date?: number;
1121
1121
  offline_payment_method?: OfflinePaymentMethodEnum;
1122
1122
  contract_term_billing_cycle_on_renewal?: number;
1123
+ free_period?: number;
1124
+ free_period_unit?: FreePeriodUnitEnum;
1123
1125
  }
1124
1126
 
1125
1127
  export interface SubscriptionItemsCreateSubItemsForCustomerQuoteInputParam {
@@ -1219,6 +1221,8 @@ declare module 'chargebee' {
1219
1221
  start_date?: number;
1220
1222
  offline_payment_method?: OfflinePaymentMethodEnum;
1221
1223
  contract_term_billing_cycle_on_renewal?: number;
1224
+ free_period?: number;
1225
+ free_period_unit?: FreePeriodUnitEnum;
1222
1226
  }
1223
1227
 
1224
1228
  export interface SubscriptionItemsEditCreateSubCustomerQuoteForItemsInputParam {
@@ -19,6 +19,8 @@ declare module 'chargebee' {
19
19
  plan_unit_price_in_decimal?: string;
20
20
  changes_scheduled_at?: number;
21
21
  change_option?: 'end_of_term' | 'specific_date' | 'immediately';
22
+ free_period?: number;
23
+ free_period_unit?: FreePeriodUnitEnum;
22
24
  contract_term_billing_cycle_on_renewal?: number;
23
25
  addons?: QuotedSubscription.Addon[];
24
26
  event_based_addons?: QuotedSubscription.EventBasedAddon[];
@@ -0,0 +1,47 @@
1
+ ///<reference path='./../core.d.ts'/>
2
+ ///<reference path='./../index.d.ts'/>
3
+ ///<reference path='./filter.d.ts'/>
4
+ declare module 'chargebee' {
5
+ export interface UsageCharge {
6
+ subscription_id: string;
7
+ feature_id: string;
8
+ included_usage?: string;
9
+ total_usage?: string;
10
+ on_demand_usage?: string;
11
+ metered_item_price_id?: string;
12
+ amount?: string;
13
+ currency_code?: string;
14
+ usage_from: number;
15
+ usage_to: number;
16
+ }
17
+
18
+ export namespace UsageCharge {
19
+ export class UsageChargeResource {
20
+ /**
21
+ * @deprecated This method is deprecated and will be removed in a future version.
22
+ */
23
+
24
+ retrieveUsageChargesForSubscription(
25
+ subscription_id: string,
26
+ input?: RetrieveUsageChargesForSubscriptionInputParam,
27
+ headers?: ChargebeeRequestHeader,
28
+ ): Promise<
29
+ ChargebeeResponse<RetrieveUsageChargesForSubscriptionResponse>
30
+ >;
31
+ }
32
+
33
+ export interface RetrieveUsageChargesForSubscriptionResponse {
34
+ list: { usage_charge: UsageCharge }[];
35
+ next_offset?: string;
36
+ }
37
+
38
+ // REQUEST PARAMS
39
+ //---------------
40
+
41
+ export interface RetrieveUsageChargesForSubscriptionInputParam {
42
+ limit?: number;
43
+ offset?: string;
44
+ feature_id?: filter.String;
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,45 @@
1
+ ///<reference path='./../core.d.ts'/>
2
+ ///<reference path='./../index.d.ts'/>
3
+ ///<reference path='./filter.d.ts'/>
4
+ declare module 'chargebee' {
5
+ export interface UsageSummary {
6
+ subscription_id: string;
7
+ feature_id: string;
8
+ aggregated_value: string;
9
+ aggregated_from: number;
10
+ aggregated_to: number;
11
+ }
12
+
13
+ export namespace UsageSummary {
14
+ export class UsageSummaryResource {
15
+ /**
16
+ * @deprecated This method is deprecated and will be removed in a future version.
17
+ */
18
+
19
+ retrieveUsageSummaryForSubscription(
20
+ subscription_id: string,
21
+ input: RetrieveUsageSummaryForSubscriptionInputParam,
22
+ headers?: ChargebeeRequestHeader,
23
+ ): Promise<
24
+ ChargebeeResponse<RetrieveUsageSummaryForSubscriptionResponse>
25
+ >;
26
+ }
27
+
28
+ export interface RetrieveUsageSummaryForSubscriptionResponse {
29
+ list: { usage_summary: UsageSummary }[];
30
+ next_offset?: string;
31
+ }
32
+
33
+ // REQUEST PARAMS
34
+ //---------------
35
+
36
+ export interface RetrieveUsageSummaryForSubscriptionInputParam {
37
+ limit?: number;
38
+ offset?: string;
39
+ feature_id: string;
40
+ window_size?: 'month' | 'week' | 'day' | 'hour' | 'minute';
41
+ timeframe_start?: number;
42
+ timeframe_end?: number;
43
+ }
44
+ }
45
+ }