orb-billing 2.2.0 → 2.3.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 (86) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/index.d.mts +8 -4
  3. package/index.d.ts +8 -4
  4. package/index.d.ts.map +1 -1
  5. package/index.js +2 -5
  6. package/index.js.map +1 -1
  7. package/index.mjs +2 -5
  8. package/index.mjs.map +1 -1
  9. package/package.json +1 -1
  10. package/resources/coupons/coupons.d.ts +3 -22
  11. package/resources/coupons/coupons.d.ts.map +1 -1
  12. package/resources/coupons/coupons.js.map +1 -1
  13. package/resources/coupons/coupons.mjs.map +1 -1
  14. package/resources/customers/costs.d.ts +4 -4
  15. package/resources/customers/costs.d.ts.map +1 -1
  16. package/resources/customers/costs.js.map +1 -1
  17. package/resources/customers/costs.mjs.map +1 -1
  18. package/resources/customers/credits/credits.d.ts +6 -4
  19. package/resources/customers/credits/credits.d.ts.map +1 -1
  20. package/resources/customers/credits/credits.js.map +1 -1
  21. package/resources/customers/credits/credits.mjs.map +1 -1
  22. package/resources/customers/credits/ledger.d.ts +16 -6
  23. package/resources/customers/credits/ledger.d.ts.map +1 -1
  24. package/resources/customers/credits/ledger.js.map +1 -1
  25. package/resources/customers/credits/ledger.mjs.map +1 -1
  26. package/resources/customers/credits/top-ups.d.ts +38 -8
  27. package/resources/customers/credits/top-ups.d.ts.map +1 -1
  28. package/resources/customers/credits/top-ups.js.map +1 -1
  29. package/resources/customers/credits/top-ups.mjs.map +1 -1
  30. package/resources/customers/usage.d.ts +2 -2
  31. package/resources/customers/usage.d.ts.map +1 -1
  32. package/resources/customers/usage.js.map +1 -1
  33. package/resources/customers/usage.mjs.map +1 -1
  34. package/resources/index.d.ts +2 -3
  35. package/resources/index.d.ts.map +1 -1
  36. package/resources/index.js +4 -6
  37. package/resources/index.js.map +1 -1
  38. package/resources/index.mjs +1 -2
  39. package/resources/index.mjs.map +1 -1
  40. package/resources/plans/plans.d.ts +65 -0
  41. package/resources/plans/plans.d.ts.map +1 -1
  42. package/resources/plans/plans.js.map +1 -1
  43. package/resources/plans/plans.mjs.map +1 -1
  44. package/resources/prices/index.d.ts +1 -1
  45. package/resources/prices/index.d.ts.map +1 -1
  46. package/resources/prices/index.js +3 -3
  47. package/resources/prices/index.js.map +1 -1
  48. package/resources/prices/index.mjs +1 -1
  49. package/resources/prices/index.mjs.map +1 -1
  50. package/resources/prices/prices.d.ts +154 -0
  51. package/resources/prices/prices.d.ts.map +1 -1
  52. package/resources/prices/prices.js +26 -0
  53. package/resources/prices/prices.js.map +1 -1
  54. package/resources/prices/prices.mjs +26 -0
  55. package/resources/prices/prices.mjs.map +1 -1
  56. package/resources/shared.d.ts +5 -0
  57. package/resources/shared.d.ts.map +1 -1
  58. package/resources/subscriptions.d.ts +47 -16
  59. package/resources/subscriptions.d.ts.map +1 -1
  60. package/resources/subscriptions.js +6 -0
  61. package/resources/subscriptions.js.map +1 -1
  62. package/resources/subscriptions.mjs +6 -0
  63. package/resources/subscriptions.mjs.map +1 -1
  64. package/resources/webhooks.d.ts.map +1 -1
  65. package/resources/webhooks.js +4 -2
  66. package/resources/webhooks.js.map +1 -1
  67. package/resources/webhooks.mjs +5 -3
  68. package/resources/webhooks.mjs.map +1 -1
  69. package/src/index.ts +9 -7
  70. package/src/resources/coupons/coupons.ts +3 -26
  71. package/src/resources/customers/costs.ts +6 -6
  72. package/src/resources/customers/credits/credits.ts +10 -6
  73. package/src/resources/customers/credits/ledger.ts +20 -8
  74. package/src/resources/customers/credits/top-ups.ts +46 -10
  75. package/src/resources/customers/usage.ts +2 -2
  76. package/src/resources/index.ts +11 -2
  77. package/src/resources/plans/plans.ts +78 -0
  78. package/src/resources/prices/index.ts +10 -1
  79. package/src/resources/prices/prices.ts +219 -0
  80. package/src/resources/shared.ts +8 -0
  81. package/src/resources/subscriptions.ts +67 -20
  82. package/src/resources/webhooks.ts +5 -3
  83. package/src/version.ts +1 -1
  84. package/version.d.ts +1 -1
  85. package/version.js +1 -1
  86. package/version.mjs +1 -1
