stripe 16.12.0 → 17.0.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 (96) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +34 -0
  3. package/VERSION +1 -1
  4. package/cjs/Error.js +31 -4
  5. package/cjs/RequestSender.js +164 -63
  6. package/cjs/StripeResource.js +8 -3
  7. package/cjs/apiVersion.js +1 -1
  8. package/cjs/autoPagination.js +51 -7
  9. package/cjs/crypto/CryptoProvider.js +6 -0
  10. package/cjs/crypto/NodeCryptoProvider.js +7 -0
  11. package/cjs/crypto/SubtleCryptoProvider.js +4 -0
  12. package/cjs/multipart.js +1 -1
  13. package/cjs/resources/Billing/CreditBalanceSummary.js +12 -0
  14. package/cjs/resources/Billing/CreditBalanceTransactions.js +17 -0
  15. package/cjs/resources/Billing/CreditGrants.js +30 -0
  16. package/cjs/resources/OAuth.js +1 -1
  17. package/cjs/resources/V2/Billing/MeterEventAdjustments.js +12 -0
  18. package/cjs/resources/V2/Billing/MeterEventSession.js +12 -0
  19. package/cjs/resources/V2/Billing/MeterEventStream.js +13 -0
  20. package/cjs/resources/V2/Billing/MeterEvents.js +9 -0
  21. package/cjs/resources/V2/Billing.js +18 -0
  22. package/cjs/resources/V2/Core/Events.js +14 -0
  23. package/cjs/resources/V2/Core.js +12 -0
  24. package/cjs/resources/V2.js +14 -0
  25. package/cjs/resources.js +9 -1
  26. package/cjs/stripe.core.js +25 -10
  27. package/cjs/utils.js +64 -6
  28. package/esm/Error.js +27 -2
  29. package/esm/RequestSender.js +165 -64
  30. package/esm/StripeResource.js +9 -4
  31. package/esm/apiVersion.js +1 -1
  32. package/esm/autoPagination.js +52 -8
  33. package/esm/crypto/CryptoProvider.js +6 -0
  34. package/esm/crypto/NodeCryptoProvider.js +7 -0
  35. package/esm/crypto/SubtleCryptoProvider.js +4 -0
  36. package/esm/multipart.js +2 -2
  37. package/esm/resources/Billing/CreditBalanceSummary.js +9 -0
  38. package/esm/resources/Billing/CreditBalanceTransactions.js +14 -0
  39. package/esm/resources/Billing/CreditGrants.js +27 -0
  40. package/esm/resources/OAuth.js +2 -2
  41. package/esm/resources/V2/Billing/MeterEventAdjustments.js +9 -0
  42. package/esm/resources/V2/Billing/MeterEventSession.js +9 -0
  43. package/esm/resources/V2/Billing/MeterEventStream.js +10 -0
  44. package/esm/resources/V2/Billing/MeterEvents.js +6 -0
  45. package/esm/resources/V2/Billing.js +15 -0
  46. package/esm/resources/V2/Core/Events.js +11 -0
  47. package/esm/resources/V2/Core.js +9 -0
  48. package/esm/resources/V2.js +11 -0
  49. package/esm/resources.js +7 -0
  50. package/esm/stripe.core.js +26 -11
  51. package/esm/utils.js +59 -4
  52. package/package.json +1 -1
  53. package/types/Billing/Alerts.d.ts +17 -13
  54. package/types/Billing/AlertsResource.d.ts +18 -21
  55. package/types/Billing/CreditBalanceSummary.d.ts +94 -0
  56. package/types/Billing/CreditBalanceSummaryResource.d.ts +64 -0
  57. package/types/Billing/CreditBalanceTransactions.d.ts +159 -0
  58. package/types/Billing/CreditBalanceTransactionsResource.d.ts +54 -0
  59. package/types/Billing/CreditGrants.d.ts +124 -0
  60. package/types/Billing/CreditGrantsResource.d.ts +219 -0
  61. package/types/BillingPortal/ConfigurationsResource.d.ts +2 -2
  62. package/types/Capabilities.d.ts +1 -1
  63. package/types/Checkout/SessionsResource.d.ts +1 -1
  64. package/types/CreditNoteLineItems.d.ts +30 -0
  65. package/types/CreditNotes.d.ts +30 -0
  66. package/types/Customers.d.ts +2 -3
  67. package/types/Errors.d.ts +32 -2
  68. package/types/EventTypes.d.ts +2 -0
  69. package/types/InvoiceLineItems.d.ts +36 -0
  70. package/types/Invoices.d.ts +38 -0
  71. package/types/Margins.d.ts +56 -0
  72. package/types/ProductsResource.d.ts +28 -1
  73. package/types/PromotionCodes.d.ts +1 -1
  74. package/types/PromotionCodesResource.d.ts +3 -1
  75. package/types/SubscriptionsResource.d.ts +3 -3
  76. package/types/Tax/Settings.d.ts +1 -1
  77. package/types/Terminal/ReadersResource.d.ts +13 -4
  78. package/types/ThinEvent.d.ts +36 -0
  79. package/types/Treasury/ReceivedCredits.d.ts +5 -1
  80. package/types/V2/Billing/MeterEventAdjustments.d.ts +65 -0
  81. package/types/V2/Billing/MeterEventAdjustmentsResource.d.ts +47 -0
  82. package/types/V2/Billing/MeterEventSessionResource.d.ts +26 -0
  83. package/types/V2/Billing/MeterEventSessions.d.ts +45 -0
  84. package/types/V2/Billing/MeterEventStreamResource.d.ts +62 -0
  85. package/types/V2/Billing/MeterEvents.d.ts +54 -0
  86. package/types/V2/Billing/MeterEventsResource.d.ts +52 -0
  87. package/types/V2/BillingResource.d.ts +14 -0
  88. package/types/V2/Core/EventsResource.d.ts +57 -0
  89. package/types/V2/CoreResource.d.ts +11 -0
  90. package/types/V2/EventTypes.d.ts +214 -0
  91. package/types/V2/Events.d.ts +75 -0
  92. package/types/V2Resource.d.ts +10 -0
  93. package/types/WebhookEndpointsResource.d.ts +2 -1
  94. package/types/index.d.ts +87 -0
  95. package/types/lib.d.ts +8 -1
  96. package/types/test/typescriptTest.ts +3 -3
