stripe 18.1.0-beta.3 → 18.2.0-beta.1

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 (89) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/OPENAPI_VERSION +1 -1
  3. package/VERSION +1 -1
  4. package/cjs/Error.js +2 -2
  5. package/cjs/RequestSender.js +3 -7
  6. package/cjs/Webhooks.js +6 -2
  7. package/cjs/apiVersion.js +1 -1
  8. package/cjs/net/FetchHttpClient.js +3 -4
  9. package/cjs/resources/Privacy/RedactionJobs.js +0 -4
  10. package/cjs/resources/V2/MoneyManagement/OutboundPaymentQuotes.js +4 -0
  11. package/cjs/stripe.core.js +2 -4
  12. package/cjs/utils.js +28 -4
  13. package/esm/Error.js +2 -2
  14. package/esm/RequestSender.js +4 -8
  15. package/esm/Webhooks.js +6 -2
  16. package/esm/apiVersion.js +1 -1
  17. package/esm/net/FetchHttpClient.js +3 -4
  18. package/esm/resources/Privacy/RedactionJobs.js +0 -4
  19. package/esm/resources/V2/MoneyManagement/OutboundPaymentQuotes.js +4 -0
  20. package/esm/stripe.core.js +2 -4
  21. package/esm/utils.js +24 -3
  22. package/package.json +12 -3
  23. package/types/AccountsResource.d.ts +2 -2
  24. package/types/ChargesResource.d.ts +2 -2
  25. package/types/Checkout/Sessions.d.ts +24 -4
  26. package/types/Checkout/SessionsResource.d.ts +7 -0
  27. package/types/ConfirmationTokens.d.ts +5 -0
  28. package/types/CustomersResource.d.ts +23 -3
  29. package/types/Events.d.ts +2 -2
  30. package/types/ExternalAccountsResource.d.ts +1 -1
  31. package/types/InvoiceLineItems.d.ts +1 -1
  32. package/types/Invoices.d.ts +12 -2
  33. package/types/InvoicesResource.d.ts +25 -1
  34. package/types/Orders.d.ts +11 -1
  35. package/types/OrdersResource.d.ts +22 -2
  36. package/types/PaymentIntentsResource.d.ts +4 -4
  37. package/types/PaymentMethods.d.ts +5 -0
  38. package/types/Privacy/RedactionJobs.d.ts +23 -1
  39. package/types/Privacy/RedactionJobsResource.d.ts +0 -22
  40. package/types/QuotePreviewInvoices.d.ts +12 -2
  41. package/types/QuotePreviewSubscriptionSchedules.d.ts +7 -0
  42. package/types/Quotes.d.ts +8 -1
  43. package/types/QuotesResource.d.ts +7 -0
  44. package/types/SubscriptionSchedules.d.ts +7 -0
  45. package/types/SubscriptionSchedulesResource.d.ts +7 -0
  46. package/types/Subscriptions.d.ts +7 -0
  47. package/types/SubscriptionsResource.d.ts +8 -1
  48. package/types/Tax/Calculations.d.ts +11 -1
  49. package/types/Tax/CalculationsResource.d.ts +11 -1
  50. package/types/Tax/Registrations.d.ts +27 -0
  51. package/types/Tax/RegistrationsResource.d.ts +36 -0
  52. package/types/Tax/Transactions.d.ts +11 -1
  53. package/types/TaxIds.d.ts +11 -1
  54. package/types/TaxIdsResource.d.ts +11 -1
  55. package/types/TestHelpers/ConfirmationTokensResource.d.ts +7 -1
  56. package/types/Treasury/OutboundPaymentsResource.d.ts +0 -5
  57. package/types/V2/Core/AccountLinks.d.ts +6 -1
  58. package/types/V2/Core/Accounts/PersonsResource.d.ts +10 -0
  59. package/types/V2/Core/Accounts.d.ts +142 -30
  60. package/types/V2/Core/AccountsResource.d.ts +25 -6
  61. package/types/V2/Core/Persons.d.ts +10 -0
  62. package/types/V2/Core/Vault/GbBankAccounts.d.ts +7 -2
  63. package/types/V2/Core/Vault/GbBankAccountsResource.d.ts +1 -1
  64. package/types/V2/Core/Vault/UsBankAccounts.d.ts +8 -3
  65. package/types/V2/Core/Vault/UsBankAccountsResource.d.ts +5 -5
  66. package/types/V2/EventTypes.d.ts +174 -33
  67. package/types/V2/FinancialAddressCreditSimulations.d.ts +5 -0
  68. package/types/V2/FinancialAddressGeneratedMicrodeposits.d.ts +5 -0
  69. package/types/V2/MoneyManagement/Adjustments.d.ts +7 -2
  70. package/types/V2/MoneyManagement/FinancialAccounts.d.ts +7 -1
  71. package/types/V2/MoneyManagement/FinancialAddresses.d.ts +6 -0
  72. package/types/V2/MoneyManagement/FinancialAddressesResource.d.ts +1 -0
  73. package/types/V2/MoneyManagement/InboundTransfers.d.ts +6 -1
  74. package/types/V2/MoneyManagement/OutboundPaymentQuotes.d.ts +28 -1
  75. package/types/V2/MoneyManagement/OutboundPaymentQuotesResource.d.ts +22 -0
  76. package/types/V2/MoneyManagement/OutboundPayments.d.ts +7 -2
  77. package/types/V2/MoneyManagement/OutboundSetupIntents.d.ts +5 -0
  78. package/types/V2/MoneyManagement/OutboundTransfers.d.ts +7 -2
  79. package/types/V2/MoneyManagement/PayoutMethods.d.ts +7 -2
  80. package/types/V2/MoneyManagement/PayoutMethodsBankAccountSpecs.d.ts +5 -0
  81. package/types/V2/MoneyManagement/ReceivedCredits.d.ts +5 -0
  82. package/types/V2/MoneyManagement/ReceivedDebits.d.ts +5 -0
  83. package/types/V2/MoneyManagement/TransactionEntries.d.ts +5 -1
  84. package/types/V2/MoneyManagement/Transactions.d.ts +5 -1
  85. package/types/WebhookEndpointsResource.d.ts +6 -5
  86. package/types/index.d.ts +0 -1
  87. package/types/lib.d.ts +1 -1
  88. package/types/test/typescriptTest.ts +3 -3
  89. package/types/Privacy/RedactionJobRootObjects.d.ts +0 -35
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 18.2.0-beta.1 - 2025-04-30
4
+ * [#2307](https://github.com/stripe/stripe-node/pull/2307) Update generated code for beta
5
+ This release changes the pinned API version to `2025-04-30.preview`.
6
+
7
+ * Add support for `billing_mode` on `Checkout.SessionCreateParams.subscription_data`, `InvoiceCreatePreviewParams.schedule_details`, `InvoiceCreatePreviewParams.subscription_details`, `Quote.subscription_data`, `QuoteCreateParams.subscription_data`, `QuotePreviewSubscriptionSchedule`, `SubscriptionCreateParams`, `SubscriptionScheduleCreateParams`, `SubscriptionSchedule`, and `Subscription`
8
+ * Add support for new values `aw_tin`, `az_tin`, `bd_bin`, `bf_ifu`, `bj_ifu`, `cm_niu`, `cv_nif`, `et_tin`, `kg_tin`, and `la_tin` on enums `Checkout.Session.collected_information.tax_ids[].type`, `Order.tax_details.tax_ids[].type`, and `QuotePreviewInvoice.customer_tax_ids[].type`
9
+ * Change `Checkout.Session.automatic_tax.provider`, `Invoice.automatic_tax.provider`, `Quote.automatic_tax.provider`, and `QuotePreviewInvoice.automatic_tax.provider` to be required
10
+ * Add support for `account_number` on `ConfirmationToken.payment_method_preview.acss_debit` and `PaymentMethod.acss_debit`
11
+ * Add support for new value `balance_settings.updated` on enum `Event.type`
12
+ * Add support for new values `aw_tin`, `az_tin`, `bd_bin`, `bf_ifu`, `bj_ifu`, `cm_niu`, `cv_nif`, `et_tin`, `kg_tin`, and `la_tin` on enums `OrderCreateParams.tax_details.tax_ids[].type` and `OrderUpdateParams.tax_details.tax_ids[].type`
13
+ * Add support for new value `balance_settings.updated` on enums `WebhookEndpointUpdateParams.enabled_events`
14
+
3
15
  ## 18.1.0-beta.3 - 2025-04-17
4
16
  * [#2302](https://github.com/stripe/stripe-node/pull/2302) Update generated code for beta
5
17
  * Add support for new resources `FxQuote` and `PaymentIntentAmountDetailsLineItem`
package/OPENAPI_VERSION CHANGED
@@ -1 +1 @@
1
- v1697
1
+ v1719
package/VERSION CHANGED
@@ -1 +1 @@
1
- 18.1.0-beta.3
1
+ 18.2.0-beta.1
package/cjs/Error.js CHANGED
@@ -69,6 +69,7 @@ exports.generateV2Error = generateV2Error;
69
69
  */
70
70
  class StripeError extends Error {
71
71
  constructor(raw = {}, type = null) {
72
+ var _a;
72
73
  super(raw.message);
73
74
  this.type = type || this.constructor.name;
74
75
  this.raw = raw;
@@ -80,8 +81,7 @@ class StripeError extends Error {
80
81
  this.headers = raw.headers;
81
82
  this.requestId = raw.requestId;
82
83
  this.statusCode = raw.statusCode;
83
- // @ts-ignore
84
- this.message = raw.message;
84
+ this.message = (_a = raw.message) !== null && _a !== void 0 ? _a : '';
85
85
  this.userMessage = raw.user_message;
86
86
  this.charge = raw.charge;
87
87
  this.decline_code = raw.decline_code;
@@ -366,11 +366,10 @@ class RequestSender {
366
366
  .getApiField('httpClient')
367
367
  .makeRequest(request.host, request.port, request.path, request.method, request.headers, request.body, request.protocol, timeout);
368
368
  const requestStartTime = Date.now();
369
- // @ts-ignore
370
369
  const requestEvent = (0, utils_js_1.removeNullish)({
371
370
  api_version: apiVersion,
372
- account: headers['Stripe-Account'],
373
- idempotency_key: headers['Idempotency-Key'],
371
+ account: (0, utils_js_1.parseHttpHeaderAsString)(headers['Stripe-Account']),
372
+ idempotency_key: (0, utils_js_1.parseHttpHeaderAsString)(headers['Idempotency-Key']),
374
373
  method,
375
374
  path,
376
375
  request_start_time: requestStartTime,
@@ -381,9 +380,7 @@ class RequestSender {
381
380
  req
382
381
  .then((res) => {
383
382
  if (RequestSender._shouldRetry(res, requestRetries, maxRetries)) {
384
- return retryRequest(makeRequest, apiVersion, headers, requestRetries,
385
- // @ts-ignore
386
- res.getHeaders()['retry-after']);
383
+ return retryRequest(makeRequest, apiVersion, headers, requestRetries, (0, utils_js_1.parseHttpHeaderAsNumber)(res.getHeaders()['retry-after']));
387
384
  }
388
385
  else if (options.streaming && res.getStatusCode() < 400) {
389
386
  return this._streamingResponseHandler(requestEvent, usage, callback)(res);
@@ -402,7 +399,6 @@ class RequestSender {
402
399
  message: isTimeoutError
403
400
  ? `Request aborted due to timeout being reached (${timeout}ms)`
404
401
  : RequestSender._generateConnectionErrorMessage(requestRetries),
405
- // @ts-ignore
406
402
  detail: error,
407
403
  }));
408
404
  }
package/cjs/Webhooks.js CHANGED
@@ -6,10 +6,12 @@ const CryptoProvider_js_1 = require("./crypto/CryptoProvider.js");
6
6
  function createWebhooks(platformFunctions) {
7
7
  const Webhook = {
8
8
  DEFAULT_TOLERANCE: 300,
9
- // @ts-ignore
10
9
  signature: null,
11
10
  constructEvent(payload, header, secret, tolerance, cryptoProvider, receivedAt) {
12
11
  try {
12
+ if (!this.signature) {
13
+ throw new Error('ERR: missing signature helper, unable to verify');
14
+ }
13
15
  this.signature.verifyHeader(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider, receivedAt);
14
16
  }
15
17
  catch (e) {
@@ -25,6 +27,9 @@ function createWebhooks(platformFunctions) {
25
27
  return jsonPayload;
26
28
  },
27
29
  async constructEventAsync(payload, header, secret, tolerance, cryptoProvider, receivedAt) {
30
+ if (!this.signature) {
31
+ throw new Error('ERR: missing signature helper, unable to verify');
32
+ }
28
33
  await this.signature.verifyHeaderAsync(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider, receivedAt);
29
34
  const jsonPayload = payload instanceof Uint8Array
30
35
  ? JSON.parse(new TextDecoder('utf8').decode(payload))
@@ -151,7 +156,6 @@ function createWebhooks(platformFunctions) {
151
156
  }
152
157
  const timestampAge = Math.floor((typeof receivedAt === 'number' ? receivedAt : Date.now()) / 1000) - details.timestamp;
153
158
  if (tolerance > 0 && timestampAge > tolerance) {
154
- // @ts-ignore
155
159
  throw new Error_js_1.StripeSignatureVerificationError(header, payload, {
156
160
  message: 'Timestamp outside the tolerance zone',
157
161
  });
package/cjs/apiVersion.js CHANGED
@@ -2,4 +2,4 @@
2
2
  // File generated from our OpenAPI spec
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.ApiVersion = void 0;
5
- exports.ApiVersion = '2025-03-31.preview';
5
+ exports.ApiVersion = '2025-04-30.preview';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FetchHttpClientResponse = exports.FetchHttpClient = void 0;
4
+ const utils_js_1 = require("../utils.js");
4
5
  const HttpClient_js_1 = require("./HttpClient.js");
5
6
  /**
6
7
  * HTTP client which uses a `fetch` function to issue requests.
@@ -97,10 +98,8 @@ class FetchHttpClient extends HttpClient_js_1.HttpClient {
97
98
  const body = requestData || (methodHasPayload ? '' : undefined);
98
99
  const res = await this._fetchFn(url.toString(), {
99
100
  method,
100
- // @ts-ignore
101
- headers,
102
- // @ts-ignore
103
- body,
101
+ headers: (0, utils_js_1.parseHeadersForFetch)(headers),
102
+ body: typeof body === 'object' ? JSON.stringify(body) : body,
104
103
  }, timeout);
105
104
  return new FetchHttpClientResponse(res);
106
105
  }
@@ -31,10 +31,6 @@ exports.RedactionJobs = StripeResource_js_1.StripeResource.extend({
31
31
  fullPath: '/v1/privacy/redaction_jobs/{job}/validation_errors',
32
32
  methodType: 'list',
33
33
  }),
34
- retrieveValidationError: stripeMethod({
35
- method: 'GET',
36
- fullPath: '/v1/privacy/redaction_jobs/{job}/validation_errors/{error}',
37
- }),
38
34
  run: stripeMethod({
39
35
  method: 'POST',
40
36
  fullPath: '/v1/privacy/redaction_jobs/{job}/run',
@@ -9,4 +9,8 @@ exports.OutboundPaymentQuotes = StripeResource_js_1.StripeResource.extend({
9
9
  method: 'POST',
10
10
  fullPath: '/v2/money_management/outbound_payment_quotes',
11
11
  }),
12
+ retrieve: stripeMethod({
13
+ method: 'GET',
14
+ fullPath: '/v2/money_management/outbound_payment_quotes/{id}',
15
+ }),
12
16
  });
@@ -36,7 +36,7 @@ const ALLOWED_CONFIG_PROPERTIES = [
36
36
  ];
37
37
  const defaultRequestSenderFactory = (stripe) => new RequestSender_js_1.RequestSender(stripe, StripeResource_js_1.StripeResource.MAX_BUFFERED_REQUEST_METRICS);
38
38
  function createStripe(platformFunctions, requestSender = defaultRequestSenderFactory) {
39
- Stripe.PACKAGE_VERSION = '18.1.0-beta.3';
39
+ Stripe.PACKAGE_VERSION = '18.2.0-beta.1';
40
40
  Stripe.USER_AGENT = Object.assign({ bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', publisher: 'stripe', uname: null, typescript: false }, (0, utils_js_1.determineProcessUserAgentProperties)());
41
41
  Stripe.StripeResource = StripeResource_js_1.StripeResource;
42
42
  Stripe.resources = resources;
@@ -176,9 +176,7 @@ function createStripe(platformFunctions, requestSender = defaultRequestSenderFac
176
176
  accum[prop] = info[prop];
177
177
  }
178
178
  return accum;
179
- },
180
- // @ts-ignore
181
- undefined);
179
+ }, {});
182
180
  },
183
181
  /**
184
182
  * @private
package/cjs/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAPIMode = exports.jsonStringifyRequestData = exports.concat = exports.createApiKeyAuthenticator = exports.determineProcessUserAgentProperties = exports.validateInteger = exports.flattenAndStringify = exports.isObject = exports.emitWarning = exports.pascalToCamelCase = exports.callbackifyPromiseWithTimeout = exports.normalizeHeader = exports.normalizeHeaders = exports.removeNullish = exports.protoExtend = exports.getOptionsFromArgs = exports.getDataFromArgs = exports.extractUrlParams = exports.makeURLInterpolator = exports.queryStringifyRequestData = exports.isOptionsHash = void 0;
3
+ exports.parseHeadersForFetch = exports.parseHttpHeaderAsNumber = exports.parseHttpHeaderAsString = exports.getAPIMode = exports.jsonStringifyRequestData = exports.concat = exports.createApiKeyAuthenticator = exports.determineProcessUserAgentProperties = exports.validateInteger = exports.flattenAndStringify = exports.isObject = exports.emitWarning = exports.pascalToCamelCase = exports.callbackifyPromiseWithTimeout = exports.normalizeHeader = exports.normalizeHeaders = exports.removeNullish = exports.protoExtend = exports.getOptionsFromArgs = exports.getDataFromArgs = exports.extractUrlParams = exports.makeURLInterpolator = exports.queryStringifyRequestData = exports.isOptionsHash = void 0;
4
4
  const qs = require("qs");
5
5
  const OPTIONS_KEYS = [
6
6
  'apiKey',
@@ -53,12 +53,18 @@ exports.makeURLInterpolator = (() => {
53
53
  return (str) => {
54
54
  const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]);
55
55
  return (outputs) => {
56
- return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) =>
57
- // @ts-ignore
58
- encodeURIComponent(outputs[$1] || ''));
56
+ return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => {
57
+ const output = outputs[$1];
58
+ if (isValidEncodeUriComponentType(output))
59
+ return encodeURIComponent(output);
60
+ return '';
61
+ });
59
62
  };
60
63
  };
61
64
  })();
65
+ function isValidEncodeUriComponentType(value) {
66
+ return ['number', 'string', 'boolean'].includes(typeof value);
67
+ }
62
68
  function extractUrlParams(path) {
63
69
  const params = path.match(/\{\w+\}/g);
64
70
  if (!params) {
@@ -361,3 +367,21 @@ function getAPIMode(path) {
361
367
  return path.startsWith('/v2') ? 'v2' : 'v1';
362
368
  }
363
369
  exports.getAPIMode = getAPIMode;
370
+ function parseHttpHeaderAsString(header) {
371
+ if (Array.isArray(header)) {
372
+ return header.join(', ');
373
+ }
374
+ return String(header);
375
+ }
376
+ exports.parseHttpHeaderAsString = parseHttpHeaderAsString;
377
+ function parseHttpHeaderAsNumber(header) {
378
+ const number = Array.isArray(header) ? header[0] : header;
379
+ return Number(number);
380
+ }
381
+ exports.parseHttpHeaderAsNumber = parseHttpHeaderAsNumber;
382
+ function parseHeadersForFetch(headers) {
383
+ return Object.entries(headers).map(([key, value]) => {
384
+ return [key, parseHttpHeaderAsString(value)];
385
+ });
386
+ }
387
+ exports.parseHeadersForFetch = parseHeadersForFetch;
package/esm/Error.js CHANGED
@@ -64,6 +64,7 @@ export const generateV2Error = (rawStripeError) => {
64
64
  */
65
65
  export class StripeError extends Error {
66
66
  constructor(raw = {}, type = null) {
67
+ var _a;
67
68
  super(raw.message);
68
69
  this.type = type || this.constructor.name;
69
70
  this.raw = raw;
@@ -75,8 +76,7 @@ export class StripeError extends Error {
75
76
  this.headers = raw.headers;
76
77
  this.requestId = raw.requestId;
77
78
  this.statusCode = raw.statusCode;
78
- // @ts-ignore
79
- this.message = raw.message;
79
+ this.message = (_a = raw.message) !== null && _a !== void 0 ? _a : '';
80
80
  this.userMessage = raw.user_message;
81
81
  this.charge = raw.charge;
82
82
  this.decline_code = raw.decline_code;
@@ -1,6 +1,6 @@
1
1
  import { StripeAPIError, StripeAuthenticationError, StripeConnectionError, StripeError, StripePermissionError, StripeRateLimitError, generateV1Error, generateV2Error, } from './Error.js';
2
2
  import { HttpClient } from './net/HttpClient.js';
3
- import { emitWarning, jsonStringifyRequestData, normalizeHeaders, queryStringifyRequestData, removeNullish, getAPIMode, getOptionsFromArgs, getDataFromArgs, } from './utils.js';
3
+ import { emitWarning, jsonStringifyRequestData, normalizeHeaders, queryStringifyRequestData, removeNullish, getAPIMode, getOptionsFromArgs, getDataFromArgs, parseHttpHeaderAsString, parseHttpHeaderAsNumber, } from './utils.js';
4
4
  const MAX_RETRY_AFTER_WAIT = 60;
5
5
  export class RequestSender {
6
6
  constructor(stripe, maxBufferedRequestMetric) {
@@ -363,11 +363,10 @@ export class RequestSender {
363
363
  .getApiField('httpClient')
364
364
  .makeRequest(request.host, request.port, request.path, request.method, request.headers, request.body, request.protocol, timeout);
365
365
  const requestStartTime = Date.now();
366
- // @ts-ignore
367
366
  const requestEvent = removeNullish({
368
367
  api_version: apiVersion,
369
- account: headers['Stripe-Account'],
370
- idempotency_key: headers['Idempotency-Key'],
368
+ account: parseHttpHeaderAsString(headers['Stripe-Account']),
369
+ idempotency_key: parseHttpHeaderAsString(headers['Idempotency-Key']),
371
370
  method,
372
371
  path,
373
372
  request_start_time: requestStartTime,
@@ -378,9 +377,7 @@ export class RequestSender {
378
377
  req
379
378
  .then((res) => {
380
379
  if (RequestSender._shouldRetry(res, requestRetries, maxRetries)) {
381
- return retryRequest(makeRequest, apiVersion, headers, requestRetries,
382
- // @ts-ignore
383
- res.getHeaders()['retry-after']);
380
+ return retryRequest(makeRequest, apiVersion, headers, requestRetries, parseHttpHeaderAsNumber(res.getHeaders()['retry-after']));
384
381
  }
385
382
  else if (options.streaming && res.getStatusCode() < 400) {
386
383
  return this._streamingResponseHandler(requestEvent, usage, callback)(res);
@@ -399,7 +396,6 @@ export class RequestSender {
399
396
  message: isTimeoutError
400
397
  ? `Request aborted due to timeout being reached (${timeout}ms)`
401
398
  : RequestSender._generateConnectionErrorMessage(requestRetries),
402
- // @ts-ignore
403
399
  detail: error,
404
400
  }));
405
401
  }
package/esm/Webhooks.js CHANGED
@@ -3,10 +3,12 @@ import { CryptoProviderOnlySupportsAsyncError, } from './crypto/CryptoProvider.j
3
3
  export function createWebhooks(platformFunctions) {
4
4
  const Webhook = {
5
5
  DEFAULT_TOLERANCE: 300,
6
- // @ts-ignore
7
6
  signature: null,
8
7
  constructEvent(payload, header, secret, tolerance, cryptoProvider, receivedAt) {
9
8
  try {
9
+ if (!this.signature) {
10
+ throw new Error('ERR: missing signature helper, unable to verify');
11
+ }
10
12
  this.signature.verifyHeader(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider, receivedAt);
11
13
  }
12
14
  catch (e) {
@@ -22,6 +24,9 @@ export function createWebhooks(platformFunctions) {
22
24
  return jsonPayload;
23
25
  },
24
26
  async constructEventAsync(payload, header, secret, tolerance, cryptoProvider, receivedAt) {
27
+ if (!this.signature) {
28
+ throw new Error('ERR: missing signature helper, unable to verify');
29
+ }
25
30
  await this.signature.verifyHeaderAsync(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider, receivedAt);
26
31
  const jsonPayload = payload instanceof Uint8Array
27
32
  ? JSON.parse(new TextDecoder('utf8').decode(payload))
@@ -148,7 +153,6 @@ export function createWebhooks(platformFunctions) {
148
153
  }
149
154
  const timestampAge = Math.floor((typeof receivedAt === 'number' ? receivedAt : Date.now()) / 1000) - details.timestamp;
150
155
  if (tolerance > 0 && timestampAge > tolerance) {
151
- // @ts-ignore
152
156
  throw new StripeSignatureVerificationError(header, payload, {
153
157
  message: 'Timestamp outside the tolerance zone',
154
158
  });
package/esm/apiVersion.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // File generated from our OpenAPI spec
2
- export const ApiVersion = '2025-03-31.preview';
2
+ export const ApiVersion = '2025-04-30.preview';
@@ -1,3 +1,4 @@
1
+ import { parseHeadersForFetch } from '../utils.js';
1
2
  import { HttpClient, HttpClientResponse, } from './HttpClient.js';
2
3
  /**
3
4
  * HTTP client which uses a `fetch` function to issue requests.
@@ -94,10 +95,8 @@ export class FetchHttpClient extends HttpClient {
94
95
  const body = requestData || (methodHasPayload ? '' : undefined);
95
96
  const res = await this._fetchFn(url.toString(), {
96
97
  method,
97
- // @ts-ignore
98
- headers,
99
- // @ts-ignore
100
- body,
98
+ headers: parseHeadersForFetch(headers),
99
+ body: typeof body === 'object' ? JSON.stringify(body) : body,
101
100
  }, timeout);
102
101
  return new FetchHttpClientResponse(res);
103
102
  }
@@ -28,10 +28,6 @@ export const RedactionJobs = StripeResource.extend({
28
28
  fullPath: '/v1/privacy/redaction_jobs/{job}/validation_errors',
29
29
  methodType: 'list',
30
30
  }),
31
- retrieveValidationError: stripeMethod({
32
- method: 'GET',
33
- fullPath: '/v1/privacy/redaction_jobs/{job}/validation_errors/{error}',
34
- }),
35
31
  run: stripeMethod({
36
32
  method: 'POST',
37
33
  fullPath: '/v1/privacy/redaction_jobs/{job}/run',
@@ -6,4 +6,8 @@ export const OutboundPaymentQuotes = StripeResource.extend({
6
6
  method: 'POST',
7
7
  fullPath: '/v2/money_management/outbound_payment_quotes',
8
8
  }),
9
+ retrieve: stripeMethod({
10
+ method: 'GET',
11
+ fullPath: '/v2/money_management/outbound_payment_quotes/{id}',
12
+ }),
9
13
  });
@@ -33,7 +33,7 @@ const ALLOWED_CONFIG_PROPERTIES = [
33
33
  ];
34
34
  const defaultRequestSenderFactory = (stripe) => new RequestSender(stripe, StripeResource.MAX_BUFFERED_REQUEST_METRICS);
35
35
  export function createStripe(platformFunctions, requestSender = defaultRequestSenderFactory) {
36
- Stripe.PACKAGE_VERSION = '18.1.0-beta.3';
36
+ Stripe.PACKAGE_VERSION = '18.2.0-beta.1';
37
37
  Stripe.USER_AGENT = Object.assign({ bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', publisher: 'stripe', uname: null, typescript: false }, determineProcessUserAgentProperties());
38
38
  Stripe.StripeResource = StripeResource;
39
39
  Stripe.resources = resources;
@@ -173,9 +173,7 @@ export function createStripe(platformFunctions, requestSender = defaultRequestSe
173
173
  accum[prop] = info[prop];
174
174
  }
175
175
  return accum;
176
- },
177
- // @ts-ignore
178
- undefined);
176
+ }, {});
179
177
  },
180
178
  /**
181
179
  * @private
package/esm/utils.js CHANGED
@@ -48,12 +48,18 @@ export const makeURLInterpolator = (() => {
48
48
  return (str) => {
49
49
  const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]);
50
50
  return (outputs) => {
51
- return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) =>
52
- // @ts-ignore
53
- encodeURIComponent(outputs[$1] || ''));
51
+ return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => {
52
+ const output = outputs[$1];
53
+ if (isValidEncodeUriComponentType(output))
54
+ return encodeURIComponent(output);
55
+ return '';
56
+ });
54
57
  };
55
58
  };
56
59
  })();
60
+ function isValidEncodeUriComponentType(value) {
61
+ return ['number', 'string', 'boolean'].includes(typeof value);
62
+ }
57
63
  export function extractUrlParams(path) {
58
64
  const params = path.match(/\{\w+\}/g);
59
65
  if (!params) {
@@ -338,3 +344,18 @@ export function getAPIMode(path) {
338
344
  }
339
345
  return path.startsWith('/v2') ? 'v2' : 'v1';
340
346
  }
347
+ export function parseHttpHeaderAsString(header) {
348
+ if (Array.isArray(header)) {
349
+ return header.join(', ');
350
+ }
351
+ return String(header);
352
+ }
353
+ export function parseHttpHeaderAsNumber(header) {
354
+ const number = Array.isArray(header) ? header[0] : header;
355
+ return Number(number);
356
+ }
357
+ export function parseHeadersForFetch(headers) {
358
+ return Object.entries(headers).map(([key, value]) => {
359
+ return [key, parseHttpHeaderAsString(value)];
360
+ });
361
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stripe",
3
- "version": "18.1.0-beta.3",
3
+ "version": "18.2.0-beta.1",
4
4
  "description": "Stripe API wrapper",
5
5
  "keywords": [
6
6
  "stripe",
@@ -31,6 +31,7 @@
31
31
  "@types/chai-as-promised": "^7.1.5",
32
32
  "@types/mocha": "^10.0.1",
33
33
  "@types/qs": "^6.9.7",
34
+ "@types/node": ">=12.0.0",
34
35
  "@typescript-eslint/eslint-plugin": "^4.33.0",
35
36
  "@typescript-eslint/parser": "^4.33.0",
36
37
  "chai": "^4.3.6",
@@ -47,16 +48,24 @@
47
48
  "nyc": "^15.1.0",
48
49
  "prettier": "^1.16.4",
49
50
  "ts-node": "^10.9.1",
50
- "typescript": "^4.9.4"
51
+ "typescript": "^4.9.4",
52
+ "undici-types": "^7.8.0"
51
53
  },
52
54
  "resolutions": {
53
55
  "minimist": "1.2.6",
54
56
  "nanoid": "^3.2.0"
55
57
  },
56
58
  "dependencies": {
57
- "@types/node": ">=8.1.0",
58
59
  "qs": "^6.11.0"
59
60
  },
61
+ "peerDependencies": {
62
+ "@types/node": ">=12.x.x"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@types/node": {
66
+ "optional": true
67
+ }
68
+ },
60
69
  "license": "MIT",
61
70
  "scripts": {
62
71
  "test": "tsc -p tsconfig.cjs.json && mocha",
@@ -2212,7 +2212,7 @@ declare module 'stripe' {
2212
2212
  currency?: string;
2213
2213
 
2214
2214
  /**
2215
- * The routing number, sort code, or other country-appropriateinstitution number for the bank account. For US bank accounts, this is required and should bethe ACH routing number, not the wire routing number. If you are providing an IBAN for`account_number`, this field is not required.
2215
+ * The routing number, sort code, or other country-appropriate institution number for the bank account. For US bank accounts, this is required and should be the ACH routing number, not the wire routing number. If you are providing an IBAN for `account_number`, this field is not required.
2216
2216
  */
2217
2217
  routing_number?: string;
2218
2218
  }
@@ -4173,7 +4173,7 @@ declare module 'stripe' {
4173
4173
  currency?: string;
4174
4174
 
4175
4175
  /**
4176
- * The routing number, sort code, or other country-appropriateinstitution number for the bank account. For US bank accounts, this is required and should bethe ACH routing number, not the wire routing number. If you are providing an IBAN for`account_number`, this field is not required.
4176
+ * The routing number, sort code, or other country-appropriate institution number for the bank account. For US bank accounts, this is required and should be the ACH routing number, not the wire routing number. If you are providing an IBAN for `account_number`, this field is not required.
4177
4177
  */
4178
4178
  routing_number?: string;
4179
4179
  }
@@ -676,7 +676,7 @@ declare module 'stripe' {
676
676
  category?: Lodging.Category;
677
677
 
678
678
  /**
679
- * Loding check-in time. Measured in seconds since the Unix epoch.
679
+ * Lodging check-in time. Measured in seconds since the Unix epoch.
680
680
  */
681
681
  checkin_at: number;
682
682
 
@@ -1438,7 +1438,7 @@ declare module 'stripe' {
1438
1438
  category?: Lodging.Category;
1439
1439
 
1440
1440
  /**
1441
- * Loding check-in time. Measured in seconds since the Unix epoch.
1441
+ * Lodging check-in time. Measured in seconds since the Unix epoch.
1442
1442
  */
1443
1443
  checkin_at: number;
1444
1444
 
@@ -301,7 +301,7 @@ declare module 'stripe' {
301
301
  submit_type: Session.SubmitType | null;
302
302
 
303
303
  /**
304
- * The ID of the subscription for Checkout Sessions in `subscription` mode.
304
+ * The ID of the [Subscription](https://stripe.com/docs/api/subscriptions) for Checkout Sessions in `subscription` mode.
305
305
  */
306
306
  subscription: string | Stripe.Subscription | null;
307
307
 
@@ -390,7 +390,7 @@ declare module 'stripe' {
390
390
  /**
391
391
  * The tax provider powering automatic tax.
392
392
  */
393
- provider?: string | null;
393
+ provider: string | null;
394
394
 
395
395
  /**
396
396
  * The status of the most recent automated tax calculation for this session.
@@ -459,7 +459,7 @@ declare module 'stripe' {
459
459
 
460
460
  interface TaxId {
461
461
  /**
462
- * The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `hr_oib`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `no_voec`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `li_vat`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, `al_tin`, `bh_vat`, `kz_bin`, `ng_tin`, `om_vat`, `de_stn`, `ch_uid`, `tz_vat`, `uz_vat`, `uz_tin`, `md_vat`, `ma_vat`, `by_tin`, `ao_tin`, `bs_tin`, `bb_tin`, `cd_nif`, `mr_nif`, `me_pib`, `zw_tin`, `ba_tin`, `gn_nif`, `mk_vat`, `sr_fin`, `sn_ninea`, `am_tin`, `np_pan`, `tj_tin`, `ug_tin`, `zm_tin`, `kh_tin`, or `unknown`
462
+ * The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `hr_oib`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `no_voec`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `li_vat`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, `al_tin`, `bh_vat`, `kz_bin`, `ng_tin`, `om_vat`, `de_stn`, `ch_uid`, `tz_vat`, `uz_vat`, `uz_tin`, `md_vat`, `ma_vat`, `by_tin`, `ao_tin`, `bs_tin`, `bb_tin`, `cd_nif`, `mr_nif`, `me_pib`, `zw_tin`, `ba_tin`, `gn_nif`, `mk_vat`, `sr_fin`, `sn_ninea`, `am_tin`, `np_pan`, `tj_tin`, `ug_tin`, `zm_tin`, `kh_tin`, `aw_tin`, `az_tin`, `bd_bin`, `bj_ifu`, `et_tin`, `kg_tin`, `la_tin`, `cm_niu`, `cv_nif`, `bf_ifu`, or `unknown`
463
463
  */
464
464
  type: TaxId.Type;
465
465
 
@@ -479,10 +479,15 @@ declare module 'stripe' {
479
479
  | 'ar_cuit'
480
480
  | 'au_abn'
481
481
  | 'au_arn'
482
+ | 'aw_tin'
483
+ | 'az_tin'
482
484
  | 'ba_tin'
483
485
  | 'bb_tin'
486
+ | 'bd_bin'
487
+ | 'bf_ifu'
484
488
  | 'bg_uic'
485
489
  | 'bh_vat'
490
+ | 'bj_ifu'
486
491
  | 'bo_tin'
487
492
  | 'br_cnpj'
488
493
  | 'br_cpf'
@@ -498,14 +503,17 @@ declare module 'stripe' {
498
503
  | 'ch_uid'
499
504
  | 'ch_vat'
500
505
  | 'cl_tin'
506
+ | 'cm_niu'
501
507
  | 'cn_tin'
502
508
  | 'co_nit'
503
509
  | 'cr_tin'
510
+ | 'cv_nif'
504
511
  | 'de_stn'
505
512
  | 'do_rcn'
506
513
  | 'ec_ruc'
507
514
  | 'eg_tin'
508
515
  | 'es_cif'
516
+ | 'et_tin'
509
517
  | 'eu_oss_vat'
510
518
  | 'eu_vat'
511
519
  | 'gb_vat'
@@ -522,9 +530,11 @@ declare module 'stripe' {
522
530
  | 'jp_rn'
523
531
  | 'jp_trn'
524
532
  | 'ke_pin'
533
+ | 'kg_tin'
525
534
  | 'kh_tin'
526
535
  | 'kr_brn'
527
536
  | 'kz_bin'
537
+ | 'la_tin'
528
538
  | 'li_uid'
529
539
  | 'li_vat'
530
540
  | 'ma_vat'
@@ -692,7 +702,7 @@ declare module 'stripe' {
692
702
 
693
703
  interface TaxId {
694
704
  /**
695
- * The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `hr_oib`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `no_voec`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `li_vat`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, `al_tin`, `bh_vat`, `kz_bin`, `ng_tin`, `om_vat`, `de_stn`, `ch_uid`, `tz_vat`, `uz_vat`, `uz_tin`, `md_vat`, `ma_vat`, `by_tin`, `ao_tin`, `bs_tin`, `bb_tin`, `cd_nif`, `mr_nif`, `me_pib`, `zw_tin`, `ba_tin`, `gn_nif`, `mk_vat`, `sr_fin`, `sn_ninea`, `am_tin`, `np_pan`, `tj_tin`, `ug_tin`, `zm_tin`, `kh_tin`, or `unknown`
705
+ * The type of the tax ID, one of `ad_nrt`, `ar_cuit`, `eu_vat`, `bo_tin`, `br_cnpj`, `br_cpf`, `cn_tin`, `co_nit`, `cr_tin`, `do_rcn`, `ec_ruc`, `eu_oss_vat`, `hr_oib`, `pe_ruc`, `ro_tin`, `rs_pib`, `sv_nit`, `uy_ruc`, `ve_rif`, `vn_tin`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `no_voec`, `za_vat`, `ch_vat`, `mx_rfc`, `sg_uen`, `ru_inn`, `ru_kpp`, `ca_bn`, `hk_br`, `es_cif`, `tw_vat`, `th_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `li_uid`, `li_vat`, `my_itn`, `us_ein`, `kr_brn`, `ca_qst`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `my_sst`, `sg_gst`, `ae_trn`, `cl_tin`, `sa_vat`, `id_npwp`, `my_frp`, `il_vat`, `ge_vat`, `ua_vat`, `is_vat`, `bg_uic`, `hu_tin`, `si_tin`, `ke_pin`, `tr_tin`, `eg_tin`, `ph_tin`, `al_tin`, `bh_vat`, `kz_bin`, `ng_tin`, `om_vat`, `de_stn`, `ch_uid`, `tz_vat`, `uz_vat`, `uz_tin`, `md_vat`, `ma_vat`, `by_tin`, `ao_tin`, `bs_tin`, `bb_tin`, `cd_nif`, `mr_nif`, `me_pib`, `zw_tin`, `ba_tin`, `gn_nif`, `mk_vat`, `sr_fin`, `sn_ninea`, `am_tin`, `np_pan`, `tj_tin`, `ug_tin`, `zm_tin`, `kh_tin`, `aw_tin`, `az_tin`, `bd_bin`, `bj_ifu`, `et_tin`, `kg_tin`, `la_tin`, `cm_niu`, `cv_nif`, `bf_ifu`, or `unknown`
696
706
  */
697
707
  type: TaxId.Type;
698
708
 
@@ -712,10 +722,15 @@ declare module 'stripe' {
712
722
  | 'ar_cuit'
713
723
  | 'au_abn'
714
724
  | 'au_arn'
725
+ | 'aw_tin'
726
+ | 'az_tin'
715
727
  | 'ba_tin'
716
728
  | 'bb_tin'
729
+ | 'bd_bin'
730
+ | 'bf_ifu'
717
731
  | 'bg_uic'
718
732
  | 'bh_vat'
733
+ | 'bj_ifu'
719
734
  | 'bo_tin'
720
735
  | 'br_cnpj'
721
736
  | 'br_cpf'
@@ -731,14 +746,17 @@ declare module 'stripe' {
731
746
  | 'ch_uid'
732
747
  | 'ch_vat'
733
748
  | 'cl_tin'
749
+ | 'cm_niu'
734
750
  | 'cn_tin'
735
751
  | 'co_nit'
736
752
  | 'cr_tin'
753
+ | 'cv_nif'
737
754
  | 'de_stn'
738
755
  | 'do_rcn'
739
756
  | 'ec_ruc'
740
757
  | 'eg_tin'
741
758
  | 'es_cif'
759
+ | 'et_tin'
742
760
  | 'eu_oss_vat'
743
761
  | 'eu_vat'
744
762
  | 'gb_vat'
@@ -755,9 +773,11 @@ declare module 'stripe' {
755
773
  | 'jp_rn'
756
774
  | 'jp_trn'
757
775
  | 'ke_pin'
776
+ | 'kg_tin'
758
777
  | 'kh_tin'
759
778
  | 'kr_brn'
760
779
  | 'kz_bin'
780
+ | 'la_tin'
761
781
  | 'li_uid'
762
782
  | 'li_vat'
763
783
  | 'ma_vat'