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,11 @@
1
+ // File generated from our OpenAPI spec
2
+ import { StripeResource } from '../StripeResource.js';
3
+ import { Billing } from './V2/Billing.js';
4
+ import { Core } from './V2/Core.js';
5
+ export const V2 = StripeResource.extend({
6
+ constructor: function (...args) {
7
+ StripeResource.apply(this, args);
8
+ this.billing = new Billing(...args);
9
+ this.core = new Core(...args);
10
+ },
11
+ });
package/esm/resources.js CHANGED
@@ -13,6 +13,9 @@ import { Configurations as BillingPortalConfigurations } from './resources/Billi
13
13
  import { Configurations as TerminalConfigurations } from './resources/Terminal/Configurations.js';
14
14
  import { ConfirmationTokens as TestHelpersConfirmationTokens } from './resources/TestHelpers/ConfirmationTokens.js';
15
15
  import { ConnectionTokens as TerminalConnectionTokens } from './resources/Terminal/ConnectionTokens.js';
16
+ import { CreditBalanceSummary as BillingCreditBalanceSummary } from './resources/Billing/CreditBalanceSummary.js';
17
+ import { CreditBalanceTransactions as BillingCreditBalanceTransactions } from './resources/Billing/CreditBalanceTransactions.js';
18
+ import { CreditGrants as BillingCreditGrants } from './resources/Billing/CreditGrants.js';
16
19
  import { CreditReversals as TreasuryCreditReversals } from './resources/Treasury/CreditReversals.js';
17
20
  import { Customers as TestHelpersCustomers } from './resources/TestHelpers/Customers.js';
18
21
  import { DebitReversals as TreasuryDebitReversals } from './resources/Treasury/DebitReversals.js';
@@ -117,10 +120,14 @@ export { TaxRates } from './resources/TaxRates.js';
117
120
  export { Tokens } from './resources/Tokens.js';
118
121
  export { Topups } from './resources/Topups.js';
119
122
  export { Transfers } from './resources/Transfers.js';
123
+ export { V2 } from './resources/V2.js';
120
124
  export { WebhookEndpoints } from './resources/WebhookEndpoints.js';
121
125
  export const Apps = resourceNamespace('apps', { Secrets: AppsSecrets });
