chargebee 3.21.0 → 3.22.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 CHANGED
@@ -1,3 +1,39 @@
1
+ ### v3.22.0 (2026-03-02)
2
+ * * *
3
+ ### New Resources:
4
+ - [`UsageCharge`](https://apidocs.chargebee.com/docs/api/usage_charges) has been added.
5
+ - [`UsageSummary`](https://apidocs.chargebee.com/docs/api/usage_summaries) has been added.
6
+
7
+
8
+ ### New Attributes:
9
+ - [`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).
10
+ - [`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).
11
+
12
+
13
+ ### New Parameters:
14
+ - [`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).
15
+ - [`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).
16
+ - [`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).
17
+ - [`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).
18
+ - [`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).
19
+ - [`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).
20
+ - [`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).
21
+
22
+
23
+ ### New Enums:
24
+ - `month`, `week`, `day`, `hour`, and `minute` have been added as new values enum `WindowSize`.
25
+ - `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).
26
+ - `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).
27
+
28
+
29
+
30
+ ### v3.21.1 (2026-02-20)
31
+ * * *
32
+
33
+ ### Core Changes:
34
+
35
+ - Added new core utility method.
36
+
1
37
  ### v3.21.0 (2026-02-11)
2
38
  * * *
3
39
 
package/README.md CHANGED
@@ -20,6 +20,16 @@ If you're upgrading from an older version of [`chargebee-typescript`](https://ww
20
20
 
21
21
  Node.js 18 or higher.
22
22
 
23
+ ## Runtime Support
24
+
25
+ This SDK supports multiple JavaScript runtimes:
26
+
27
+ - **Node.js** 18+
28
+ - **Deno**
29
+ - **Bun**
30
+ - **Cloudflare Workers**
31
+ - **Edge Runtimes** (e.g., Vercel Edge, Netlify Edge Functions)
32
+
23
33
  ## Installation
24
34
 
25
35
  Install the library with npm:
@@ -37,6 +47,16 @@ With yarn:
37
47
  yarn add chargebee
38
48
  ```
39
49
 
50
+ With bun:
51
+ ```sh
52
+ bun add chargebee
53
+ ```
54
+
55
+ With deno:
56
+ ```sh
57
+ deno add npm:chargebee
58
+ ```
59
+
40
60
  ## Usage
41
61
 
42
62
  The package needs to be configured with your site's API key, which is available under Configure Chargebee Section. Refer [here](https://www.chargebee.com/docs/2.0/api_keys.html) for more details.
@@ -63,6 +83,34 @@ const chargebee = new Chargebee({
63
83
  });
64
84
  ```
65
85
 
86
+ ### Using Deno:
87
+
88
+ ```typescript
89
+ import Chargebee from "npm:chargebee";
90
+
91
+ const chargebee = new Chargebee({
92
+ site: "{{site}}",
93
+ apiKey: "{{api-key}}",
94
+ });
95
+
96
+ const response = await chargebee.customer.list();
97
+ console.log(response);
98
+ ```
99
+
100
+ ### Using Bun:
101
+
102
+ ```typescript
103
+ import Chargebee from "chargebee";
104
+
105
+ const chargebee = new Chargebee({
106
+ site: "{{site}}",
107
+ apiKey: "{{api-key}}",
108
+ });
109
+
110
+ const response = await chargebee.customer.list();
111
+ console.log(response);
112
+ ```
113
+
66
114
  ### Using Async / Await
67
115
 
68
116
  ```typescript
@@ -159,6 +207,7 @@ The simplest way to handle webhooks is using the `webhooks` property on your ini
159
207
  ```typescript
160
208
  import express from 'express';
161
209
  import Chargebee, {
210
+ WebhookEventType,
162
211
  AuthenticationError,
163
212
  PayloadValidationError,
164
213
  PayloadParseError,
@@ -173,7 +222,7 @@ const app = express();
173
222
  app.use(express.json());
174
223
 
175
224
  // ⚠️ Register listeners once at startup, not inside request handlers
176
- chargebee.webhooks.on('subscription_created', async ({ event, response }) => {
225
+ chargebee.webhooks.on(WebhookEventType.SubscriptionCreated, async ({ event, response }) => {
177
226
  console.log(`Subscription created: ${event.id}`);
178
227
  const subscription = event.content.subscription;
179
228
  console.log(`Customer: ${subscription.customer_id}`);
@@ -217,6 +266,7 @@ For more control or multiple webhook endpoints, use `chargebee.webhooks.createHa
217
266
  ```typescript
218
267
  import express, { Request, Response } from 'express';
219
268
  import Chargebee, {
269
+ WebhookEventType,
220
270
  basicAuthValidator,
221
271
  AuthenticationError,
222
272
  PayloadValidationError,
@@ -240,7 +290,7 @@ handler.requestValidator = basicAuthValidator((username, password) => {
240
290
  });
241
291
 
242
292
  // ⚠️ Register event listeners once at startup, not inside request handlers
243
- handler.on('subscription_created', async ({ event, response }) => {
293
+ handler.on(WebhookEventType.SubscriptionCreated, async ({ event, response }) => {
244
294
  console.log(`Subscription created: ${event.id}`);
245
295
  const subscription = event.content.subscription;
246
296
  console.log(`Customer: ${subscription.customer_id}`);
@@ -248,7 +298,7 @@ handler.on('subscription_created', async ({ event, response }) => {
248
298
  response?.status(200).send('OK');
249
299
  });
250
300
 
251
- handler.on('payment_succeeded', async ({ event, response }) => {
301
+ handler.on(WebhookEventType.PaymentSucceeded, async ({ event, response }) => {
252
302
  console.log(`Payment succeeded: ${event.id}`);
253
303
  const transaction = event.content.transaction;
254
304
  const customer = event.content.customer;
@@ -285,7 +335,7 @@ For more control, you can parse webhook events manually:
285
335
 
286
336
  ```typescript
287
337
  import express from 'express';
288
- import Chargebee, { type WebhookEvent } from 'chargebee';
338
+ import Chargebee, { type WebhookEvent, WebhookEventType } from 'chargebee';
289
339
 
290
340
  const app = express();
291
341
  app.use(express.json());
@@ -293,23 +343,27 @@ app.use(express.json());
293
343
  app.post('/chargebee/webhooks', async (req, res) => {
294
344
  try {
295
345
  const event = req.body as WebhookEvent;
296
-
346
+
297
347
  switch (event.event_type) {
298
- case 'subscription_created':
299
- // Access event content with proper typing
300
- const subscription = event.content.subscription;
348
+ case WebhookEventType.SubscriptionCreated: {
349
+ // Cast to specific event type for proper content typing
350
+ const typedEvent = event as WebhookEvent<WebhookEventType.SubscriptionCreated>;
351
+ const subscription = typedEvent.content.subscription;
301
352
  console.log('Subscription created:', subscription.id);
302
353
  break;
303
-
304
- case 'payment_succeeded':
305
- const transaction = event.content.transaction;
354
+ }
355
+
356
+ case WebhookEventType.PaymentSucceeded: {
357
+ const typedEvent = event as WebhookEvent<WebhookEventType.PaymentSucceeded>;
358
+ const transaction = typedEvent.content.transaction;
306
359
  console.log('Payment succeeded:', transaction.amount);
307
360
  break;
308
-
361
+ }
362
+
309
363
  default:
310
364
  console.log('Unhandled event type:', event.event_type);
311
365
  }
312
-
366
+
313
367
  res.status(200).send('OK');
314
368
  } catch (err) {
315
369
  console.error('Error processing webhook:', err);
@@ -327,7 +381,7 @@ app.listen(8080);
327
381
  **Respond with 200** to acknowledge receipt:
328
382
 
329
383
  ```typescript
330
- handler.on('subscription_created', async ({ event, response }) => {
384
+ handler.on(WebhookEventType.SubscriptionCreated, async ({ event, response }) => {
331
385
  await provisionAccess(event.content.subscription);
332
386
  response?.status(200).json({ received: true });
333
387
  });
@@ -336,7 +390,7 @@ handler.on('subscription_created', async ({ event, response }) => {
336
390
  **Respond with 5xx** so Chargebee retries on failure:
337
391
 
338
392
  ```typescript
339
- handler.on('payment_succeeded', async ({ event, response }) => {
393
+ handler.on(WebhookEventType.PaymentSucceeded, async ({ event, response }) => {
340
394
  try {
341
395
  await recordPayment(event.content.transaction);
342
396
  response?.status(200).send('OK');
@@ -349,7 +403,7 @@ handler.on('payment_succeeded', async ({ event, response }) => {
349
403
  **Access request context** (headers, middleware data):
350
404
 
351
405
  ```typescript
352
- handler.on('customer_created', async ({ event, request, response }) => {
406
+ handler.on(WebhookEventType.CustomerCreated, async ({ event, request, response }) => {
353
407
  const tenantId = (request as any)?.tenant?.id;
354
408
  await createCustomerForTenant(tenantId, event.content.customer);
355
409
  response?.status(200).send('OK');
@@ -18,6 +18,9 @@ const CreateChargebee = (httpClient) => {
18
18
  this._endpoints = api_endpoints_js_1.Endpoints;
19
19
  // Initialize webhooks handler with auto-configured Basic Auth (if env vars are set)
20
20
  const handler = (0, handler_js_1.createDefaultHandler)();
21
+ this.__clientIdentifier = (serviceName) => {
22
+ (0, util_js_1.extend)(true, this._env, { userAgentSuffix: serviceName });
23
+ };
21
24
  // Create webhooks namespace with handler methods + createHandler factory
22
25
  this.webhooks = Object.assign(handler, {
23
26
  createHandler(options) {
@@ -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.0',
14
+ clientVersion: 'v3.22.0',
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: [],
@@ -15,6 +15,9 @@ export const CreateChargebee = (httpClient) => {
15
15
  this._endpoints = Endpoints;
16
16
  // Initialize webhooks handler with auto-configured Basic Auth (if env vars are set)
17
17
  const handler = createDefaultHandler();
18
+ this.__clientIdentifier = (serviceName) => {
19
+ extend(true, this._env, { userAgentSuffix: serviceName });
20
+ };
18
21
  // Create webhooks namespace with handler methods + createHandler factory
19
22
  this.webhooks = Object.assign(handler, {
20
23
  createHandler(options) {
@@ -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.0',
11
+ clientVersion: 'v3.22.0',
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.0",
3
+ "version": "3.22.0",
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
+ }