chargebee 3.28.1 → 3.30.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.
Files changed (97) hide show
  1. package/CHANGELOG.md +140 -0
  2. package/cjs/chargebee.cjs.js +1 -1
  3. package/cjs/environment.js +1 -1
  4. package/cjs/resources/api_endpoints.js +126 -0
  5. package/cjs/resources/webhook/eventType.js +5 -0
  6. package/cjs/schema/alert.schema.js +11 -5
  7. package/cjs/schema/coupon.schema.js +1 -1
  8. package/cjs/schema/credit_note.schema.js +13 -0
  9. package/cjs/schema/credit_unit.schema.js +38 -0
  10. package/cjs/schema/customer.schema.js +39 -0
  11. package/cjs/schema/entitlement.schema.js +4 -4
  12. package/cjs/schema/estimate.schema.js +18 -0
  13. package/cjs/schema/event.schema.js +20 -0
  14. package/cjs/schema/export.schema.js +33 -1
  15. package/cjs/schema/feature.schema.js +0 -1
  16. package/cjs/schema/gift.schema.js +14 -0
  17. package/cjs/schema/grant_block.schema.js +4 -0
  18. package/cjs/schema/index.js +1 -0
  19. package/cjs/schema/invoice.schema.js +63 -3
  20. package/cjs/schema/ledger_operation.schema.js +14 -4
  21. package/cjs/schema/meter.schema.js +10 -0
  22. package/cjs/schema/omnichannel_subscription.schema.js +2 -2
  23. package/cjs/schema/payment_intent.schema.js +14 -0
  24. package/cjs/schema/payment_source.schema.js +49 -0
  25. package/cjs/schema/purchase.schema.js +7 -0
  26. package/cjs/schema/ramp.schema.js +4 -2
  27. package/cjs/schema/recorded_purchase.schema.js +3 -0
  28. package/cjs/schema/subscription.schema.js +94 -0
  29. package/cjs/schema/transaction.schema.js +32 -0
  30. package/cjs/schema/webhook_endpoint.schema.js +10 -0
  31. package/cjs/telemetry/TelemetryAdapter.js +12 -7
  32. package/esm/environment.js +1 -1
  33. package/esm/resources/api_endpoints.js +126 -0
  34. package/esm/resources/webhook/eventType.js +5 -0
  35. package/esm/schema/alert.schema.js +11 -5
  36. package/esm/schema/coupon.schema.js +1 -1
  37. package/esm/schema/credit_note.schema.js +13 -0
  38. package/esm/schema/credit_unit.schema.js +35 -0
  39. package/esm/schema/customer.schema.js +39 -0
  40. package/esm/schema/entitlement.schema.js +4 -4
  41. package/esm/schema/estimate.schema.js +18 -0
  42. package/esm/schema/event.schema.js +20 -0
  43. package/esm/schema/export.schema.js +33 -1
  44. package/esm/schema/feature.schema.js +0 -1
  45. package/esm/schema/gift.schema.js +14 -0
  46. package/esm/schema/grant_block.schema.js +4 -0
  47. package/esm/schema/index.js +1 -0
  48. package/esm/schema/invoice.schema.js +63 -3
  49. package/esm/schema/ledger_operation.schema.js +13 -3
  50. package/esm/schema/meter.schema.js +10 -0
  51. package/esm/schema/omnichannel_subscription.schema.js +2 -2
  52. package/esm/schema/payment_intent.schema.js +14 -0
  53. package/esm/schema/payment_source.schema.js +49 -0
  54. package/esm/schema/purchase.schema.js +7 -0
  55. package/esm/schema/ramp.schema.js +4 -2
  56. package/esm/schema/recorded_purchase.schema.js +3 -0
  57. package/esm/schema/subscription.schema.js +94 -0
  58. package/esm/schema/transaction.schema.js +32 -0
  59. package/esm/schema/webhook_endpoint.schema.js +10 -0
  60. package/esm/telemetry/TelemetryAdapter.js +12 -7
  61. package/package.json +1 -1
  62. package/types/core.d.ts +65 -6
  63. package/types/index.d.ts +15 -8
  64. package/types/resources/Alert.d.ts +18 -3
  65. package/types/resources/AsyncResponse.d.ts +35 -0
  66. package/types/resources/AsyncResponseList.d.ts +8 -0
  67. package/types/resources/AttachedItem.d.ts +2 -2
  68. package/types/resources/ColumnDefinition.d.ts +9 -0
  69. package/types/resources/Content.d.ts +7 -0
  70. package/types/resources/CreditNote.d.ts +15 -0
  71. package/types/resources/CreditNoteEstimate.d.ts +5 -0
  72. package/types/resources/CreditUnit.d.ts +90 -0
  73. package/types/resources/Customer.d.ts +16 -2
  74. package/types/resources/Estimate.d.ts +20 -2
  75. package/types/resources/Event.d.ts +5 -0
  76. package/types/resources/Export.d.ts +1 -0
  77. package/types/resources/Feature.d.ts +2 -0
  78. package/types/resources/Gift.d.ts +16 -2
  79. package/types/resources/GrantBlock.d.ts +12 -6
  80. package/types/resources/Invoice.d.ts +41 -3
  81. package/types/resources/InvoiceEstimate.d.ts +5 -0
  82. package/types/resources/LedgerAccountBalance.d.ts +3 -1
  83. package/types/resources/LedgerEntry.d.ts +22 -0
  84. package/types/resources/LedgerOperation.d.ts +34 -9
  85. package/types/resources/Meter.d.ts +42 -0
  86. package/types/resources/MeteredFeature.d.ts +70 -0
  87. package/types/resources/PaymentIntent.d.ts +57 -5
  88. package/types/resources/PaymentSource.d.ts +8 -1
  89. package/types/resources/PromotionalGrant.d.ts +1 -1
  90. package/types/resources/Purchase.d.ts +8 -1
  91. package/types/resources/Quote.d.ts +5 -0
  92. package/types/resources/QuoteLineGroup.d.ts +5 -0
  93. package/types/resources/QuotedCharge.d.ts +3 -0
  94. package/types/resources/Ramp.d.ts +4 -1
  95. package/types/resources/RecordedPurchase.d.ts +3 -0
  96. package/types/resources/Subscription.d.ts +58 -7
  97. package/types/resources/WebhookEvent.d.ts +33 -0