@@ -43,6 +43,37 @@ export class Prices extends APIResource {
43
43
  return this._client.getAPIList('/prices', PricesPage, { query, ...options });
44
44
  }
45
45
 
46
+ /**
47
+ * This endpoint is used to evaluate the output of a price for a given customer and
48
+ * time range. It enables filtering and grouping the output using
49
+ * [computed properties](../guides/extensibility/advanced-metrics#computed-properties),
50
+ * supporting the following workflows:
51
+ *
52
+ * 1. Showing detailed usage and costs to the end customer.
53
+ * 2. Auditing subtotals on invoice line items.
54
+ *
55
+ * For these workflows, the expressiveness of computed properties in both the
56
+ * filters and grouping is critical. For example, if you'd like to show your
57
+ * customer their usage grouped by hour and another property, you can do so with
58
+ * the following `grouping_keys`:
59
+ * `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd
60
+ * like to examine a customer's usage for a specific property value, you can do so
61
+ * with the following `filter`:
62
+ * `my_property = 'foo' AND my_other_property = 'bar'`.
63
+ *
64
+ * By default, the start of the time range must be no more than 100 days ago and
65
+ * the length of the results must be no greater than 1000. Note that this is a POST
66
+ * endpoint rather than a GET endpoint because it employs a JSON body rather than
67
+ * query parameters.
68
+ */
69
+ evaluate(
70
+ priceId: string,
71
+ body: PriceEvaluateParams,
72
+ options?: Core.RequestOptions,
73
+ ): Core.APIPromise<PriceEvaluateResponse> {
74
+ return this._client.post(`/prices/${priceId}/evaluate`, { body, ...options });
75
+ }
76
+
46
77
  /**
47
78
  * This endpoint returns a price given an identifier.
48
79
  */