122
126
  export const Billing = resourceNamespace('billing', {
123
127
  Alerts: BillingAlerts,
128
+ CreditBalanceSummary: BillingCreditBalanceSummary,
129
+ CreditBalanceTransactions: BillingCreditBalanceTransactions,
130
+ CreditGrants: BillingCreditGrants,
124
131
  MeterEventAdjustments: BillingMeterEventAdjustments,
125
132
  MeterEvents: BillingMeterEvents,
126
133
  Meters: BillingMeters,
@@ -2,20 +2,21 @@ import * as _Error from './Error.js';
2
2
  import { RequestSender } from './RequestSender.js';
3
3
  import { StripeResource } from './StripeResource.js';
4
4
  import { createWebhooks } from './Webhooks.js';
5
- import * as apiVersion from './apiVersion.js';
5
+ import { ApiVersion } from './apiVersion.js';
6
6
  import { CryptoProvider } from './crypto/CryptoProvider.js';
7
7
  import { HttpClient, HttpClientResponse } from './net/HttpClient.js';
8
8
  import * as resources from './resources.js';
9
- import { determineProcessUserAgentProperties, pascalToCamelCase, validateInteger, } from './utils.js';
9
+ import { createApiKeyAuthenticator, determineProcessUserAgentProperties, pascalToCamelCase, validateInteger, } from './utils.js';
10
10
  const DEFAULT_HOST = 'api.stripe.com';
11
11
  const DEFAULT_PORT = '443';
12
12
  const DEFAULT_BASE_PATH = '/v1/';
13
- const DEFAULT_API_VERSION = apiVersion.ApiVersion;
13
+ const DEFAULT_API_VERSION = ApiVersion;
14
14
  const DEFAULT_TIMEOUT = 80000;
15
- const MAX_NETWORK_RETRY_DELAY_SEC = 2;
15
+ const MAX_NETWORK_RETRY_DELAY_SEC = 5;
16
16
  const INITIAL_NETWORK_RETRY_DELAY_SEC = 0.5;
17
17
  const APP_INFO_PROPERTIES = ['name', 'version', 'url', 'partner_id'];
18
18
  const ALLOWED_CONFIG_PROPERTIES = [
19
+ 'authenticator',
19
20
  'apiVersion',
20
21
  'typescript',
21
22
  'maxNetworkRetries',
@@ -28,10 +29,11 @@ const ALLOWED_CONFIG_PROPERTIES = [
28
29
  'telemetry',
29
30
  'appInfo',
30
31
  'stripeAccount',
32
+ 'stripeContext',
31
33
  ];
32
34
  const defaultRequestSenderFactory = (stripe) => new RequestSender(stripe, StripeResource.MAX_BUFFERED_REQUEST_METRICS);
33
35
  export function createStripe(platformFunctions, requestSender = defaultRequestSenderFactory) {
34
- Stripe.PACKAGE_VERSION = '16.12.0';
36
+ Stripe.PACKAGE_VERSION = '17.0.0';
35
37
  Stripe.USER_AGENT = Object.assign({ bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', publisher: 'stripe', uname: null, typescript: false }, determineProcessUserAgentProperties());
36
38
  Stripe.StripeResource = StripeResource;
37
39
  Stripe.resources = resources;
@@ -66,14 +68,13 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
66
68
  this.off = this._emitter.removeListener.bind(this._emitter);
67
69
  const agent = props.httpAgent || null;
68
70
  this._api = {
69
- auth: null,
70
71
  host: props.host || DEFAULT_HOST,
71
72
  port: props.port || DEFAULT_PORT,
72
73
  protocol: props.protocol || 'https',
73
74
  basePath: DEFAULT_BASE_PATH,
74
75
  version: props.apiVersion || DEFAULT_API_VERSION,
75
76
  timeout: validateInteger('timeout', props.timeout, DEFAULT_TIMEOUT),
76
- maxNetworkRetries: validateInteger('maxNetworkRetries', props.maxNetworkRetries, 1),
77
+ maxNetworkRetries: validateInteger('maxNetworkRetries', props.maxNetworkRetries, 2),
77
78
  agent: agent,
78
79
  httpClient: props.httpClient ||
79
80
  (agent
@@ -81,6 +82,7 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
81
82
  : this._platformFunctions.createDefaultHttpClient()),
82
83
  dev: false,
83
84
  stripeAccount: props.stripeAccount || null,
85
+ stripeContext: props.stripeContext || null,
84
86
  };
85
87
  const typescript = props.typescript || false;
86
88
  if (typescript !== Stripe.USER_AGENT.typescript) {
@@ -94,7 +96,7 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
94
96
  this._setAppInfo(props.appInfo);
95
97
  }
96
98
  this._prepResources();
97
- this._setApiKey(key);
99
+ this._setAuthenticator(key, props.authenticator);
98
100
  this.errors = _Error;
99
101
  // Once Stripe.webhooks looses the factory function signature in a future release
100
102
  // then this should become this.webhooks = Stripe.webhooks
@@ -147,13 +149,22 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
147
149
  _enableTelemetry: null,
148
150
  _requestSender: null,
149
151
  _platformFunctions: null,
152
+ rawRequest(method, path, params, options) {
153
+ return this._requestSender._rawRequest(method, path, params, options);
154
+ },
150
155
  /**
151
156
  * @private
152
157
  */
153
- _setApiKey(key) {
154
- if (key) {
155
- this._setApiField('auth', `Bearer ${key}`);
158
+ _setAuthenticator(key, authenticator) {
159
+ if (key && authenticator) {
160
+ throw new Error("Can't specify both apiKey and authenticator");
161
+ }
162
+ if (!key && !authenticator) {
163
+ throw new Error('Neither apiKey nor config.authenticator provided');
156
164
  }
165
+ this._authenticator = key
166
+ ? createApiKeyAuthenticator(key)
167
+ : authenticator;
157
168
  },
158
169
  /**
159
170
  * @private
@@ -352,6 +363,10 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
352
363
  }
353
364
  return config;
354
365
  },
366
+ parseThinEvent(payload, header, secret, tolerance, cryptoProvider, receivedAt) {
367
+ // parses and validates the event payload all in one go
368
+ return this.webhooks.constructEvent(payload, header, secret, tolerance, cryptoProvider, receivedAt);
369
+ },
355
370
  };
356
371
  return Stripe;
357
372
  }
package/esm/utils.js CHANGED
@@ -7,6 +7,9 @@ const OPTIONS_KEYS = [
7
7
  'maxNetworkRetries',
8
8
  'timeout',
9
9
  'host',
10
+ 'authenticator',
11
+ 'stripeContext',
12
+ 'additionalHeaders',
10
13
  ];
11
14
  export function isOptionsHash(o) {
12
15
  return (o &&
@@ -17,10 +20,11 @@ export function isOptionsHash(o) {
17
20
  * Stringifies an Object, accommodating nested objects
18
21
  * (forming the conventional key 'parent[child]=value')
19
22
  */
20
- export function stringifyRequestData(data) {
23
+ export function queryStringifyRequestData(data, apiMode) {
21
24
  return (qs
22
25
  .stringify(data, {
23
26
  serializeDate: (d) => Math.floor(d.getTime() / 1000).toString(),
27
+ arrayFormat: apiMode == 'v2' ? 'repeat' : 'indices',
24
28
  })
25
29
  // Don't use strict form encoding by changing the square bracket control
26
30
  // characters back to their literals. This is fine by the server, and
@@ -87,7 +91,6 @@ export function getDataFromArgs(args) {
87
91
  */
88
92
  export function getOptionsFromArgs(args) {
89
93
  const opts = {
90
- auth: null,
91
94
  host: null,
92
95
  headers: {},
93
96
  settings: {},
@@ -95,7 +98,7 @@ export function getOptionsFromArgs(args) {
95
98
  if (args.length > 0) {
96
99
  const arg = args[args.length - 1];
97
100
  if (typeof arg === 'string') {
98
- opts.auth = args.pop();
101
+ opts.authenticator = createApiKeyAuthenticator(args.pop());
99
102
  }
100
103
  else if (isOptionsHash(arg)) {
101
104
  const params = Object.assign({}, args.pop());
@@ -104,7 +107,7 @@ export function getOptionsFromArgs(args) {
104
107
  emitWarning(`Invalid options found (${extraKeys.join(', ')}); ignoring.`);
105
108
  }
106
109
  if (params.apiKey) {
107
- opts.auth = params.apiKey;
110
+ opts.authenticator = createApiKeyAuthenticator(params.apiKey);
108
111
  }
109
112
  if (params.idempotencyKey) {
110
113
  opts.headers['Idempotency-Key'] = params.idempotencyKey;
@@ -112,6 +115,12 @@ export function getOptionsFromArgs(args) {
112
115
  if (params.stripeAccount) {
113
116
  opts.headers['Stripe-Account'] = params.stripeAccount;
114
117
  }
118
+ if (params.stripeContext) {
119
+ if (opts.headers['Stripe-Account']) {
120
+ throw new Error("Can't specify both stripeAccount and stripeContext.");
121
+ }
122
+ opts.headers['Stripe-Context'] = params.stripeContext;
123
+ }
115
124
  if (params.apiVersion) {
116
125
  opts.headers['Stripe-Version'] = params.apiVersion;
117
126
  }
@@ -124,6 +133,19 @@ export function getOptionsFromArgs(args) {
124
133
  if (params.host) {
125
134
  opts.host = params.host;
126
135
  }
136
+ if (params.authenticator) {
137
+ if (params.apiKey) {
138
+ throw new Error("Can't specify both apiKey and authenticator.");
139
+ }
140
+ if (typeof params.authenticator !== 'function') {
141
+ throw new Error('The authenticator must be a function ' +
142
+ 'receiving a request as the first parameter.');
143
+ }
144
+ opts.authenticator = params.authenticator;
145
+ }
146
+ if (params.additionalHeaders) {
147
+ opts.headers = params.additionalHeaders;
148
+ }
127
149
  }
128
150
  }
129
151
  return opts;
@@ -270,6 +292,15 @@ export function determineProcessUserAgentProperties() {
270
292
  platform: process.platform,
271
293
  };
272
294
  }
295
+ export function createApiKeyAuthenticator(apiKey) {
296
+ const authenticator = (request) => {
297
+ request.headers.Authorization = 'Bearer ' + apiKey;
298
+ return Promise.resolve();
299
+ };
300
+ // For testing
301
+ authenticator._apiKey = apiKey;
302
+ return authenticator;
303
+ }
273
304
  /**
274
305
  * Joins an array of Uint8Arrays into a single Uint8Array
275
306
  */
@@ -283,3 +314,27 @@ export function concat(arrays) {
283
314
  });
284
315
  return merged;
285
316
  }
317
+ /**
318
+ * Replaces Date objects with Unix timestamps
319
+ */
320
+ function dateTimeReplacer(key, value) {
321
+ if (this[key] instanceof Date) {
322
+ return Math.floor(this[key].getTime() / 1000).toString();
323
+ }
324
+ return value;
325
+ }
326
+ /**
327
+ * JSON stringifies an Object, replacing Date objects with Unix timestamps
328
+ */
329
+ export function jsonStringifyRequestData(data) {
330
+ return JSON.stringify(data, dateTimeReplacer);
331
+ }
332
+ /**
333
+ * Inspects the given path to determine if the endpoint is for v1 or v2 API
334
+ */
335
+ export function getAPIMode(path) {
336
+ if (!path) {
337
+ return 'v1';
338
+ }
339
+ return path.startsWith('/v2') ? 'v2' : 'v1';
340
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stripe",
3
- "version": "16.12.0",
3
+ "version": "17.0.0",
4
4
  "description": "Stripe API wrapper",
5
5
  "keywords": [
6
6
  "stripe",
@@ -22,11 +22,6 @@ declare module 'stripe' {
22
22
  */
23
23
  alert_type: 'usage_threshold';
24
24
 
25
- /**
26
- * Limits the scope of the alert to a specific [customer](https://stripe.com/docs/api/customers).
27
- */
28
- filter: Alert.Filter | null;
29
-
30
25
  /**
31
26
  * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
32
27
  */
@@ -45,20 +40,18 @@ declare module 'stripe' {
45
40
  /**
46
41
  * Encapsulates configuration of the alert to monitor usage on a specific [Billing Meter](https://stripe.com/docs/api/billing/meter).
47
42
  */
48
- usage_threshold_config: Alert.UsageThresholdConfig | null;
43
+ usage_threshold: Alert.UsageThreshold | null;
49
44
  }
50
45
 
51
46
  namespace Alert {
52
- interface Filter {
47
+ type Status = 'active' | 'archived' | 'inactive';
48
+
49
+ interface UsageThreshold {
53
50
  /**
54
- * Limit the scope of the alert to this customer ID
51
+ * The filters allow limiting the scope of this usage alert. You can only specify up to one filter at this time.
55
52
  */
56
- customer: string | Stripe.Customer | null;
57
- }
53
+ filters: Array<UsageThreshold.Filter> | null;
58
54
 
59
- type Status = 'active' | 'archived' | 'inactive';
60
-
61
- interface UsageThresholdConfig {
62
55
  /**
63
56
  * The value at which this alert will trigger.
64
57
  */
@@ -74,6 +67,17 @@ declare module 'stripe' {
74
67
  */
75
68
  recurrence: 'one_time';
76
69
  }
70
+
71
+ namespace UsageThreshold {
72
+ interface Filter {
73
+ /**
74
+ * Limit the scope of the alert to this customer ID
75
+ */
76
+ customer: string | Stripe.Customer | null;
77
+
78
+ type: 'customer';
79
+ }
80
+ }
77
81
  }
78
82
  }
79
83
  }
@@ -19,36 +19,19 @@ declare module 'stripe' {
19
19
  */
20
20
  expand?: Array<string>;
21
21
 
22
- /**
23
- * Filters to limit the scope of an alert.
24
- */
25
- filter?: AlertCreateParams.Filter;
26
-
27
22
  /**
28
23
  * The configuration of the usage threshold.
29
24
  */
30
- usage_threshold_config?: AlertCreateParams.UsageThresholdConfig;
25
+ usage_threshold?: AlertCreateParams.UsageThreshold;
31
26
  }
32
27
 
33
28
  namespace AlertCreateParams {
34
- interface Filter {
35
- /**
36
- * Limit the scope to this alert only to this customer.
37
- */
38
- customer?: string;
39
-
29
+ interface UsageThreshold {
40
30
  /**
41
- * Limit the scope of this rated usage alert to this subscription.
31
+ * The filters allows limiting the scope of this usage alert. You can only specify up to one filter at this time.
42
32
  */
43
- subscription?: string;
33
+ filters?: Array<UsageThreshold.Filter>;
44
34
 
45
- /**
46
- * Limit the scope of this rated usage alert to this subscription item.
47
- */
48
- subscription_item?: string;
49
- }
50
-
51
- interface UsageThresholdConfig {
52
35
  /**
53
36
  * Defines at which value the alert will fire.
54
37
  */
@@ -64,6 +47,20 @@ declare module 'stripe' {
64
47
  */
65
48
  recurrence: 'one_time';
66
49
  }
50
+
51
+ namespace UsageThreshold {
52
+ interface Filter {
53
+ /**
54
+ * Limit the scope to this usage alert only to this customer.
55
+ */
56
+ customer?: string;
57
+
58
+ /**
59
+ * What type of filter is being applied to this usage alert.
60
+ */
61
+ type: 'customer';
62
+ }
63
+ }
67
64
  }
68
65
 
69
66
  interface AlertRetrieveParams {
@@ -0,0 +1,94 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace Billing {
6
+ /**
7
+ * Indicates the credit balance for credits granted to a customer.
8
+ */
9
+ interface CreditBalanceSummary {
10
+ /**
11
+ * String representing the object's type. Objects of the same type share the same value.
12
+ */
13
+ object: 'billing.credit_balance_summary';
14
+
15
+ /**
16
+ * The credit balances. One entry per credit grant currency. If a customer only has credit grants in a single currency, then this will have a single balance entry.
17
+ */
18
+ balances: Array<CreditBalanceSummary.Balance>;
19
+
20
+ /**
21
+ * The customer the balance is for.
22
+ */
23
+ customer: string | Stripe.Customer | Stripe.DeletedCustomer;
24
+
25
+ /**
26
+ * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
27
+ */
28
+ livemode: boolean;
29
+ }
30
+
31
+ namespace CreditBalanceSummary {
32
+ interface Balance {
33
+ available_balance: Balance.AvailableBalance;
34
+
35
+ ledger_balance: Balance.LedgerBalance;
36
+ }
37
+
38
+ namespace Balance {
39
+ interface AvailableBalance {
40
+ /**
41
+ * The monetary amount.
42
+ */
43
+ monetary: AvailableBalance.Monetary | null;
44
+
45
+ /**
46
+ * The type of this amount. We currently only support `monetary` credits.
47
+ */
48
+ type: 'monetary';
49
+ }
50
+
51
+ namespace AvailableBalance {
52
+ interface Monetary {
53
+ /**
54
+ * Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
55
+ */
56
+ currency: string;
57
+
58
+ /**
59
+ * A positive integer representing the amount.
60
+ */
61
+ value: number;
62
+ }
63
+ }
64
+
65
+ interface LedgerBalance {
66
+ /**
67
+ * The monetary amount.
68
+ */
69
+ monetary: LedgerBalance.Monetary | null;
70
+
71
+ /**
72
+ * The type of this amount. We currently only support `monetary` credits.
73
+ */
74
+ type: 'monetary';
75
+ }
76
+
77
+ namespace LedgerBalance {
78
+ interface Monetary {
79
+ /**
80
+ * Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Must be a [supported currency](https://stripe.com/docs/currencies).
81
+ */
82
+ currency: string;
83
+
84
+ /**
85
+ * A positive integer representing the amount.
86
+ */
87
+ value: number;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }
@@ -0,0 +1,64 @@
1
+ // File generated from our OpenAPI spec
2
+
3
+ declare module 'stripe' {
4
+ namespace Stripe {
5
+ namespace Billing {
6
+ interface CreditBalanceSummaryRetrieveParams {
7
+ /**
8
+ * The customer for which to fetch credit balance summary.
9
+ */
10
+ customer: string;
11
+
12
+ /**
13
+ * The filter criteria for the credit balance summary.
14
+ */
15
+ filter: CreditBalanceSummaryRetrieveParams.Filter;
16
+
17
+ /**
18
+ * Specifies which fields in the response should be expanded.
19
+ */
20
+ expand?: Array<string>;
21
+ }
22
+
23
+ namespace CreditBalanceSummaryRetrieveParams {
24
+ interface Filter {
25
+ /**
26
+ * The credit applicability scope for which to fetch balance summary.
27
+ */
28
+ applicability_scope?: Filter.ApplicabilityScope;
29
+
30
+ /**
31
+ * The credit grant for which to fetch balance summary.
32
+ */
33
+ credit_grant?: string;
34
+
35
+ /**
36
+ * Specify the type of this filter.
37
+ */
38
+ type: Filter.Type;
39
+ }
40
+
41
+ namespace Filter {
42
+ interface ApplicabilityScope {
43
+ /**
44
+ * The price type to which credit grants can apply to. We currently only support `metered` price type.
45
+ */
46
+ price_type: 'metered';
47
+ }
48
+
49
+ type Type = 'applicability_scope' | 'credit_grant';
50
+ }
51
+ }
52
+
53
+ class CreditBalanceSummaryResource {
54
+ /**
55
+ * Retrieves the credit balance summary for a customer
56
+ */
57
+ retrieve(
58
+ params: CreditBalanceSummaryRetrieveParams,
59
+ options?: RequestOptions
60
+ ): Promise<Stripe.Response<Stripe.Billing.CreditBalanceSummary>>;
61
+ }
62
+ }
63
+ }
64
+ }