@@ -85,6 +85,7 @@ const CreateForSubscriptionRampDiscountsToAddSchema = zod_1.z.object({
85
85
  duration_type: zod_1.z.array(zod_1.z.enum(['one_time', 'forever', 'limited_period']).optional()),
86
86
  percentage: zod_1.z.array(zod_1.z.number().min(0.01).max(100).optional()).optional(),
87
87
  amount: zod_1.z.array(zod_1.z.number().int().min(0).optional()).optional(),
88
+ quantity: zod_1.z.array(zod_1.z.number().int().min(1).optional()).optional(),
88
89
  period: zod_1.z.array(zod_1.z.number().int().min(1).optional()).optional(),
89
90
  period_unit: zod_1.z
90
91
  .array(zod_1.z.enum(['day', 'week', 'month', 'year']).optional())
@@ -186,6 +187,7 @@ const UpdateRampDiscountsToAddSchema = zod_1.z.object({
186
187
  duration_type: zod_1.z.array(zod_1.z.enum(['one_time', 'forever', 'limited_period']).optional()),
187
188
  percentage: zod_1.z.array(zod_1.z.number().min(0.01).max(100).optional()).optional(),
188
189
  amount: zod_1.z.array(zod_1.z.number().int().min(0).optional()).optional(),
190
+ quantity: zod_1.z.array(zod_1.z.number().int().min(1).optional()).optional(),
189
191
  period: zod_1.z.array(zod_1.z.number().int().min(1).optional()).optional(),
190
192
  period_unit: zod_1.z
191
193
  .array(zod_1.z.enum(['day', 'week', 'month', 'year']).optional())
@@ -209,12 +211,12 @@ const UpdateRampBodySchema = zod_1.z.looseObject({
209
211
  exports.UpdateRampBodySchema = UpdateRampBodySchema;
210
212
  //Ramp.list
211
213
  const ListRampStatusSchema = zod_1.z.object({
212
- is: zod_1.z.enum(['scheduled', 'succeeded', 'failed', 'draft']).optional(),
213
214
  in: zod_1.z.enum(['scheduled', 'succeeded', 'failed', 'draft']).optional(),
215
+ is: zod_1.z.enum(['scheduled', 'succeeded', 'failed', 'draft']).optional(),
214
216
  });
215
217
  const ListRampSubscriptionIdSchema = zod_1.z.object({
216
- is: zod_1.z.string().min(1).optional(),
217
218
  in: zod_1.z.string().regex(RegExp('^\\[(.*)(,.*)*\\]$')).optional(),
219
+ is: zod_1.z.string().min(1).optional(),
218
220
  });
219
221
  const ListRampEffectiveFromSchema = zod_1.z.object({
220
222
  after: zod_1.z.string().regex(RegExp('^\\d{10}$')).optional(),
@@ -8,6 +8,9 @@ const zod_1 = require("zod");
8
8
  //RecordedPurchase.create
9
9
  const CreateRecordedPurchaseCustomerSchema = zod_1.z.object({
10
10
  id: zod_1.z.string().max(50),
11
+ email: zod_1.z.string().email().max(70).optional(),
12
+ first_name: zod_1.z.string().max(150).optional(),
13
+ last_name: zod_1.z.string().max(150).optional(),
11
14
  });
12
15
  const CreateRecordedPurchaseAppleAppStoreSchema = zod_1.z.object({
13
16
  transaction_id: zod_1.z.string().max(100).optional(),
@@ -235,6 +235,13 @@ const CreateSubscriptionPaymentMethodSchema = zod_1.z.object({
235
235
  'paypay',
236
236
  'gcash',
237
237
  'south_korean_cards',
238
+ 'paynow',
239
+ 'bizum',
240
+ 'promptpay',
241
+ 'dana',
242
+ 'touch_n_go',
243
+ 'tamara',
244
+ 'qpay',
238
245
  ])
239
246
  .optional(),
240
247
  gateway: zod_1.z
@@ -357,6 +364,13 @@ const CreateSubscriptionPaymentIntentSchema = zod_1.z.object({
357
364
  'paypay',
358
365
  'gcash',
359
366
  'south_korean_cards',
367
+ 'paynow',
368
+ 'bizum',
369
+ 'promptpay',
370
+ 'dana',
371
+ 'touch_n_go',
372
+ 'tamara',
373
+ 'qpay',
360
374
  ])
361
375
  .optional(),
362
376
  reference_id: zod_1.z.string().max(65000).optional(),
@@ -588,6 +602,13 @@ const CreateForCustomerSubscriptionPaymentIntentSchema = zod_1.z.object({
588
602
  'paypay',
589
603
  'gcash',
590
604
  'south_korean_cards',
605
+ 'paynow',
606
+ 'bizum',
607
+ 'promptpay',
608
+ 'dana',
609
+ 'touch_n_go',
610
+ 'tamara',
611
+ 'qpay',
591
612
  ])
592
613
  .optional(),
593
614
  reference_id: zod_1.z.string().max(65000).optional(),
@@ -779,6 +800,13 @@ const CreateWithItemsSubscriptionPaymentIntentSchema = zod_1.z.object({
779
800
  'paypay',
780
801
  'gcash',
781
802
  'south_korean_cards',
803
+ 'paynow',
804
+ 'bizum',
805
+ 'promptpay',
806
+ 'dana',
807
+ 'touch_n_go',
808
+ 'tamara',
809
+ 'qpay',
782
810
  ])
783
811
  .optional(),
784
812
  reference_id: zod_1.z.string().max(65000).optional(),
@@ -1189,6 +1217,9 @@ const ListSubscriptionChannelSchema = zod_1.z.object({
1189
1217
  in: zod_1.z.enum(['web', 'app_store', 'play_store']).optional(),
1190
1218
  not_in: zod_1.z.enum(['web', 'app_store', 'play_store']).optional(),
1191
1219
  });
1220
+ const ListSubscriptionDecommissionedSchema = zod_1.z.object({
1221
+ is: zod_1.z.enum(['true', 'false']).optional(),
1222
+ });
1192
1223
  const ListSubscriptionPlanIdSchema = zod_1.z.object({
1193
1224
  is: zod_1.z.string().min(1).optional(),
1194
1225
  is_not: zod_1.z.string().min(1).optional(),
@@ -1220,6 +1251,7 @@ const ListSubscriptionBodySchema = zod_1.z.looseObject({
1220
1251
  sort_by: ListSubscriptionSortBySchema.optional(),
1221
1252
  business_entity_id: ListSubscriptionBusinessEntityIdSchema.optional(),
1222
1253
  channel: ListSubscriptionChannelSchema.optional(),
1254
+ decommissioned: ListSubscriptionDecommissionedSchema.optional(),
1223
1255
  plan_id: ListSubscriptionPlanIdSchema.optional(),
1224
1256
  });
1225
1257
  exports.ListSubscriptionBodySchema = ListSubscriptionBodySchema;
@@ -1405,6 +1437,13 @@ const UpdateSubscriptionPaymentMethodSchema = zod_1.z.object({
1405
1437
  'paypay',
1406
1438
  'gcash',
1407
1439
  'south_korean_cards',
1440
+ 'paynow',
1441
+ 'bizum',
1442
+ 'promptpay',
1443
+ 'dana',
1444
+ 'touch_n_go',
1445
+ 'tamara',
1446
+ 'qpay',
1408
1447
  ])
1409
1448
  .optional(),
1410
1449
  gateway: zod_1.z
@@ -1527,6 +1566,13 @@ const UpdateSubscriptionPaymentIntentSchema = zod_1.z.object({
1527
1566
  'paypay',
1528
1567
  'gcash',
1529
1568
  'south_korean_cards',
1569
+ 'paynow',
1570
+ 'bizum',
1571
+ 'promptpay',
1572
+ 'dana',
1573
+ 'touch_n_go',
1574
+ 'tamara',
1575
+ 'qpay',
1530
1576
  ])
1531
1577
  .optional(),
1532
1578
  reference_id: zod_1.z.string().max(65000).optional(),
@@ -1847,6 +1893,13 @@ const UpdateForItemsSubscriptionPaymentMethodSchema = zod_1.z.object({
1847
1893
  'paypay',
1848
1894
  'gcash',
1849
1895
  'south_korean_cards',
1896
+ 'paynow',
1897
+ 'bizum',
1898
+ 'promptpay',
1899
+ 'dana',
1900
+ 'touch_n_go',
1901
+ 'tamara',
1902
+ 'qpay',
1850
1903
  ])
1851
1904
  .optional(),
1852
1905
  gateway: zod_1.z
@@ -1969,6 +2022,13 @@ const UpdateForItemsSubscriptionPaymentIntentSchema = zod_1.z.object({
1969
2022
  'paypay',
1970
2023
  'gcash',
1971
2024
  'south_korean_cards',
2025
+ 'paynow',
2026
+ 'bizum',
2027
+ 'promptpay',
2028
+ 'dana',
2029
+ 'touch_n_go',
2030
+ 'tamara',
2031
+ 'qpay',
1972
2032
  ])
1973
2033
  .optional(),
1974
2034
  reference_id: zod_1.z.string().max(65000).optional(),
@@ -2252,6 +2312,13 @@ const ReactivateSubscriptionPaymentIntentSchema = zod_1.z.object({
2252
2312
  'paypay',
2253
2313
  'gcash',
2254
2314
  'south_korean_cards',
2315
+ 'paynow',
2316
+ 'bizum',
2317
+ 'promptpay',
2318
+ 'dana',
2319
+ 'touch_n_go',
2320
+ 'tamara',
2321
+ 'qpay',
2255
2322
  ])
2256
2323
  .optional(),
2257
2324
  reference_id: zod_1.z.string().max(65000).optional(),
@@ -2558,6 +2625,13 @@ const ImportSubscriptionSubscriptionPaymentMethodSchema = zod_1.z.object({
2558
2625
  'paypay',
2559
2626
  'gcash',
2560
2627
  'south_korean_cards',
2628
+ 'paynow',
2629
+ 'bizum',
2630
+ 'promptpay',
2631
+ 'dana',
2632
+ 'touch_n_go',
2633
+ 'tamara',
2634
+ 'qpay',
2561
2635
  ])
2562
2636
  .optional(),
2563
2637
  gateway: zod_1.z
@@ -2675,6 +2749,10 @@ const ImportSubscriptionSubscriptionTransactionSchema = zod_1.z.object({
2675
2749
  'app_store',
2676
2750
  'play_store',
2677
2751
  'custom',
2752
+ 'dana',
2753
+ 'touch_n_go',
2754
+ 'tamara',
2755
+ 'qpay',
2678
2756
  ])
2679
2757
  .optional(),
2680
2758
  reference_number: zod_1.z.string().max(100).optional(),
@@ -2798,6 +2876,10 @@ const ImportForCustomerSubscriptionTransactionSchema = zod_1.z.object({
2798
2876
  'app_store',
2799
2877
  'play_store',
2800
2878
  'custom',
2879
+ 'dana',
2880
+ 'touch_n_go',
2881
+ 'tamara',
2882
+ 'qpay',
2801
2883
  ])
2802
2884
  .optional(),
2803
2885
  reference_number: zod_1.z.string().max(100).optional(),
@@ -3022,6 +3104,10 @@ const ImportForItemsSubscriptionTransactionSchema = zod_1.z.object({
3022
3104
  'app_store',
3023
3105
  'play_store',
3024
3106
  'custom',
3107
+ 'dana',
3108
+ 'touch_n_go',
3109
+ 'tamara',
3110
+ 'qpay',
3025
3111
  ])
3026
3112
  .optional(),
3027
3113
  reference_number: zod_1.z.string().max(100).optional(),
@@ -3259,6 +3345,7 @@ const CancelForItemsSubscriptionBodySchema = zod_1.z.looseObject({
3259
3345
  ])
3260
3346
  .optional(),
3261
3347
  invoice_date: zod_1.z.number().int().optional(),
3348
+ include_cancellation_day_in_billing: zod_1.z.boolean().optional(),
3262
3349
  cancel_reason_code: zod_1.z.string().max(100).optional(),
3263
3350
  decommissioned: zod_1.z.boolean().default(false).optional(),
3264
3351
  subscription_items: CancelForItemsSubscriptionSubscriptionItemsSchema.optional(),
@@ -3317,6 +3404,13 @@ const ResumeSubscriptionPaymentIntentSchema = zod_1.z.object({
3317
3404
  'paypay',
3318
3405
  'gcash',
3319
3406
  'south_korean_cards',
3407
+ 'paynow',
3408
+ 'bizum',
3409
+ 'promptpay',
3410
+ 'dana',
3411
+ 'touch_n_go',
3412
+ 'tamara',
3413
+ 'qpay',
3320
3414
  ])
3321
3415
  .optional(),
3322
3416
  reference_id: zod_1.z.string().max(65000).optional(),
@@ -25,6 +25,10 @@ const RecordRefundTransactionBodySchema = zod_1.z.looseObject({
25
25
  'app_store',
26
26
  'play_store',
27
27
  'custom',
28
+ 'dana',
29
+ 'touch_n_go',
30
+ 'tamara',
31
+ 'qpay',
28
32
  ]),
29
33
  date: zod_1.z.number().int(),
30
34
  reference_number: zod_1.z.string().max(100).optional(),
@@ -137,6 +141,13 @@ const ListTransactionPaymentMethodSchema = zod_1.z.object({
137
141
  'paypay',
138
142
  'gcash',
139
143
  'south_korean_cards',
144
+ 'paynow',
145
+ 'bizum',
146
+ 'promptpay',
147
+ 'dana',
148
+ 'touch_n_go',
149
+ 'tamara',
150
+ 'qpay',
140
151
  ])
141
152
  .optional(),
142
153
  is_not: zod_1.z
@@ -198,6 +209,13 @@ const ListTransactionPaymentMethodSchema = zod_1.z.object({
198
209
  'paypay',
199
210
  'gcash',
200
211
  'south_korean_cards',
212
+ 'paynow',
213
+ 'bizum',
214
+ 'promptpay',
215
+ 'dana',
216
+ 'touch_n_go',
217
+ 'tamara',
218
+ 'qpay',
201
219
  ])
202
220
  .optional(),
203
221
  in: zod_1.z
@@ -259,6 +277,13 @@ const ListTransactionPaymentMethodSchema = zod_1.z.object({
259
277
  'paypay',
260
278
  'gcash',
261
279
  'south_korean_cards',
280
+ 'paynow',
281
+ 'bizum',
282
+ 'promptpay',
283
+ 'dana',
284
+ 'touch_n_go',
285
+ 'tamara',
286
+ 'qpay',
262
287
  ])
263
288
  .optional(),
264
289
  not_in: zod_1.z
@@ -320,6 +345,13 @@ const ListTransactionPaymentMethodSchema = zod_1.z.object({
320
345
  'paypay',
321
346
  'gcash',
322
347
  'south_korean_cards',
348
+ 'paynow',
349
+ 'bizum',
350
+ 'promptpay',
351
+ 'dana',
352
+ 'touch_n_go',
353
+ 'tamara',
354
+ 'qpay',
323
355
  ])
324
356
  .optional(),
325
357
  });
@@ -182,6 +182,7 @@ const CreateWebhookEndpointBodySchema = zod_1.z.looseObject({
182
182
  'business_entity_deleted',
183
183
  'customer_business_entity_changed',
184
184
  'subscription_business_entity_changed',
185
+ 'payment_source_business_entity_changed',
185
186
  'purchase_created',
186
187
  'voucher_created',
187
188
  'voucher_expired',
@@ -243,6 +244,10 @@ const CreateWebhookEndpointBodySchema = zod_1.z.looseObject({
243
244
  'alert_status_changed',
244
245
  'omnichannel_subscription_item_updated',
245
246
  'omnichannel_subscription_item_recovered',
247
+ 'ledger_account_balance_updated',
248
+ 'grant_blocks_created',
249
+ 'grant_blocks_updated',
250
+ 'ledger_updated',
246
251
  'plan_created',
247
252
  'plan_updated',
248
253
  'plan_deleted',
@@ -428,6 +433,7 @@ const UpdateWebhookEndpointBodySchema = zod_1.z.looseObject({
428
433
  'business_entity_deleted',
429
434
  'customer_business_entity_changed',
430
435
  'subscription_business_entity_changed',
436
+ 'payment_source_business_entity_changed',
431
437
  'purchase_created',
432
438
  'voucher_created',
433
439
  'voucher_expired',
@@ -489,6 +495,10 @@ const UpdateWebhookEndpointBodySchema = zod_1.z.looseObject({
489
495
  'alert_status_changed',
490
496
  'omnichannel_subscription_item_updated',
491
497
  'omnichannel_subscription_item_recovered',
498
+ 'ledger_account_balance_updated',
499
+ 'grant_blocks_created',
500
+ 'grant_blocks_updated',
501
+ 'ledger_updated',
492
502
  'plan_created',
493
503
  'plan_updated',
494
504
  'plan_deleted',
@@ -70,16 +70,16 @@ function buildRequestEndSpanAttributes(result) {
70
70
  [types_js_1.TelemetryAttributeKeys.HTTP_RESPONSE_STATUS_CODE]: result.httpStatusCode,
71
71
  };
72
72
  if (result.error) {
73
- // error.type is the status code on failed requests
74
- attributes[types_js_1.TelemetryAttributeKeys.ERROR_TYPE] = String(result.httpStatusCode);
75
- if (result.error.chargebeeErrorCode) {
76
- attributes[types_js_1.TelemetryAttributeKeys.CHARGEBEE_ERROR_CODE] =
77
- result.error.chargebeeErrorCode;
78
- }
79
73
  if (result.error.chargebeeApiErrorType) {
74
+ attributes[types_js_1.TelemetryAttributeKeys.ERROR_TYPE] =
75
+ result.error.chargebeeApiErrorType;
80
76
  attributes[types_js_1.TelemetryAttributeKeys.CHARGEBEE_ERROR_TYPE] =
81
77
  result.error.chargebeeApiErrorType;
82
78
  }
79
+ if (result.error.chargebeeErrorCode) {
80
+ attributes[types_js_1.TelemetryAttributeKeys.CHARGEBEE_ERROR_CODE] =
81
+ result.error.chargebeeErrorCode;
82
+ }
83
83
  if (result.error.chargebeeErrorParam) {
84
84
  attributes[types_js_1.TelemetryAttributeKeys.CHARGEBEE_ERROR_PARAM] =
85
85
  result.error.chargebeeErrorParam;
@@ -107,12 +107,17 @@ function buildRequestTelemetryResult(result) {
107
107
  }
108
108
  function extractRequestTelemetryError(err) {
109
109
  if (err == null || typeof err !== 'object') {
110
+ if (err instanceof Error) {
111
+ return { message: err.message };
112
+ }
110
113
  return undefined;
111
114
  }
112
115
  const errorObj = err;
113
116
  const message = typeof errorObj.message === 'string'
114
117
  ? errorObj.message
115
- : 'Chargebee API request failed';
118
+ : err instanceof Error
119
+ ? err.message
120
+ : 'Chargebee API request failed';
116
121
  const result = { message };
117
122
  if (typeof errorObj.api_error_code === 'string') {
118
123
  result.chargebeeErrorCode = errorObj.api_error_code;
@@ -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.28.1',
11
+ clientVersion: 'v3.30.0',
12
12
  port: DEFAULT_PORT,
13
13
  timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT,
14
14
  exportWaitInMillis: DEFAULT_EXPORT_WAIT,
@@ -1,4 +1,6 @@
1
1
  export const Endpoints = {
2
+ asyncResponseList: [],
3
+ asyncResponse: [],
2
4
  subscription: [
3
5
  [
4
6
  'create',
@@ -4227,6 +4229,61 @@ export const Endpoints = {
4227
4229
  impactedItem: [],
4228
4230
  impactedItemPrice: [],
4229
4231
  metadata: [],
4232
+ creditUnit: [
4233
+ ['list', 'GET', '/credit_units', null, false, null, false, {}, {}],
4234
+ [
4235
+ 'create',
4236
+ 'POST',
4237
+ '/credit_units',
4238
+ null,
4239
+ false,
4240
+ null,
4241
+ false,
4242
+ {},
4243
+ {
4244
+ isIdempotent: true,
4245
+ },
4246
+ ],
4247
+ [
4248
+ 'update',
4249
+ 'POST',
4250
+ '/credit_units',
4251
+ null,
4252
+ true,
4253
+ null,
4254
+ false,
4255
+ {},
4256
+ {
4257
+ isIdempotent: true,
4258
+ },
4259
+ ],
4260
+ [
4261
+ 'archive',
4262
+ 'POST',
4263
+ '/credit_units',
4264
+ '/archive_command',
4265
+ true,
4266
+ null,
4267
+ false,
4268
+ {},
4269
+ {
4270
+ isIdempotent: true,
4271
+ },
4272
+ ],
4273
+ [
4274
+ 'reactivate',
4275
+ 'POST',
4276
+ '/credit_units',
4277
+ '/reactivate_command',
4278
+ true,
4279
+ null,
4280
+ false,
4281
+ {},
4282
+ {
4283
+ isIdempotent: true,
4284
+ },
4285
+ ],
4286
+ ],
4230
4287
  subscriptionEntitlement: [
4231
4288
  [
4232
4289
  'subscriptionEntitlementsForSubscription',
@@ -4797,6 +4854,7 @@ export const Endpoints = {
4797
4854
  ],
4798
4855
  omnichannelOneTimeOrderItem: [],
4799
4856
  rule: [['retrieve', 'GET', '/rules', null, true, null, false, {}, {}]],
4857
+ meter: [['list', 'GET', '/meters', null, false, null, false, {}, {}]],
4800
4858
  usageEvent: [
4801
4859
  [
4802
4860
  'create',
@@ -4825,6 +4883,60 @@ export const Endpoints = {
4825
4883
  {},
4826
4884
  ],
4827
4885
  ],
4886
+ meteredFeature: [
4887
+ [
4888
+ 'create',
4889
+ 'POST',
4890
+ '/metered_features',
4891
+ null,
4892
+ false,
4893
+ null,
4894
+ false,
4895
+ {},
4896
+ {
4897
+ isIdempotent: true,
4898
+ },
4899
+ ],
4900
+ [
4901
+ 'archive',
4902
+ 'POST',
4903
+ '/metered_features',
4904
+ '/archive_command',
4905
+ true,
4906
+ null,
4907
+ false,
4908
+ {},
4909
+ {
4910
+ isIdempotent: true,
4911
+ },
4912
+ ],
4913
+ [
4914
+ 'reactivate',
4915
+ 'POST',
4916
+ '/metered_features',
4917
+ '/reactivate_command',
4918
+ true,
4919
+ null,
4920
+ false,
4921
+ {},
4922
+ {
4923
+ isIdempotent: true,
4924
+ },
4925
+ ],
4926
+ [
4927
+ 'delete',
4928
+ 'POST',
4929
+ '/metered_features',
4930
+ '/delete',
4931
+ true,
4932
+ null,
4933
+ false,
4934
+ {},
4935
+ {
4936
+ isIdempotent: true,
4937
+ },
4938
+ ],
4939
+ ],
4828
4940
  usageFile: [
4829
4941
  [
4830
4942
  'uploadUrl',
@@ -5139,6 +5251,19 @@ export const Endpoints = {
5139
5251
  },
5140
5252
  {},
5141
5253
  ],
5254
+ [
5255
+ 'allocate',
5256
+ 'POST',
5257
+ '/ledger_operations',
5258
+ '/allocate',
5259
+ false,
5260
+ null,
5261
+ true,
5262
+ {
5263
+ metadata: 0,
5264
+ },
5265
+ {},
5266
+ ],
5142
5267
  ],
5143
5268
  grantBlock: [
5144
5269
  [
@@ -5153,6 +5278,7 @@ export const Endpoints = {
5153
5278
  {},
5154
5279
  ],
5155
5280
  ],
5281
+ ledgerEntry: [],
5156
5282
  promotionalGrant: [
5157
5283
  [
5158
5284
  'promotionalGrants',
@@ -66,6 +66,8 @@ export var WebhookEventType;
66
66
  WebhookEventType["GiftScheduled"] = "gift_scheduled";
67
67
  WebhookEventType["GiftUnclaimed"] = "gift_unclaimed";
68
68
  WebhookEventType["GiftUpdated"] = "gift_updated";
69
+ WebhookEventType["GrantBlocksCreated"] = "grant_blocks_created";
70
+ WebhookEventType["GrantBlocksUpdated"] = "grant_blocks_updated";
69
71
  WebhookEventType["HierarchyCreated"] = "hierarchy_created";
70
72
  WebhookEventType["HierarchyDeleted"] = "hierarchy_deleted";
71
73
  WebhookEventType["InvoiceDeleted"] = "invoice_deleted";
@@ -85,6 +87,8 @@ export var WebhookEventType;
85
87
  WebhookEventType["ItemPriceEntitlementsUpdated"] = "item_price_entitlements_updated";
86
88
  WebhookEventType["ItemPriceUpdated"] = "item_price_updated";
87
89
  WebhookEventType["ItemUpdated"] = "item_updated";
90
+ WebhookEventType["LedgerAccountBalanceUpdated"] = "ledger_account_balance_updated";
91
+ WebhookEventType["LedgerUpdated"] = "ledger_updated";
88
92
  WebhookEventType["MrrUpdated"] = "mrr_updated";
89
93
  WebhookEventType["NetdPaymentDueReminder"] = "netd_payment_due_reminder";
90
94
  WebhookEventType["OmnichannelOneTimeOrderCreated"] = "omnichannel_one_time_order_created";
@@ -136,6 +140,7 @@ export var WebhookEventType;
136
140
  WebhookEventType["PaymentSchedulesCreated"] = "payment_schedules_created";
137
141
  WebhookEventType["PaymentSchedulesUpdated"] = "payment_schedules_updated";
138
142
  WebhookEventType["PaymentSourceAdded"] = "payment_source_added";
143
+ WebhookEventType["PaymentSourceBusinessEntityChanged"] = "payment_source_business_entity_changed";
139
144
  WebhookEventType["PaymentSourceDeleted"] = "payment_source_deleted";
140
145
  WebhookEventType["PaymentSourceExpired"] = "payment_source_expired";
141
146
  WebhookEventType["PaymentSourceExpiring"] = "payment_source_expiring";
@@ -4,7 +4,7 @@
4
4
  import { z } from 'zod';
5
5
  //Alert.create
6
6
  const CreateAlertThresholdSchema = z.object({
7
- mode: z.enum(['absolute', 'percentage']),
7
+ mode: z.enum(['absolute', 'percentage']).optional(),
8
8
  value: z.number(),
9
9
  });
10
10
  const CreateAlertFilterConditionsSchema = z.object({
@@ -13,10 +13,12 @@ const CreateAlertFilterConditionsSchema = z.object({
13
13
  value: z.array(z.string().max(50).optional()).optional(),
14
14
  });
15
15
  const CreateAlertBodySchema = z.looseObject({
16
- type: z.enum(['usage_exceeded']),
16
+ type: z.enum(['usage_exceeded', 'spend_exceeded', 'credit_balance_dropped']),
17
17
  name: z.string().max(50),
18
18
  description: z.string().max(65000).optional(),
19
- metered_feature_id: z.string().max(50),
19
+ metered_feature_id: z.string().max(50).optional(),
20
+ currency_code: z.string().max(3).optional(),
21
+ unit_id: z.string().max(50).optional(),
20
22
  subscription_id: z.string().max(50).optional(),
21
23
  meta: z.string().max(65000).optional(),
22
24
  threshold: CreateAlertThresholdSchema.optional(),
@@ -28,7 +30,9 @@ const ListAlertIdSchema = z.object({
28
30
  in: z.string().regex(RegExp('^\\[(.*)(,.*)*\\]$')).optional(),
29
31
  });
30
32
  const ListAlertTypeSchema = z.object({
31
- is: z.enum(['usage_exceeded']).optional(),
33
+ is: z
34
+ .enum(['usage_exceeded', 'spend_exceeded', 'credit_balance_dropped'])
35
+ .optional(),
32
36
  });
33
37
  const ListAlertSubscriptionIdSchema = z.object({
34
38
  is: z.string().min(1).optional(),
@@ -60,7 +64,9 @@ const ApplicationAlertsforsubscriptionAlertStatusSchema = z.object({
60
64
  is: z.enum(['enabled', 'disabled']).optional(),
61
65
  });
62
66
  const ApplicationAlertsforsubscriptionAlertTypeSchema = z.object({
63
- is: z.enum(['usage_exceeded']).optional(),
67
+ is: z
68
+ .enum(['usage_exceeded', 'spend_exceeded', 'credit_balance_dropped'])
69
+ .optional(),
64
70
  });
65
71
  const ApplicationAlertsforsubscriptionAlertBodySchema = z.looseObject({
66
72
  limit: z.number().int().min(1).max(100).optional(),
@@ -256,8 +256,8 @@ const ListCouponCurrencyCodeSchema = z.object({
256
256
  not_in: z.string().regex(RegExp('^\\[(.*)(,.*)*\\]$')).optional(),
257
257
  });
258
258
  const ListCouponApplicableItemPriceIdsSchema = z.object({
259
- is: z.string().min(1).optional(),
260
259
  in: z.string().regex(RegExp('^\\[(.*)(,.*)*\\]$')).optional(),
260
+ is: z.string().min(1).optional(),
261
261
  });
262
262
  const ListCouponBodySchema = z.looseObject({
263
263
  limit: z.number().int().min(1).max(100).optional(),
@@ -92,6 +92,10 @@ const RecordRefundCreditNoteTransactionSchema = z.object({
92
92
  'app_store',
93
93
  'play_store',
94
94
  'custom',
95
+ 'dana',
96
+ 'touch_n_go',
97
+ 'tamara',
98
+ 'qpay',
95
99
  ]),
96
100
  reference_number: z.string().max(100).optional(),
97
101
  custom_payment_method_id: z.string().max(50).optional(),
@@ -401,6 +405,11 @@ const ImportCreditNoteCreditNoteLineItemsSchema = z.object({
401
405
  tax9_amount: z.array(z.number().int().min(0).optional()).optional(),
402
406
  tax10_name: z.array(z.string().max(50).optional()).optional(),
403
407
  tax10_amount: z.array(z.number().int().min(0).optional()).optional(),
408
+ proration_mode: z
409
+ .array(z
410
+ .enum(['reset', 'delta', 'service_period_revision', 'adjusted_term'])
411
+ .optional())
412
+ .optional(),
404
413
  });
405
414
  const ImportCreditNoteCreditNoteLineItemTiersSchema = z.object({
406
415
  line_item_id: z.array(z.string().max(40).optional()),
@@ -467,6 +476,10 @@ const ImportCreditNoteCreditNoteLinkedRefundsSchema = z.object({
467
476
  'app_store',
468
477
  'play_store',
469
478
  'custom',
479
+ 'dana',
480
+ 'touch_n_go',
481
+ 'tamara',
482
+ 'qpay',
470
483
  ])
471
484
  .optional()),
472
485
  date: z.array(z.number().int().optional()),