@@ -53,6 +84,23 @@ export class Prices extends APIResource {
53
84
 
54
85
  export class PricesPage extends Page<Price> {}
55
86
 
87
+ export interface EvaluatePriceGroup {
88
+ /**
89
+ * The price's output for the group
90
+ */
91
+ amount: string;
92
+
93
+ /**
94
+ * The values for the group in the order specified by `grouping_keys`
95
+ */
96
+ grouping_values: Array<string | number | boolean>;
97
+
98
+ /**
99
+ * The price's usage quantity for the group
100
+ */
101
+ quantity: number;
102
+ }
103
+
56
104
  /**
57
105
  * The Price resource represents a price that can be billed on a subscription,
58
106
  * resulting in a charge on an invoice in the form of an invoice line item. Prices
@@ -314,6 +362,8 @@ export namespace Price {
314
362
 
315
363
  created_at: string;
316
364
 
365
+ credit_allocation: UnitPrice.CreditAllocation | null;
366
+
317
367
  currency: string;
318
368
 
319
369
  discount: Shared.Discount | null;
@@ -348,6 +398,12 @@ export namespace Price {
348
398
  id: string;
349
399
  }
350
400
 
401
+ export interface CreditAllocation {
402
+ allows_rollover: boolean;
403
+
404
+ currency: string;
405
+ }
406
+
351
407
  export interface Item {
352
408
  id: string;
353
409
 
@@ -397,6 +453,8 @@ export namespace Price {
397
453
 
398
454
  created_at: string;
399
455
 
456
+ credit_allocation: PackagePrice.CreditAllocation | null;
457
+
400
458
  currency: string;
401
459
 
402
460
  discount: Shared.Discount | null;
@@ -431,6 +489,12 @@ export namespace Price {
431
489
  id: string;
432
490
  }
433
491
 
492
+ export interface CreditAllocation {
493
+ allows_rollover: boolean;
494
+
495
+ currency: string;
496
+ }
497
+
434
498
  export interface Item {
435
499
  id: string;
436
500
 
@@ -486,6 +550,8 @@ export namespace Price {
486
550
 
487
551
  created_at: string;
488
552
 
553
+ credit_allocation: MatrixPrice.CreditAllocation | null;
554
+
489
555
  currency: string;
490
556
 
491
557
  discount: Shared.Discount | null;
@@ -520,6 +586,12 @@ export namespace Price {
520
586
  id: string;
521
587
  }
522
588
 
589
+ export interface CreditAllocation {
590
+ allows_rollover: boolean;
591
+
592
+ currency: string;
593
+ }
594
+
523
595
  export interface Item {
524
596
  id: string;
525
597
 
@@ -595,6 +667,8 @@ export namespace Price {
595
667
 
596
668
  created_at: string;
597
669
 
670
+ credit_allocation: TieredPrice.CreditAllocation | null;
671
+
598
672
  currency: string;
599
673
 
600
674
  discount: Shared.Discount | null;
@@ -629,6 +703,12 @@ export namespace Price {
629
703
  id: string;
630
704
  }
631
705
 
706
+ export interface CreditAllocation {
707
+ allows_rollover: boolean;
708
+
709
+ currency: string;
710
+ }
711
+
632
712
  export interface Item {
633
713
  id: string;
634
714
 
@@ -697,6 +777,8 @@ export namespace Price {
697
777
 
698
778
  created_at: string;
699
779
 
780
+ credit_allocation: TieredBpsPrice.CreditAllocation | null;
781
+
700
782
  currency: string;
701
783
 
702
784
  discount: Shared.Discount | null;
@@ -731,6 +813,12 @@ export namespace Price {
731
813
  id: string;
732
814
  }
733
815
 
816
+ export interface CreditAllocation {
817
+ allows_rollover: boolean;
818
+
819
+ currency: string;
820
+ }
821
+
734
822
  export interface Item {
735
823
  id: string;
736
824
 
@@ -807,6 +895,8 @@ export namespace Price {
807
895
 
808
896
  created_at: string;
809
897
 
898
+ credit_allocation: BpsPrice.CreditAllocation | null;
899
+
810
900
  currency: string;
811
901
 
812
902
  discount: Shared.Discount | null;
@@ -851,6 +941,12 @@ export namespace Price {
851
941
  per_unit_maximum?: string | null;
852
942
  }
853
943
 
944
+ export interface CreditAllocation {
945
+ allows_rollover: boolean;
946
+
947
+ currency: string;
948
+ }
949
+
854
950
  export interface Item {
855
951
  id: string;
856
952
 
@@ -895,6 +991,8 @@ export namespace Price {
895
991
 
896
992
  created_at: string;
897
993
 
994
+ credit_allocation: BulkBpsPrice.CreditAllocation | null;
995
+
898
996
  currency: string;
899
997
 
900
998
  discount: Shared.Discount | null;
@@ -954,6 +1052,12 @@ export namespace Price {
954
1052
  }
955
1053
  }
956
1054
 
1055
+ export interface CreditAllocation {
1056
+ allows_rollover: boolean;
1057
+
1058
+ currency: string;
1059
+ }
1060
+
957
1061
  export interface Item {
958
1062
  id: string;
959
1063
 
@@ -998,6 +1102,8 @@ export namespace Price {
998
1102
 
999
1103
  created_at: string;
1000
1104
 
1105
+ credit_allocation: BulkPrice.CreditAllocation | null;
1106
+
1001
1107
  currency: string;
1002
1108
 
1003
1109
  discount: Shared.Discount | null;
@@ -1051,6 +1157,12 @@ export namespace Price {
1051
1157
  }
1052
1158
  }
1053
1159
 
1160
+ export interface CreditAllocation {
1161
+ allows_rollover: boolean;
1162
+
1163
+ currency: string;
1164
+ }
1165
+
1054
1166
  export interface Item {
1055
1167
  id: string;
1056
1168
 
@@ -1093,6 +1205,8 @@ export namespace Price {
1093
1205
 
1094
1206
  created_at: string;
1095
1207
 
1208
+ credit_allocation: ThresholdTotalAmountPrice.CreditAllocation | null;
1209
+
1096
1210
  currency: string;
1097
1211
 
1098
1212
  discount: Shared.Discount | null;
@@ -1127,6 +1241,12 @@ export namespace Price {
1127
1241
  id: string;
1128
1242
  }
1129
1243
 
1244
+ export interface CreditAllocation {
1245
+ allows_rollover: boolean;
1246
+
1247
+ currency: string;
1248
+ }
1249
+
1130
1250
  export interface Item {
1131
1251
  id: string;
1132
1252
 
@@ -1169,6 +1289,8 @@ export namespace Price {
1169
1289
 
1170
1290
  created_at: string;
1171
1291
 
1292
+ credit_allocation: TieredPackagePrice.CreditAllocation | null;
1293
+
1172
1294
  currency: string;
1173
1295
 
1174
1296
  discount: Shared.Discount | null;
@@ -1203,6 +1325,12 @@ export namespace Price {
1203
1325
  id: string;
1204
1326
  }
1205
1327
 
1328
+ export interface CreditAllocation {
1329
+ allows_rollover: boolean;
1330
+
1331
+ currency: string;
1332
+ }
1333
+
1206
1334
  export interface Item {
1207
1335
  id: string;
1208
1336
 
@@ -1245,6 +1373,8 @@ export namespace Price {
1245
1373
 
1246
1374
  created_at: string;
1247
1375
 
1376
+ credit_allocation: GroupedTieredPrice.CreditAllocation | null;
1377
+
1248
1378
  currency: string;
1249
1379
 
1250
1380
  discount: Shared.Discount | null;
@@ -1279,6 +1409,12 @@ export namespace Price {
1279
1409
  id: string;
1280
1410
  }
1281
1411
 
1412
+ export interface CreditAllocation {
1413
+ allows_rollover: boolean;
1414
+
1415
+ currency: string;
1416
+ }
1417
+
1282
1418
  export interface Item {
1283
1419
  id: string;
1284
1420
 
@@ -1321,6 +1457,8 @@ export namespace Price {
1321
1457
 
1322
1458
  created_at: string;
1323
1459
 
1460
+ credit_allocation: TieredWithMinimumPrice.CreditAllocation | null;
1461
+
1324
1462
  currency: string;
1325
1463
 
1326
1464
  discount: Shared.Discount | null;
@@ -1355,6 +1493,12 @@ export namespace Price {
1355
1493
  id: string;
1356
1494
  }
1357
1495
 
1496
+ export interface CreditAllocation {
1497
+ allows_rollover: boolean;
1498
+
1499
+ currency: string;
1500
+ }
1501
+
1358
1502
  export interface Item {
1359
1503
  id: string;
1360
1504
 
@@ -1397,6 +1541,8 @@ export namespace Price {
1397
1541
 
1398
1542
  created_at: string;
1399
1543
 
1544
+ credit_allocation: TieredPackageWithMinimumPrice.CreditAllocation | null;
1545
+
1400
1546
  currency: string;
1401
1547
 
1402
1548
  discount: Shared.Discount | null;
@@ -1431,6 +1577,12 @@ export namespace Price {
1431
1577
  id: string;
1432
1578
  }
1433
1579
 
1580
+ export interface CreditAllocation {
1581
+ allows_rollover: boolean;
1582
+
1583
+ currency: string;
1584
+ }
1585
+
1434
1586
  export interface Item {
1435
1587
  id: string;
1436
1588
 
@@ -1473,6 +1625,8 @@ export namespace Price {
1473
1625
 
1474
1626
  created_at: string;
1475
1627
 
1628
+ credit_allocation: PackageWithAllocationPrice.CreditAllocation | null;
1629
+
1476
1630
  currency: string;
1477
1631
 
1478
1632
  discount: Shared.Discount | null;
@@ -1507,6 +1661,12 @@ export namespace Price {
1507
1661
  id: string;
1508
1662
  }
1509
1663
 
1664
+ export interface CreditAllocation {
1665
+ allows_rollover: boolean;
1666
+
1667
+ currency: string;
1668
+ }
1669
+
1510
1670
  export interface Item {
1511
1671
  id: string;
1512
1672
 
@@ -1549,6 +1709,8 @@ export namespace Price {
1549
1709
 
1550
1710
  created_at: string;
1551
1711
 
1712
+ credit_allocation: UnitWithPercentPrice.CreditAllocation | null;
1713
+
1552
1714
  currency: string;
1553
1715
 
1554
1716
  discount: Shared.Discount | null;
@@ -1583,6 +1745,12 @@ export namespace Price {
1583
1745
  id: string;
1584
1746
  }
1585
1747
 
1748
+ export interface CreditAllocation {
1749
+ allows_rollover: boolean;
1750
+
1751
+ currency: string;
1752
+ }
1753
+
1586
1754
  export interface Item {
1587
1755
  id: string;
1588
1756
 
@@ -1625,6 +1793,8 @@ export namespace Price {
1625
1793
 
1626
1794
  created_at: string;
1627
1795
 
1796
+ credit_allocation: MatrixWithAllocationPrice.CreditAllocation | null;
1797
+
1628
1798
  currency: string;
1629
1799
 
1630
1800
  discount: Shared.Discount | null;
@@ -1659,6 +1829,12 @@ export namespace Price {
1659
1829
  id: string;
1660
1830
  }
1661
1831
 
1832
+ export interface CreditAllocation {
1833
+ allows_rollover: boolean;
1834
+
1835
+ currency: string;
1836
+ }
1837
+
1662
1838
  export interface Item {
1663
1839
  id: string;
1664
1840
 
@@ -1731,6 +1907,10 @@ export namespace Price {
1731
1907
  }
1732
1908
  }
1733
1909
 
1910
+ export interface PriceEvaluateResponse {
1911
+ data: Array<EvaluatePriceGroup>;
1912
+ }
1913
+
1734
1914
  export type PriceCreateParams =
1735
1915
  | PriceCreateParams.NewFloatingUnitPrice
1736
1916
  | PriceCreateParams.NewFloatingPackagePrice
@@ -2844,10 +3024,49 @@ export namespace PriceCreateParams {
2844
3024
 
2845
3025
  export interface PriceListParams extends PageParams {}
2846
3026
 
3027
+ export interface PriceEvaluateParams {
3028
+ /**
3029
+ * The exclusive upper bound for event timestamps
3030
+ */
3031
+ timeframe_end: string;
3032
+
3033
+ /**
3034
+ * The inclusive lower bound for event timestamps
3035
+ */
3036
+ timeframe_start: string;
3037
+
3038
+ /**
3039
+ * The ID of the customer to which this evaluation is scoped.
3040
+ */
3041
+ customer_id?: string | null;
3042
+
3043
+ /**
3044
+ * The external customer ID of the customer to which this evaluation is scoped.
3045
+ */
3046
+ external_customer_id?: string | null;
3047
+
3048
+ /**
3049
+ * A boolean
3050
+ * [computed property](../guides/extensibility/advanced-metrics#computed-properties)
3051
+ * used to filter the underlying billable metric
3052
+ */
3053
+ filter?: string | null;
3054
+
3055
+ /**
3056
+ * Properties (or
3057
+ * [computed properties](../guides/extensibility/advanced-metrics#computed-properties))
3058
+ * used to group the underlying billable metric
3059
+ */
3060
+ grouping_keys?: Array<string>;
3061
+ }
3062
+
2847
3063
  export namespace Prices {
3064
+ export import EvaluatePriceGroup = PricesAPI.EvaluatePriceGroup;
2848
3065
  export import Price = PricesAPI.Price;
3066
+ export import PriceEvaluateResponse = PricesAPI.PriceEvaluateResponse;
2849
3067
  export import PricesPage = PricesAPI.PricesPage;
2850
3068
  export import PriceCreateParams = PricesAPI.PriceCreateParams;
2851
3069
  export import PriceListParams = PricesAPI.PriceListParams;
3070
+ export import PriceEvaluateParams = PricesAPI.PriceEvaluateParams;
2852
3071
  export import ExternalPriceID = ExternalPriceIDAPI.ExternalPriceID;
2853
3072
  }