@@ -0,0 +1,62 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace V2 {
6
+ namespace Billing {
7
+ interface MeterEventStreamCreateParams {
8
+ /**
9
+ * List of meter events to include in the request.
10
+ */
11
+ events: Array<MeterEventStreamCreateParams.Event>;
12
+ }
13
+
14
+ namespace MeterEventStreamCreateParams {
15
+ interface Event {
16
+ /**
17
+ * The name of the meter event. Corresponds with the `event_name` field on a meter.
18
+ */
19
+ event_name: string;
20
+
21
+ /**
22
+ * A unique identifier for the event. If not provided, one will be generated.
23
+ * We recommend using a globally unique identifier for this. We'll enforce
24
+ * uniqueness within a rolling 24 hour period.
25
+ */
26
+ identifier?: string;
27
+
28
+ /**
29
+ * The payload of the event. This must contain the fields corresponding to a meter's
30
+ * `customer_mapping.event_payload_key` (default is `stripe_customer_id`) and
31
+ * `value_settings.event_payload_key` (default is `value`). Read more about
32
+ * the
33
+ * [payload](https://docs.stripe.com/billing/subscriptions/usage-based/recording-usage#payload-key-overrides).
34
+ */
35
+ payload: {
36
+ [key: string]: string;
37
+ };
38
+
39
+ /**
40
+ * The time of the event. Must be within the past 35 calendar days or up to
41
+ * 5 minutes in the future. Defaults to current timestamp if not specified.
42
+ */
43
+ timestamp?: string;
44
+ }
45
+ }
46
+ }
47
+
48
+ namespace Billing {
49
+ class MeterEventStreamResource {
50
+ /**
51
+ * Creates meter events. Events are processed asynchronously, including validation. Requires a meter event session for authentication. Supports up to 10,000 requests per second in livemode. For even higher rate-limits, contact sales.
52
+ * @throws Stripe.TemporarySessionExpiredError
53
+ */
54
+ create(
55
+ params: MeterEventStreamCreateParams,
56
+ options?: RequestOptions
57
+ ): Promise<void>;
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,54 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace V2 {
6
+ namespace Billing {
7
+ /**
8
+ * Fix me empty_doc_string.
9
+ */
10
+ interface MeterEvent {
11
+ /**
12
+ * String representing the object's type. Objects of the same type share the same value of the object field.
13
+ */
14
+ object: 'billing.meter_event';
15
+
16
+ /**
17
+ * The creation time of this meter event.
18
+ */
19
+ created: string;
20
+
21
+ /**
22
+ * The name of the meter event. Corresponds with the `event_name` field on a meter.
23
+ */
24
+ event_name: string;
25
+
26
+ /**
27
+ * A unique identifier for the event. If not provided, one will be generated. We recommend using a globally unique identifier for this. We'll enforce uniqueness within a rolling 24 hour period.
28
+ */
29
+ identifier: string;
30
+
31
+ /**
32
+ * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
33
+ */
34
+ livemode: boolean;
35
+
36
+ /**
37
+ * The payload of the event. This must contain the fields corresponding to a meter's
38
+ * `customer_mapping.event_payload_key` (default is `stripe_customer_id`) and
39
+ * `value_settings.event_payload_key` (default is `value`). Read more about the payload.
40
+ */
41
+ payload: {
42
+ [key: string]: string;
43
+ };
44
+
45
+ /**
46
+ * The time of the event. Must be within the past 35 calendar days or up to
47
+ * 5 minutes in the future. Defaults to current timestamp if not specified.
48
+ */
49
+ timestamp: string;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,52 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace V2 {
6
+ namespace Billing {
7
+ interface MeterEventCreateParams {
8
+ /**
9
+ * The name of the meter event. Corresponds with the `event_name` field on a meter.
10
+ */
11
+ event_name: string;
12
+
13
+ /**
14
+ * The payload of the event. This must contain the fields corresponding to a meter's
15
+ * `customer_mapping.event_payload_key` (default is `stripe_customer_id`) and
16
+ * `value_settings.event_payload_key` (default is `value`). Read more about
17
+ * the
18
+ * [payload](https://docs.stripe.com/billing/subscriptions/usage-based/recording-usage#payload-key-overrides).
19
+ */
20
+ payload: {
21
+ [key: string]: string;
22
+ };
23
+
24
+ /**
25
+ * A unique identifier for the event. If not provided, one will be generated.
26
+ * We recommend using a globally unique identifier for this. We'll enforce
27
+ * uniqueness within a rolling 24 hour period.
28
+ */
29
+ identifier?: string;
30
+
31
+ /**
32
+ * The time of the event. Must be within the past 35 calendar days or up to
33
+ * 5 minutes in the future. Defaults to current timestamp if not specified.
34
+ */
35
+ timestamp?: string;
36
+ }
37
+ }
38
+
39
+ namespace Billing {
40
+ class MeterEventsResource {
41
+ /**
42
+ * Creates a meter event. Events are validated synchronously, but are processed asynchronously. Supports up to 1,000 events per second in livemode. For higher rate-limits, please use meter event streams instead.
43
+ */
44
+ create(
45
+ params: MeterEventCreateParams,
46
+ options?: RequestOptions
47
+ ): Promise<Stripe.Response<Stripe.V2.Billing.MeterEvent>>;
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,14 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace V2 {
6
+ class BillingResource {
7
+ meterEventSession: Stripe.V2.Billing.MeterEventSessionResource;
8
+ meterEventAdjustments: Stripe.V2.Billing.MeterEventAdjustmentsResource;
9
+ meterEventStream: Stripe.V2.Billing.MeterEventStreamResource;
10
+ meterEvents: Stripe.V2.Billing.MeterEventsResource;
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,57 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ /// <reference path='../EventTypes.d.ts' />
4
+
5
+ declare module 'stripe' {
6
+ namespace Stripe {
7
+ namespace V2 {
8
+ namespace Core {
9
+ interface EventRetrieveParams {}
10
+ }
11
+
12
+ namespace Core {
13
+ interface EventListParams {
14
+ /**
15
+ * Primary object ID used to retrieve related events.
16
+ */
17
+ object_id: string;
18
+
19
+ /**
20
+ * The page size.
21
+ */
22
+ limit?: number;
23
+
24
+ /**
25
+ * The requested page number.
26
+ */
27
+ page?: string;
28
+ }
29
+ }
30
+
31
+ namespace Core {
32
+ class EventsResource {
33
+ /**
34
+ * Retrieves the details of an event.
35
+ */
36
+ retrieve(
37
+ id: string,
38
+ params?: EventRetrieveParams,
39
+ options?: RequestOptions
40
+ ): Promise<Stripe.Response<Stripe.V2.Event>>;
41
+ retrieve(
42
+ id: string,
43
+ options?: RequestOptions
44
+ ): Promise<Stripe.Response<Stripe.V2.Event>>;
45
+
46
+ /**
47
+ * List events, going back up to 30 days.
48
+ */
49
+ list(
50
+ params: EventListParams,
51
+ options?: RequestOptions
52
+ ): ApiListPromise<Stripe.V2.Event>;
53
+ }
54
+ }
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,11 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace V2 {
6
+ class CoreResource {
7
+ events: Stripe.V2.Core.EventsResource;
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,214 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe.V2 {
5
+ export type Event =
6
+ | Stripe.Events.V1BillingMeterErrorReportTriggeredEvent
7
+ | Stripe.Events.V1BillingMeterNoMeterFoundEvent;
8
+ }
9
+
10
+ namespace Stripe.Events {
11
+ /**
12
+ * This event occurs when there are invalid async usage events for a given meter.
13
+ */
14
+ export interface V1BillingMeterErrorReportTriggeredEvent
15
+ extends V2.EventBase {
16
+ type: 'v1.billing.meter.error_report_triggered';
17
+ // Retrieves data specific to this event.
18
+ data: V1BillingMeterErrorReportTriggeredEvent.Data;
19
+ // Retrieves the object associated with the event.
20
+ related_object: Event.RelatedObject;
21
+ }
22
+
23
+ namespace V1BillingMeterErrorReportTriggeredEvent {
24
+ export interface Data {
25
+ /**
26
+ * Extra field included in the event's `data` when fetched from /v2/events.
27
+ */
28
+ developer_message_summary: string;
29
+
30
+ /**
31
+ * This contains information about why meter error happens.
32
+ */
33
+ reason: Data.Reason;
34
+
35
+ /**
36
+ * The end of the window that is encapsulated by this summary.
37
+ */
38
+ validation_end: string;
39
+
40
+ /**
41
+ * The start of the window that is encapsulated by this summary.
42
+ */
43
+ validation_start: string;
44
+ }
45
+
46
+ namespace Data {
47
+ export interface Reason {
48
+ /**
49
+ * The total error count within this window.
50
+ */
51
+ error_count: number;
52
+
53
+ /**
54
+ * The error details.
55
+ */
56
+ error_types: Array<Reason.ErrorType>;
57
+ }
58
+
59
+ namespace Reason {
60
+ export interface ErrorType {
61
+ /**
62
+ * Open Enum.
63
+ */
64
+ code: ErrorType.Code;
65
+
66
+ /**
67
+ * The number of errors of this type.
68
+ */
69
+ error_count: number;
70
+
71
+ /**
72
+ * A list of sample errors of this type.
73
+ */
74
+ sample_errors: Array<ErrorType.SampleError>;
75
+ }
76
+
77
+ namespace ErrorType {
78
+ export type Code =
79
+ | 'archived_meter'
80
+ | 'meter_event_customer_not_found'
81
+ | 'meter_event_dimension_count_too_high'
82
+ | 'meter_event_invalid_value'
83
+ | 'meter_event_no_customer_defined'
84
+ | 'missing_dimension_payload_keys'
85
+ | 'no_meter'
86
+ | 'timestamp_in_future'
87
+ | 'timestamp_too_far_in_past';
88
+
89
+ export interface SampleError {
90
+ /**
91
+ * The error message.
92
+ */
93
+ error_message: string;
94
+
95
+ /**
96
+ * The request causes the error.
97
+ */
98
+ request: SampleError.Request;
99
+ }
100
+
101
+ namespace SampleError {
102
+ export interface Request {
103
+ /**
104
+ * The request idempotency key.
105
+ */
106
+ identifier: string;
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ /**
115
+ * This event occurs when async usage events have missing or invalid meter ids.
116
+ */
117
+ export interface V1BillingMeterNoMeterFoundEvent extends V2.EventBase {
118
+ type: 'v1.billing.meter.no_meter_found';
119
+ // Retrieves data specific to this event.
120
+ data: V1BillingMeterNoMeterFoundEvent.Data;
121
+ }
122
+
123
+ namespace V1BillingMeterNoMeterFoundEvent {
124
+ export interface Data {
125
+ /**
126
+ * Extra field included in the event's `data` when fetched from /v2/events.
127
+ */
128
+ developer_message_summary: string;
129
+
130
+ /**
131
+ * This contains information about why meter error happens.
132
+ */
133
+ reason: Data.Reason;
134
+
135
+ /**
136
+ * The end of the window that is encapsulated by this summary.
137
+ */
138
+ validation_end: string;
139
+
140
+ /**
141
+ * The start of the window that is encapsulated by this summary.
142
+ */
143
+ validation_start: string;
144
+ }
145
+
146
+ namespace Data {
147
+ export interface Reason {
148
+ /**
149
+ * The total error count within this window.
150
+ */
151
+ error_count: number;
152
+
153
+ /**
154
+ * The error details.
155
+ */
156
+ error_types: Array<Reason.ErrorType>;
157
+ }
158
+
159
+ namespace Reason {
160
+ export interface ErrorType {
161
+ /**
162
+ * Open Enum.
163
+ */
164
+ code: ErrorType.Code;
165
+
166
+ /**
167
+ * The number of errors of this type.
168
+ */
169
+ error_count: number;
170
+
171
+ /**
172
+ * A list of sample errors of this type.
173
+ */
174
+ sample_errors: Array<ErrorType.SampleError>;
175
+ }
176
+
177
+ namespace ErrorType {
178
+ export type Code =
179
+ | 'archived_meter'
180
+ | 'meter_event_customer_not_found'
181
+ | 'meter_event_dimension_count_too_high'
182
+ | 'meter_event_invalid_value'
183
+ | 'meter_event_no_customer_defined'
184
+ | 'missing_dimension_payload_keys'
185
+ | 'no_meter'
186
+ | 'timestamp_in_future'
187
+ | 'timestamp_too_far_in_past';
188
+
189
+ export interface SampleError {
190
+ /**
191
+ * The error message.
192
+ */
193
+ error_message: string;
194
+
195
+ /**
196
+ * The request causes the error.
197
+ */
198
+ request: SampleError.Request;
199
+ }
200
+
201
+ namespace SampleError {
202
+ export interface Request {
203
+ /**
204
+ * The request idempotency key.
205
+ */
206
+ identifier: string;
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
@@ -0,0 +1,75 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace V2 {
6
+ namespace Event {
7
+ interface Reason {
8
+ /**
9
+ * Event reason type.
10
+ */
11
+ type: 'request';
12
+
13
+ /**
14
+ * Information on the API request that instigated the event.
15
+ */
16
+ request: Reason.Request | null;
17
+ }
18
+
19
+ namespace Reason {
20
+ interface Request {
21
+ /**
22
+ * ID of the API request that caused the event.
23
+ */
24
+ id: string;
25
+
26
+ /**
27
+ * The idempotency key transmitted during the request.
28
+ */
29
+ idempotency_key: string;
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * The Event object.
36
+ */
37
+ interface EventBase {
38
+ /**
39
+ * Unique identifier for the event.
40
+ */
41
+ id: string;
42
+
43
+ /**
44
+ * String representing the object's type. Objects of the same type share the same value of the object field.
45
+ */
46
+ object: 'v2.core.event';
47
+
48
+ /**
49
+ * Authentication context needed to fetch the event or related object.
50
+ */
51
+ context: string | null;
52
+
53
+ /**
54
+ * Time at which the object was created.
55
+ */
56
+ created: string;
57
+
58
+ /**
59
+ * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
60
+ */
61
+ livemode: boolean;
62
+
63
+ /**
64
+ * Reason for the event.
65
+ */
66
+ reason: Event.Reason | null;
67
+
68
+ /**
69
+ * The type of the event.
70
+ */
71
+ type: string;
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,10 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ class V2Resource {
6
+ billing: Stripe.V2.BillingResource;
7
+ core: Stripe.V2.CoreResource;
8
+ }
9
+ }
10
+ }
@@ -142,7 +142,8 @@ declare module 'stripe' {
142
142
  | '2023-08-16'
143
143
  | '2023-10-16'
144
144
  | '2024-04-10'
145
- | '2024-06-20';
145
+ | '2024-06-20'
146
+ | '2024-09-30.acacia';
146
147
 
147
148
  type EnabledEvent =
148
149
  | '*'