@@ -1,5 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
+ export type BillingCycleRelativeDate = 'start_of_term' | 'end_of_term';
4
+
3
5
  export type Discount =
4
6
  | Discount.PercentageDiscount
5
7
  | Discount.TrialDiscount
@@ -82,3 +84,9 @@ export namespace Discount {
82
84
  reason?: string | null;
83
85
  }
84
86
  }
87
+
88
+ export interface PaginationMetadata {
89
+ has_more: boolean;
90
+
91
+ next_cursor: string | null;
92
+ }
@@ -4,6 +4,7 @@ import * as Core from "../core";
4
4
  import { APIResource } from "../resource";
5
5
  import { isRequestOptions } from "../core";
6
6
  import * as SubscriptionsAPI from "./subscriptions";
7
+ import * as Shared from "./shared";
7
8
  import * as CustomersAPI from "./customers/customers";
8
9
  import * as PlansAPI from "./plans/plans";
9
10
  import * as PricesAPI from "./prices/prices";
@@ -414,6 +415,28 @@ export class Subscriptions extends APIResource {
414
415
  return this._client.post('/subscriptions', { body, ...options });
415
416
  }
416
417
 
418
+ /**
419
+ * This endpoint can be used to update the `metadata`, `net terms`,
420
+ * `auto_collection`, `invoicing_threshold`, and `default_invoice_memo` properties
421
+ * on a subscription.
422
+ */
423
+ update(
424
+ subscriptionId: string,
425
+ body?: SubscriptionUpdateParams,
426
+ options?: Core.RequestOptions,
427
+ ): Core.APIPromise<Subscription>;
428
+ update(subscriptionId: string, options?: Core.RequestOptions): Core.APIPromise<Subscription>;
429
+ update(
430
+ subscriptionId: string,
431
+ body: SubscriptionUpdateParams | Core.RequestOptions = {},
432
+ options?: Core.RequestOptions,
433
+ ): Core.APIPromise<Subscription> {
434
+ if (isRequestOptions(body)) {
435
+ return this.update(subscriptionId, {}, body);
436
+ }
437
+ return this._client.put(`/subscriptions/${subscriptionId}`, { body, ...options });
438
+ }
439
+
417
440
  /**
418
441
  * This endpoint returns a list of all subscriptions for an account as a
419
442
  * [paginated](../reference/pagination) list, ordered starting from the most
@@ -1670,7 +1693,7 @@ export namespace SubscriptionUsage {
1670
1693
  export interface GroupedSubscriptionUsage {
1671
1694
  data: Array<GroupedSubscriptionUsage.Data>;
1672
1695
 
1673
- pagination_metadata?: GroupedSubscriptionUsage.PaginationMetadata | null;
1696
+ pagination_metadata?: Shared.PaginationMetadata | null;
1674
1697
  }
1675
1698
 
1676
1699
  export namespace GroupedSubscriptionUsage {
@@ -1705,27 +1728,13 @@ export namespace SubscriptionUsage {
1705
1728
  timeframe_start: string;
1706
1729
  }
1707
1730
  }
1708
-
1709
- export interface PaginationMetadata {
1710
- has_more: boolean;
1711
-
1712
- next_cursor: string | null;
1713
- }
1714
1731
  }
1715
1732
  }
1716
1733
 
1717
1734
  export interface Subscriptions {
1718
1735
  data: Array<Subscription>;
1719
1736
 
1720
- pagination_metadata: Subscriptions.PaginationMetadata;
1721
- }
1722
-
1723
- export namespace Subscriptions {
1724
- export interface PaginationMetadata {
1725
- has_more: boolean;
1726
-
1727
- next_cursor: string | null;
1728
- }
1737
+ pagination_metadata: Shared.PaginationMetadata;
1729
1738
  }
1730
1739
 
1731
1740
  export interface SubscriptionFetchCostsResponse {
@@ -3121,6 +3130,43 @@ export namespace SubscriptionCreateParams {
3121
3130
  }
3122
3131
  }
3123
3132
 
3133
+ export interface SubscriptionUpdateParams {
3134
+ /**
3135
+ * Determines whether issued invoices for this subscription will automatically be
3136
+ * charged with the saved payment method on the due date. This property defaults to
3137
+ * the plan's behavior.
3138
+ */
3139
+ auto_collection?: boolean | null;
3140
+
3141
+ /**
3142
+ * Determines the default memo on this subscription's invoices. Note that if this
3143
+ * is not provided, it is determined by the plan configuration.
3144
+ */
3145
+ default_invoice_memo?: string | null;
3146
+
3147
+ /**
3148
+ * When this subscription's accrued usage reaches this threshold, an invoice will
3149
+ * be issued for the subscription. If not specified, invoices will only be issued
3150
+ * at the end of the billing period.
3151
+ */
3152
+ invoicing_threshold?: string | null;
3153
+
3154
+ /**
3155
+ * User-specified key/value pairs for the resource. Individual keys can be removed
3156
+ * by setting the value to `null`, and the entire metadata mapping can be cleared
3157
+ * by setting `metadata` to `null`.
3158
+ */
3159
+ metadata?: Record<string, string | null> | null;
3160
+
3161
+ /**
3162
+ * Determines the difference between the invoice issue date for subscription
3163
+ * invoices as the date that they are due. A value of `0` here represents that the
3164
+ * invoice is due on issue, whereas a value of `30` represents that the customer
3165
+ * has a month to pay the invoice.
3166
+ */
3167
+ net_terms?: number | null;
3168
+ }
3169
+
3124
3170
  export interface SubscriptionListParams extends PageParams {
3125
3171
  'created_at[gt]'?: string | null;
3126
3172
 
@@ -3255,7 +3301,7 @@ export namespace SubscriptionPriceIntervalsParams {
3255
3301
  * The start date of the price interval. This is the date that the price will start
3256
3302
  * billing on the subscription.
3257
3303
  */
3258
- start_date: (string & {}) | 'start_of_term' | 'end_of_term';
3304
+ start_date: (string & {}) | Shared.BillingCycleRelativeDate;
3259
3305
 
3260
3306
  /**
3261
3307
  * A list of discounts to initialize on the price interval.
@@ -3270,7 +3316,7 @@ export namespace SubscriptionPriceIntervalsParams {
3270
3316
  * The end date of the price interval. This is the date that the price will stop
3271
3317
  * billing on the subscription.
3272
3318
  */
3273
- end_date?: (string & {}) | 'start_of_term' | 'end_of_term' | null;
3319
+ end_date?: (string & {}) | Shared.BillingCycleRelativeDate | null;
3274
3320
 
3275
3321
  /**
3276
3322
  * The external price id of the price to add to the subscription.
@@ -4473,7 +4519,7 @@ export namespace SubscriptionPriceIntervalsParams {
4473
4519
  * The updated end date of this price interval. If not specified, the start date
4474
4520
  * will not be updated.
4475
4521
  */
4476
- end_date?: (string & {}) | 'start_of_term' | 'end_of_term' | null;
4522
+ end_date?: (string & {}) | Shared.BillingCycleRelativeDate | null;
4477
4523
 
4478
4524
  /**
4479
4525
  * A list of fixed fee quantity transitions to use for this price interval. Note
@@ -4486,7 +4532,7 @@ export namespace SubscriptionPriceIntervalsParams {
4486
4532
  * The updated start date of this price interval. If not specified, the start date
4487
4533
  * will not be updated.
4488
4534
  */
4489
- start_date?: (string & {}) | 'start_of_term' | 'end_of_term';
4535
+ start_date?: (string & {}) | Shared.BillingCycleRelativeDate;
4490
4536
  }
4491
4537
 
4492
4538
  export namespace Edit {
@@ -5646,6 +5692,7 @@ export namespace Subscriptions {
5646
5692
  export import SubscriptionsPage = SubscriptionsAPI.SubscriptionsPage;
5647
5693
  export import SubscriptionFetchScheduleResponsesPage = SubscriptionsAPI.SubscriptionFetchScheduleResponsesPage;
5648
5694
  export import SubscriptionCreateParams = SubscriptionsAPI.SubscriptionCreateParams;
5695
+ export import SubscriptionUpdateParams = SubscriptionsAPI.SubscriptionUpdateParams;
5649
5696
  export import SubscriptionListParams = SubscriptionsAPI.SubscriptionListParams;
5650
5697
  export import SubscriptionCancelParams = SubscriptionsAPI.SubscriptionCancelParams;
5651
5698
  export import SubscriptionFetchCostsParams = SubscriptionsAPI.SubscriptionFetchCostsParams;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { APIResource } from "../resource";
4
4
  import { createHmac } from 'crypto';
5
- import { getRequiredHeader, HeadersLike } from "../core";
5
+ import { debug, getRequiredHeader, HeadersLike } from "../core";
6
6
 
7
7
  export class Webhooks extends APIResource {
8
8
  /**
@@ -93,7 +93,9 @@ export class Webhooks extends APIResource {
93
93
  const msgSignature = getRequiredHeader(headers, 'X-Orb-Signature');
94
94
 
95
95
  const nowSeconds = Math.floor(Date.now() / 1000);
96
- const timestamp = new Date(msgTimestamp);
96
+ // The timestamp header does not include a timezone (it is UTC by default)
97
+ const timezoneSuffix = msgTimestamp.includes('Z') || msgTimestamp.includes('+') ? '' : 'Z'
98
+ const timestamp = new Date(msgTimestamp + timezoneSuffix);
97
99
  const timestampSeconds = Math.floor(timestamp.getTime() / 1000);
98
100
  if (isNaN(timestampSeconds)) {
99
101
  throw new Error('Invalid timestamp header');
@@ -123,7 +125,7 @@ export class Webhooks extends APIResource {
123
125
  const encoder = new globalThis.TextEncoder();
124
126
  for (const versionedSignature of passedSignatures) {
125
127
  const [version, signature] = versionedSignature.split('=');
126
- console.log({ version, signature, expectedSignature, computedSignature });
128
+ debug('verifySignature', { version, signature, expectedSignature, computedSignature });
127
129
 
128
130
  if (version !== 'v1') {
129
131
  continue;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.2.0'; // x-release-please-version
1
+ export const VERSION = '2.3.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.2.0";
1
+ export declare const VERSION = "2.3.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.2.0'; // x-release-please-version
4
+ exports.VERSION = '2.3.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.2.0'; // x-release-please-version
1
+ export const VERSION = '2.3.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map