From ca933401da70f2b817a0a1cf3e285698ab077685 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Fri, 7 Oct 2022 10:33:37 -0700 Subject: [PATCH 01/16] Update StripeSignatureVerificationError to accept header and payload strings --- lib/Error.js | 8 +++++++- lib/Webhooks.js | 29 +++++------------------------ src/Error.ts | 11 ++++++++++- src/Webhooks.ts | 28 ++++------------------------ 4 files changed, 26 insertions(+), 50 deletions(-) diff --git a/lib/Error.js b/lib/Error.js index a50ccab948..3b54ff7af9 100644 --- a/lib/Error.js +++ b/lib/Error.js @@ -93,7 +93,13 @@ class StripeConnectionError extends StripeError {} * SignatureVerificationError is raised when the signature verification for a * webhook fails */ -class StripeSignatureVerificationError extends StripeError {} +class StripeSignatureVerificationError extends StripeError { + constructor(header, payload, raw = {}) { + super(raw); + this.header = header; + this.payload = payload; + } +} /** * IdempotencyError is raised in cases where an idempotency key was used * improperly. diff --git a/lib/Webhooks.js b/lib/Webhooks.js index f7570b3946..6c5f4ae97a 100644 --- a/lib/Webhooks.js +++ b/lib/Webhooks.js @@ -142,23 +142,14 @@ function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) { : encodedHeader; const details = parseHeader(decodedHeader, expectedScheme); if (!details || details.timestamp === -1) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { message: 'Unable to extract timestamp and signatures from header', - // @ts-expect-error Type '{ decodedHeader: any; decodedPayload: any; }' is not assignable to type 'string'. - detail: { - decodedHeader, - decodedPayload, - }, }); } if (!details.signatures.length) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { message: 'No signatures found with expected scheme', - // @ts-expect-error Type '{ decodedHeader: any; decodedPayload: any; }' is not assignable to type 'string'. - detail: { - decodedHeader, - decodedPayload, - }, + detail: decodedHeader, }); } return { @@ -178,27 +169,17 @@ function validateComputedSignature( utils.secureCompare.bind(utils, expectedSignature) ).length; if (!signatureFound) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(header, payload, { message: 'No signatures found matching the expected signature for payload.' + ' Are you passing the raw request body you received from Stripe?' + ' https://github.com/stripe/stripe-node#webhook-signing', - // @ts-expect-error Type '{ header: any; payload: any; }' is not assignable to type 'string'. - detail: { - header, - payload, - }, }); } const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; if (tolerance > 0 && timestampAge > tolerance) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(header, payload, { message: 'Timestamp outside the tolerance zone', - // @ts-expect-error Type '{ header: any; payload: any; }' is not assignable to type 'string'. - detail: { - header, - payload, - }, }); } return true; diff --git a/src/Error.ts b/src/Error.ts index fbf88cc5d6..b1396581af 100644 --- a/src/Error.ts +++ b/src/Error.ts @@ -157,7 +157,16 @@ class StripeConnectionError extends StripeError {} * SignatureVerificationError is raised when the signature verification for a * webhook fails */ -class StripeSignatureVerificationError extends StripeError {} +class StripeSignatureVerificationError extends StripeError { + header: string; + payload: string; + + constructor(header: string, payload: string, raw: StripeRawError = {}) { + super(raw); + this.header = header; + this.payload = payload; + } +} /** * IdempotencyError is raised in cases where an idempotency key was used diff --git a/src/Webhooks.ts b/src/Webhooks.ts index 14d5a4ed8f..76663e881a 100644 --- a/src/Webhooks.ts +++ b/src/Webhooks.ts @@ -167,24 +167,14 @@ function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) { const details = parseHeader(decodedHeader, expectedScheme); if (!details || details.timestamp === -1) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { message: 'Unable to extract timestamp and signatures from header', - // @ts-expect-error Type '{ decodedHeader: any; decodedPayload: any; }' is not assignable to type 'string'. - detail: { - decodedHeader, - decodedPayload, - }, }); } if (!details.signatures.length) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { message: 'No signatures found with expected scheme', - // @ts-expect-error Type '{ decodedHeader: any; decodedPayload: any; }' is not assignable to type 'string'. - detail: { - decodedHeader, - decodedPayload, - }, }); } @@ -207,29 +197,19 @@ function validateComputedSignature( ).length; if (!signatureFound) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(header, payload, { message: 'No signatures found matching the expected signature for payload.' + ' Are you passing the raw request body you received from Stripe?' + ' https://github.com/stripe/stripe-node#webhook-signing', - // @ts-expect-error Type '{ header: any; payload: any; }' is not assignable to type 'string'. - detail: { - header, - payload, - }, }); } const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; if (tolerance > 0 && timestampAge > tolerance) { - throw new StripeSignatureVerificationError({ + throw new StripeSignatureVerificationError(header, payload, { message: 'Timestamp outside the tolerance zone', - // @ts-expect-error Type '{ header: any; payload: any; }' is not assignable to type 'string'. - detail: { - header, - payload, - }, }); } From f9bc027b606858a5d69f47f52c055b5ae67c1e46 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Fri, 7 Oct 2022 10:33:37 -0700 Subject: [PATCH 02/16] Build --- lib/Webhooks.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Webhooks.js b/lib/Webhooks.js index 6c5f4ae97a..97d4704a7a 100644 --- a/lib/Webhooks.js +++ b/lib/Webhooks.js @@ -149,7 +149,6 @@ function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) { if (!details.signatures.length) { throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { message: 'No signatures found with expected scheme', - detail: decodedHeader, }); } return { From c7e26c36168f8a7fad8854fe5da65bd50fea0946 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 11 Oct 2022 14:52:32 -0700 Subject: [PATCH 03/16] Update supported runtime versions --- .github/workflows/main.yml | 1 - README.md | 2 +- package.json | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6fde9bdf62..3cb861682f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -69,7 +69,6 @@ jobs: - "16" - "14" - "12" - - "10" runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 12801a9ef0..cfaeab81ab 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ See [video demonstrations][youtube-playlist] covering how to use the library. ## Requirements -Node 8, 10 or higher. +Node 12 or higher. ## Installation diff --git a/package.json b/package.json index afacfbbfd1..20fd022519 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "bugs": "https://github.com/stripe/stripe-node/issues", "engines": { - "node": "^8.1 || >=10.*" + "node": ">=12.*" }, "main": "lib/stripe.js", "types": "types/2022-08-01/index.d.ts", From 5cf9eb30cad17848d232dc6cae7278b2e380ee91 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 11 Oct 2022 15:30:51 -0700 Subject: [PATCH 04/16] Remove Orders and subscription_data[items] --- lib/resources.js | 1 - lib/resources/Orders.js | 41 - src/resources.js | 1 - src/resources/Orders.js | 52 - types/2022-08-01/Checkout/Sessions.d.ts | 23 - types/2022-08-01/Invoices.d.ts | 5 + types/2022-08-01/Issuing/Authorizations.d.ts | 12 + types/2022-08-01/LineItems.d.ts | 7 - types/2022-08-01/Orders.d.ts | 3341 ------------------ types/2022-08-01/PaymentIntents.d.ts | 7 +- types/2022-08-01/SetupAttempts.d.ts | 5 + types/2022-08-01/SetupIntents.d.ts | 5 + types/2022-08-01/index.d.ts | 4 +- 13 files changed, 34 insertions(+), 3470 deletions(-) delete mode 100644 lib/resources/Orders.js delete mode 100644 src/resources/Orders.js delete mode 100644 types/2022-08-01/Orders.d.ts diff --git a/lib/resources.js b/lib/resources.js index 60e5444aad..83b3bd3fde 100644 --- a/lib/resources.js +++ b/lib/resources.js @@ -25,7 +25,6 @@ module.exports = { InvoiceItems: require('./resources/InvoiceItems'), Mandates: require('./resources/Mandates'), OAuth: require('./resources/OAuth'), - Orders: require('./resources/Orders'), PaymentIntents: require('./resources/PaymentIntents'), PaymentLinks: require('./resources/PaymentLinks'), PaymentMethods: require('./resources/PaymentMethods'), diff --git a/lib/resources/Orders.js b/lib/resources/Orders.js deleted file mode 100644 index 61697d6a14..0000000000 --- a/lib/resources/Orders.js +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec -'use strict'; -const StripeResource = require('../StripeResource'); -const stripeMethod = StripeResource.method; -module.exports = StripeResource.extend({ - path: 'orders', - create: stripeMethod({ - method: 'POST', - path: '', - }), - retrieve: stripeMethod({ - method: 'GET', - path: '/{id}', - }), - update: stripeMethod({ - method: 'POST', - path: '/{id}', - }), - list: stripeMethod({ - method: 'GET', - path: '', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - path: '/{id}/cancel', - }), - listLineItems: stripeMethod({ - method: 'GET', - path: '/{id}/line_items', - methodType: 'list', - }), - reopen: stripeMethod({ - method: 'POST', - path: '/{id}/reopen', - }), - submit: stripeMethod({ - method: 'POST', - path: '/{id}/submit', - }), -}); diff --git a/src/resources.js b/src/resources.js index 825c8f1d9d..98dcf27ac9 100644 --- a/src/resources.js +++ b/src/resources.js @@ -28,7 +28,6 @@ module.exports = { InvoiceItems: require('./resources/InvoiceItems'), Mandates: require('./resources/Mandates'), OAuth: require('./resources/OAuth'), - Orders: require('./resources/Orders'), PaymentIntents: require('./resources/PaymentIntents'), PaymentLinks: require('./resources/PaymentLinks'), PaymentMethods: require('./resources/PaymentMethods'), diff --git a/src/resources/Orders.js b/src/resources/Orders.js deleted file mode 100644 index a216b32fc7..0000000000 --- a/src/resources/Orders.js +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec - -'use strict'; - -const StripeResource = require('../StripeResource'); -const stripeMethod = StripeResource.method; - -module.exports = StripeResource.extend({ - path: 'orders', - - create: stripeMethod({ - method: 'POST', - path: '', - }), - - retrieve: stripeMethod({ - method: 'GET', - path: '/{id}', - }), - - update: stripeMethod({ - method: 'POST', - path: '/{id}', - }), - - list: stripeMethod({ - method: 'GET', - path: '', - methodType: 'list', - }), - - cancel: stripeMethod({ - method: 'POST', - path: '/{id}/cancel', - }), - - listLineItems: stripeMethod({ - method: 'GET', - path: '/{id}/line_items', - methodType: 'list', - }), - - reopen: stripeMethod({ - method: 'POST', - path: '/{id}/reopen', - }), - - submit: stripeMethod({ - method: 'POST', - path: '/{id}/submit', - }), -}); diff --git a/types/2022-08-01/Checkout/Sessions.d.ts b/types/2022-08-01/Checkout/Sessions.d.ts index 13afebb3a2..6eaec7a47b 100644 --- a/types/2022-08-01/Checkout/Sessions.d.ts +++ b/types/2022-08-01/Checkout/Sessions.d.ts @@ -3150,11 +3150,6 @@ declare module 'stripe' { */ description?: string; - /** - * This parameter is deprecated. Use the line_items parameter on the Session instead. - */ - items?: Array; - /** * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. */ @@ -3185,24 +3180,6 @@ declare module 'stripe' { } namespace SubscriptionData { - interface Item { - /** - * Plan ID for this item. - */ - plan: string; - - /** - * The quantity of the subscription item being purchased. Quantity should not be defined when `recurring.usage_type=metered`. - */ - quantity?: number; - - /** - * The tax rates which apply to this item. When set, the `default_tax_rates` - * on `subscription_data` do not apply to this item. - */ - tax_rates?: Array; - } - interface TransferData { /** * A non-negative decimal between 0 and 100, with at most two decimal places. This represents the percentage of the subscription invoice subtotal that will be transferred to the destination account. By default, the entire amount is transferred to the destination. diff --git a/types/2022-08-01/Invoices.d.ts b/types/2022-08-01/Invoices.d.ts index 4ce0946231..2839bf0356 100644 --- a/types/2022-08-01/Invoices.d.ts +++ b/types/2022-08-01/Invoices.d.ts @@ -619,6 +619,11 @@ declare module 'stripe' { */ payment_method_type?: string; + /** + * A URL to the request log entry in your dashboard. + */ + request_log_url?: string; + /** * A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments. * For example, you could use a SetupIntent to set up and save your customer's card without immediately collecting a payment. diff --git a/types/2022-08-01/Issuing/Authorizations.d.ts b/types/2022-08-01/Issuing/Authorizations.d.ts index 95514ec376..936d99a094 100644 --- a/types/2022-08-01/Issuing/Authorizations.d.ts +++ b/types/2022-08-01/Issuing/Authorizations.d.ts @@ -88,6 +88,11 @@ declare module 'stripe' { */ metadata: Stripe.Metadata; + /** + * Details about the authorization, such as identifiers, set by the card network. + */ + network_data: Authorization.NetworkData | null; + /** * The pending authorization request. This field will only be non-null during an `issuing_authorization.request` webhook. */ @@ -178,6 +183,13 @@ declare module 'stripe' { state: string | null; } + interface NetworkData { + /** + * ID from the network that identifies the acquiring financial institution. For Visa and Mastercard credit transactions this is as 6 digit code. For Maestro debit transactions this is a 9 digit code. Uncommonly, acquiring institution ID is not provided. When this occurs, the value will be null. + */ + acquiring_institution_id: string | null; + } + interface PendingRequest { /** * The additional amount Stripe will hold if the authorization is approved, in the card's [currency](https://stripe.com/docs/api#issuing_authorization_object-pending-request-currency) and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal). diff --git a/types/2022-08-01/LineItems.d.ts b/types/2022-08-01/LineItems.d.ts index eff3ec0f3c..9c88c9a8ba 100644 --- a/types/2022-08-01/LineItems.d.ts +++ b/types/2022-08-01/LineItems.d.ts @@ -56,13 +56,6 @@ declare module 'stripe' { */ price: Stripe.Price | null; - /** - * The ID of the product for this line item. - * - * This will always be the same as `price.product`. - */ - product?: string | Stripe.Product | Stripe.DeletedProduct; - /** * The quantity of products being purchased. */ diff --git a/types/2022-08-01/Orders.d.ts b/types/2022-08-01/Orders.d.ts deleted file mode 100644 index fa491817bd..0000000000 --- a/types/2022-08-01/Orders.d.ts +++ /dev/null @@ -1,3341 +0,0 @@ -// File generated from our OpenAPI spec - -declare module 'stripe' { - namespace Stripe { - /** - * An Order describes a purchase being made by a customer, including the - * products & quantities being purchased, the order status, the payment information, - * and the billing/shipping details. - * - * Related guide: [Orders overview](https://stripe.com/docs/orders) - */ - interface Order { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'order'; - - /** - * Order cost before any discounts or taxes are applied. A positive integer representing the subtotal of the order in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). - */ - amount_subtotal: number; - - /** - * Total order cost after discounts and taxes are applied. A positive integer representing the cost of the order in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). To submit an order, the total must be either 0 or at least $0.50 USD or [equivalent in charge currency](https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts). - */ - amount_total: number; - - /** - * ID of the Connect application that created the Order, if any. - */ - application: string | Stripe.Application | null; - - automatic_tax?: Order.AutomaticTax; - - /** - * Customer billing details associated with the order. - */ - billing_details: Order.BillingDetails | null; - - /** - * The client secret of this Order. Used for client-side retrieval using a publishable key. - * - * The client secret can be used to complete a payment for an Order from your frontend. It should not be stored, logged, embedded in URLs, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret. - * - * Refer to our docs for [creating and processing an order](https://stripe.com/docs/orders-beta/create-and-process) to learn about how client_secret should be handled. - */ - client_secret: string | null; - - /** - * Time at which the object was created. Measured in seconds since the Unix epoch. - */ - created: number; - - /** - * 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). - */ - currency: string; - - /** - * The customer which this orders belongs to. - */ - customer: string | Stripe.Customer | Stripe.DeletedCustomer | null; - - /** - * An arbitrary string attached to the object. Often useful for displaying to users. - */ - description: string | null; - - /** - * The discounts applied to the order. Use `expand[]=discounts` to expand each discount. - */ - discounts: Array | null; - - /** - * A recent IP address of the purchaser used for tax reporting and tax location inference. - */ - ip_address: string | null; - - /** - * A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. There is a maximum of 100 line items. - */ - line_items?: ApiList; - - /** - * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - */ - livemode: boolean; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - */ - metadata: Stripe.Metadata | null; - - payment: Order.Payment; - - /** - * The details of the customer cost of shipping, including the customer chosen ShippingRate. - */ - shipping_cost: Order.ShippingCost | null; - - /** - * Customer shipping information associated with the order. - */ - shipping_details: Order.ShippingDetails | null; - - /** - * The overall status of the order. - */ - status: Order.Status; - - tax_details?: Order.TaxDetails; - - total_details: Order.TotalDetails; - } - - namespace Order { - interface AutomaticTax { - /** - * Whether Stripe automatically computes tax on this Order. - */ - enabled: boolean; - - /** - * The status of the most recent automated tax calculation for this Order. - */ - status: AutomaticTax.Status | null; - } - - namespace AutomaticTax { - type Status = 'complete' | 'failed' | 'requires_location_inputs'; - } - - interface BillingDetails { - /** - * Billing address for the order. - */ - address: Stripe.Address | null; - - /** - * Email address for the order. - */ - email: string | null; - - /** - * Full name for the order. - */ - name: string | null; - - /** - * Billing phone number for the order (including extension). - */ - phone: string | null; - } - - interface Payment { - /** - * ID of the payment intent associated with this order. Null when the order is `open`. - */ - payment_intent: string | Stripe.PaymentIntent | null; - - /** - * Settings describing how the order should configure generated PaymentIntents. - */ - settings: Payment.Settings | null; - - /** - * The status of the underlying payment associated with this order, if any. Null when the order is `open`. - */ - status: Payment.Status | null; - } - - namespace Payment { - interface Settings { - /** - * The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. - */ - application_fee_amount: number | null; - - /** - * Indicates whether order has been opted into using [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods) to manage payment method types. - */ - automatic_payment_methods: Settings.AutomaticPaymentMethods | null; - - /** - * PaymentMethod-specific configuration to provide to the order's PaymentIntent. - */ - payment_method_options: Settings.PaymentMethodOptions | null; - - /** - * The list of [payment method types](https://stripe.com/docs/payments/payment-methods/overview) to provide to the order's PaymentIntent. Do not include this attribute if you prefer to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). - */ - payment_method_types: Array | null; - - /** - * The URL to redirect the customer to after they authenticate their payment. - */ - return_url: string | null; - - /** - * For non-card charges, you can use this value as the complete description that appears on your customers' statements. Must contain at least one letter, maximum 22 characters. - */ - statement_descriptor: string | null; - - /** - * Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that's set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. - */ - statement_descriptor_suffix: string | null; - - /** - * Provides configuration for completing a transfer for the order after it is paid. - */ - transfer_data: Settings.TransferData | null; - } - - namespace Settings { - interface AutomaticPaymentMethods { - /** - * Whether this Order has been opted into managing payment method types via the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). - */ - enabled: boolean; - } - - interface PaymentMethodOptions { - acss_debit?: PaymentMethodOptions.AcssDebit; - - afterpay_clearpay?: PaymentMethodOptions.AfterpayClearpay; - - alipay?: PaymentMethodOptions.Alipay; - - bancontact?: PaymentMethodOptions.Bancontact; - - card?: PaymentMethodOptions.Card; - - customer_balance?: PaymentMethodOptions.CustomerBalance; - - ideal?: PaymentMethodOptions.Ideal; - - klarna?: PaymentMethodOptions.Klarna; - - link?: PaymentMethodOptions.Link; - - oxxo?: PaymentMethodOptions.Oxxo; - - p24?: PaymentMethodOptions.P24; - - paypal?: PaymentMethodOptions.Paypal; - - sepa_debit?: PaymentMethodOptions.SepaDebit; - - sofort?: PaymentMethodOptions.Sofort; - - wechat_pay?: PaymentMethodOptions.WechatPay; - } - - namespace PaymentMethodOptions { - interface AcssDebit { - mandate_options?: AcssDebit.MandateOptions; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: AcssDebit.SetupFutureUsage; - - /** - * Bank account verification method. - */ - verification_method?: AcssDebit.VerificationMethod; - } - - namespace AcssDebit { - interface MandateOptions { - /** - * A URL for custom mandate text - */ - custom_mandate_url?: string; - - /** - * Description of the interval. Only required if the 'payment_schedule' parameter is 'interval' or 'combined'. - */ - interval_description: string | null; - - /** - * Payment schedule for the mandate. - */ - payment_schedule: MandateOptions.PaymentSchedule | null; - - /** - * Transaction type of the mandate. - */ - transaction_type: MandateOptions.TransactionType | null; - } - - namespace MandateOptions { - type PaymentSchedule = 'combined' | 'interval' | 'sporadic'; - - type TransactionType = 'business' | 'personal'; - } - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - - type VerificationMethod = - | 'automatic' - | 'instant' - | 'microdeposits'; - } - - interface AfterpayClearpay { - /** - * Controls when the funds will be captured from the customer's account. - */ - capture_method?: AfterpayClearpay.CaptureMethod; - - /** - * Order identifier shown to the user in Afterpay's online portal. We recommend using a value that helps you answer any questions a customer might have about the payment. The identifier is limited to 128 characters and may contain only letters, digits, underscores, backslashes and dashes. - */ - reference: string | null; - - /** - * Indicates that you intend to make future payments with the payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace AfterpayClearpay { - type CaptureMethod = 'automatic' | 'manual'; - } - - interface Alipay { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: Alipay.SetupFutureUsage; - } - - namespace Alipay { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Bancontact { - /** - * Preferred language of the Bancontact authorization page that the customer is redirected to. - */ - preferred_language: Bancontact.PreferredLanguage; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: Bancontact.SetupFutureUsage; - } - - namespace Bancontact { - type PreferredLanguage = 'de' | 'en' | 'fr' | 'nl'; - - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Card { - /** - * Controls when the funds will be captured from the customer's account. - */ - capture_method: Card.CaptureMethod; - - /** - * Indicates that you intend to make future payments with the payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Card.SetupFutureUsage; - } - - namespace Card { - type CaptureMethod = 'automatic' | 'manual'; - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - } - - interface CustomerBalance { - bank_transfer?: CustomerBalance.BankTransfer; - - /** - * The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`. - */ - funding_type: 'bank_transfer' | null; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: 'none'; - } - - namespace CustomerBalance { - interface BankTransfer { - eu_bank_transfer?: BankTransfer.EuBankTransfer; - - /** - * List of address types that should be returned in the financial_addresses response. If not specified, all valid types will be returned. - * - * Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. - */ - requested_address_types?: Array< - BankTransfer.RequestedAddressType - >; - - /** - * The bank transfer type that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, or `mx_bank_transfer`. - */ - type: BankTransfer.Type | null; - } - - namespace BankTransfer { - interface EuBankTransfer { - /** - * The desired country code of the bank account information. Permitted values include: `DE`, `ES`, `FR`, `IE`, or `NL`. - */ - country: EuBankTransfer.Country; - } - - namespace EuBankTransfer { - type Country = 'DE' | 'ES' | 'FR' | 'IE' | 'NL'; - } - - type RequestedAddressType = - | 'iban' - | 'sepa' - | 'sort_code' - | 'spei' - | 'zengin'; - - type Type = - | 'eu_bank_transfer' - | 'gb_bank_transfer' - | 'jp_bank_transfer' - | 'mx_bank_transfer'; - } - } - - interface Ideal { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: Ideal.SetupFutureUsage; - } - - namespace Ideal { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Klarna { - /** - * Controls when the funds will be captured from the customer's account. - */ - capture_method?: 'manual'; - - /** - * Preferred locale of the Klarna checkout page that the customer is redirected to. - */ - preferred_locale: string | null; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: 'none'; - } - - interface Link { - /** - * Controls when the funds will be captured from the customer's account. - */ - capture_method?: 'manual'; - - /** - * Token used for persistent Link logins. - */ - persistent_token: string | null; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: Link.SetupFutureUsage; - } - - namespace Link { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Oxxo { - /** - * The number of calendar days before an OXXO invoice expires. For example, if you create an OXXO invoice on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time. - */ - expires_after_days: number; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: 'none'; - } - - interface P24 { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: 'none'; - } - - interface Paypal { - /** - * Controls when the funds will be captured from the customer's account. - */ - capture_method?: 'manual'; - - /** - * Preferred locale of the PayPal checkout page that the customer is redirected to. - */ - preferred_locale: string | null; - } - - interface SepaDebit { - mandate_options?: SepaDebit.MandateOptions; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: SepaDebit.SetupFutureUsage; - } - - namespace SepaDebit { - interface MandateOptions {} - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - } - - interface Sofort { - /** - * Preferred language of the SOFORT authorization page that the customer is redirected to. - */ - preferred_language: Sofort.PreferredLanguage | null; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: Sofort.SetupFutureUsage; - } - - namespace Sofort { - type PreferredLanguage = - | 'de' - | 'en' - | 'es' - | 'fr' - | 'it' - | 'nl' - | 'pl'; - - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface WechatPay { - /** - * The app ID registered with WeChat Pay. Only required when client is ios or android. - */ - app_id: string | null; - - /** - * The client type that the end customer will pay from - */ - client: WechatPay.Client | null; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - */ - setup_future_usage?: 'none'; - } - - namespace WechatPay { - type Client = 'android' | 'ios' | 'web'; - } - } - - type PaymentMethodType = - | 'acss_debit' - | 'afterpay_clearpay' - | 'alipay' - | 'au_becs_debit' - | 'bacs_debit' - | 'bancontact' - | 'card' - | 'customer_balance' - | 'eps' - | 'fpx' - | 'giropay' - | 'grabpay' - | 'ideal' - | 'klarna' - | 'link' - | 'oxxo' - | 'p24' - | 'sepa_debit' - | 'sofort' - | 'wechat_pay'; - - interface TransferData { - /** - * The amount that will be transferred automatically when the order is paid. If no amount is set, the full amount is transferred. There cannot be any line items with recurring prices when using this field. - */ - amount: number | null; - - /** - * ID of the Connected account receiving the transfer. - */ - destination: string | Stripe.Account; - } - } - - type Status = - | 'canceled' - | 'complete' - | 'not_required' - | 'processing' - | 'requires_action' - | 'requires_capture' - | 'requires_confirmation' - | 'requires_payment_method'; - } - - interface ShippingCost { - /** - * Total shipping cost before any discounts or taxes are applied. - */ - amount_subtotal: number; - - /** - * Total tax amount applied due to shipping costs. If no tax was applied, defaults to 0. - */ - amount_tax: number; - - /** - * Total shipping cost after discounts and taxes are applied. - */ - amount_total: number; - - /** - * The ID of the ShippingRate for this order. - */ - shipping_rate: string | Stripe.ShippingRate | null; - - /** - * The taxes applied to the shipping rate. - */ - taxes?: Array; - } - - namespace ShippingCost { - interface Tax { - /** - * Amount of tax applied for this rate. - */ - amount: number; - - /** - * Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax. - * - * Related guide: [Tax Rates](https://stripe.com/docs/billing/taxes/tax-rates). - */ - rate: Stripe.TaxRate; - } - } - - interface ShippingDetails { - /** - * Recipient shipping address. Required if the order includes products that are shippable. - */ - address: Stripe.Address | null; - - /** - * Recipient name. - */ - name: string | null; - - /** - * Recipient phone (including extension). - */ - phone: string | null; - } - - type Status = - | 'canceled' - | 'complete' - | 'open' - | 'processing' - | 'submitted'; - - interface TaxDetails { - /** - * Describes the purchaser's tax exemption status. One of `none`, `exempt`, or `reverse`. - */ - tax_exempt: TaxDetails.TaxExempt; - - /** - * The purchaser's tax IDs to be used in calculation of tax for this Order. - */ - tax_ids: Array; - } - - namespace TaxDetails { - type TaxExempt = 'exempt' | 'none' | 'reverse'; - - interface TaxId { - /** - * The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `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`, `li_uid`, `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`, or `unknown` - */ - type: TaxId.Type; - - /** - * The value of the tax ID. - */ - value: string | null; - } - - namespace TaxId { - type Type = - | 'ae_trn' - | 'au_abn' - | 'au_arn' - | 'bg_uic' - | 'br_cnpj' - | 'br_cpf' - | 'ca_bn' - | 'ca_gst_hst' - | 'ca_pst_bc' - | 'ca_pst_mb' - | 'ca_pst_sk' - | 'ca_qst' - | 'ch_vat' - | 'cl_tin' - | 'es_cif' - | 'eu_oss_vat' - | 'eu_vat' - | 'gb_vat' - | 'ge_vat' - | 'hk_br' - | 'hu_tin' - | 'id_npwp' - | 'il_vat' - | 'in_gst' - | 'is_vat' - | 'jp_cn' - | 'jp_rn' - | 'kr_brn' - | 'li_uid' - | 'mx_rfc' - | 'my_frp' - | 'my_itn' - | 'my_sst' - | 'no_vat' - | 'nz_gst' - | 'ru_inn' - | 'ru_kpp' - | 'sa_vat' - | 'sg_gst' - | 'sg_uen' - | 'si_tin' - | 'th_vat' - | 'tw_vat' - | 'ua_vat' - | 'unknown' - | 'us_ein' - | 'za_vat'; - } - } - - interface TotalDetails { - /** - * This is the sum of all the discounts. - */ - amount_discount: number; - - /** - * This is the sum of all the shipping amounts. - */ - amount_shipping: number | null; - - /** - * This is the sum of all the tax amounts. - */ - amount_tax: number; - - breakdown?: TotalDetails.Breakdown; - } - - namespace TotalDetails { - interface Breakdown { - /** - * The aggregated discounts. - */ - discounts: Array; - - /** - * The aggregated tax amounts by rate. - */ - taxes: Array; - } - - namespace Breakdown { - interface Discount { - /** - * The amount discounted. - */ - amount: number; - - /** - * A discount represents the actual application of a [coupon](https://stripe.com/docs/api#coupons) or [promotion code](https://stripe.com/docs/api#promotion_codes). - * It contains information about when the discount began, when it will end, and what it is applied to. - * - * Related guide: [Applying Discounts to Subscriptions](https://stripe.com/docs/billing/subscriptions/discounts). - */ - discount: Stripe.Discount; - } - - interface Tax { - /** - * Amount of tax applied for this rate. - */ - amount: number; - - /** - * Tax rates can be applied to [invoices](https://stripe.com/docs/billing/invoices/tax-rates), [subscriptions](https://stripe.com/docs/billing/subscriptions/taxes) and [Checkout Sessions](https://stripe.com/docs/payments/checkout/set-up-a-subscription#tax-rates) to collect tax. - * - * Related guide: [Tax Rates](https://stripe.com/docs/billing/taxes/tax-rates). - */ - rate: Stripe.TaxRate; - } - } - } - } - - interface OrderCreateParams { - /** - * 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). - */ - currency: string; - - /** - * A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. - */ - line_items: Array; - - /** - * Settings for automatic tax calculation for this order. - */ - automatic_tax?: OrderCreateParams.AutomaticTax; - - /** - * Billing details for the customer. If a customer is provided, this will be automatically populated with values from that customer if override values are not provided. - */ - billing_details?: Stripe.Emptyable; - - /** - * The customer associated with this order. - */ - customer?: string; - - /** - * An arbitrary string attached to the object. Often useful for displaying to users. - */ - description?: string; - - /** - * The coupons, promotion codes, and/or discounts to apply to the order. - */ - discounts?: Stripe.Emptyable>; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * The IP address of the purchaser for this order. - */ - ip_address?: string; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.MetadataParam; - - /** - * Payment information associated with the order, including payment settings. - */ - payment?: OrderCreateParams.Payment; - - /** - * Settings for the customer cost of shipping for this order. - */ - shipping_cost?: Stripe.Emptyable; - - /** - * Shipping details for the order. - */ - shipping_details?: Stripe.Emptyable; - - /** - * Additional tax details about the purchaser to be used for this order. - */ - tax_details?: OrderCreateParams.TaxDetails; - } - - namespace OrderCreateParams { - interface AutomaticTax { - /** - * Enable automatic tax calculation which will automatically compute tax rates on this order. - */ - enabled: boolean; - } - - interface BillingDetails { - /** - * The billing address provided by the customer. - */ - address?: Stripe.AddressParam; - - /** - * The billing email provided by the customer. - */ - email?: string; - - /** - * The billing name provided by the customer. - */ - name?: string; - - /** - * The billing phone number provided by the customer. - */ - phone?: string; - } - - interface Discount { - /** - * ID of the coupon to create a new discount for. - */ - coupon?: string; - - /** - * ID of an existing discount on the object (or one of its ancestors) to reuse. - */ - discount?: string; - - /** - * ID of the promotion code to create a new discount for. - */ - promotion_code?: string; - } - - interface LineItem { - /** - * The description for the line item. Will default to the name of the associated product. - */ - description?: string; - - /** - * The discounts applied to this line item. - */ - discounts?: Stripe.Emptyable>; - - /** - * The ID of a [Price](https://stripe.com/docs/api/prices) to add to the Order. - * - * The `price` parameter is an alternative to using the `product` parameter. If each of your products are sold at a single price, you can set `Product.default_price` and then pass the `product` parameter when creating a line item. If your products are sold at several possible prices, use the `price` parameter to explicitly specify which one to use. - */ - price?: string; - - /** - * Data used to generate a new Price object inline. - * - * The `price_data` parameter is an alternative to using the `product` or `price` parameters. If you create products upfront and configure a `Product.default_price`, pass the `product` parameter when creating a line item. If you prefer not to define products upfront, or if you charge variable prices, pass the `price_data` parameter to describe the price for this line item. - * - * Each time you pass `price_data` we create a Price for the product. This Price is hidden in both the Dashboard and API lists and cannot be reused. - */ - price_data?: LineItem.PriceData; - - /** - * The ID of a [Product](https://stripe.com/docs/api/products) to add to the Order. - * - * The product must have a `default_price` specified. Otherwise, specify the price by passing the `price` or `price_data` parameter. - */ - product?: string; - - /** - * Defines a Product inline and adds it to the Order. - * - * `product_data` is an alternative to the `product` parameter. If you created a Product upfront, use the `product` parameter to refer to the existing Product. But if you prefer not to create Products upfront, pass the `product_data` parameter to define a Product inline as part of configuring the Order. - * - * `product_data` automatically creates a Product, just as if you had manually created the Product. If a Product with the same ID already exists, then `product_data` re-uses it to avoid duplicates. - */ - product_data?: LineItem.ProductData; - - /** - * The quantity of the line item. - */ - quantity?: number; - - /** - * The tax rates applied to this line item. - */ - tax_rates?: Stripe.Emptyable>; - } - - namespace LineItem { - interface Discount { - /** - * ID of the coupon to create a new discount for. - */ - coupon?: string; - - /** - * ID of an existing discount on the object (or one of its ancestors) to reuse. - */ - discount?: string; - } - - interface PriceData { - /** - * 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). - */ - currency?: string; - - /** - * ID of the product this price belongs to. - * - * Use this to implement a variable-pricing model in your integration. This is required if `product_data` is not specifed. - */ - product?: string; - - /** - * Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. - */ - tax_behavior?: PriceData.TaxBehavior; - - /** - * A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. - */ - unit_amount?: number; - - /** - * Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. - */ - unit_amount_decimal?: string; - } - - namespace PriceData { - type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; - } - - interface ProductData { - /** - * The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. - */ - description?: string; - - /** - * A unique identifier for this product. - * - * `product_data` automatically creates a Product with this ID. If a Product with the same ID already exists, then `product_data` re-uses it to avoid duplicates. If any of the fields in the existing Product are different from the values in `product_data`, `product_data` updates the existing Product with the new information. So set `product_data[id]` to the same string every time you sell the same product, but don't re-use the same string for different products. - */ - id: string; - - /** - * A list of up to 8 URLs of images for this product, meant to be displayable to the customer. - */ - images?: Stripe.Emptyable>; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.Emptyable; - - /** - * The product's name, meant to be displayable to the customer. - */ - name: string; - - /** - * The dimensions of this product for shipping purposes. - */ - package_dimensions?: Stripe.Emptyable; - - /** - * Whether this product is shipped (i.e., physical goods). - */ - shippable?: boolean; - - /** - * A [tax code](https://stripe.com/docs/tax/tax-categories) ID. - */ - tax_code?: string; - - /** - * A URL of a publicly-accessible webpage for this product. - */ - url?: Stripe.Emptyable; - } - - namespace ProductData { - interface PackageDimensions { - /** - * Height, in inches. Maximum precision is 2 decimal places. - */ - height: number; - - /** - * Length, in inches. Maximum precision is 2 decimal places. - */ - length: number; - - /** - * Weight, in ounces. Maximum precision is 2 decimal places. - */ - weight: number; - - /** - * Width, in inches. Maximum precision is 2 decimal places. - */ - width: number; - } - } - } - - interface Payment { - /** - * Settings describing how the order should configure generated PaymentIntents. - */ - settings: Payment.Settings; - } - - namespace Payment { - interface Settings { - /** - * The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. - */ - application_fee_amount?: number; - - /** - * PaymentMethod-specific configuration to provide to the order's PaymentIntent. - */ - payment_method_options?: Settings.PaymentMethodOptions; - - /** - * The list of [payment method types](https://stripe.com/docs/payments/payment-methods/overview) to provide to the order's PaymentIntent. Do not include this attribute if you prefer to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). - */ - payment_method_types?: Array; - - /** - * The URL to redirect the customer to after they authenticate their payment. - */ - return_url?: string; - - /** - * For non-card charges, you can use this value as the complete description that appears on your customers' statements. Must contain at least one letter, maximum 22 characters. - */ - statement_descriptor?: string; - - /** - * Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that's set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. - */ - statement_descriptor_suffix?: string; - - /** - * Provides configuration for completing a transfer for the order after it is paid. - */ - transfer_data?: Settings.TransferData; - } - - namespace Settings { - interface PaymentMethodOptions { - /** - * If paying by `acss_debit`, this sub-hash contains details about the ACSS Debit payment method options to pass to the order's PaymentIntent. - */ - acss_debit?: PaymentMethodOptions.AcssDebit; - - /** - * If paying by `afterpay_clearpay`, this sub-hash contains details about the AfterpayClearpay payment method options to pass to the order's PaymentIntent. - */ - afterpay_clearpay?: PaymentMethodOptions.AfterpayClearpay; - - /** - * If paying by `alipay`, this sub-hash contains details about the Alipay payment method options to pass to the order's PaymentIntent. - */ - alipay?: PaymentMethodOptions.Alipay; - - /** - * If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the order's PaymentIntent. - */ - bancontact?: PaymentMethodOptions.Bancontact; - - /** - * If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the order's PaymentIntent. - */ - card?: PaymentMethodOptions.Card; - - /** - * If paying by `customer_balance`, this sub-hash contains details about the Customer Balance payment method options to pass to the order's PaymentIntent. - */ - customer_balance?: PaymentMethodOptions.CustomerBalance; - - /** - * If paying by `ideal`, this sub-hash contains details about the iDEAL payment method options to pass to the order's PaymentIntent. - */ - ideal?: PaymentMethodOptions.Ideal; - - /** - * If paying by `klarna`, this sub-hash contains details about the Klarna payment method options to pass to the order's PaymentIntent. - */ - klarna?: PaymentMethodOptions.Klarna; - - /** - * If paying by `link`, this sub-hash contains details about the Link payment method options to pass to the order's PaymentIntent. - */ - link?: PaymentMethodOptions.Link; - - /** - * If paying by `oxxo`, this sub-hash contains details about the OXXO payment method options to pass to the order's PaymentIntent. - */ - oxxo?: PaymentMethodOptions.Oxxo; - - /** - * If paying by `p24`, this sub-hash contains details about the P24 payment method options to pass to the order's PaymentIntent. - */ - p24?: PaymentMethodOptions.P24; - - /** - * If paying by `sepa_debit`, this sub-hash contains details about the SEPA Debit payment method options to pass to the order's PaymentIntent. - */ - sepa_debit?: PaymentMethodOptions.SepaDebit; - - /** - * If paying by `sofort`, this sub-hash contains details about the Sofort payment method options to pass to the order's PaymentIntent. - */ - sofort?: PaymentMethodOptions.Sofort; - - /** - * If paying by `wechat_pay`, this sub-hash contains details about the WeChat Pay payment method options to pass to the order's PaymentIntent. - */ - wechat_pay?: PaymentMethodOptions.WechatPay; - } - - namespace PaymentMethodOptions { - interface AcssDebit { - /** - * Additional fields for Mandate creation - */ - mandate_options?: AcssDebit.MandateOptions; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - - /** - * Verification method for the intent - */ - verification_method?: AcssDebit.VerificationMethod; - } - - namespace AcssDebit { - interface MandateOptions { - /** - * A URL for custom mandate text to render during confirmation step. - * The URL will be rendered with additional GET parameters `payment_intent` and `payment_intent_client_secret` when confirming a Payment Intent, - * or `setup_intent` and `setup_intent_client_secret` when confirming a Setup Intent. - */ - custom_mandate_url?: Stripe.Emptyable; - - /** - * Description of the mandate interval. Only required if 'payment_schedule' parameter is 'interval' or 'combined'. - */ - interval_description?: string; - - /** - * Payment schedule for the mandate. - */ - payment_schedule?: MandateOptions.PaymentSchedule; - - /** - * Transaction type of the mandate. - */ - transaction_type?: MandateOptions.TransactionType; - } - - namespace MandateOptions { - type PaymentSchedule = 'combined' | 'interval' | 'sporadic'; - - type TransactionType = 'business' | 'personal'; - } - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - - type VerificationMethod = - | 'automatic' - | 'instant' - | 'microdeposits'; - } - - interface AfterpayClearpay { - /** - * Controls when the funds will be captured from the customer's account. - * - * If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. - * - * If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. - */ - capture_method?: AfterpayClearpay.CaptureMethod; - - /** - * Order identifier shown to the customer in Afterpay's online portal. We recommend using a value that helps you answer any questions a customer might have about - * the payment. The identifier is limited to 128 characters and may contain only letters, digits, underscores, backslashes and dashes. - */ - reference?: string; - - /** - * Indicates that you intend to make future payments with the payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace AfterpayClearpay { - type CaptureMethod = 'automatic' | 'manual'; - } - - interface Alipay { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Alipay { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Bancontact { - /** - * Preferred language of the Bancontact authorization page that the customer is redirected to. - */ - preferred_language?: Bancontact.PreferredLanguage; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable< - Bancontact.SetupFutureUsage - >; - } - - namespace Bancontact { - type PreferredLanguage = 'de' | 'en' | 'fr' | 'nl'; - - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Card { - /** - * Controls when the funds will be captured from the customer's account. - */ - capture_method?: Card.CaptureMethod; - - /** - * Indicates that you intend to make future payments with the payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Card.SetupFutureUsage; - } - - namespace Card { - type CaptureMethod = 'automatic' | 'manual'; - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - } - - interface CustomerBalance { - /** - * Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. - */ - bank_transfer?: CustomerBalance.BankTransfer; - - /** - * The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`. - */ - funding_type?: 'bank_transfer'; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace CustomerBalance { - interface BankTransfer { - eu_bank_transfer?: BankTransfer.EuBankTransfer; - - /** - * List of address types that should be returned in the financial_addresses response. If not specified, all valid types will be returned. - * - * Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. - */ - requested_address_types?: Array< - BankTransfer.RequestedAddressType - >; - - /** - * The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, or `mx_bank_transfer`. - */ - type: BankTransfer.Type; - } - - namespace BankTransfer { - interface EuBankTransfer { - /** - * The desired country code of the bank account information. Permitted values include: `DE`, `ES`, `FR`, `IE`, or `NL`. - */ - country: string; - } - - type RequestedAddressType = - | 'iban' - | 'sepa' - | 'sort_code' - | 'spei' - | 'zengin'; - - type Type = - | 'eu_bank_transfer' - | 'gb_bank_transfer' - | 'jp_bank_transfer' - | 'mx_bank_transfer'; - } - } - - interface Ideal { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Ideal { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Klarna { - /** - * Controls when the funds will be captured from the customer's account. - * - * If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. - * - * If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. - */ - capture_method?: Stripe.Emptyable<'manual'>; - - /** - * Preferred language of the Klarna authorization page that the customer is redirected to - */ - preferred_locale?: Klarna.PreferredLocale; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace Klarna { - type PreferredLocale = - | 'da-DK' - | 'de-AT' - | 'de-CH' - | 'de-DE' - | 'en-AT' - | 'en-AU' - | 'en-BE' - | 'en-CA' - | 'en-CH' - | 'en-DE' - | 'en-DK' - | 'en-ES' - | 'en-FI' - | 'en-FR' - | 'en-GB' - | 'en-IE' - | 'en-IT' - | 'en-NL' - | 'en-NO' - | 'en-NZ' - | 'en-PL' - | 'en-PT' - | 'en-SE' - | 'en-US' - | 'es-ES' - | 'es-US' - | 'fi-FI' - | 'fr-BE' - | 'fr-CA' - | 'fr-CH' - | 'fr-FR' - | 'it-CH' - | 'it-IT' - | 'nb-NO' - | 'nl-BE' - | 'nl-NL' - | 'pl-PL' - | 'pt-PT' - | 'sv-FI' - | 'sv-SE'; - } - - interface Link { - /** - * Controls when the funds will be captured from the customer's account. - * - * If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. - * - * If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. - */ - capture_method?: Stripe.Emptyable<'manual'>; - - /** - * Token used for persistent Link logins. - */ - persistent_token?: string; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Link { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Oxxo { - /** - * The number of calendar days before an OXXO voucher expires. For example, if you create an OXXO voucher on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time. - */ - expires_after_days?: number; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - interface P24 { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - - /** - * Confirm that the payer has accepted the P24 terms and conditions. - */ - tos_shown_and_accepted?: boolean; - } - - interface SepaDebit { - /** - * Additional fields for Mandate creation - */ - mandate_options?: SepaDebit.MandateOptions; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace SepaDebit { - interface MandateOptions {} - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - } - - interface Sofort { - /** - * Language shown to the payer on redirect. - */ - preferred_language?: Stripe.Emptyable; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Sofort { - type PreferredLanguage = - | 'de' - | 'en' - | 'es' - | 'fr' - | 'it' - | 'nl' - | 'pl'; - - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface WechatPay { - /** - * The app ID registered with WeChat Pay. Only required when client is ios or android. - */ - app_id?: string; - - /** - * The client type that the end customer will pay from - */ - client: WechatPay.Client; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace WechatPay { - type Client = 'android' | 'ios' | 'web'; - } - } - - type PaymentMethodType = - | 'acss_debit' - | 'afterpay_clearpay' - | 'alipay' - | 'au_becs_debit' - | 'bacs_debit' - | 'bancontact' - | 'card' - | 'customer_balance' - | 'eps' - | 'fpx' - | 'giropay' - | 'grabpay' - | 'ideal' - | 'klarna' - | 'link' - | 'oxxo' - | 'p24' - | 'sepa_debit' - | 'sofort' - | 'wechat_pay'; - - interface TransferData { - /** - * The amount that will be transferred automatically when the order is paid. If no amount is set, the full amount is transferred. There cannot be any line items with recurring prices when using this field. - */ - amount?: number; - - /** - * ID of the Connected account receiving the transfer. - */ - destination: string; - } - } - } - - interface ShippingCost { - /** - * The ID of the shipping rate to use for this order. - */ - shipping_rate?: string; - - /** - * Parameters to create a new ad-hoc shipping rate for this order. - */ - shipping_rate_data?: ShippingCost.ShippingRateData; - } - - namespace ShippingCost { - interface ShippingRateData { - /** - * The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions. - */ - delivery_estimate?: ShippingRateData.DeliveryEstimate; - - /** - * The name of the shipping rate, meant to be displayable to the customer. This will appear on CheckoutSessions. - */ - display_name: string; - - /** - * Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. - */ - fixed_amount?: ShippingRateData.FixedAmount; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.MetadataParam; - - /** - * Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. - */ - tax_behavior?: ShippingRateData.TaxBehavior; - - /** - * A [tax code](https://stripe.com/docs/tax/tax-categories) ID. The Shipping tax code is `txcd_92010001`. - */ - tax_code?: string; - - /** - * The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - */ - type?: 'fixed_amount'; - } - - namespace ShippingRateData { - interface DeliveryEstimate { - /** - * The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. - */ - maximum?: DeliveryEstimate.Maximum; - - /** - * The lower bound of the estimated range. If empty, represents no lower bound. - */ - minimum?: DeliveryEstimate.Minimum; - } - - namespace DeliveryEstimate { - interface Maximum { - /** - * A unit of time. - */ - unit: Maximum.Unit; - - /** - * Must be greater than 0. - */ - value: number; - } - - namespace Maximum { - type Unit = 'business_day' | 'day' | 'hour' | 'month' | 'week'; - } - - interface Minimum { - /** - * A unit of time. - */ - unit: Minimum.Unit; - - /** - * Must be greater than 0. - */ - value: number; - } - - namespace Minimum { - type Unit = 'business_day' | 'day' | 'hour' | 'month' | 'week'; - } - } - - interface FixedAmount { - /** - * A non-negative integer in cents representing how much to charge. - */ - amount: number; - - /** - * 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). - */ - currency: string; - - /** - * Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). - */ - currency_options?: { - [key: string]: FixedAmount.CurrencyOptions; - }; - } - - namespace FixedAmount { - interface CurrencyOptions { - /** - * A non-negative integer in cents representing how much to charge. - */ - amount: number; - - /** - * Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. - */ - tax_behavior?: CurrencyOptions.TaxBehavior; - } - - namespace CurrencyOptions { - type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; - } - } - - type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; - } - } - - interface ShippingDetails { - /** - * The shipping address for the order. - */ - address: Stripe.AddressParam; - - /** - * The name of the recipient of the order. - */ - name: string; - - /** - * The phone number (including extension) for the recipient of the order. - */ - phone?: string; - } - - interface TaxDetails { - /** - * The purchaser's tax exemption status. One of `none`, `exempt`, or `reverse`. - */ - tax_exempt?: Stripe.Emptyable; - - /** - * The purchaser's tax IDs to be used for this order. - */ - tax_ids?: Array; - } - - namespace TaxDetails { - type TaxExempt = 'exempt' | 'none' | 'reverse'; - - interface TaxId { - /** - * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` - */ - type: TaxId.Type; - - /** - * Value of the tax ID. - */ - value: string; - } - - namespace TaxId { - type Type = - | 'ae_trn' - | 'au_abn' - | 'au_arn' - | 'bg_uic' - | 'br_cnpj' - | 'br_cpf' - | 'ca_bn' - | 'ca_gst_hst' - | 'ca_pst_bc' - | 'ca_pst_mb' - | 'ca_pst_sk' - | 'ca_qst' - | 'ch_vat' - | 'cl_tin' - | 'es_cif' - | 'eu_oss_vat' - | 'eu_vat' - | 'gb_vat' - | 'ge_vat' - | 'hk_br' - | 'hu_tin' - | 'id_npwp' - | 'il_vat' - | 'in_gst' - | 'is_vat' - | 'jp_cn' - | 'jp_rn' - | 'kr_brn' - | 'li_uid' - | 'mx_rfc' - | 'my_frp' - | 'my_itn' - | 'my_sst' - | 'no_vat' - | 'nz_gst' - | 'ru_inn' - | 'ru_kpp' - | 'sa_vat' - | 'sg_gst' - | 'sg_uen' - | 'si_tin' - | 'th_vat' - | 'tw_vat' - | 'ua_vat' - | 'us_ein' - | 'za_vat'; - } - } - } - - interface OrderRetrieveParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - interface OrderUpdateParams { - /** - * Settings for automatic tax calculation for this order. - */ - automatic_tax?: OrderUpdateParams.AutomaticTax; - - /** - * Billing details for the customer. If a customer is provided, this will be automatically populated with values from that customer if override values are not provided. - */ - billing_details?: Stripe.Emptyable; - - /** - * 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). - */ - currency?: string; - - /** - * The customer associated with this order. - */ - customer?: string; - - /** - * An arbitrary string attached to the object. Often useful for displaying to users. - */ - description?: string; - - /** - * The coupons, promotion codes, and/or discounts to apply to the order. Pass the empty string `""` to unset this field. - */ - discounts?: Stripe.Emptyable>; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * The IP address of the purchaser for this order. - */ - ip_address?: string; - - /** - * A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. - */ - line_items?: Array; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.Emptyable; - - /** - * Payment information associated with the order, including payment settings. - */ - payment?: OrderUpdateParams.Payment; - - /** - * Settings for the customer cost of shipping for this order. - */ - shipping_cost?: Stripe.Emptyable; - - /** - * Shipping details for the order. - */ - shipping_details?: Stripe.Emptyable; - - /** - * Additional tax details about the purchaser to be used for this order. - */ - tax_details?: OrderUpdateParams.TaxDetails; - } - - namespace OrderUpdateParams { - interface AutomaticTax { - /** - * Enable automatic tax calculation which will automatically compute tax rates on this order. - */ - enabled: boolean; - } - - interface BillingDetails { - /** - * The billing address provided by the customer. - */ - address?: Stripe.AddressParam; - - /** - * The billing email provided by the customer. - */ - email?: string; - - /** - * The billing name provided by the customer. - */ - name?: string; - - /** - * The billing phone number provided by the customer. - */ - phone?: string; - } - - interface Discount { - /** - * ID of the coupon to create a new discount for. - */ - coupon?: string; - - /** - * ID of an existing discount on the object (or one of its ancestors) to reuse. - */ - discount?: string; - - /** - * ID of the promotion code to create a new discount for. - */ - promotion_code?: string; - } - - interface LineItem { - /** - * The description for the line item. Will default to the name of the associated product. - */ - description?: string; - - /** - * The discounts applied to this line item. - */ - discounts?: Stripe.Emptyable>; - - /** - * The ID of an existing line item on the order. - */ - id?: string; - - /** - * The ID of a [Price](https://stripe.com/docs/api/prices) to add to the Order. - * - * The `price` parameter is an alternative to using the `product` parameter. If each of your products are sold at a single price, you can set `Product.default_price` and then pass the `product` parameter when creating a line item. If your products are sold at several possible prices, use the `price` parameter to explicitly specify which one to use. - */ - price?: string; - - /** - * Data used to generate a new Price object inline. - * - * The `price_data` parameter is an alternative to using the `product` or `price` parameters. If you create products upfront and configure a `Product.default_price`, pass the `product` parameter when creating a line item. If you prefer not to define products upfront, or if you charge variable prices, pass the `price_data` parameter to describe the price for this line item. - * - * Each time you pass `price_data` we create a Price for the product. This Price is hidden in both the Dashboard and API lists and cannot be reused. - */ - price_data?: LineItem.PriceData; - - /** - * The ID of a [Product](https://stripe.com/docs/api/products) to add to the Order. - * - * The product must have a `default_price` specified. Otherwise, specify the price by passing the `price` or `price_data` parameter. - */ - product?: string; - - /** - * Defines a Product inline and adds it to the Order. - * - * `product_data` is an alternative to the `product` parameter. If you created a Product upfront, use the `product` parameter to refer to the existing Product. But if you prefer not to create Products upfront, pass the `product_data` parameter to define a Product inline as part of configuring the Order. - * - * `product_data` automatically creates a Product, just as if you had manually created the Product. If a Product with the same ID already exists, then `product_data` re-uses it to avoid duplicates. - */ - product_data?: LineItem.ProductData; - - /** - * The quantity of the line item. - */ - quantity?: number; - - /** - * The tax rates applied to this line item. - */ - tax_rates?: Stripe.Emptyable>; - } - - namespace LineItem { - interface Discount { - /** - * ID of the coupon to create a new discount for. - */ - coupon?: string; - - /** - * ID of an existing discount on the object (or one of its ancestors) to reuse. - */ - discount?: string; - } - - interface PriceData { - /** - * 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). - */ - currency?: string; - - /** - * ID of the product this price belongs to. - * - * Use this to implement a variable-pricing model in your integration. This is required if `product_data` is not specifed. - */ - product?: string; - - /** - * Specifies whether the price is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. Once specified as either `inclusive` or `exclusive`, it cannot be changed. - */ - tax_behavior?: PriceData.TaxBehavior; - - /** - * A positive integer in cents (or local equivalent) (or 0 for a free price) representing how much to charge. - */ - unit_amount?: number; - - /** - * Same as `unit_amount`, but accepts a decimal value in cents (or local equivalent) with at most 12 decimal places. Only one of `unit_amount` and `unit_amount_decimal` can be set. - */ - unit_amount_decimal?: string; - } - - namespace PriceData { - type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; - } - - interface ProductData { - /** - * The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. - */ - description?: string; - - /** - * A unique identifier for this product. - * - * `product_data` automatically creates a Product with this ID. If a Product with the same ID already exists, then `product_data` re-uses it to avoid duplicates. If any of the fields in the existing Product are different from the values in `product_data`, `product_data` updates the existing Product with the new information. So set `product_data[id]` to the same string every time you sell the same product, but don't re-use the same string for different products. - */ - id: string; - - /** - * A list of up to 8 URLs of images for this product, meant to be displayable to the customer. - */ - images?: Stripe.Emptyable>; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.Emptyable; - - /** - * The product's name, meant to be displayable to the customer. - */ - name: string; - - /** - * The dimensions of this product for shipping purposes. - */ - package_dimensions?: Stripe.Emptyable; - - /** - * Whether this product is shipped (i.e., physical goods). - */ - shippable?: boolean; - - /** - * A [tax code](https://stripe.com/docs/tax/tax-categories) ID. - */ - tax_code?: string; - - /** - * A URL of a publicly-accessible webpage for this product. - */ - url?: Stripe.Emptyable; - } - - namespace ProductData { - interface PackageDimensions { - /** - * Height, in inches. Maximum precision is 2 decimal places. - */ - height: number; - - /** - * Length, in inches. Maximum precision is 2 decimal places. - */ - length: number; - - /** - * Weight, in ounces. Maximum precision is 2 decimal places. - */ - weight: number; - - /** - * Width, in inches. Maximum precision is 2 decimal places. - */ - width: number; - } - } - } - - interface Payment { - /** - * Settings describing how the order should configure generated PaymentIntents. - */ - settings: Payment.Settings; - } - - namespace Payment { - interface Settings { - /** - * The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account. - */ - application_fee_amount?: Stripe.Emptyable; - - /** - * PaymentMethod-specific configuration to provide to the order's PaymentIntent. - */ - payment_method_options?: Settings.PaymentMethodOptions; - - /** - * The list of [payment method types](https://stripe.com/docs/payments/payment-methods/overview) to provide to the order's PaymentIntent. Do not include this attribute if you prefer to manage your payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods). - */ - payment_method_types?: Array; - - /** - * The URL to redirect the customer to after they authenticate their payment. - */ - return_url?: Stripe.Emptyable; - - /** - * For non-card charges, you can use this value as the complete description that appears on your customers' statements. Must contain at least one letter, maximum 22 characters. - */ - statement_descriptor?: string; - - /** - * Provides information about a card payment that customers see on their statements. Concatenated with the prefix (shortened descriptor) or statement descriptor that's set on the account to form the complete statement descriptor. Maximum 22 characters for the concatenated descriptor. - */ - statement_descriptor_suffix?: string; - - /** - * Provides configuration for completing a transfer for the order after it is paid. - */ - transfer_data?: Stripe.Emptyable; - } - - namespace Settings { - interface PaymentMethodOptions { - /** - * If paying by `acss_debit`, this sub-hash contains details about the ACSS Debit payment method options to pass to the order's PaymentIntent. - */ - acss_debit?: Stripe.Emptyable; - - /** - * If paying by `afterpay_clearpay`, this sub-hash contains details about the AfterpayClearpay payment method options to pass to the order's PaymentIntent. - */ - afterpay_clearpay?: Stripe.Emptyable< - PaymentMethodOptions.AfterpayClearpay - >; - - /** - * If paying by `alipay`, this sub-hash contains details about the Alipay payment method options to pass to the order's PaymentIntent. - */ - alipay?: Stripe.Emptyable; - - /** - * If paying by `bancontact`, this sub-hash contains details about the Bancontact payment method options to pass to the order's PaymentIntent. - */ - bancontact?: Stripe.Emptyable; - - /** - * If paying by `card`, this sub-hash contains details about the Card payment method options to pass to the order's PaymentIntent. - */ - card?: Stripe.Emptyable; - - /** - * If paying by `customer_balance`, this sub-hash contains details about the Customer Balance payment method options to pass to the order's PaymentIntent. - */ - customer_balance?: Stripe.Emptyable< - PaymentMethodOptions.CustomerBalance - >; - - /** - * If paying by `ideal`, this sub-hash contains details about the iDEAL payment method options to pass to the order's PaymentIntent. - */ - ideal?: Stripe.Emptyable; - - /** - * If paying by `klarna`, this sub-hash contains details about the Klarna payment method options to pass to the order's PaymentIntent. - */ - klarna?: Stripe.Emptyable; - - /** - * If paying by `link`, this sub-hash contains details about the Link payment method options to pass to the order's PaymentIntent. - */ - link?: Stripe.Emptyable; - - /** - * If paying by `oxxo`, this sub-hash contains details about the OXXO payment method options to pass to the order's PaymentIntent. - */ - oxxo?: Stripe.Emptyable; - - /** - * If paying by `p24`, this sub-hash contains details about the P24 payment method options to pass to the order's PaymentIntent. - */ - p24?: Stripe.Emptyable; - - /** - * If paying by `sepa_debit`, this sub-hash contains details about the SEPA Debit payment method options to pass to the order's PaymentIntent. - */ - sepa_debit?: Stripe.Emptyable; - - /** - * If paying by `sofort`, this sub-hash contains details about the Sofort payment method options to pass to the order's PaymentIntent. - */ - sofort?: Stripe.Emptyable; - - /** - * If paying by `wechat_pay`, this sub-hash contains details about the WeChat Pay payment method options to pass to the order's PaymentIntent. - */ - wechat_pay?: Stripe.Emptyable; - } - - namespace PaymentMethodOptions { - interface AcssDebit { - /** - * Additional fields for Mandate creation - */ - mandate_options?: AcssDebit.MandateOptions; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - - /** - * Verification method for the intent - */ - verification_method?: AcssDebit.VerificationMethod; - } - - namespace AcssDebit { - interface MandateOptions { - /** - * A URL for custom mandate text to render during confirmation step. - * The URL will be rendered with additional GET parameters `payment_intent` and `payment_intent_client_secret` when confirming a Payment Intent, - * or `setup_intent` and `setup_intent_client_secret` when confirming a Setup Intent. - */ - custom_mandate_url?: Stripe.Emptyable; - - /** - * Description of the mandate interval. Only required if 'payment_schedule' parameter is 'interval' or 'combined'. - */ - interval_description?: string; - - /** - * Payment schedule for the mandate. - */ - payment_schedule?: MandateOptions.PaymentSchedule; - - /** - * Transaction type of the mandate. - */ - transaction_type?: MandateOptions.TransactionType; - } - - namespace MandateOptions { - type PaymentSchedule = 'combined' | 'interval' | 'sporadic'; - - type TransactionType = 'business' | 'personal'; - } - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - - type VerificationMethod = - | 'automatic' - | 'instant' - | 'microdeposits'; - } - - interface AfterpayClearpay { - /** - * Controls when the funds will be captured from the customer's account. - * - * If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. - * - * If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. - */ - capture_method?: AfterpayClearpay.CaptureMethod; - - /** - * Order identifier shown to the customer in Afterpay's online portal. We recommend using a value that helps you answer any questions a customer might have about - * the payment. The identifier is limited to 128 characters and may contain only letters, digits, underscores, backslashes and dashes. - */ - reference?: string; - - /** - * Indicates that you intend to make future payments with the payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace AfterpayClearpay { - type CaptureMethod = 'automatic' | 'manual'; - } - - interface Alipay { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Alipay { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Bancontact { - /** - * Preferred language of the Bancontact authorization page that the customer is redirected to. - */ - preferred_language?: Bancontact.PreferredLanguage; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable< - Bancontact.SetupFutureUsage - >; - } - - namespace Bancontact { - type PreferredLanguage = 'de' | 'en' | 'fr' | 'nl'; - - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Card { - /** - * Controls when the funds will be captured from the customer's account. - */ - capture_method?: Card.CaptureMethod; - - /** - * Indicates that you intend to make future payments with the payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the order's Customer, if present, after the order's PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Card.SetupFutureUsage; - } - - namespace Card { - type CaptureMethod = 'automatic' | 'manual'; - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - } - - interface CustomerBalance { - /** - * Configuration for the bank transfer funding type, if the `funding_type` is set to `bank_transfer`. - */ - bank_transfer?: CustomerBalance.BankTransfer; - - /** - * The funding method type to be used when there are not enough funds in the customer balance. Permitted values include: `bank_transfer`. - */ - funding_type?: 'bank_transfer'; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace CustomerBalance { - interface BankTransfer { - eu_bank_transfer?: BankTransfer.EuBankTransfer; - - /** - * List of address types that should be returned in the financial_addresses response. If not specified, all valid types will be returned. - * - * Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`. - */ - requested_address_types?: Array< - BankTransfer.RequestedAddressType - >; - - /** - * The list of bank transfer types that this PaymentIntent is allowed to use for funding Permitted values include: `eu_bank_transfer`, `gb_bank_transfer`, `jp_bank_transfer`, or `mx_bank_transfer`. - */ - type: BankTransfer.Type; - } - - namespace BankTransfer { - interface EuBankTransfer { - /** - * The desired country code of the bank account information. Permitted values include: `DE`, `ES`, `FR`, `IE`, or `NL`. - */ - country: string; - } - - type RequestedAddressType = - | 'iban' - | 'sepa' - | 'sort_code' - | 'spei' - | 'zengin'; - - type Type = - | 'eu_bank_transfer' - | 'gb_bank_transfer' - | 'jp_bank_transfer' - | 'mx_bank_transfer'; - } - } - - interface Ideal { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Ideal { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Klarna { - /** - * Controls when the funds will be captured from the customer's account. - * - * If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. - * - * If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. - */ - capture_method?: Stripe.Emptyable<'manual'>; - - /** - * Preferred language of the Klarna authorization page that the customer is redirected to - */ - preferred_locale?: Klarna.PreferredLocale; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace Klarna { - type PreferredLocale = - | 'da-DK' - | 'de-AT' - | 'de-CH' - | 'de-DE' - | 'en-AT' - | 'en-AU' - | 'en-BE' - | 'en-CA' - | 'en-CH' - | 'en-DE' - | 'en-DK' - | 'en-ES' - | 'en-FI' - | 'en-FR' - | 'en-GB' - | 'en-IE' - | 'en-IT' - | 'en-NL' - | 'en-NO' - | 'en-NZ' - | 'en-PL' - | 'en-PT' - | 'en-SE' - | 'en-US' - | 'es-ES' - | 'es-US' - | 'fi-FI' - | 'fr-BE' - | 'fr-CA' - | 'fr-CH' - | 'fr-FR' - | 'it-CH' - | 'it-IT' - | 'nb-NO' - | 'nl-BE' - | 'nl-NL' - | 'pl-PL' - | 'pt-PT' - | 'sv-FI' - | 'sv-SE'; - } - - interface Link { - /** - * Controls when the funds will be captured from the customer's account. - * - * If provided, this parameter will override the top-level `capture_method` when finalizing the payment with this payment method type. - * - * If `capture_method` is already set on the PaymentIntent, providing an empty value for this parameter will unset the stored value for this payment method type. - */ - capture_method?: Stripe.Emptyable<'manual'>; - - /** - * Token used for persistent Link logins. - */ - persistent_token?: string; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Link { - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface Oxxo { - /** - * The number of calendar days before an OXXO voucher expires. For example, if you create an OXXO voucher on Monday and you set expires_after_days to 2, the OXXO invoice will expire on Wednesday at 23:59 America/Mexico_City time. - */ - expires_after_days?: number; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - interface P24 { - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - - /** - * Confirm that the payer has accepted the P24 terms and conditions. - */ - tos_shown_and_accepted?: boolean; - } - - interface SepaDebit { - /** - * Additional fields for Mandate creation - */ - mandate_options?: SepaDebit.MandateOptions; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace SepaDebit { - interface MandateOptions {} - - type SetupFutureUsage = 'none' | 'off_session' | 'on_session'; - } - - interface Sofort { - /** - * Language shown to the payer on redirect. - */ - preferred_language?: Stripe.Emptyable; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: Stripe.Emptyable; - } - - namespace Sofort { - type PreferredLanguage = - | 'de' - | 'en' - | 'es' - | 'fr' - | 'it' - | 'nl' - | 'pl'; - - type SetupFutureUsage = 'none' | 'off_session'; - } - - interface WechatPay { - /** - * The app ID registered with WeChat Pay. Only required when client is ios or android. - */ - app_id?: string; - - /** - * The client type that the end customer will pay from - */ - client: WechatPay.Client; - - /** - * Indicates that you intend to make future payments with this PaymentIntent's payment method. - * - * Providing this parameter will [attach the payment method](https://stripe.com/docs/payments/save-during-payment) to the PaymentIntent's Customer, if present, after the PaymentIntent is confirmed and any required actions from the user are complete. If no Customer was provided, the payment method can still be [attached](https://stripe.com/docs/api/payment_methods/attach) to a Customer after the transaction completes. - * - * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). - * - * If `setup_future_usage` is already set and you are performing a request using a publishable key, you may only update the value from `on_session` to `off_session`. - */ - setup_future_usage?: 'none'; - } - - namespace WechatPay { - type Client = 'android' | 'ios' | 'web'; - } - } - - type PaymentMethodType = - | 'acss_debit' - | 'afterpay_clearpay' - | 'alipay' - | 'au_becs_debit' - | 'bacs_debit' - | 'bancontact' - | 'card' - | 'customer_balance' - | 'eps' - | 'fpx' - | 'giropay' - | 'grabpay' - | 'ideal' - | 'klarna' - | 'link' - | 'oxxo' - | 'p24' - | 'sepa_debit' - | 'sofort' - | 'wechat_pay'; - - interface TransferData { - /** - * The amount that will be transferred automatically when the order is paid. If no amount is set, the full amount is transferred. There cannot be any line items with recurring prices when using this field. - */ - amount?: number; - - /** - * ID of the Connected account receiving the transfer. - */ - destination: string; - } - } - } - - interface ShippingCost { - /** - * The ID of the shipping rate to use for this order. - */ - shipping_rate?: string; - - /** - * Parameters to create a new ad-hoc shipping rate for this order. - */ - shipping_rate_data?: ShippingCost.ShippingRateData; - } - - namespace ShippingCost { - interface ShippingRateData { - /** - * The estimated range for how long shipping will take, meant to be displayable to the customer. This will appear on CheckoutSessions. - */ - delivery_estimate?: ShippingRateData.DeliveryEstimate; - - /** - * The name of the shipping rate, meant to be displayable to the customer. This will appear on CheckoutSessions. - */ - display_name: string; - - /** - * Describes a fixed amount to charge for shipping. Must be present if type is `fixed_amount`. - */ - fixed_amount?: ShippingRateData.FixedAmount; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.MetadataParam; - - /** - * Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. - */ - tax_behavior?: ShippingRateData.TaxBehavior; - - /** - * A [tax code](https://stripe.com/docs/tax/tax-categories) ID. The Shipping tax code is `txcd_92010001`. - */ - tax_code?: string; - - /** - * The type of calculation to use on the shipping rate. Can only be `fixed_amount` for now. - */ - type?: 'fixed_amount'; - } - - namespace ShippingRateData { - interface DeliveryEstimate { - /** - * The upper bound of the estimated range. If empty, represents no upper bound i.e., infinite. - */ - maximum?: DeliveryEstimate.Maximum; - - /** - * The lower bound of the estimated range. If empty, represents no lower bound. - */ - minimum?: DeliveryEstimate.Minimum; - } - - namespace DeliveryEstimate { - interface Maximum { - /** - * A unit of time. - */ - unit: Maximum.Unit; - - /** - * Must be greater than 0. - */ - value: number; - } - - namespace Maximum { - type Unit = 'business_day' | 'day' | 'hour' | 'month' | 'week'; - } - - interface Minimum { - /** - * A unit of time. - */ - unit: Minimum.Unit; - - /** - * Must be greater than 0. - */ - value: number; - } - - namespace Minimum { - type Unit = 'business_day' | 'day' | 'hour' | 'month' | 'week'; - } - } - - interface FixedAmount { - /** - * A non-negative integer in cents representing how much to charge. - */ - amount: number; - - /** - * 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). - */ - currency: string; - - /** - * Shipping rates defined in each available currency option. Each key must be a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html) and a [supported currency](https://stripe.com/docs/currencies). - */ - currency_options?: { - [key: string]: FixedAmount.CurrencyOptions; - }; - } - - namespace FixedAmount { - interface CurrencyOptions { - /** - * A non-negative integer in cents representing how much to charge. - */ - amount: number; - - /** - * Specifies whether the rate is considered inclusive of taxes or exclusive of taxes. One of `inclusive`, `exclusive`, or `unspecified`. - */ - tax_behavior?: CurrencyOptions.TaxBehavior; - } - - namespace CurrencyOptions { - type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; - } - } - - type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; - } - } - - interface ShippingDetails { - /** - * The shipping address for the order. - */ - address: Stripe.AddressParam; - - /** - * The name of the recipient of the order. - */ - name: string; - - /** - * The phone number (including extension) for the recipient of the order. - */ - phone?: string; - } - - interface TaxDetails { - /** - * The purchaser's tax exemption status. One of `none`, `exempt`, or `reverse`. - */ - tax_exempt?: Stripe.Emptyable; - - /** - * The purchaser's tax IDs to be used for this order. - */ - tax_ids?: Array; - } - - namespace TaxDetails { - type TaxExempt = 'exempt' | 'none' | 'reverse'; - - interface TaxId { - /** - * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` - */ - type: TaxId.Type; - - /** - * Value of the tax ID. - */ - value: string; - } - - namespace TaxId { - type Type = - | 'ae_trn' - | 'au_abn' - | 'au_arn' - | 'bg_uic' - | 'br_cnpj' - | 'br_cpf' - | 'ca_bn' - | 'ca_gst_hst' - | 'ca_pst_bc' - | 'ca_pst_mb' - | 'ca_pst_sk' - | 'ca_qst' - | 'ch_vat' - | 'cl_tin' - | 'es_cif' - | 'eu_oss_vat' - | 'eu_vat' - | 'gb_vat' - | 'ge_vat' - | 'hk_br' - | 'hu_tin' - | 'id_npwp' - | 'il_vat' - | 'in_gst' - | 'is_vat' - | 'jp_cn' - | 'jp_rn' - | 'kr_brn' - | 'li_uid' - | 'mx_rfc' - | 'my_frp' - | 'my_itn' - | 'my_sst' - | 'no_vat' - | 'nz_gst' - | 'ru_inn' - | 'ru_kpp' - | 'sa_vat' - | 'sg_gst' - | 'sg_uen' - | 'si_tin' - | 'th_vat' - | 'tw_vat' - | 'ua_vat' - | 'us_ein' - | 'za_vat'; - } - } - } - - interface OrderListParams extends PaginationParams { - /** - * Only return orders for the given customer. - */ - customer?: string; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - interface OrderCancelParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - interface OrderListLineItemsParams extends PaginationParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - interface OrderReopenParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - interface OrderSubmitParams { - /** - * `expected_total` should always be set to the order's `amount_total` field. If they don't match, submitting the order will fail. This helps detect race conditions where something else concurrently modifies the order. - */ - expected_total: number; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - class OrdersResource { - /** - * Creates a new open order object. - */ - create( - params: OrderCreateParams, - options?: RequestOptions - ): Promise>; - - /** - * Retrieves the details of an existing order. Supply the unique order ID from either an order creation request or the order list, and Stripe will return the corresponding order information. - */ - retrieve( - id: string, - params?: OrderRetrieveParams, - options?: RequestOptions - ): Promise>; - retrieve( - id: string, - options?: RequestOptions - ): Promise>; - - /** - * Updates the specific order by setting the values of the parameters passed. Any parameters not provided will be left unchanged. - */ - update( - id: string, - params?: OrderUpdateParams, - options?: RequestOptions - ): Promise>; - - /** - * Returns a list of your orders. The orders are returned sorted by creation date, with the most recently created orders appearing first. - */ - list( - params?: OrderListParams, - options?: RequestOptions - ): ApiListPromise; - list(options?: RequestOptions): ApiListPromise; - - /** - * Cancels the order as well as the payment intent if one is attached. - */ - cancel( - id: string, - params?: OrderCancelParams, - options?: RequestOptions - ): Promise>; - cancel( - id: string, - options?: RequestOptions - ): Promise>; - - /** - * When retrieving an order, there is an includable line_items property containing the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. - */ - listLineItems( - id: string, - params?: OrderListLineItemsParams, - options?: RequestOptions - ): ApiListPromise; - listLineItems( - id: string, - options?: RequestOptions - ): ApiListPromise; - - /** - * Reopens a submitted order. - */ - reopen( - id: string, - params?: OrderReopenParams, - options?: RequestOptions - ): Promise>; - reopen( - id: string, - options?: RequestOptions - ): Promise>; - - /** - * Submitting an Order transitions the status to processing and creates a PaymentIntent object so the order can be paid. If the Order has an amount_total of 0, no PaymentIntent object will be created. Once the order is submitted, its contents cannot be changed, unless the [reopen](https://stripe.com/docs/api#reopen_order) method is called. - */ - submit( - id: string, - params: OrderSubmitParams, - options?: RequestOptions - ): Promise>; - } - } -} diff --git a/types/2022-08-01/PaymentIntents.d.ts b/types/2022-08-01/PaymentIntents.d.ts index 9ee206724a..4f28ab1ed1 100644 --- a/types/2022-08-01/PaymentIntents.d.ts +++ b/types/2022-08-01/PaymentIntents.d.ts @@ -76,7 +76,7 @@ declare module 'stripe' { /** * Charges that were created by this PaymentIntent, if any. */ - charges?: ApiList; + charges: ApiList; /** * The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key. @@ -317,6 +317,11 @@ declare module 'stripe' { */ payment_method_type?: string; + /** + * A URL to the request log entry in your dashboard. + */ + request_log_url?: string; + /** * A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments. * For example, you could use a SetupIntent to set up and save your customer's card without immediately collecting a payment. diff --git a/types/2022-08-01/SetupAttempts.d.ts b/types/2022-08-01/SetupAttempts.d.ts index 11043e066b..1f0572c855 100644 --- a/types/2022-08-01/SetupAttempts.d.ts +++ b/types/2022-08-01/SetupAttempts.d.ts @@ -428,6 +428,11 @@ declare module 'stripe' { */ payment_method_type?: string; + /** + * A URL to the request log entry in your dashboard. + */ + request_log_url?: string; + /** * A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments. * For example, you could use a SetupIntent to set up and save your customer's card without immediately collecting a payment. diff --git a/types/2022-08-01/SetupIntents.d.ts b/types/2022-08-01/SetupIntents.d.ts index bba293a326..72132f0240 100644 --- a/types/2022-08-01/SetupIntents.d.ts +++ b/types/2022-08-01/SetupIntents.d.ts @@ -221,6 +221,11 @@ declare module 'stripe' { */ payment_method_type?: string; + /** + * A URL to the request log entry in your dashboard. + */ + request_log_url?: string; + /** * A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments. * For example, you could use a SetupIntent to set up and save your customer's card without immediately collecting a payment. diff --git a/types/2022-08-01/index.d.ts b/types/2022-08-01/index.d.ts index ab72cdea9f..b8ad10f5ae 100644 --- a/types/2022-08-01/index.d.ts +++ b/types/2022-08-01/index.d.ts @@ -59,7 +59,6 @@ /// /// /// -/// /// /// /// @@ -134,7 +133,7 @@ declare module 'stripe' { export class Stripe { static Stripe: typeof Stripe; - constructor(apiKey: string, config: Stripe.StripeConfig); + constructor(apiKey: string, config?: Stripe.StripeConfig); setAppInfo(info: Stripe.AppInfo): void; @@ -163,7 +162,6 @@ declare module 'stripe' { invoices: Stripe.InvoicesResource; invoiceItems: Stripe.InvoiceItemsResource; mandates: Stripe.MandatesResource; - orders: Stripe.OrdersResource; paymentIntents: Stripe.PaymentIntentsResource; paymentLinks: Stripe.PaymentLinksResource; paymentMethods: Stripe.PaymentMethodsResource; From 16ff04fee1f3b2b7b7fb5e581f26f1623c96bd6b Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 13 Oct 2022 12:41:56 -0700 Subject: [PATCH 05/16] Remove SKU resource --- lib/resources.js | 1 - lib/resources/SKUs.js | 28 -- src/resources.js | 1 - src/resources/SKUs.js | 36 -- .../resources/generated_examples_test.spec.js | 35 -- types/2022-08-01/SKUs.d.ts | 453 ------------------ types/2022-08-01/index.d.ts | 2 - 7 files changed, 556 deletions(-) delete mode 100644 lib/resources/SKUs.js delete mode 100644 src/resources/SKUs.js delete mode 100644 types/2022-08-01/SKUs.d.ts diff --git a/lib/resources.js b/lib/resources.js index 83b3bd3fde..eb497e3587 100644 --- a/lib/resources.js +++ b/lib/resources.js @@ -39,7 +39,6 @@ module.exports = { SetupAttempts: require('./resources/SetupAttempts'), SetupIntents: require('./resources/SetupIntents'), ShippingRates: require('./resources/ShippingRates'), - Skus: require('./resources/SKUs'), Sources: require('./resources/Sources'), Subscriptions: require('./resources/Subscriptions'), SubscriptionItems: require('./resources/SubscriptionItems'), diff --git a/lib/resources/SKUs.js b/lib/resources/SKUs.js deleted file mode 100644 index 9347fb54e0..0000000000 --- a/lib/resources/SKUs.js +++ /dev/null @@ -1,28 +0,0 @@ -// File generated from our OpenAPI spec -'use strict'; -const StripeResource = require('../StripeResource'); -const stripeMethod = StripeResource.method; -module.exports = StripeResource.extend({ - path: 'skus', - create: stripeMethod({ - method: 'POST', - path: '', - }), - retrieve: stripeMethod({ - method: 'GET', - path: '/{id}', - }), - update: stripeMethod({ - method: 'POST', - path: '/{id}', - }), - list: stripeMethod({ - method: 'GET', - path: '', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - path: '/{id}', - }), -}); diff --git a/src/resources.js b/src/resources.js index 98dcf27ac9..5e36ae42d3 100644 --- a/src/resources.js +++ b/src/resources.js @@ -42,7 +42,6 @@ module.exports = { SetupAttempts: require('./resources/SetupAttempts'), SetupIntents: require('./resources/SetupIntents'), ShippingRates: require('./resources/ShippingRates'), - Skus: require('./resources/SKUs'), Sources: require('./resources/Sources'), Subscriptions: require('./resources/Subscriptions'), SubscriptionItems: require('./resources/SubscriptionItems'), diff --git a/src/resources/SKUs.js b/src/resources/SKUs.js deleted file mode 100644 index 26812405ff..0000000000 --- a/src/resources/SKUs.js +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec - -'use strict'; - -const StripeResource = require('../StripeResource'); -const stripeMethod = StripeResource.method; - -module.exports = StripeResource.extend({ - path: 'skus', - - create: stripeMethod({ - method: 'POST', - path: '', - }), - - retrieve: stripeMethod({ - method: 'GET', - path: '/{id}', - }), - - update: stripeMethod({ - method: 'POST', - path: '/{id}', - }), - - list: stripeMethod({ - method: 'GET', - path: '', - methodType: 'list', - }), - - del: stripeMethod({ - method: 'DELETE', - path: '/{id}', - }), -}); diff --git a/test/resources/generated_examples_test.spec.js b/test/resources/generated_examples_test.spec.js index 526d209001..d51bcf971a 100644 --- a/test/resources/generated_examples_test.spec.js +++ b/test/resources/generated_examples_test.spec.js @@ -2270,41 +2270,6 @@ describe('Sigma.ScheduledQueryRun', function() { }); }); -describe('Sku', function() { - it('list method', async function() { - const skus = await stripe.skus.list({limit: 3}); - expect(skus).not.to.be.null; - }); - - it('create method', async function() { - const sku = await stripe.skus.create({ - attributes: {size: 'Medium', gender: 'Unisex'}, - price: 1500, - currency: 'usd', - inventory: {type: 'finite', quantity: 500}, - product: 'prod_xxxxxxxxxxxxx', - }); - expect(sku).not.to.be.null; - }); - - it('del method', async function() { - const deleted = await stripe.skus.del('sku_xxxxxxxxxxxxx'); - expect(deleted).not.to.be.null; - }); - - it('retrieve method', async function() { - const sku = await stripe.skus.retrieve('sku_xxxxxxxxxxxxx'); - expect(sku).not.to.be.null; - }); - - it('update method', async function() { - const sku = await stripe.skus.update('sku_xxxxxxxxxxxxx', { - metadata: {order_id: '6735'}, - }); - expect(sku).not.to.be.null; - }); -}); - describe('Source', function() { it('retrieve method', async function() { const source = await stripe.sources.retrieve('src_xxxxxxxxxxxxx'); diff --git a/types/2022-08-01/SKUs.d.ts b/types/2022-08-01/SKUs.d.ts deleted file mode 100644 index 8653c30301..0000000000 --- a/types/2022-08-01/SKUs.d.ts +++ /dev/null @@ -1,453 +0,0 @@ -// File generated from our OpenAPI spec - -declare module 'stripe' { - namespace Stripe { - /** - * Stores representations of [stock keeping units](http://en.wikipedia.org/wiki/Stock_keeping_unit). - * SKUs describe specific product variations, taking into account any combination of: attributes, - * currency, and cost. For example, a product may be a T-shirt, whereas a specific SKU represents - * the `size: large`, `color: red` version of that shirt. - * - * Can also be used to manage inventory. - */ - interface Sku { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'sku'; - - /** - * Whether the SKU is available for purchase. - */ - active: boolean; - - /** - * A dictionary of attributes and values for the attributes defined by the product. If, for example, a product's attributes are `["size", "gender"]`, a valid SKU has the following dictionary of attributes: `{"size": "Medium", "gender": "Unisex"}`. - */ - attributes: { - [key: string]: string; - }; - - /** - * Time at which the object was created. Measured in seconds since the Unix epoch. - */ - created: number; - - /** - * 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). - */ - currency: string; - - deleted?: void; - - /** - * The URL of an image for this SKU, meant to be displayable to the customer. - */ - image: string | null; - - inventory: Sku.Inventory; - - /** - * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. - */ - livemode: boolean; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. - */ - metadata: Stripe.Metadata; - - /** - * The dimensions of this SKU for shipping purposes. - */ - package_dimensions: Sku.PackageDimensions | null; - - /** - * The cost of the item as a positive integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 100 to charge ¥100, Japanese Yen being a zero-decimal currency). - */ - price: number; - - /** - * The ID of the product this SKU is associated with. The product must be currently active. - */ - product: string | Stripe.Product; - - /** - * Time at which the object was last updated. Measured in seconds since the Unix epoch. - */ - updated: number; - } - - namespace Sku { - interface Inventory { - /** - * The count of inventory available. Will be present if and only if `type` is `finite`. - */ - quantity: number | null; - - /** - * Inventory type. Possible values are `finite`, `bucket` (not quantified), and `infinite`. - */ - type: string; - - /** - * An indicator of the inventory available. Possible values are `in_stock`, `limited`, and `out_of_stock`. Will be present if and only if `type` is `bucket`. - */ - value: string | null; - } - - interface PackageDimensions { - /** - * Height, in inches. - */ - height: number; - - /** - * Length, in inches. - */ - length: number; - - /** - * Weight, in ounces. - */ - weight: number; - - /** - * Width, in inches. - */ - width: number; - } - } - - /** - * The DeletedSku object. - */ - interface DeletedSku { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'sku'; - - /** - * Always true for a deleted object - */ - deleted: true; - } - - interface SkuCreateParams { - /** - * 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). - */ - currency: string; - - /** - * Description of the SKU's inventory. - */ - inventory: SkuCreateParams.Inventory; - - /** - * The cost of the item as a nonnegative integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 100 to charge ¥100, Japanese Yen being a zero-decimal currency). - */ - price: number; - - /** - * The ID of the product this SKU is associated with. Must be a product with type `good`. - */ - product: string; - - /** - * Whether the SKU is available for purchase. Default to `true`. - */ - active?: boolean; - - /** - * A dictionary of attributes and values for the attributes defined by the product. If, for example, a product's attributes are `["size", "gender"]`, a valid SKU has the following dictionary of attributes: `{"size": "Medium", "gender": "Unisex"}`. - */ - attributes?: { - [key: string]: string; - }; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * The identifier for the SKU. Must be unique. If not provided, an identifier will be randomly generated. - */ - id?: string; - - /** - * The URL of an image for this SKU, meant to be displayable to the customer. - */ - image?: string; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.MetadataParam; - - /** - * The dimensions of this SKU for shipping purposes. - */ - package_dimensions?: SkuCreateParams.PackageDimensions; - } - - namespace SkuCreateParams { - interface Inventory { - /** - * The count of inventory available. Required if `type` is `finite`. - */ - quantity?: number; - - /** - * Inventory type. Possible values are `finite`, `bucket` (not quantified), and `infinite`. - */ - type: Inventory.Type; - - /** - * An indicator of the inventory available. Possible values are `in_stock`, `limited`, and `out_of_stock`. Will be present if and only if `type` is `bucket`. - */ - value?: Stripe.Emptyable; - } - - namespace Inventory { - type Type = 'bucket' | 'finite' | 'infinite'; - - type Value = 'in_stock' | 'limited' | 'out_of_stock'; - } - - interface PackageDimensions { - /** - * Height, in inches. Maximum precision is 2 decimal places. - */ - height: number; - - /** - * Length, in inches. Maximum precision is 2 decimal places. - */ - length: number; - - /** - * Weight, in ounces. Maximum precision is 2 decimal places. - */ - weight: number; - - /** - * Width, in inches. Maximum precision is 2 decimal places. - */ - width: number; - } - } - - interface SkuRetrieveParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - interface SkuUpdateParams { - /** - * Whether this SKU is available for purchase. - */ - active?: boolean; - - /** - * A dictionary of attributes and values for the attributes defined by the product. When specified, `attributes` will partially update the existing attributes dictionary on the product, with the postcondition that a value must be present for each attribute key on the product. - */ - attributes?: { - [key: string]: string; - }; - - /** - * 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). - */ - currency?: string; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * The URL of an image for this SKU, meant to be displayable to the customer. - */ - image?: string; - - /** - * Description of the SKU's inventory. - */ - inventory?: SkuUpdateParams.Inventory; - - /** - * Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format. Individual keys can be unset by posting an empty value to them. All keys can be unset by posting an empty value to `metadata`. - */ - metadata?: Stripe.Emptyable; - - /** - * The dimensions of this SKU for shipping purposes. - */ - package_dimensions?: Stripe.Emptyable; - - /** - * The cost of the item as a positive integer in the smallest currency unit (that is, 100 cents to charge $1.00, or 100 to charge ¥100, Japanese Yen being a zero-decimal currency). - */ - price?: number; - - /** - * The ID of the product that this SKU should belong to. The product must exist, have the same set of attribute names as the SKU's current product, and be of type `good`. - */ - product?: string; - } - - namespace SkuUpdateParams { - interface Inventory { - /** - * The count of inventory available. Required if `type` is `finite`. - */ - quantity?: number; - - /** - * Inventory type. Possible values are `finite`, `bucket` (not quantified), and `infinite`. - */ - type?: Inventory.Type; - - /** - * An indicator of the inventory available. Possible values are `in_stock`, `limited`, and `out_of_stock`. Will be present if and only if `type` is `bucket`. - */ - value?: Stripe.Emptyable; - } - - namespace Inventory { - type Type = 'bucket' | 'finite' | 'infinite'; - - type Value = 'in_stock' | 'limited' | 'out_of_stock'; - } - - interface PackageDimensions { - /** - * Height, in inches. Maximum precision is 2 decimal places. - */ - height: number; - - /** - * Length, in inches. Maximum precision is 2 decimal places. - */ - length: number; - - /** - * Weight, in ounces. Maximum precision is 2 decimal places. - */ - weight: number; - - /** - * Width, in inches. Maximum precision is 2 decimal places. - */ - width: number; - } - } - - interface SkuListParams extends PaginationParams { - /** - * Only return SKUs that are active or inactive (e.g., pass `false` to list all inactive products). - */ - active?: boolean; - - /** - * Only return SKUs that have the specified key-value pairs in this partially constructed dictionary. Can be specified only if `product` is also supplied. For instance, if the associated product has attributes `["color", "size"]`, passing in `attributes[color]=red` returns all the SKUs for this product that have `color` set to `red`. - */ - attributes?: { - [key: string]: string; - }; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * Only return SKUs with the given IDs. - */ - ids?: Array; - - /** - * Only return SKUs that are either in stock or out of stock (e.g., pass `false` to list all SKUs that are out of stock). If no value is provided, all SKUs are returned. - */ - in_stock?: boolean; - - /** - * The ID of the product whose SKUs will be retrieved. Must be a product with type `good`. - */ - product?: string; - } - - interface SkuDeleteParams {} - - class SkusResource { - /** - * Creates a new SKU associated with a product. - */ - create( - params: SkuCreateParams, - options?: RequestOptions - ): Promise>; - - /** - * Retrieves the details of an existing SKU. Supply the unique SKU identifier from either a SKU creation request or from the product, and Stripe will return the corresponding SKU information. - */ - retrieve( - id: string, - params?: SkuRetrieveParams, - options?: RequestOptions - ): Promise>; - retrieve( - id: string, - options?: RequestOptions - ): Promise>; - - /** - * Updates the specific SKU by setting the values of the parameters passed. Any parameters not provided will be left unchanged. - * - * Note that a SKU's attributes are not editable. Instead, you would need to deactivate the existing SKU and create a new one with the new attribute values. - */ - update( - id: string, - params?: SkuUpdateParams, - options?: RequestOptions - ): Promise>; - - /** - * Returns a list of your SKUs. The SKUs are returned sorted by creation date, with the most recently created SKUs appearing first. - */ - list( - params?: SkuListParams, - options?: RequestOptions - ): ApiListPromise; - list(options?: RequestOptions): ApiListPromise; - - /** - * Delete a SKU. Deleting a SKU is only possible until it has been used in an order. - */ - del( - id: string, - params?: SkuDeleteParams, - options?: RequestOptions - ): Promise>; - del( - id: string, - options?: RequestOptions - ): Promise>; - } - } -} diff --git a/types/2022-08-01/index.d.ts b/types/2022-08-01/index.d.ts index b8ad10f5ae..bd8c1c27ef 100644 --- a/types/2022-08-01/index.d.ts +++ b/types/2022-08-01/index.d.ts @@ -78,7 +78,6 @@ /// /// /// -/// /// /// /// @@ -176,7 +175,6 @@ declare module 'stripe' { setupAttempts: Stripe.SetupAttemptsResource; setupIntents: Stripe.SetupIntentsResource; shippingRates: Stripe.ShippingRatesResource; - skus: Stripe.SkusResource; sources: Stripe.SourcesResource; subscriptions: Stripe.SubscriptionsResource; subscriptionItems: Stripe.SubscriptionItemsResource; From 3e9785b3e5c718f18381b23676aed9dce16b4e13 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Thu, 13 Oct 2022 12:53:55 -0700 Subject: [PATCH 06/16] Remove SKUs.spec.js --- test/resources/SKUs.spec.js | 98 ------------------------------------- 1 file changed, 98 deletions(-) delete mode 100644 test/resources/SKUs.spec.js diff --git a/test/resources/SKUs.spec.js b/test/resources/SKUs.spec.js deleted file mode 100644 index d165427075..0000000000 --- a/test/resources/SKUs.spec.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -const stripe = require('../../testUtils').getSpyableStripe(); -const expect = require('chai').expect; - -describe('SKU Resource', () => { - describe('retrieve', () => { - it('Sends the correct request', () => { - stripe.skus.retrieve('skuIdFoo123'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/skus/skuIdFoo123', - data: {}, - headers: {}, - settings: {}, - }); - }); - }); - - describe('create', () => { - it('Sends the correct request', () => { - stripe.skus.create({ - currency: 'usd', - inventory: {type: 'finite', quantity: 500}, - attributes: {size: 'Medium', gender: 'Unisex'}, - price: 500, - product: 'prodIdTest123', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/skus', - data: { - currency: 'usd', - inventory: {type: 'finite', quantity: 500}, - attributes: {size: 'Medium', gender: 'Unisex'}, - price: 500, - product: 'prodIdTest123', - }, - headers: {}, - settings: {}, - }); - }); - }); - - describe('list', () => { - it('Sends the correct request', () => { - stripe.skus.list({ - limit: 3, - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/skus?limit=3', - data: {}, - headers: {}, - settings: {}, - }); - }); - - it('Supports filtering by product', () => { - stripe.skus.list({ - product: 'prodId123', - }); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/skus?product=prodId123', - data: {}, - headers: {}, - settings: {}, - }); - }); - }); - - describe('update', () => { - it('Sends the correct request', () => { - stripe.skus.update('skuIdFoo3242', {caption: 'test'}); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'POST', - url: '/v1/skus/skuIdFoo3242', - headers: {}, - data: {caption: 'test'}, - settings: {}, - }); - }); - }); - - describe('del', () => { - it('Sends the correct request', () => { - stripe.skus.del('skuIdFoo3242'); - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'DELETE', - url: '/v1/skus/skuIdFoo3242', - headers: {}, - data: {}, - settings: {}, - }); - }); - }); -}); From 71f615bcc126c98d7eab0ada73caac910cdc3290 Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Tue, 1 Nov 2022 14:39:30 -0700 Subject: [PATCH 07/16] Remove deprecated configuration setter methods (#1597) * Remove deprecated config properties * Update test and remove config properties from types/ * Remove setProtocol from types, refactor old tests * Replace more require('../lib/stripe') with Stripe * Remove global stripe from EphemeralKeys test * Rename local stripe to newStripe in stripe.spec.js * Refactor EphemeralKeys.spec.js --- lib/stripe.js | 158 ------------------------- src/stripe.ts | 168 --------------------------- test/StripeResource.spec.js | 2 - test/resources/EphemeralKeys.spec.js | 36 +++--- test/stripe.spec.js | 112 +++++++++++------- test/telemetry.spec.js | 30 +++-- testUtils/index.js | 4 +- types/2022-08-01/index.d.ts | 23 ---- types/test/typescriptTest.ts | 10 +- 9 files changed, 108 insertions(+), 435 deletions(-) diff --git a/lib/stripe.js b/lib/stripe.js index 60b82e7312..2907e49e08 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -148,93 +148,6 @@ Stripe.createSubtleCryptoProvider = (subtleCrypto) => { return new SubtleCryptoProvider(subtleCrypto); }; Stripe.prototype = { - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * host: 'example.com', - * port: '8080', - * protocol: 'http', - * }); - * - */ - setHost(host, port, protocol) { - emitWarning( - '`setHost` is deprecated. Use the `host` config option instead.' - ); - this._setApiField('host', host); - if (port) { - this.setPort(port); - } - if (protocol) { - this.setProtocol(protocol); - } - }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * protocol: 'http', - * }); - * - */ - setProtocol(protocol) { - emitWarning( - '`setProtocol` is deprecated. Use the `protocol` config option instead.' - ); - this._setApiField('protocol', protocol.toLowerCase()); - }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * port: 3000, - * }); - * - */ - setPort(port) { - emitWarning( - '`setPort` is deprecated. Use the `port` config option instead.' - ); - this._setApiField('port', port); - }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * apiVersion: API_VERSION, - * }); - * - */ - setApiVersion(version) { - emitWarning( - '`setApiVersion` is deprecated. Use the `apiVersion` config or request option instead.' - ); - if (version) { - this._setApiField('version', version); - } - }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY); - * - * Or, for Stripe Connect, use `stripeAccount` instead: - * - * const stripe = new Stripe(API_KEY, { - * stripeAccount: 'acct_...', - * }); - * - * Or, to use a different apiKey on a given request: - * - * stripe.customers.create(params, {apiKey: 'sk_test_...'}); - */ - setApiKey(key) { - emitWarning( - '`setApiKey` is deprecated. Use the `apiKey` request option instead.' - ); - this._setApiKey(key); - }, /** * @private */ @@ -243,37 +156,6 @@ Stripe.prototype = { this._setApiField('auth', `Bearer ${key}`); } }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * timeout: TIMEOUT_MS, - * }); - */ - setTimeout(timeout) { - emitWarning( - '`setTimeout` is deprecated. Use the `timeout` config or request option instead.' - ); - this._setApiField('timeout', timeout == null ? DEFAULT_TIMEOUT : timeout); - }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * appInfo: { - * name: 'MyPlugin', - * version: '1.4.2', - * url: 'https://myplugin.com', - * partner_id: '1234', - * }, - * }); - */ - setAppInfo(info) { - emitWarning( - '`setAppInfo` is deprecated. Use the `appInfo` config option instead.' - ); - this._setAppInfo(info); - }, /** * @private * This may be removed in the future. @@ -295,21 +177,6 @@ Stripe.prototype = { }, undefined); this._appInfo = appInfo; }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const ProxyAgent = require('https-proxy-agent'); - * const stripe = new Stripe(API_KEY, { - * httpAgent: new ProxyAgent(process.env.http_proxy), - * }); - * - */ - setHttpAgent(agent) { - emitWarning( - '`setHttpAgent` is deprecated. Use the `httpAgent` config option instead.' - ); - this._setApiField('agent', agent); - }, /** * @private * This may be removed in the future. @@ -362,17 +229,6 @@ Stripe.prototype = { getMaxNetworkRetries() { return this.getApiField('maxNetworkRetries'); }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * maxNetworkRetries: 2, - * }); - * - */ - setMaxNetworkRetries(maxNetworkRetries) { - this._setApiNumberField('maxNetworkRetries', maxNetworkRetries); - }, /** * @private * This may be removed in the future. @@ -461,20 +317,6 @@ Stripe.prototype = { } return formatted; }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * telemetry: false, - * }); - * - */ - setTelemetryEnabled(enableTelemetry) { - emitWarning( - '`setTelemetryEnabled` is deprecated. Use the `telemetry` config option instead.' - ); - this._enableTelemetry = enableTelemetry; - }, getTelemetryEnabled() { return this._enableTelemetry; }, diff --git a/src/stripe.ts b/src/stripe.ts index 5d6cb7e377..4dbb40689c 100644 --- a/src/stripe.ts +++ b/src/stripe.ts @@ -178,98 +178,6 @@ Stripe.createSubtleCryptoProvider = (subtleCrypto) => { }; Stripe.prototype = { - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * host: 'example.com', - * port: '8080', - * protocol: 'http', - * }); - * - */ - setHost(host, port, protocol) { - emitWarning( - '`setHost` is deprecated. Use the `host` config option instead.' - ); - this._setApiField('host', host); - if (port) { - this.setPort(port); - } - if (protocol) { - this.setProtocol(protocol); - } - }, - - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * protocol: 'http', - * }); - * - */ - setProtocol(protocol) { - emitWarning( - '`setProtocol` is deprecated. Use the `protocol` config option instead.' - ); - this._setApiField('protocol', protocol.toLowerCase()); - }, - - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * port: 3000, - * }); - * - */ - setPort(port) { - emitWarning( - '`setPort` is deprecated. Use the `port` config option instead.' - ); - this._setApiField('port', port); - }, - - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * apiVersion: API_VERSION, - * }); - * - */ - setApiVersion(version) { - emitWarning( - '`setApiVersion` is deprecated. Use the `apiVersion` config or request option instead.' - ); - if (version) { - this._setApiField('version', version); - } - }, - - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY); - * - * Or, for Stripe Connect, use `stripeAccount` instead: - * - * const stripe = new Stripe(API_KEY, { - * stripeAccount: 'acct_...', - * }); - * - * Or, to use a different apiKey on a given request: - * - * stripe.customers.create(params, {apiKey: 'sk_test_...'}); - */ - setApiKey(key) { - emitWarning( - '`setApiKey` is deprecated. Use the `apiKey` request option instead.' - ); - this._setApiKey(key); - }, - /** * @private */ @@ -279,39 +187,6 @@ Stripe.prototype = { } }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * timeout: TIMEOUT_MS, - * }); - */ - setTimeout(timeout) { - emitWarning( - '`setTimeout` is deprecated. Use the `timeout` config or request option instead.' - ); - this._setApiField('timeout', timeout == null ? DEFAULT_TIMEOUT : timeout); - }, - - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * appInfo: { - * name: 'MyPlugin', - * version: '1.4.2', - * url: 'https://myplugin.com', - * partner_id: '1234', - * }, - * }); - */ - setAppInfo(info) { - emitWarning( - '`setAppInfo` is deprecated. Use the `appInfo` config option instead.' - ); - this._setAppInfo(info); - }, - /** * @private * This may be removed in the future. @@ -343,22 +218,6 @@ Stripe.prototype = { this._appInfo = appInfo; }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const ProxyAgent = require('https-proxy-agent'); - * const stripe = new Stripe(API_KEY, { - * httpAgent: new ProxyAgent(process.env.http_proxy), - * }); - * - */ - setHttpAgent(agent) { - emitWarning( - '`setHttpAgent` is deprecated. Use the `httpAgent` config option instead.' - ); - this._setApiField('agent', agent); - }, - /** * @private * This may be removed in the future. @@ -417,18 +276,6 @@ Stripe.prototype = { return this.getApiField('maxNetworkRetries'); }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * maxNetworkRetries: 2, - * }); - * - */ - setMaxNetworkRetries(maxNetworkRetries) { - this._setApiNumberField('maxNetworkRetries', maxNetworkRetries); - }, - /** * @private * This may be removed in the future. @@ -533,21 +380,6 @@ Stripe.prototype = { return formatted; }, - /** - * @deprecated will be removed in a future major version. Use the config object instead: - * - * const stripe = new Stripe(API_KEY, { - * telemetry: false, - * }); - * - */ - setTelemetryEnabled(enableTelemetry) { - emitWarning( - '`setTelemetryEnabled` is deprecated. Use the `telemetry` config option instead.' - ); - this._enableTelemetry = enableTelemetry; - }, - getTelemetryEnabled() { return this._enableTelemetry; }, diff --git a/test/StripeResource.spec.js b/test/StripeResource.spec.js index 78b999aedb..5b7217d2f2 100644 --- a/test/StripeResource.spec.js +++ b/test/StripeResource.spec.js @@ -1023,8 +1023,6 @@ describe('StripeResource', () => { describe('Request Timeout', () => { it('should allow the setting of a request timeout on a per-request basis', (done) => { - stripe.setTimeout(1000); - stripe.charges.create({}); expect(stripe.LAST_REQUEST.settings).to.deep.equal({}); diff --git a/test/resources/EphemeralKeys.spec.js b/test/resources/EphemeralKeys.spec.js index 2a64f5a978..e77866ea29 100644 --- a/test/resources/EphemeralKeys.spec.js +++ b/test/resources/EphemeralKeys.spec.js @@ -1,9 +1,9 @@ 'use strict'; -const stripe = require('../../testUtils').getSpyableStripe(); +const getSpyableStripe = require('../../testUtils').getSpyableStripe; const expect = require('chai').expect; -function errorsOnNoStripeVersion() { +function errorsOnNoStripeVersion(stripe) { return expect( stripe.ephemeralKeys.create({customer: 'cus_123'}) ).to.be.eventually.rejectedWith( @@ -11,7 +11,7 @@ function errorsOnNoStripeVersion() { ); } -function sendsCorrectStripeVersion() { +function sendsCorrectStripeVersion(stripe) { stripe.ephemeralKeys.create( {customer: 'cus_123'}, {apiVersion: '2017-06-05'} @@ -32,6 +32,8 @@ function sendsCorrectStripeVersion() { describe('EphemeralKey Resource', () => { describe('create', () => { + const stripe = getSpyableStripe(); + it('Sends the correct request', () => { stripe.ephemeralKeys.create( {customer: 'cus_123'}, @@ -51,43 +53,35 @@ describe('EphemeralKey Resource', () => { }); describe('when an api version is set', () => { - beforeEach(function() { - this.oldVersion = stripe.getApiField('version'); - stripe.setApiVersion('2017-05-25'); - }); - - afterEach(function() { - stripe.setApiVersion(this.oldVersion); + const stripe = getSpyableStripe({ + apiVersion: '2017-05-25', }); it('Errors if no stripe-version is specified', () => - errorsOnNoStripeVersion()); + errorsOnNoStripeVersion(stripe)); it('Sends the correct stripe-version', () => { - sendsCorrectStripeVersion(); + sendsCorrectStripeVersion(stripe); }); }); describe('when no api version is set', () => { - beforeEach(function() { - this.oldVersion = stripe.getApiField('version'); - stripe.setApiVersion(null); - }); - - afterEach(function() { - stripe.setApiVersion(this.oldVersion); + const stripe = getSpyableStripe({ + apiVersion: null, }); it('Errors if no stripe-version is specified', () => - errorsOnNoStripeVersion()); + errorsOnNoStripeVersion(stripe)); it('Sends the correct stripe-version', () => { - sendsCorrectStripeVersion(); + sendsCorrectStripeVersion(stripe); }); }); }); describe('delete', () => { + const stripe = getSpyableStripe(); + it('Sends the correct request', () => { stripe.ephemeralKeys.del('ephkey_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ diff --git a/test/stripe.spec.js b/test/stripe.spec.js index c2111b39b1..f3d4c3b9c4 100644 --- a/test/stripe.spec.js +++ b/test/stripe.spec.js @@ -111,8 +111,8 @@ describe('Stripe Module', function() { }); cases.forEach((item) => { - const stripe = Stripe(testUtils.getUserStripeKey(), item); - expect(stripe.getApiField('version')).to.equal(null); + const newStripe = Stripe(testUtils.getUserStripeKey(), item); + expect(newStripe.getApiField('version')).to.equal(null); }); }); @@ -178,22 +178,22 @@ describe('Stripe Module', function() { it('Should include whether typescript: true was passed, respecting reinstantiations', () => { return new Promise((resolve) => resolve()) .then(() => { - const stripe = new Stripe('sk_test_123', { + const newStripe = new Stripe('sk_test_123', { typescript: true, }); return expect( new Promise((resolve, reject) => { - stripe.getClientUserAgent((c) => { + newStripe.getClientUserAgent((c) => { resolve(JSON.parse(c)); }); }) ).to.eventually.have.property('typescript', 'true'); }) .then(() => { - const stripe = new Stripe('sk_test_123', {}); + const newStripe = new Stripe('sk_test_123', {}); return expect( new Promise((resolve, reject) => { - stripe.getClientUserAgent((c) => { + newStripe.getClientUserAgent((c) => { resolve(JSON.parse(c)); }); }) @@ -276,25 +276,28 @@ describe('Stripe Module', function() { }); }); - describe('setTimeout', () => { + describe('timeout config', () => { const defaultTimeout = 80000; it('Should define a default of 80000', () => { expect(stripe.getApiField('timeout')).to.equal(defaultTimeout); }); it('Should allow me to set a custom timeout', () => { - stripe.setTimeout(900); - expect(stripe.getApiField('timeout')).to.equal(900); + const newStripe = Stripe('sk_test', { + timeout: 900, + }); + expect(newStripe.getApiField('timeout')).to.equal(900); }); it('Should allow me to set null, to reset to the default', () => { - stripe.setTimeout(null); - expect(stripe.getApiField('timeout')).to.equal(defaultTimeout); + const newStripe = Stripe('sk_test', { + timeout: null, + }); + expect(newStripe.getApiField('timeout')).to.equal(defaultTimeout); }); }); - describe('setAppInfo', () => { + describe('appInfo config', () => { describe('when given nothing or an empty object', () => { it('should unset stripe._appInfo', () => { - stripe.setAppInfo(); expect(stripe._appInfo).to.be.undefined; }); }); @@ -308,7 +311,9 @@ describe('Stripe Module', function() { describe('when given a non-object variable', () => { it('should throw an error', () => { expect(() => { - stripe.setAppInfo('foo'); + Stripe('sk_test', { + appInfo: 'foo', + }); }).to.throw(/AppInfo must be an object./); }); }); @@ -316,18 +321,24 @@ describe('Stripe Module', function() { describe('when given an object with no `name`', () => { it('should throw an error', () => { expect(() => { - stripe.setAppInfo({}); + Stripe('sk_test', { + appInfo: {}, + }); }).to.throw(/AppInfo.name is required/); expect(() => { - stripe.setAppInfo({ - version: '1.2.3', + Stripe('sk_test', { + appInfo: { + version: '1.2.3', + }, }); }).to.throw(/AppInfo.name is required/); expect(() => { - stripe.setAppInfo({ - cats: '42', + Stripe('sk_test', { + appInfo: { + cats: '42', + }, }); }).to.throw(/AppInfo.name is required/); }); @@ -335,50 +346,60 @@ describe('Stripe Module', function() { describe('when given at least a `name`', () => { it('should set name, partner ID, url, and version of stripe._appInfo', () => { - stripe.setAppInfo({ - name: 'MyAwesomeApp', + let newStripe = Stripe('sk_test', { + appInfo: { + name: 'MyAwesomeApp', + }, }); - expect(stripe._appInfo).to.eql({ + expect(newStripe._appInfo).to.eql({ name: 'MyAwesomeApp', }); - stripe.setAppInfo({ - name: 'MyAwesomeApp', - version: '1.2.345', + newStripe = Stripe('sk_test', { + appInfo: { + name: 'MyAwesomeApp', + version: '1.2.345', + }, }); - expect(stripe._appInfo).to.eql({ + expect(newStripe._appInfo).to.eql({ name: 'MyAwesomeApp', version: '1.2.345', }); - stripe.setAppInfo({ - name: 'MyAwesomeApp', - url: 'https://myawesomeapp.info', + newStripe = Stripe('sk_test', { + appInfo: { + name: 'MyAwesomeApp', + url: 'https://myawesomeapp.info', + }, }); - expect(stripe._appInfo).to.eql({ + expect(newStripe._appInfo).to.eql({ name: 'MyAwesomeApp', url: 'https://myawesomeapp.info', }); - stripe.setAppInfo({ - name: 'MyAwesomeApp', - partner_id: 'partner_1234', + newStripe = Stripe('sk_test', { + appInfo: { + name: 'MyAwesomeApp', + partner_id: 'partner_1234', + }, }); - expect(stripe._appInfo).to.eql({ + expect(newStripe._appInfo).to.eql({ name: 'MyAwesomeApp', partner_id: 'partner_1234', }); }); it('should ignore any invalid properties', () => { - stripe.setAppInfo({ - name: 'MyAwesomeApp', - partner_id: 'partner_1234', - version: '1.2.345', - url: 'https://myawesomeapp.info', - countOfRadishes: 512, + const newStripe = Stripe('sk_test', { + appInfo: { + name: 'MyAwesomeApp', + partner_id: 'partner_1234', + version: '1.2.345', + url: 'https://myawesomeapp.info', + countOfRadishes: 512, + }, }); - expect(stripe._appInfo).to.eql({ + expect(newStripe._appInfo).to.eql({ name: 'MyAwesomeApp', partner_id: 'partner_1234', version: '1.2.345', @@ -394,12 +415,14 @@ describe('Stripe Module', function() { url: 'https://myawesomeapp.info', }; - stripe.setAppInfo(appInfo); + const newStripe = Stripe('sk_test', { + appInfo, + }); - stripe.getClientUserAgent((uaString) => { + newStripe.getClientUserAgent((uaString) => { expect(JSON.parse(uaString).application).to.eql(appInfo); - expect(stripe.getAppInfoAsString()).to.eql( + expect(newStripe.getAppInfoAsString()).to.eql( `${appInfo.name}/${appInfo.version} (${appInfo.url})` ); @@ -496,7 +519,6 @@ describe('Stripe Module', function() { describe('errors', () => { it('Exports errors as types', () => { - const Stripe = require('../lib/stripe'); expect( new Stripe.errors.StripeInvalidRequestError({ message: 'error', diff --git a/test/telemetry.spec.js b/test/telemetry.spec.js index f408c92c60..c73650ac34 100644 --- a/test/telemetry.spec.js +++ b/test/telemetry.spec.js @@ -58,10 +58,14 @@ describe('Client Telemetry', () => { }, (host, port) => { const stripe = require('../lib/stripe')( - 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' + 'sk_test_FEiILxKZwnmmocJDUjUNO6pa', + { + telemetry: false, + host, + port, + protocol: 'http', + } ); - stripe.setTelemetryEnabled(false); - stripe.setHost(host, port, 'http'); stripe.balance .retrieve() @@ -104,10 +108,14 @@ describe('Client Telemetry', () => { }, (host, port) => { const stripe = require('../lib/stripe')( - 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' + 'sk_test_FEiILxKZwnmmocJDUjUNO6pa', + { + telemetry: true, + host, + port, + protocol: 'http', + } ); - stripe.setTelemetryEnabled(true); - stripe.setHost(host, port, 'http'); stripe.balance .retrieve() @@ -152,10 +160,14 @@ describe('Client Telemetry', () => { }, (host, port) => { const stripe = require('../lib/stripe')( - 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' + 'sk_test_FEiILxKZwnmmocJDUjUNO6pa', + { + telemetry: true, + host, + port, + protocol: 'http', + } ); - stripe.setTelemetryEnabled(true); - stripe.setHost(host, port, 'http'); Promise.all([stripe.balance.retrieve(), stripe.balance.retrieve()]) .then(() => diff --git a/testUtils/index.js b/testUtils/index.js index f527a44765..4e090fc4c1 100644 --- a/testUtils/index.js +++ b/testUtils/index.js @@ -58,12 +58,12 @@ const utils = (module.exports = { return key; }, - getSpyableStripe: () => { + getSpyableStripe: (config) => { // Provide a testable stripe instance // That is, with mock-requests built in and hookable const stripe = require('../lib/stripe'); - const stripeInstance = stripe('fakeAuthToken'); + const stripeInstance = stripe('fakeAuthToken', config); stripeInstance.REQUESTS = []; diff --git a/types/2022-08-01/index.d.ts b/types/2022-08-01/index.d.ts index bd8c1c27ef..57f7591dde 100644 --- a/types/2022-08-01/index.d.ts +++ b/types/2022-08-01/index.d.ts @@ -134,8 +134,6 @@ declare module 'stripe' { constructor(apiKey: string, config?: Stripe.StripeConfig); - setAppInfo(info: Stripe.AppInfo): void; - StripeResource: Stripe.StripeResource; /** @@ -281,27 +279,6 @@ declare module 'stripe' { event: 'response', handler: (event: Stripe.ResponseEvent) => void ): void; - - setProtocol(protocol: string): void; - - /** @deprecated Please use the StripeConfig object instead. */ - setHost(host: string, port?: string | number, protocol?: string): void; - - /** @deprecated Please use the StripeConfig object instead. */ - setPort(port: string | number): void; - /** @deprecated Please use the StripeConfig object instead. */ - setApiVersion(version: Stripe.LatestApiVersion): void; - /** @deprecated Please use the StripeConfig object instead. */ - setApiKey(key: string): void; - - /** @deprecated Please use the StripeConfig object instead. */ - setTimeout(timeout?: number): void; - /** @deprecated Please use the StripeConfig object instead. */ - setMaxNetworkRetries(maxNetworkRetries: number): void; - /** @deprecated Please use the StripeConfig object instead. */ - setTelemetryEnabled(enabled: boolean): void; - /** @deprecated Please use the StripeConfig object instead. */ - setHttpAgent(agent: Stripe.HttpAgent): void; } export default Stripe; diff --git a/types/test/typescriptTest.ts b/types/test/typescriptTest.ts index ebd0b7da64..42d0fec726 100644 --- a/types/test/typescriptTest.ts +++ b/types/test/typescriptTest.ts @@ -35,15 +35,11 @@ stripe = new Stripe('sk_test_123', { port: 123, telemetry: true, httpClient: Stripe.createNodeHttpClient(), + appInfo: { + name: 'my-wordpress-plugin', + }, }); -stripe.setTimeout(3000); -stripe.setAppInfo({ - name: 'my-wordpress-plugin', -}); - -stripe.setHost('host', 'port', 'protocol'); - (async (): Promise => { const params: Stripe.CustomerCreateParams = { description: 'test', From 651324b7e779cecc1a2695a3c32e84e4916e14b8 Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Fri, 4 Nov 2022 12:47:49 -0700 Subject: [PATCH 08/16] Remove more deprecated items (#1600) Remove remaining deprecated items --- lib/StripeMethod.basic.js | 26 ------------ lib/StripeResource.js | 12 +----- lib/utils.js | 39 ++---------------- src/StripeMethod.basic.js | 32 --------------- src/StripeResource.ts | 14 +------ src/utils.ts | 40 ++---------------- test/utils.spec.js | 85 --------------------------------------- 7 files changed, 10 insertions(+), 238 deletions(-) delete mode 100644 lib/StripeMethod.basic.js delete mode 100644 src/StripeMethod.basic.js diff --git a/lib/StripeMethod.basic.js b/lib/StripeMethod.basic.js deleted file mode 100644 index 1949b543c9..0000000000 --- a/lib/StripeMethod.basic.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; -const stripeMethod = require('./StripeMethod'); -// DEPRECATED: These were kept for backwards compatibility in case users were -// using this, but basic methods are now explicitly defined on a resource. -module.exports = { - create: stripeMethod({ - method: 'POST', - }), - list: stripeMethod({ - method: 'GET', - methodType: 'list', - }), - retrieve: stripeMethod({ - method: 'GET', - path: '/{id}', - }), - update: stripeMethod({ - method: 'POST', - path: '{id}', - }), - // Avoid 'delete' keyword in JS - del: stripeMethod({ - method: 'DELETE', - path: '{id}', - }), -}; diff --git a/lib/StripeResource.js b/lib/StripeResource.js index bfced38996..fa1e2422a6 100644 --- a/lib/StripeResource.js +++ b/lib/StripeResource.js @@ -12,9 +12,8 @@ const { const {HttpClient} = require('./net/HttpClient'); // Provide extension mechanism for Stripe Resource Sub-Classes StripeResource.extend = utils.protoExtend; -// Expose method-creator & prepared (basic) methods +// Expose method-creator StripeResource.method = require('./StripeMethod'); -StripeResource.BASIC_METHODS = require('./StripeMethod.basic'); StripeResource.MAX_BUFFERED_REQUEST_METRICS = 100; const MAX_RETRY_AFTER_WAIT = 60; /** @@ -32,13 +31,6 @@ function StripeResource(stripe, deprecatedUrlData) { ); this.resourcePath = this.path; this.path = utils.makeURLInterpolator(this.path); - // DEPRECATED: This was kept for backwards compatibility in case users were - // using this, but basic methods are now explicitly defined on a resource. - if (this.includeBasic) { - this.includeBasic.forEach(function(methodName) { - this[methodName] = StripeResource.BASIC_METHODS[methodName]; - }, this); - } this.initialize(...arguments); } StripeResource.prototype = { @@ -88,8 +80,6 @@ StripeResource.prototype = { // interface and so we need to preserve backwards compatibility. return parts.join('/').replace(/\/{2,}/g, '/'); }, - // DEPRECATED: Here for backcompat in case users relied on this. - wrapTimeout: utils.callbackifyPromiseWithTimeout, _timeoutHandler(timeout, req, callback) { return () => { const timeoutErr = new TypeError('ETIMEDOUT'); diff --git a/lib/utils.js b/lib/utils.js index 2ed6fb43cf..116de9218e 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -22,25 +22,12 @@ const OPTIONS_KEYS = [ 'timeout', 'host', ]; -const DEPRECATED_OPTIONS = { - api_key: 'apiKey', - idempotency_key: 'idempotencyKey', - stripe_account: 'stripeAccount', - stripe_version: 'apiVersion', - stripeVersion: 'apiVersion', -}; -const DEPRECATED_OPTIONS_KEYS = Object.keys(DEPRECATED_OPTIONS); const utils = { isOptionsHash(o) { return ( o && typeof o === 'object' && - (OPTIONS_KEYS.some((prop) => - Object.prototype.hasOwnProperty.call(o, prop) - ) || - DEPRECATED_OPTIONS_KEYS.some((prop) => - Object.prototype.hasOwnProperty.call(o, prop) - )) + OPTIONS_KEYS.some((prop) => Object.prototype.hasOwnProperty.call(o, prop)) ); }, /** @@ -141,27 +128,9 @@ const utils = { (key) => !OPTIONS_KEYS.includes(key) ); if (extraKeys.length) { - const nonDeprecated = extraKeys.filter((key) => { - if (!DEPRECATED_OPTIONS[key]) { - return true; - } - const newParam = DEPRECATED_OPTIONS[key]; - if (params[newParam]) { - throw Error( - `Both '${newParam}' and '${key}' were provided; please remove '${key}', which is deprecated.` - ); - } - /** - * TODO turn this into a hard error in a future major version (once we have fixed our docs). - */ - emitWarning(`'${key}' is deprecated; use '${newParam}' instead.`); - params[newParam] = params[key]; - }); - if (nonDeprecated.length) { - emitWarning( - `Invalid options found (${extraKeys.join(', ')}); ignoring.` - ); - } + emitWarning( + `Invalid options found (${extraKeys.join(', ')}); ignoring.` + ); } if (params.apiKey) { opts.auth = params.apiKey; diff --git a/src/StripeMethod.basic.js b/src/StripeMethod.basic.js deleted file mode 100644 index b9be5302e4..0000000000 --- a/src/StripeMethod.basic.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const stripeMethod = require('./StripeMethod'); - -// DEPRECATED: These were kept for backwards compatibility in case users were -// using this, but basic methods are now explicitly defined on a resource. -module.exports = { - create: stripeMethod({ - method: 'POST', - }), - - list: stripeMethod({ - method: 'GET', - methodType: 'list', - }), - - retrieve: stripeMethod({ - method: 'GET', - path: '/{id}', - }), - - update: stripeMethod({ - method: 'POST', - path: '{id}', - }), - - // Avoid 'delete' keyword in JS - del: stripeMethod({ - method: 'DELETE', - path: '{id}', - }), -}; diff --git a/src/StripeResource.ts b/src/StripeResource.ts index e8f85599fe..7e0a76d63e 100644 --- a/src/StripeResource.ts +++ b/src/StripeResource.ts @@ -25,9 +25,8 @@ type Options = { // Provide extension mechanism for Stripe Resource Sub-Classes StripeResource.extend = utils.protoExtend; -// Expose method-creator & prepared (basic) methods +// Expose method-creator StripeResource.method = require('./StripeMethod'); -StripeResource.BASIC_METHODS = require('./StripeMethod.basic'); StripeResource.MAX_BUFFERED_REQUEST_METRICS = 100; const MAX_RETRY_AFTER_WAIT = 60; @@ -49,14 +48,6 @@ function StripeResource(stripe, deprecatedUrlData) { this.resourcePath = this.path; this.path = utils.makeURLInterpolator(this.path); - // DEPRECATED: This was kept for backwards compatibility in case users were - // using this, but basic methods are now explicitly defined on a resource. - if (this.includeBasic) { - this.includeBasic.forEach(function(methodName) { - this[methodName] = StripeResource.BASIC_METHODS[methodName]; - }, this); - } - this.initialize(...arguments); } @@ -117,9 +108,6 @@ StripeResource.prototype = { return parts.join('/').replace(/\/{2,}/g, '/'); }, - // DEPRECATED: Here for backcompat in case users relied on this. - wrapTimeout: utils.callbackifyPromiseWithTimeout, - _timeoutHandler(timeout, req, callback) { return () => { const timeoutErr = new TypeError('ETIMEDOUT'); diff --git a/src/utils.ts b/src/utils.ts index 40b12656bd..0a734d55aa 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -24,15 +24,6 @@ const OPTIONS_KEYS = [ 'host', ]; -const DEPRECATED_OPTIONS = { - api_key: 'apiKey', - idempotency_key: 'idempotencyKey', - stripe_account: 'stripeAccount', - stripe_version: 'apiVersion', - stripeVersion: 'apiVersion', -}; -const DEPRECATED_OPTIONS_KEYS = Object.keys(DEPRECATED_OPTIONS); - type Settings = { timeout?: number; maxNetworkRetries?: number; @@ -51,12 +42,7 @@ const utils = { return ( o && typeof o === 'object' && - (OPTIONS_KEYS.some((prop) => - Object.prototype.hasOwnProperty.call(o, prop) - ) || - DEPRECATED_OPTIONS_KEYS.some((prop) => - Object.prototype.hasOwnProperty.call(o, prop) - )) + OPTIONS_KEYS.some((prop) => Object.prototype.hasOwnProperty.call(o, prop)) ); }, @@ -170,27 +156,9 @@ const utils = { ); if (extraKeys.length) { - const nonDeprecated = extraKeys.filter((key) => { - if (!DEPRECATED_OPTIONS[key]) { - return true; - } - const newParam = DEPRECATED_OPTIONS[key]; - if (params[newParam]) { - throw Error( - `Both '${newParam}' and '${key}' were provided; please remove '${key}', which is deprecated.` - ); - } - /** - * TODO turn this into a hard error in a future major version (once we have fixed our docs). - */ - emitWarning(`'${key}' is deprecated; use '${newParam}' instead.`); - params[newParam] = params[key]; - }); - if (nonDeprecated.length) { - emitWarning( - `Invalid options found (${extraKeys.join(', ')}); ignoring.` - ); - } + emitWarning( + `Invalid options found (${extraKeys.join(', ')}); ignoring.` + ); } if (params.apiKey) { diff --git a/test/utils.spec.js b/test/utils.spec.js index 91a6e1f9f9..5162f5dcbf 100644 --- a/test/utils.spec.js +++ b/test/utils.spec.js @@ -309,91 +309,6 @@ describe('utils', () => { }); }); - it('parses snake case for backwards compatibility', () => { - return new Promise((resolve, reject) => { - const args = [ - { - api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', - idempotency_key: 'key', - stripe_account: 'acct_123', - stripe_version: '2019-08-08', - }, - ]; - const desiredWarnings = [ - "Stripe: 'api_key' is deprecated; use 'apiKey' instead.", - "Stripe: 'idempotency_key' is deprecated; use 'idempotencyKey' instead.", - "Stripe: 'stripe_account' is deprecated; use 'stripeAccount' instead.", - "Stripe: 'stripe_version' is deprecated; use 'apiVersion' instead.", - ]; - - const warnings = []; - const onWarn = (message) => { - warnings.push(message); - if (warnings.length === desiredWarnings.length) { - expect(warnings).to.deep.equal(desiredWarnings); - resolve(); - } - }; - handleWarnings(() => { - expect(utils.getOptionsFromArgs(args)).to.deep.equal({ - auth: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', - headers: { - 'Idempotency-Key': 'key', - 'Stripe-Version': '2019-08-08', - 'Stripe-Account': 'acct_123', - }, - settings: {}, - }); - }, onWarn); - }); - }); - - it('parses stripeVersion for backwards compatibility', () => { - return new Promise((resolve, reject) => { - const args = [ - { - apiKey: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', - stripeVersion: '2019-08-08', - }, - ]; - const desiredWarnings = [ - "Stripe: 'stripeVersion' is deprecated; use 'apiVersion' instead.", - ]; - - const warnings = []; - const onWarn = (message) => { - warnings.push(message); - if (warnings.length === desiredWarnings.length) { - expect(warnings).to.deep.equal(desiredWarnings); - resolve(); - } - }; - handleWarnings(() => { - expect(utils.getOptionsFromArgs(args)).to.deep.equal({ - auth: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', - headers: { - 'Stripe-Version': '2019-08-08', - }, - settings: {}, - }); - }, onWarn); - }); - }); - - it('errors if you pass both a deprecated and non-deprecated version of the same param', () => { - const args = [ - { - stripeVersion: 'bad', - apiVersion: 'good', - }, - ]; - expect(() => { - utils.getOptionsFromArgs(args); - }).to.throw( - "Both 'apiVersion' and 'stripeVersion' were provided; please remove 'stripeVersion', which is deprecated." - ); - }); - it('warns if the hash contains something that does not belong', (done) => { const args = [ {foo: 'bar'}, From 20f978fd11593cfcff716740100fde46efdb1de1 Mon Sep 17 00:00:00 2001 From: anniel-stripe <97691964+anniel-stripe@users.noreply.github.com> Date: Mon, 7 Nov 2022 09:53:33 -0800 Subject: [PATCH 09/16] Generate files for next major (#1603) * Generate next major * Deprecate StripeResource.path and related interfaces (#1604) * Deprecate path * More fully deprecate * Fix linting errors * Revert "Fix linting errors" This reverts commit 68ac772749e6e403650ad22fdeb448c6af09293e. * Revert "Deprecate StripeResource.path and related interfaces (#1604)" This reverts commit 9c9de9e9852369e575a701b33e8e47e277862a14. * fix tests to work without Invoices defining fullPAth Co-authored-by: Richard Marmorstein <52928443+richardm-stripe@users.noreply.github.com> Co-authored-by: Richard Marmorstein --- lib/resources/AccountLinks.js | 3 +- lib/resources/Accounts.js | 43 +++++++------- lib/resources/ApplePayDomains.js | 9 ++- lib/resources/ApplicationFees.js | 13 ++-- lib/resources/Apps/Secrets.js | 9 ++- lib/resources/Balance.js | 3 +- lib/resources/BalanceTransactions.js | 5 +- lib/resources/BillingPortal/Configurations.js | 9 ++- lib/resources/BillingPortal/Sessions.js | 3 +- lib/resources/Charges.js | 13 ++-- lib/resources/Checkout/Sessions.js | 11 ++-- lib/resources/CountrySpecs.js | 5 +- lib/resources/Coupons.js | 11 ++-- lib/resources/CreditNotes.js | 17 +++--- lib/resources/Customers.js | 58 +++++++++--------- lib/resources/Disputes.js | 9 ++- lib/resources/EphemeralKeys.js | 5 +- lib/resources/Events.js | 5 +- lib/resources/ExchangeRates.js | 5 +- lib/resources/FileLinks.js | 9 ++- lib/resources/Files.js | 6 +- .../FinancialConnections/Accounts.js | 11 ++-- .../FinancialConnections/Sessions.js | 5 +- lib/resources/Identity/VerificationReports.js | 5 +- .../Identity/VerificationSessions.js | 13 ++-- lib/resources/InvoiceItems.js | 11 ++-- lib/resources/Invoices.js | 29 +++++---- lib/resources/Issuing/Authorizations.js | 11 ++-- lib/resources/Issuing/Cardholders.js | 9 ++- lib/resources/Issuing/Cards.js | 9 ++- lib/resources/Issuing/Disputes.js | 11 ++-- lib/resources/Issuing/Transactions.js | 7 +-- lib/resources/Mandates.js | 3 +- lib/resources/PaymentIntents.js | 23 ++++---- lib/resources/PaymentLinks.js | 11 ++-- lib/resources/PaymentMethods.js | 13 ++-- lib/resources/Payouts.js | 13 ++-- lib/resources/Plans.js | 11 ++-- lib/resources/Prices.js | 11 ++-- lib/resources/Products.js | 13 ++-- lib/resources/PromotionCodes.js | 9 ++- lib/resources/Quotes.js | 21 ++++--- lib/resources/Radar/EarlyFraudWarnings.js | 5 +- lib/resources/Radar/ValueListItems.js | 9 ++- lib/resources/Radar/ValueLists.js | 11 ++-- lib/resources/Refunds.js | 11 ++-- lib/resources/Reporting/ReportRuns.js | 7 +-- lib/resources/Reporting/ReportTypes.js | 5 +- lib/resources/Reviews.js | 7 +-- lib/resources/SetupAttempts.js | 3 +- lib/resources/SetupIntents.js | 15 +++-- lib/resources/ShippingRates.js | 9 ++- lib/resources/Sigma/ScheduledQueryRuns.js | 5 +- lib/resources/Sources.js | 11 ++-- lib/resources/SubscriptionItems.js | 16 ++--- lib/resources/SubscriptionSchedules.js | 13 ++-- lib/resources/Subscriptions.js | 17 +++--- lib/resources/TaxCodes.js | 5 +- lib/resources/TaxRates.js | 9 ++- lib/resources/Terminal/Configurations.js | 11 ++-- lib/resources/Terminal/ConnectionTokens.js | 3 +- lib/resources/Terminal/Locations.js | 11 ++-- lib/resources/Terminal/Readers.js | 19 +++--- lib/resources/TestHelpers/Customers.js | 3 +- lib/resources/TestHelpers/Issuing/Cards.js | 9 ++- lib/resources/TestHelpers/Refunds.js | 3 +- lib/resources/TestHelpers/Terminal/Readers.js | 4 +- lib/resources/TestHelpers/TestClocks.js | 11 ++-- .../TestHelpers/Treasury/InboundTransfers.js | 7 +-- .../TestHelpers/Treasury/OutboundPayments.js | 7 +-- .../TestHelpers/Treasury/OutboundTransfers.js | 10 ++-- .../TestHelpers/Treasury/ReceivedCredits.js | 3 +- .../TestHelpers/Treasury/ReceivedDebits.js | 3 +- lib/resources/Tokens.js | 5 +- lib/resources/Topups.js | 11 ++-- lib/resources/Transfers.js | 17 +++--- lib/resources/Treasury/CreditReversals.js | 7 +-- lib/resources/Treasury/DebitReversals.js | 7 +-- lib/resources/Treasury/FinancialAccounts.js | 13 ++-- lib/resources/Treasury/InboundTransfers.js | 9 ++- lib/resources/Treasury/OutboundPayments.js | 9 ++- lib/resources/Treasury/OutboundTransfers.js | 9 ++- lib/resources/Treasury/ReceivedCredits.js | 5 +- lib/resources/Treasury/ReceivedDebits.js | 5 +- lib/resources/Treasury/TransactionEntries.js | 5 +- lib/resources/Treasury/Transactions.js | 5 +- lib/resources/WebhookEndpoints.js | 11 ++-- src/resources/AccountLinks.js | 4 +- src/resources/Accounts.js | 44 +++++++------- src/resources/ApplePayDomains.js | 10 ++-- src/resources/ApplicationFees.js | 14 ++--- src/resources/Apps/Secrets.js | 10 ++-- src/resources/Balance.js | 4 +- src/resources/BalanceTransactions.js | 6 +- src/resources/BillingPortal/Configurations.js | 10 ++-- src/resources/BillingPortal/Sessions.js | 4 +- src/resources/Charges.js | 14 ++--- src/resources/Checkout/Sessions.js | 12 ++-- src/resources/CountrySpecs.js | 6 +- src/resources/Coupons.js | 12 ++-- src/resources/CreditNotes.js | 18 +++--- src/resources/Customers.js | 59 +++++++++---------- src/resources/Disputes.js | 10 ++-- src/resources/EphemeralKeys.js | 6 +- src/resources/Events.js | 6 +- src/resources/ExchangeRates.js | 6 +- src/resources/FileLinks.js | 10 ++-- src/resources/Files.js | 7 +-- .../FinancialConnections/Accounts.js | 12 ++-- .../FinancialConnections/Sessions.js | 6 +- src/resources/Identity/VerificationReports.js | 6 +- .../Identity/VerificationSessions.js | 14 ++--- src/resources/InvoiceItems.js | 12 ++-- src/resources/Invoices.js | 30 +++++----- src/resources/Issuing/Authorizations.js | 12 ++-- src/resources/Issuing/Cardholders.js | 10 ++-- src/resources/Issuing/Cards.js | 10 ++-- src/resources/Issuing/Disputes.js | 12 ++-- src/resources/Issuing/Transactions.js | 8 +-- src/resources/Mandates.js | 4 +- src/resources/PaymentIntents.js | 24 ++++---- src/resources/PaymentLinks.js | 12 ++-- src/resources/PaymentMethods.js | 14 ++--- src/resources/Payouts.js | 14 ++--- src/resources/Plans.js | 12 ++-- src/resources/Prices.js | 12 ++-- src/resources/Products.js | 14 ++--- src/resources/PromotionCodes.js | 10 ++-- src/resources/Quotes.js | 22 ++++--- src/resources/Radar/EarlyFraudWarnings.js | 6 +- src/resources/Radar/ValueListItems.js | 10 ++-- src/resources/Radar/ValueLists.js | 12 ++-- src/resources/Refunds.js | 12 ++-- src/resources/Reporting/ReportRuns.js | 8 +-- src/resources/Reporting/ReportTypes.js | 6 +- src/resources/Reviews.js | 8 +-- src/resources/SetupAttempts.js | 4 +- src/resources/SetupIntents.js | 16 +++-- src/resources/ShippingRates.js | 10 ++-- src/resources/Sigma/ScheduledQueryRuns.js | 6 +- src/resources/Sources.js | 12 ++-- src/resources/SubscriptionItems.js | 17 +++--- src/resources/SubscriptionSchedules.js | 14 ++--- src/resources/Subscriptions.js | 18 +++--- src/resources/TaxCodes.js | 6 +- src/resources/TaxRates.js | 10 ++-- src/resources/Terminal/Configurations.js | 12 ++-- src/resources/Terminal/ConnectionTokens.js | 4 +- src/resources/Terminal/Locations.js | 12 ++-- src/resources/Terminal/Readers.js | 20 +++---- src/resources/TestHelpers/Customers.js | 4 +- src/resources/TestHelpers/Issuing/Cards.js | 10 ++-- src/resources/TestHelpers/Refunds.js | 4 +- src/resources/TestHelpers/Terminal/Readers.js | 5 +- src/resources/TestHelpers/TestClocks.js | 12 ++-- .../TestHelpers/Treasury/InboundTransfers.js | 8 +-- .../TestHelpers/Treasury/OutboundPayments.js | 8 +-- .../TestHelpers/Treasury/OutboundTransfers.js | 11 ++-- .../TestHelpers/Treasury/ReceivedCredits.js | 4 +- .../TestHelpers/Treasury/ReceivedDebits.js | 4 +- src/resources/Tokens.js | 6 +- src/resources/Topups.js | 12 ++-- src/resources/Transfers.js | 18 +++--- src/resources/Treasury/CreditReversals.js | 8 +-- src/resources/Treasury/DebitReversals.js | 8 +-- src/resources/Treasury/FinancialAccounts.js | 14 ++--- src/resources/Treasury/InboundTransfers.js | 10 ++-- src/resources/Treasury/OutboundPayments.js | 10 ++-- src/resources/Treasury/OutboundTransfers.js | 10 ++-- src/resources/Treasury/ReceivedCredits.js | 6 +- src/resources/Treasury/ReceivedDebits.js | 6 +- src/resources/Treasury/TransactionEntries.js | 6 +- src/resources/Treasury/Transactions.js | 6 +- src/resources/WebhookEndpoints.js | 12 ++-- test/StripeResource.spec.js | 28 ++++++--- types/2022-08-01/Checkout/Sessions.d.ts | 5 +- types/2022-08-01/Customers.d.ts | 5 +- types/2022-08-01/Invoices.d.ts | 15 ++++- types/2022-08-01/PaymentIntents.d.ts | 2 +- types/2022-08-01/TaxIds.d.ts | 10 +++- types/2022-08-01/index.d.ts | 2 +- 181 files changed, 849 insertions(+), 1065 deletions(-) diff --git a/lib/resources/AccountLinks.js b/lib/resources/AccountLinks.js index 2e8453e200..45a2185524 100644 --- a/lib/resources/AccountLinks.js +++ b/lib/resources/AccountLinks.js @@ -3,9 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'account_links', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/account_links', }), }); diff --git a/lib/resources/Accounts.js b/lib/resources/Accounts.js index 44d78baf59..63aa6e6bb5 100644 --- a/lib/resources/Accounts.js +++ b/lib/resources/Accounts.js @@ -4,10 +4,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; // Since path can either be `account` or `accounts`, support both through stripeMethod path; module.exports = StripeResource.extend({ - path: '', create: stripeMethod({ method: 'POST', - path: 'accounts', + fullPath: '/v1/accounts', }), retrieve(id) { // No longer allow an api key to be passed as the first string to this function due to ambiguity between @@ -15,7 +14,7 @@ module.exports = StripeResource.extend({ if (typeof id === 'string') { return stripeMethod({ method: 'GET', - path: 'accounts/{id}', + fullPath: '/v1/accounts/{id}', }).apply(this, arguments); } else { if (id === null || id === undefined) { @@ -24,84 +23,84 @@ module.exports = StripeResource.extend({ } return stripeMethod({ method: 'GET', - path: 'account', + fullPath: '/v1/account', }).apply(this, arguments); } }, update: stripeMethod({ method: 'POST', - path: 'accounts/{account}', + fullPath: '/v1/accounts/{account}', }), list: stripeMethod({ method: 'GET', - path: 'accounts', + fullPath: '/v1/accounts', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: 'accounts/{account}', + fullPath: '/v1/accounts/{account}', }), reject: stripeMethod({ method: 'POST', - path: 'accounts/{account}/reject', + fullPath: '/v1/accounts/{account}/reject', }), retrieveCapability: stripeMethod({ method: 'GET', - path: 'accounts/{account}/capabilities/{capability}', + fullPath: '/v1/accounts/{account}/capabilities/{capability}', }), updateCapability: stripeMethod({ method: 'POST', - path: 'accounts/{account}/capabilities/{capability}', + fullPath: '/v1/accounts/{account}/capabilities/{capability}', }), listCapabilities: stripeMethod({ method: 'GET', - path: 'accounts/{account}/capabilities', + fullPath: '/v1/accounts/{account}/capabilities', methodType: 'list', }), createExternalAccount: stripeMethod({ method: 'POST', - path: 'accounts/{account}/external_accounts', + fullPath: '/v1/accounts/{account}/external_accounts', }), retrieveExternalAccount: stripeMethod({ method: 'GET', - path: 'accounts/{account}/external_accounts/{id}', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', }), updateExternalAccount: stripeMethod({ method: 'POST', - path: 'accounts/{account}/external_accounts/{id}', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', }), listExternalAccounts: stripeMethod({ method: 'GET', - path: 'accounts/{account}/external_accounts', + fullPath: '/v1/accounts/{account}/external_accounts', methodType: 'list', }), deleteExternalAccount: stripeMethod({ method: 'DELETE', - path: 'accounts/{account}/external_accounts/{id}', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', }), createLoginLink: stripeMethod({ method: 'POST', - path: 'accounts/{account}/login_links', + fullPath: '/v1/accounts/{account}/login_links', }), createPerson: stripeMethod({ method: 'POST', - path: 'accounts/{account}/persons', + fullPath: '/v1/accounts/{account}/persons', }), retrievePerson: stripeMethod({ method: 'GET', - path: 'accounts/{account}/persons/{person}', + fullPath: '/v1/accounts/{account}/persons/{person}', }), updatePerson: stripeMethod({ method: 'POST', - path: 'accounts/{account}/persons/{person}', + fullPath: '/v1/accounts/{account}/persons/{person}', }), listPersons: stripeMethod({ method: 'GET', - path: 'accounts/{account}/persons', + fullPath: '/v1/accounts/{account}/persons', methodType: 'list', }), deletePerson: stripeMethod({ method: 'DELETE', - path: 'accounts/{account}/persons/{person}', + fullPath: '/v1/accounts/{account}/persons/{person}', }), }); diff --git a/lib/resources/ApplePayDomains.js b/lib/resources/ApplePayDomains.js index e9a24f3638..4ca4546ec3 100644 --- a/lib/resources/ApplePayDomains.js +++ b/lib/resources/ApplePayDomains.js @@ -3,22 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'apple_pay/domains', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/apple_pay/domains', }), retrieve: stripeMethod({ method: 'GET', - path: '/{domain}', + fullPath: '/v1/apple_pay/domains/{domain}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/apple_pay/domains', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{domain}', + fullPath: '/v1/apple_pay/domains/{domain}', }), }); diff --git a/lib/resources/ApplicationFees.js b/lib/resources/ApplicationFees.js index c2e524df7a..7f0fa49662 100644 --- a/lib/resources/ApplicationFees.js +++ b/lib/resources/ApplicationFees.js @@ -3,31 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'application_fees', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/application_fees/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/application_fees', methodType: 'list', }), createRefund: stripeMethod({ method: 'POST', - path: '/{id}/refunds', + fullPath: '/v1/application_fees/{id}/refunds', }), retrieveRefund: stripeMethod({ method: 'GET', - path: '/{fee}/refunds/{id}', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', }), updateRefund: stripeMethod({ method: 'POST', - path: '/{fee}/refunds/{id}', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', }), listRefunds: stripeMethod({ method: 'GET', - path: '/{id}/refunds', + fullPath: '/v1/application_fees/{id}/refunds', methodType: 'list', }), }); diff --git a/lib/resources/Apps/Secrets.js b/lib/resources/Apps/Secrets.js index d5a0831a6f..112e3539e5 100644 --- a/lib/resources/Apps/Secrets.js +++ b/lib/resources/Apps/Secrets.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'apps/secrets', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/apps/secrets', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/apps/secrets', methodType: 'list', }), deleteWhere: stripeMethod({ method: 'POST', - path: '/delete', + fullPath: '/v1/apps/secrets/delete', }), find: stripeMethod({ method: 'GET', - path: '/find', + fullPath: '/v1/apps/secrets/find', }), }); diff --git a/lib/resources/Balance.js b/lib/resources/Balance.js index 9b6f692d86..84378bb100 100644 --- a/lib/resources/Balance.js +++ b/lib/resources/Balance.js @@ -3,9 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'balance', retrieve: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/balance', }), }); diff --git a/lib/resources/BalanceTransactions.js b/lib/resources/BalanceTransactions.js index 00438d0dc0..3e205b9dc5 100644 --- a/lib/resources/BalanceTransactions.js +++ b/lib/resources/BalanceTransactions.js @@ -3,14 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'balance_transactions', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/balance_transactions/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/balance_transactions', methodType: 'list', }), }); diff --git a/lib/resources/BillingPortal/Configurations.js b/lib/resources/BillingPortal/Configurations.js index 624852cb04..df450890e9 100644 --- a/lib/resources/BillingPortal/Configurations.js +++ b/lib/resources/BillingPortal/Configurations.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'billing_portal/configurations', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/billing_portal/configurations', }), retrieve: stripeMethod({ method: 'GET', - path: '/{configuration}', + fullPath: '/v1/billing_portal/configurations/{configuration}', }), update: stripeMethod({ method: 'POST', - path: '/{configuration}', + fullPath: '/v1/billing_portal/configurations/{configuration}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/billing_portal/configurations', methodType: 'list', }), }); diff --git a/lib/resources/BillingPortal/Sessions.js b/lib/resources/BillingPortal/Sessions.js index 909b3e077e..db2e2e5d2a 100644 --- a/lib/resources/BillingPortal/Sessions.js +++ b/lib/resources/BillingPortal/Sessions.js @@ -3,9 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'billing_portal/sessions', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/billing_portal/sessions', }), }); diff --git a/lib/resources/Charges.js b/lib/resources/Charges.js index ebe6b16a76..6e3302700c 100644 --- a/lib/resources/Charges.js +++ b/lib/resources/Charges.js @@ -3,31 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'charges', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/charges', }), retrieve: stripeMethod({ method: 'GET', - path: '/{charge}', + fullPath: '/v1/charges/{charge}', }), update: stripeMethod({ method: 'POST', - path: '/{charge}', + fullPath: '/v1/charges/{charge}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/charges', methodType: 'list', }), capture: stripeMethod({ method: 'POST', - path: '/{charge}/capture', + fullPath: '/v1/charges/{charge}/capture', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/charges/search', methodType: 'search', }), }); diff --git a/lib/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js index 9e3e61f000..ecaafb11d2 100644 --- a/lib/resources/Checkout/Sessions.js +++ b/lib/resources/Checkout/Sessions.js @@ -3,27 +3,26 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'checkout/sessions', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/checkout/sessions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{session}', + fullPath: '/v1/checkout/sessions/{session}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/checkout/sessions', methodType: 'list', }), expire: stripeMethod({ method: 'POST', - path: '/{session}/expire', + fullPath: '/v1/checkout/sessions/{session}/expire', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{session}/line_items', + fullPath: '/v1/checkout/sessions/{session}/line_items', methodType: 'list', }), }); diff --git a/lib/resources/CountrySpecs.js b/lib/resources/CountrySpecs.js index 5f76abfdcd..6a9d410b4d 100644 --- a/lib/resources/CountrySpecs.js +++ b/lib/resources/CountrySpecs.js @@ -3,14 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'country_specs', retrieve: stripeMethod({ method: 'GET', - path: '/{country}', + fullPath: '/v1/country_specs/{country}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/country_specs', methodType: 'list', }), }); diff --git a/lib/resources/Coupons.js b/lib/resources/Coupons.js index 0e3d7c8acb..043eeead74 100644 --- a/lib/resources/Coupons.js +++ b/lib/resources/Coupons.js @@ -3,26 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'coupons', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/coupons', }), retrieve: stripeMethod({ method: 'GET', - path: '/{coupon}', + fullPath: '/v1/coupons/{coupon}', }), update: stripeMethod({ method: 'POST', - path: '/{coupon}', + fullPath: '/v1/coupons/{coupon}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/coupons', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{coupon}', + fullPath: '/v1/coupons/{coupon}', }), }); diff --git a/lib/resources/CreditNotes.js b/lib/resources/CreditNotes.js index 94865f45e6..6574070881 100644 --- a/lib/resources/CreditNotes.js +++ b/lib/resources/CreditNotes.js @@ -3,40 +3,39 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'credit_notes', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/credit_notes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/credit_notes/{id}', }), update: stripeMethod({ method: 'POST', - path: '/{id}', + fullPath: '/v1/credit_notes/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/credit_notes', methodType: 'list', }), listPreviewLineItems: stripeMethod({ method: 'GET', - path: '/preview/lines', + fullPath: '/v1/credit_notes/preview/lines', methodType: 'list', }), preview: stripeMethod({ method: 'GET', - path: '/preview', + fullPath: '/v1/credit_notes/preview', }), voidCreditNote: stripeMethod({ method: 'POST', - path: '/{id}/void', + fullPath: '/v1/credit_notes/{id}/void', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{creditNote}/lines', + fullPath: '/v1/credit_notes/{credit_note}/lines', methodType: 'list', }), }); diff --git a/lib/resources/Customers.js b/lib/resources/Customers.js index d0236d5444..0c98e91590 100644 --- a/lib/resources/Customers.js +++ b/lib/resources/Customers.js @@ -3,124 +3,124 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'customers', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/customers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{customer}', + fullPath: '/v1/customers/{customer}', }), update: stripeMethod({ method: 'POST', - path: '/{customer}', + fullPath: '/v1/customers/{customer}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/customers', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{customer}', + fullPath: '/v1/customers/{customer}', }), createFundingInstructions: stripeMethod({ method: 'POST', - path: '/{customer}/funding_instructions', + fullPath: '/v1/customers/{customer}/funding_instructions', }), deleteDiscount: stripeMethod({ method: 'DELETE', - path: '/{customer}/discount', + fullPath: '/v1/customers/{customer}/discount', }), listPaymentMethods: stripeMethod({ method: 'GET', - path: '/{customer}/payment_methods', + fullPath: '/v1/customers/{customer}/payment_methods', methodType: 'list', }), retrievePaymentMethod: stripeMethod({ method: 'GET', - path: '/{customer}/payment_methods/{paymentMethod}', + fullPath: '/v1/customers/{customer}/payment_methods/{payment_method}', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/customers/search', methodType: 'search', }), retrieveCashBalance: stripeMethod({ method: 'GET', - path: '/{customer}/cash_balance', + fullPath: '/v1/customers/{customer}/cash_balance', }), updateCashBalance: stripeMethod({ method: 'POST', - path: '/{customer}/cash_balance', + fullPath: '/v1/customers/{customer}/cash_balance', }), createBalanceTransaction: stripeMethod({ method: 'POST', - path: '/{customer}/balance_transactions', + fullPath: '/v1/customers/{customer}/balance_transactions', }), retrieveBalanceTransaction: stripeMethod({ method: 'GET', - path: '/{customer}/balance_transactions/{transaction}', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', }), updateBalanceTransaction: stripeMethod({ method: 'POST', - path: '/{customer}/balance_transactions/{transaction}', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', }), listBalanceTransactions: stripeMethod({ method: 'GET', - path: '/{customer}/balance_transactions', + fullPath: '/v1/customers/{customer}/balance_transactions', methodType: 'list', }), retrieveCashBalanceTransaction: stripeMethod({ method: 'GET', - path: '/{customer}/cash_balance_transactions/{transaction}', + fullPath: + '/v1/customers/{customer}/cash_balance_transactions/{transaction}', }), listCashBalanceTransactions: stripeMethod({ method: 'GET', - path: '/{customer}/cash_balance_transactions', + fullPath: '/v1/customers/{customer}/cash_balance_transactions', methodType: 'list', }), createSource: stripeMethod({ method: 'POST', - path: '/{customer}/sources', + fullPath: '/v1/customers/{customer}/sources', }), retrieveSource: stripeMethod({ method: 'GET', - path: '/{customer}/sources/{id}', + fullPath: '/v1/customers/{customer}/sources/{id}', }), updateSource: stripeMethod({ method: 'POST', - path: '/{customer}/sources/{id}', + fullPath: '/v1/customers/{customer}/sources/{id}', }), listSources: stripeMethod({ method: 'GET', - path: '/{customer}/sources', + fullPath: '/v1/customers/{customer}/sources', methodType: 'list', }), deleteSource: stripeMethod({ method: 'DELETE', - path: '/{customer}/sources/{id}', + fullPath: '/v1/customers/{customer}/sources/{id}', }), verifySource: stripeMethod({ method: 'POST', - path: '/{customer}/sources/{id}/verify', + fullPath: '/v1/customers/{customer}/sources/{id}/verify', }), createTaxId: stripeMethod({ method: 'POST', - path: '/{customer}/tax_ids', + fullPath: '/v1/customers/{customer}/tax_ids', }), retrieveTaxId: stripeMethod({ method: 'GET', - path: '/{customer}/tax_ids/{id}', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', }), listTaxIds: stripeMethod({ method: 'GET', - path: '/{customer}/tax_ids', + fullPath: '/v1/customers/{customer}/tax_ids', methodType: 'list', }), deleteTaxId: stripeMethod({ method: 'DELETE', - path: '/{customer}/tax_ids/{id}', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', }), }); diff --git a/lib/resources/Disputes.js b/lib/resources/Disputes.js index 6ca079cd87..3679668634 100644 --- a/lib/resources/Disputes.js +++ b/lib/resources/Disputes.js @@ -3,22 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'disputes', retrieve: stripeMethod({ method: 'GET', - path: '/{dispute}', + fullPath: '/v1/disputes/{dispute}', }), update: stripeMethod({ method: 'POST', - path: '/{dispute}', + fullPath: '/v1/disputes/{dispute}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/disputes', methodType: 'list', }), close: stripeMethod({ method: 'POST', - path: '/{dispute}/close', + fullPath: '/v1/disputes/{dispute}/close', }), }); diff --git a/lib/resources/EphemeralKeys.js b/lib/resources/EphemeralKeys.js index 962d341761..186a3b091e 100644 --- a/lib/resources/EphemeralKeys.js +++ b/lib/resources/EphemeralKeys.js @@ -3,10 +3,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'ephemeral_keys', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/ephemeral_keys', validator: (data, options) => { if (!options.headers || !options.headers['Stripe-Version']) { throw new Error( @@ -17,6 +16,6 @@ module.exports = StripeResource.extend({ }), del: stripeMethod({ method: 'DELETE', - path: '/{key}', + fullPath: '/v1/ephemeral_keys/{key}', }), }); diff --git a/lib/resources/Events.js b/lib/resources/Events.js index 5c2c8ceb86..e148e305ae 100644 --- a/lib/resources/Events.js +++ b/lib/resources/Events.js @@ -3,14 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'events', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/events/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/events', methodType: 'list', }), }); diff --git a/lib/resources/ExchangeRates.js b/lib/resources/ExchangeRates.js index 3c1464a3ae..f92da86aab 100644 --- a/lib/resources/ExchangeRates.js +++ b/lib/resources/ExchangeRates.js @@ -3,14 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'exchange_rates', retrieve: stripeMethod({ method: 'GET', - path: '/{rateId}', + fullPath: '/v1/exchange_rates/{rate_id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/exchange_rates', methodType: 'list', }), }); diff --git a/lib/resources/FileLinks.js b/lib/resources/FileLinks.js index 805e37ee5d..b474227b31 100644 --- a/lib/resources/FileLinks.js +++ b/lib/resources/FileLinks.js @@ -3,22 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'file_links', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/file_links', }), retrieve: stripeMethod({ method: 'GET', - path: '/{link}', + fullPath: '/v1/file_links/{link}', }), update: stripeMethod({ method: 'POST', - path: '/{link}', + fullPath: '/v1/file_links/{link}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/file_links', methodType: 'list', }), }); diff --git a/lib/resources/Files.js b/lib/resources/Files.js index b436f465d9..11856b1323 100644 --- a/lib/resources/Files.js +++ b/lib/resources/Files.js @@ -4,9 +4,9 @@ const {multipartRequestDataProcessor} = require('../multipart'); const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'files', create: stripeMethod({ method: 'POST', + fullPath: '/v1/files', headers: { 'Content-Type': 'multipart/form-data', }, @@ -14,11 +14,11 @@ module.exports = StripeResource.extend({ }), retrieve: stripeMethod({ method: 'GET', - path: '/{file}', + fullPath: '/v1/files/{file}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/files', methodType: 'list', }), requestDataProcessor: multipartRequestDataProcessor, diff --git a/lib/resources/FinancialConnections/Accounts.js b/lib/resources/FinancialConnections/Accounts.js index 2a85a3b0d8..8ce36e37b2 100644 --- a/lib/resources/FinancialConnections/Accounts.js +++ b/lib/resources/FinancialConnections/Accounts.js @@ -3,27 +3,26 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'financial_connections/accounts', retrieve: stripeMethod({ method: 'GET', - path: '/{account}', + fullPath: '/v1/financial_connections/accounts/{account}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/financial_connections/accounts', methodType: 'list', }), disconnect: stripeMethod({ method: 'POST', - path: '/{account}/disconnect', + fullPath: '/v1/financial_connections/accounts/{account}/disconnect', }), listOwners: stripeMethod({ method: 'GET', - path: '/{account}/owners', + fullPath: '/v1/financial_connections/accounts/{account}/owners', methodType: 'list', }), refresh: stripeMethod({ method: 'POST', - path: '/{account}/refresh', + fullPath: '/v1/financial_connections/accounts/{account}/refresh', }), }); diff --git a/lib/resources/FinancialConnections/Sessions.js b/lib/resources/FinancialConnections/Sessions.js index 0508a13fc3..b5bbb4c641 100644 --- a/lib/resources/FinancialConnections/Sessions.js +++ b/lib/resources/FinancialConnections/Sessions.js @@ -3,13 +3,12 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'financial_connections/sessions', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/financial_connections/sessions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{session}', + fullPath: '/v1/financial_connections/sessions/{session}', }), }); diff --git a/lib/resources/Identity/VerificationReports.js b/lib/resources/Identity/VerificationReports.js index 058451119b..3bd584a265 100644 --- a/lib/resources/Identity/VerificationReports.js +++ b/lib/resources/Identity/VerificationReports.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'identity/verification_reports', retrieve: stripeMethod({ method: 'GET', - path: '/{report}', + fullPath: '/v1/identity/verification_reports/{report}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/identity/verification_reports', methodType: 'list', }), }); diff --git a/lib/resources/Identity/VerificationSessions.js b/lib/resources/Identity/VerificationSessions.js index 4f9ae5d151..e9d3b72e87 100644 --- a/lib/resources/Identity/VerificationSessions.js +++ b/lib/resources/Identity/VerificationSessions.js @@ -3,30 +3,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'identity/verification_sessions', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/identity/verification_sessions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{session}', + fullPath: '/v1/identity/verification_sessions/{session}', }), update: stripeMethod({ method: 'POST', - path: '/{session}', + fullPath: '/v1/identity/verification_sessions/{session}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/identity/verification_sessions', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{session}/cancel', + fullPath: '/v1/identity/verification_sessions/{session}/cancel', }), redact: stripeMethod({ method: 'POST', - path: '/{session}/redact', + fullPath: '/v1/identity/verification_sessions/{session}/redact', }), }); diff --git a/lib/resources/InvoiceItems.js b/lib/resources/InvoiceItems.js index 58ed3d88fd..1a961fddb8 100644 --- a/lib/resources/InvoiceItems.js +++ b/lib/resources/InvoiceItems.js @@ -3,26 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'invoiceitems', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/invoiceitems', }), retrieve: stripeMethod({ method: 'GET', - path: '/{invoiceitem}', + fullPath: '/v1/invoiceitems/{invoiceitem}', }), update: stripeMethod({ method: 'POST', - path: '/{invoiceitem}', + fullPath: '/v1/invoiceitems/{invoiceitem}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/invoiceitems', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{invoiceitem}', + fullPath: '/v1/invoiceitems/{invoiceitem}', }), }); diff --git a/lib/resources/Invoices.js b/lib/resources/Invoices.js index 67237d020d..e1ac39f34f 100644 --- a/lib/resources/Invoices.js +++ b/lib/resources/Invoices.js @@ -3,65 +3,64 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'invoices', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/invoices', }), retrieve: stripeMethod({ method: 'GET', - path: '/{invoice}', + fullPath: '/v1/invoices/{invoice}', }), update: stripeMethod({ method: 'POST', - path: '/{invoice}', + fullPath: '/v1/invoices/{invoice}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/invoices', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{invoice}', + fullPath: '/v1/invoices/{invoice}', }), finalizeInvoice: stripeMethod({ method: 'POST', - path: '/{invoice}/finalize', + fullPath: '/v1/invoices/{invoice}/finalize', }), listUpcomingLines: stripeMethod({ method: 'GET', - path: '/upcoming/lines', + fullPath: '/v1/invoices/upcoming/lines', methodType: 'list', }), markUncollectible: stripeMethod({ method: 'POST', - path: '/{invoice}/mark_uncollectible', + fullPath: '/v1/invoices/{invoice}/mark_uncollectible', }), pay: stripeMethod({ method: 'POST', - path: '/{invoice}/pay', + fullPath: '/v1/invoices/{invoice}/pay', }), retrieveUpcoming: stripeMethod({ method: 'GET', - path: '/upcoming', + fullPath: '/v1/invoices/upcoming', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/invoices/search', methodType: 'search', }), sendInvoice: stripeMethod({ method: 'POST', - path: '/{invoice}/send', + fullPath: '/v1/invoices/{invoice}/send', }), voidInvoice: stripeMethod({ method: 'POST', - path: '/{invoice}/void', + fullPath: '/v1/invoices/{invoice}/void', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{invoice}/lines', + fullPath: '/v1/invoices/{invoice}/lines', methodType: 'list', }), }); diff --git a/lib/resources/Issuing/Authorizations.js b/lib/resources/Issuing/Authorizations.js index 649d2b0595..7d9e894b97 100644 --- a/lib/resources/Issuing/Authorizations.js +++ b/lib/resources/Issuing/Authorizations.js @@ -3,26 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/authorizations', retrieve: stripeMethod({ method: 'GET', - path: '/{authorization}', + fullPath: '/v1/issuing/authorizations/{authorization}', }), update: stripeMethod({ method: 'POST', - path: '/{authorization}', + fullPath: '/v1/issuing/authorizations/{authorization}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/authorizations', methodType: 'list', }), approve: stripeMethod({ method: 'POST', - path: '/{authorization}/approve', + fullPath: '/v1/issuing/authorizations/{authorization}/approve', }), decline: stripeMethod({ method: 'POST', - path: '/{authorization}/decline', + fullPath: '/v1/issuing/authorizations/{authorization}/decline', }), }); diff --git a/lib/resources/Issuing/Cardholders.js b/lib/resources/Issuing/Cardholders.js index 20f17017b3..a76764eba3 100644 --- a/lib/resources/Issuing/Cardholders.js +++ b/lib/resources/Issuing/Cardholders.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/cardholders', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/issuing/cardholders', }), retrieve: stripeMethod({ method: 'GET', - path: '/{cardholder}', + fullPath: '/v1/issuing/cardholders/{cardholder}', }), update: stripeMethod({ method: 'POST', - path: '/{cardholder}', + fullPath: '/v1/issuing/cardholders/{cardholder}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/cardholders', methodType: 'list', }), }); diff --git a/lib/resources/Issuing/Cards.js b/lib/resources/Issuing/Cards.js index 35d66cd465..98cc817f1e 100644 --- a/lib/resources/Issuing/Cards.js +++ b/lib/resources/Issuing/Cards.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/cards', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/issuing/cards', }), retrieve: stripeMethod({ method: 'GET', - path: '/{card}', + fullPath: '/v1/issuing/cards/{card}', }), update: stripeMethod({ method: 'POST', - path: '/{card}', + fullPath: '/v1/issuing/cards/{card}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/cards', methodType: 'list', }), }); diff --git a/lib/resources/Issuing/Disputes.js b/lib/resources/Issuing/Disputes.js index 4d14d03db2..803d4b6149 100644 --- a/lib/resources/Issuing/Disputes.js +++ b/lib/resources/Issuing/Disputes.js @@ -3,26 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/disputes', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/issuing/disputes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{dispute}', + fullPath: '/v1/issuing/disputes/{dispute}', }), update: stripeMethod({ method: 'POST', - path: '/{dispute}', + fullPath: '/v1/issuing/disputes/{dispute}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/disputes', methodType: 'list', }), submit: stripeMethod({ method: 'POST', - path: '/{dispute}/submit', + fullPath: '/v1/issuing/disputes/{dispute}/submit', }), }); diff --git a/lib/resources/Issuing/Transactions.js b/lib/resources/Issuing/Transactions.js index 23a8e4f41e..789dd7e3df 100644 --- a/lib/resources/Issuing/Transactions.js +++ b/lib/resources/Issuing/Transactions.js @@ -3,18 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/transactions', retrieve: stripeMethod({ method: 'GET', - path: '/{transaction}', + fullPath: '/v1/issuing/transactions/{transaction}', }), update: stripeMethod({ method: 'POST', - path: '/{transaction}', + fullPath: '/v1/issuing/transactions/{transaction}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/transactions', methodType: 'list', }), }); diff --git a/lib/resources/Mandates.js b/lib/resources/Mandates.js index 37bc7fae45..06240ae2d2 100644 --- a/lib/resources/Mandates.js +++ b/lib/resources/Mandates.js @@ -3,9 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'mandates', retrieve: stripeMethod({ method: 'GET', - path: '/{mandate}', + fullPath: '/v1/mandates/{mandate}', }), }); diff --git a/lib/resources/PaymentIntents.js b/lib/resources/PaymentIntents.js index b79f5aa6f5..963f1688e6 100644 --- a/lib/resources/PaymentIntents.js +++ b/lib/resources/PaymentIntents.js @@ -3,51 +3,50 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payment_intents', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payment_intents', }), retrieve: stripeMethod({ method: 'GET', - path: '/{intent}', + fullPath: '/v1/payment_intents/{intent}', }), update: stripeMethod({ method: 'POST', - path: '/{intent}', + fullPath: '/v1/payment_intents/{intent}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payment_intents', methodType: 'list', }), applyCustomerBalance: stripeMethod({ method: 'POST', - path: '/{intent}/apply_customer_balance', + fullPath: '/v1/payment_intents/{intent}/apply_customer_balance', }), cancel: stripeMethod({ method: 'POST', - path: '/{intent}/cancel', + fullPath: '/v1/payment_intents/{intent}/cancel', }), capture: stripeMethod({ method: 'POST', - path: '/{intent}/capture', + fullPath: '/v1/payment_intents/{intent}/capture', }), confirm: stripeMethod({ method: 'POST', - path: '/{intent}/confirm', + fullPath: '/v1/payment_intents/{intent}/confirm', }), incrementAuthorization: stripeMethod({ method: 'POST', - path: '/{intent}/increment_authorization', + fullPath: '/v1/payment_intents/{intent}/increment_authorization', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/payment_intents/search', methodType: 'search', }), verifyMicrodeposits: stripeMethod({ method: 'POST', - path: '/{intent}/verify_microdeposits', + fullPath: '/v1/payment_intents/{intent}/verify_microdeposits', }), }); diff --git a/lib/resources/PaymentLinks.js b/lib/resources/PaymentLinks.js index b2e76d285f..86acf3cb8c 100644 --- a/lib/resources/PaymentLinks.js +++ b/lib/resources/PaymentLinks.js @@ -3,27 +3,26 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payment_links', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payment_links', }), retrieve: stripeMethod({ method: 'GET', - path: '/{paymentLink}', + fullPath: '/v1/payment_links/{payment_link}', }), update: stripeMethod({ method: 'POST', - path: '/{paymentLink}', + fullPath: '/v1/payment_links/{payment_link}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payment_links', methodType: 'list', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{paymentLink}/line_items', + fullPath: '/v1/payment_links/{payment_link}/line_items', methodType: 'list', }), }); diff --git a/lib/resources/PaymentMethods.js b/lib/resources/PaymentMethods.js index dff07ab37e..85fc630698 100644 --- a/lib/resources/PaymentMethods.js +++ b/lib/resources/PaymentMethods.js @@ -3,30 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payment_methods', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payment_methods', }), retrieve: stripeMethod({ method: 'GET', - path: '/{paymentMethod}', + fullPath: '/v1/payment_methods/{payment_method}', }), update: stripeMethod({ method: 'POST', - path: '/{paymentMethod}', + fullPath: '/v1/payment_methods/{payment_method}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payment_methods', methodType: 'list', }), attach: stripeMethod({ method: 'POST', - path: '/{paymentMethod}/attach', + fullPath: '/v1/payment_methods/{payment_method}/attach', }), detach: stripeMethod({ method: 'POST', - path: '/{paymentMethod}/detach', + fullPath: '/v1/payment_methods/{payment_method}/detach', }), }); diff --git a/lib/resources/Payouts.js b/lib/resources/Payouts.js index 3ba5176ffc..fd8ddde975 100644 --- a/lib/resources/Payouts.js +++ b/lib/resources/Payouts.js @@ -3,30 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payouts', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payouts', }), retrieve: stripeMethod({ method: 'GET', - path: '/{payout}', + fullPath: '/v1/payouts/{payout}', }), update: stripeMethod({ method: 'POST', - path: '/{payout}', + fullPath: '/v1/payouts/{payout}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payouts', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{payout}/cancel', + fullPath: '/v1/payouts/{payout}/cancel', }), reverse: stripeMethod({ method: 'POST', - path: '/{payout}/reverse', + fullPath: '/v1/payouts/{payout}/reverse', }), }); diff --git a/lib/resources/Plans.js b/lib/resources/Plans.js index ade0a6cab4..a39523bd8c 100644 --- a/lib/resources/Plans.js +++ b/lib/resources/Plans.js @@ -3,26 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'plans', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/plans', }), retrieve: stripeMethod({ method: 'GET', - path: '/{plan}', + fullPath: '/v1/plans/{plan}', }), update: stripeMethod({ method: 'POST', - path: '/{plan}', + fullPath: '/v1/plans/{plan}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/plans', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{plan}', + fullPath: '/v1/plans/{plan}', }), }); diff --git a/lib/resources/Prices.js b/lib/resources/Prices.js index f48b5b9981..7406e1362f 100644 --- a/lib/resources/Prices.js +++ b/lib/resources/Prices.js @@ -3,27 +3,26 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'prices', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/prices', }), retrieve: stripeMethod({ method: 'GET', - path: '/{price}', + fullPath: '/v1/prices/{price}', }), update: stripeMethod({ method: 'POST', - path: '/{price}', + fullPath: '/v1/prices/{price}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/prices', methodType: 'list', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/prices/search', methodType: 'search', }), }); diff --git a/lib/resources/Products.js b/lib/resources/Products.js index fdb03d6a30..eba8e78d30 100644 --- a/lib/resources/Products.js +++ b/lib/resources/Products.js @@ -3,31 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'products', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/products', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/products/{id}', }), update: stripeMethod({ method: 'POST', - path: '/{id}', + fullPath: '/v1/products/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/products', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{id}', + fullPath: '/v1/products/{id}', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/products/search', methodType: 'search', }), }); diff --git a/lib/resources/PromotionCodes.js b/lib/resources/PromotionCodes.js index 77d3ac71bd..e112795f02 100644 --- a/lib/resources/PromotionCodes.js +++ b/lib/resources/PromotionCodes.js @@ -3,22 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'promotion_codes', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/promotion_codes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{promotionCode}', + fullPath: '/v1/promotion_codes/{promotion_code}', }), update: stripeMethod({ method: 'POST', - path: '/{promotionCode}', + fullPath: '/v1/promotion_codes/{promotion_code}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/promotion_codes', methodType: 'list', }), }); diff --git a/lib/resources/Quotes.js b/lib/resources/Quotes.js index ca6073104d..f5c97a375b 100644 --- a/lib/resources/Quotes.js +++ b/lib/resources/Quotes.js @@ -3,50 +3,49 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'quotes', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/quotes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{quote}', + fullPath: '/v1/quotes/{quote}', }), update: stripeMethod({ method: 'POST', - path: '/{quote}', + fullPath: '/v1/quotes/{quote}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/quotes', methodType: 'list', }), accept: stripeMethod({ method: 'POST', - path: '/{quote}/accept', + fullPath: '/v1/quotes/{quote}/accept', }), cancel: stripeMethod({ method: 'POST', - path: '/{quote}/cancel', + fullPath: '/v1/quotes/{quote}/cancel', }), finalizeQuote: stripeMethod({ method: 'POST', - path: '/{quote}/finalize', + fullPath: '/v1/quotes/{quote}/finalize', }), listComputedUpfrontLineItems: stripeMethod({ method: 'GET', - path: '/{quote}/computed_upfront_line_items', + fullPath: '/v1/quotes/{quote}/computed_upfront_line_items', methodType: 'list', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{quote}/line_items', + fullPath: '/v1/quotes/{quote}/line_items', methodType: 'list', }), pdf: stripeMethod({ host: 'files.stripe.com', method: 'GET', - path: '/{quote}/pdf', + fullPath: '/v1/quotes/{quote}/pdf', streaming: true, }), }); diff --git a/lib/resources/Radar/EarlyFraudWarnings.js b/lib/resources/Radar/EarlyFraudWarnings.js index 3b32b7aee5..5eaf23768a 100644 --- a/lib/resources/Radar/EarlyFraudWarnings.js +++ b/lib/resources/Radar/EarlyFraudWarnings.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'radar/early_fraud_warnings', retrieve: stripeMethod({ method: 'GET', - path: '/{earlyFraudWarning}', + fullPath: '/v1/radar/early_fraud_warnings/{early_fraud_warning}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/radar/early_fraud_warnings', methodType: 'list', }), }); diff --git a/lib/resources/Radar/ValueListItems.js b/lib/resources/Radar/ValueListItems.js index 2555807345..4fd46fd0ac 100644 --- a/lib/resources/Radar/ValueListItems.js +++ b/lib/resources/Radar/ValueListItems.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'radar/value_list_items', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/radar/value_list_items', }), retrieve: stripeMethod({ method: 'GET', - path: '/{item}', + fullPath: '/v1/radar/value_list_items/{item}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/radar/value_list_items', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{item}', + fullPath: '/v1/radar/value_list_items/{item}', }), }); diff --git a/lib/resources/Radar/ValueLists.js b/lib/resources/Radar/ValueLists.js index 8f3b6f9648..e89b5500c8 100644 --- a/lib/resources/Radar/ValueLists.js +++ b/lib/resources/Radar/ValueLists.js @@ -3,26 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'radar/value_lists', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/radar/value_lists', }), retrieve: stripeMethod({ method: 'GET', - path: '/{valueList}', + fullPath: '/v1/radar/value_lists/{value_list}', }), update: stripeMethod({ method: 'POST', - path: '/{valueList}', + fullPath: '/v1/radar/value_lists/{value_list}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/radar/value_lists', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{valueList}', + fullPath: '/v1/radar/value_lists/{value_list}', }), }); diff --git a/lib/resources/Refunds.js b/lib/resources/Refunds.js index 698646e681..87d3f6e1dc 100644 --- a/lib/resources/Refunds.js +++ b/lib/resources/Refunds.js @@ -3,26 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'refunds', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/refunds', }), retrieve: stripeMethod({ method: 'GET', - path: '/{refund}', + fullPath: '/v1/refunds/{refund}', }), update: stripeMethod({ method: 'POST', - path: '/{refund}', + fullPath: '/v1/refunds/{refund}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/refunds', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{refund}/cancel', + fullPath: '/v1/refunds/{refund}/cancel', }), }); diff --git a/lib/resources/Reporting/ReportRuns.js b/lib/resources/Reporting/ReportRuns.js index 0d0055f6da..d6e853aff0 100644 --- a/lib/resources/Reporting/ReportRuns.js +++ b/lib/resources/Reporting/ReportRuns.js @@ -3,18 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'reporting/report_runs', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/reporting/report_runs', }), retrieve: stripeMethod({ method: 'GET', - path: '/{reportRun}', + fullPath: '/v1/reporting/report_runs/{report_run}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/reporting/report_runs', methodType: 'list', }), }); diff --git a/lib/resources/Reporting/ReportTypes.js b/lib/resources/Reporting/ReportTypes.js index 7a1f1bb67c..58e8075460 100644 --- a/lib/resources/Reporting/ReportTypes.js +++ b/lib/resources/Reporting/ReportTypes.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'reporting/report_types', retrieve: stripeMethod({ method: 'GET', - path: '/{reportType}', + fullPath: '/v1/reporting/report_types/{report_type}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/reporting/report_types', methodType: 'list', }), }); diff --git a/lib/resources/Reviews.js b/lib/resources/Reviews.js index f4426b2703..201fbc1d64 100644 --- a/lib/resources/Reviews.js +++ b/lib/resources/Reviews.js @@ -3,18 +3,17 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'reviews', retrieve: stripeMethod({ method: 'GET', - path: '/{review}', + fullPath: '/v1/reviews/{review}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/reviews', methodType: 'list', }), approve: stripeMethod({ method: 'POST', - path: '/{review}/approve', + fullPath: '/v1/reviews/{review}/approve', }), }); diff --git a/lib/resources/SetupAttempts.js b/lib/resources/SetupAttempts.js index c8144bf284..36f232f4b9 100644 --- a/lib/resources/SetupAttempts.js +++ b/lib/resources/SetupAttempts.js @@ -3,10 +3,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'setup_attempts', list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/setup_attempts', methodType: 'list', }), }); diff --git a/lib/resources/SetupIntents.js b/lib/resources/SetupIntents.js index adbf79a340..9ce7ca7231 100644 --- a/lib/resources/SetupIntents.js +++ b/lib/resources/SetupIntents.js @@ -3,34 +3,33 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'setup_intents', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/setup_intents', }), retrieve: stripeMethod({ method: 'GET', - path: '/{intent}', + fullPath: '/v1/setup_intents/{intent}', }), update: stripeMethod({ method: 'POST', - path: '/{intent}', + fullPath: '/v1/setup_intents/{intent}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/setup_intents', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{intent}/cancel', + fullPath: '/v1/setup_intents/{intent}/cancel', }), confirm: stripeMethod({ method: 'POST', - path: '/{intent}/confirm', + fullPath: '/v1/setup_intents/{intent}/confirm', }), verifyMicrodeposits: stripeMethod({ method: 'POST', - path: '/{intent}/verify_microdeposits', + fullPath: '/v1/setup_intents/{intent}/verify_microdeposits', }), }); diff --git a/lib/resources/ShippingRates.js b/lib/resources/ShippingRates.js index 859f07772d..abda3a77c0 100644 --- a/lib/resources/ShippingRates.js +++ b/lib/resources/ShippingRates.js @@ -3,22 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'shipping_rates', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/shipping_rates', }), retrieve: stripeMethod({ method: 'GET', - path: '/{shippingRateToken}', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', }), update: stripeMethod({ method: 'POST', - path: '/{shippingRateToken}', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/shipping_rates', methodType: 'list', }), }); diff --git a/lib/resources/Sigma/ScheduledQueryRuns.js b/lib/resources/Sigma/ScheduledQueryRuns.js index e518c11a46..4e6c7211a1 100644 --- a/lib/resources/Sigma/ScheduledQueryRuns.js +++ b/lib/resources/Sigma/ScheduledQueryRuns.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'sigma/scheduled_query_runs', retrieve: stripeMethod({ method: 'GET', - path: '/{scheduledQueryRun}', + fullPath: '/v1/sigma/scheduled_query_runs/{scheduled_query_run}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/sigma/scheduled_query_runs', methodType: 'list', }), }); diff --git a/lib/resources/Sources.js b/lib/resources/Sources.js index 8dc06c4df6..e26f8ad3b9 100644 --- a/lib/resources/Sources.js +++ b/lib/resources/Sources.js @@ -3,26 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'sources', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/sources', }), retrieve: stripeMethod({ method: 'GET', - path: '/{source}', + fullPath: '/v1/sources/{source}', }), update: stripeMethod({ method: 'POST', - path: '/{source}', + fullPath: '/v1/sources/{source}', }), listSourceTransactions: stripeMethod({ method: 'GET', - path: '/{source}/source_transactions', + fullPath: '/v1/sources/{source}/source_transactions', methodType: 'list', }), verify: stripeMethod({ method: 'POST', - path: '/{source}/verify', + fullPath: '/v1/sources/{source}/verify', }), }); diff --git a/lib/resources/SubscriptionItems.js b/lib/resources/SubscriptionItems.js index 8d05380657..7681fb88ac 100644 --- a/lib/resources/SubscriptionItems.js +++ b/lib/resources/SubscriptionItems.js @@ -3,35 +3,35 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscription_items', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/subscription_items', }), retrieve: stripeMethod({ method: 'GET', - path: '/{item}', + fullPath: '/v1/subscription_items/{item}', }), update: stripeMethod({ method: 'POST', - path: '/{item}', + fullPath: '/v1/subscription_items/{item}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/subscription_items', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{item}', + fullPath: '/v1/subscription_items/{item}', }), createUsageRecord: stripeMethod({ method: 'POST', - path: '/{subscriptionItem}/usage_records', + fullPath: '/v1/subscription_items/{subscription_item}/usage_records', }), listUsageRecordSummaries: stripeMethod({ method: 'GET', - path: '/{subscriptionItem}/usage_record_summaries', + fullPath: + '/v1/subscription_items/{subscription_item}/usage_record_summaries', methodType: 'list', }), }); diff --git a/lib/resources/SubscriptionSchedules.js b/lib/resources/SubscriptionSchedules.js index 4bb9916c21..c2d3e634f3 100644 --- a/lib/resources/SubscriptionSchedules.js +++ b/lib/resources/SubscriptionSchedules.js @@ -3,30 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscription_schedules', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/subscription_schedules', }), retrieve: stripeMethod({ method: 'GET', - path: '/{schedule}', + fullPath: '/v1/subscription_schedules/{schedule}', }), update: stripeMethod({ method: 'POST', - path: '/{schedule}', + fullPath: '/v1/subscription_schedules/{schedule}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/subscription_schedules', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{schedule}/cancel', + fullPath: '/v1/subscription_schedules/{schedule}/cancel', }), release: stripeMethod({ method: 'POST', - path: '/{schedule}/release', + fullPath: '/v1/subscription_schedules/{schedule}/release', }), }); diff --git a/lib/resources/Subscriptions.js b/lib/resources/Subscriptions.js index 14494398b8..4790d2d0ca 100644 --- a/lib/resources/Subscriptions.js +++ b/lib/resources/Subscriptions.js @@ -3,39 +3,38 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscriptions', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/subscriptions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), update: stripeMethod({ method: 'POST', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/subscriptions', methodType: 'list', }), cancel: stripeMethod({ method: 'DELETE', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), del: stripeMethod({ method: 'DELETE', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), deleteDiscount: stripeMethod({ method: 'DELETE', - path: '/{subscriptionExposedId}/discount', + fullPath: '/v1/subscriptions/{subscription_exposed_id}/discount', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/subscriptions/search', methodType: 'search', }), }); diff --git a/lib/resources/TaxCodes.js b/lib/resources/TaxCodes.js index 37c76cfb2d..d590878674 100644 --- a/lib/resources/TaxCodes.js +++ b/lib/resources/TaxCodes.js @@ -3,14 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'tax_codes', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/tax_codes/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/tax_codes', methodType: 'list', }), }); diff --git a/lib/resources/TaxRates.js b/lib/resources/TaxRates.js index 2d2242c80d..e4975933ad 100644 --- a/lib/resources/TaxRates.js +++ b/lib/resources/TaxRates.js @@ -3,22 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'tax_rates', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/tax_rates', }), retrieve: stripeMethod({ method: 'GET', - path: '/{taxRate}', + fullPath: '/v1/tax_rates/{tax_rate}', }), update: stripeMethod({ method: 'POST', - path: '/{taxRate}', + fullPath: '/v1/tax_rates/{tax_rate}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/tax_rates', methodType: 'list', }), }); diff --git a/lib/resources/Terminal/Configurations.js b/lib/resources/Terminal/Configurations.js index c040bbc9f7..02c8297c27 100644 --- a/lib/resources/Terminal/Configurations.js +++ b/lib/resources/Terminal/Configurations.js @@ -3,26 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/configurations', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/configurations', }), retrieve: stripeMethod({ method: 'GET', - path: '/{configuration}', + fullPath: '/v1/terminal/configurations/{configuration}', }), update: stripeMethod({ method: 'POST', - path: '/{configuration}', + fullPath: '/v1/terminal/configurations/{configuration}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/terminal/configurations', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{configuration}', + fullPath: '/v1/terminal/configurations/{configuration}', }), }); diff --git a/lib/resources/Terminal/ConnectionTokens.js b/lib/resources/Terminal/ConnectionTokens.js index fc16a45e17..640a6b8712 100644 --- a/lib/resources/Terminal/ConnectionTokens.js +++ b/lib/resources/Terminal/ConnectionTokens.js @@ -3,9 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/connection_tokens', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/connection_tokens', }), }); diff --git a/lib/resources/Terminal/Locations.js b/lib/resources/Terminal/Locations.js index e89ac4c4d7..6b893361a6 100644 --- a/lib/resources/Terminal/Locations.js +++ b/lib/resources/Terminal/Locations.js @@ -3,26 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/locations', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/locations', }), retrieve: stripeMethod({ method: 'GET', - path: '/{location}', + fullPath: '/v1/terminal/locations/{location}', }), update: stripeMethod({ method: 'POST', - path: '/{location}', + fullPath: '/v1/terminal/locations/{location}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/terminal/locations', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{location}', + fullPath: '/v1/terminal/locations/{location}', }), }); diff --git a/lib/resources/Terminal/Readers.js b/lib/resources/Terminal/Readers.js index ec5cbae9a0..879835e91c 100644 --- a/lib/resources/Terminal/Readers.js +++ b/lib/resources/Terminal/Readers.js @@ -3,42 +3,41 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/readers', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/readers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{reader}', + fullPath: '/v1/terminal/readers/{reader}', }), update: stripeMethod({ method: 'POST', - path: '/{reader}', + fullPath: '/v1/terminal/readers/{reader}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/terminal/readers', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{reader}', + fullPath: '/v1/terminal/readers/{reader}', }), cancelAction: stripeMethod({ method: 'POST', - path: '/{reader}/cancel_action', + fullPath: '/v1/terminal/readers/{reader}/cancel_action', }), processPaymentIntent: stripeMethod({ method: 'POST', - path: '/{reader}/process_payment_intent', + fullPath: '/v1/terminal/readers/{reader}/process_payment_intent', }), processSetupIntent: stripeMethod({ method: 'POST', - path: '/{reader}/process_setup_intent', + fullPath: '/v1/terminal/readers/{reader}/process_setup_intent', }), setReaderDisplay: stripeMethod({ method: 'POST', - path: '/{reader}/set_reader_display', + fullPath: '/v1/terminal/readers/{reader}/set_reader_display', }), }); diff --git a/lib/resources/TestHelpers/Customers.js b/lib/resources/TestHelpers/Customers.js index 418ac2b91b..98bb0b651f 100644 --- a/lib/resources/TestHelpers/Customers.js +++ b/lib/resources/TestHelpers/Customers.js @@ -3,9 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/customers', fundCashBalance: stripeMethod({ method: 'POST', - path: '/{customer}/fund_cash_balance', + fullPath: '/v1/test_helpers/customers/{customer}/fund_cash_balance', }), }); diff --git a/lib/resources/TestHelpers/Issuing/Cards.js b/lib/resources/TestHelpers/Issuing/Cards.js index 67d2ae6841..4e13f2245e 100644 --- a/lib/resources/TestHelpers/Issuing/Cards.js +++ b/lib/resources/TestHelpers/Issuing/Cards.js @@ -3,21 +3,20 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/issuing/cards', deliverCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/deliver', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/deliver', }), failCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/fail', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/fail', }), returnCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/return', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/return', }), shipCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/ship', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/ship', }), }); diff --git a/lib/resources/TestHelpers/Refunds.js b/lib/resources/TestHelpers/Refunds.js index 23c6e4a536..79f2f221bc 100644 --- a/lib/resources/TestHelpers/Refunds.js +++ b/lib/resources/TestHelpers/Refunds.js @@ -3,9 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/refunds', expire: stripeMethod({ method: 'POST', - path: '/{refund}/expire', + fullPath: '/v1/test_helpers/refunds/{refund}/expire', }), }); diff --git a/lib/resources/TestHelpers/Terminal/Readers.js b/lib/resources/TestHelpers/Terminal/Readers.js index 9e1b961009..a828c20ccf 100644 --- a/lib/resources/TestHelpers/Terminal/Readers.js +++ b/lib/resources/TestHelpers/Terminal/Readers.js @@ -3,9 +3,9 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/terminal/readers', presentPaymentMethod: stripeMethod({ method: 'POST', - path: '/{reader}/present_payment_method', + fullPath: + '/v1/test_helpers/terminal/readers/{reader}/present_payment_method', }), }); diff --git a/lib/resources/TestHelpers/TestClocks.js b/lib/resources/TestHelpers/TestClocks.js index 23e443c940..d3686c123e 100644 --- a/lib/resources/TestHelpers/TestClocks.js +++ b/lib/resources/TestHelpers/TestClocks.js @@ -3,26 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/test_clocks', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/test_helpers/test_clocks', }), retrieve: stripeMethod({ method: 'GET', - path: '/{testClock}', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/test_helpers/test_clocks', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{testClock}', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', }), advance: stripeMethod({ method: 'POST', - path: '/{testClock}/advance', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}/advance', }), }); diff --git a/lib/resources/TestHelpers/Treasury/InboundTransfers.js b/lib/resources/TestHelpers/Treasury/InboundTransfers.js index a565bdb064..0143e4b71a 100644 --- a/lib/resources/TestHelpers/Treasury/InboundTransfers.js +++ b/lib/resources/TestHelpers/Treasury/InboundTransfers.js @@ -3,17 +3,16 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/inbound_transfers', fail: stripeMethod({ method: 'POST', - path: '/{id}/fail', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/fail', }), returnInboundTransfer: stripeMethod({ method: 'POST', - path: '/{id}/return', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/return', }), succeed: stripeMethod({ method: 'POST', - path: '/{id}/succeed', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/succeed', }), }); diff --git a/lib/resources/TestHelpers/Treasury/OutboundPayments.js b/lib/resources/TestHelpers/Treasury/OutboundPayments.js index 3b0e9c0b28..7bed50182d 100644 --- a/lib/resources/TestHelpers/Treasury/OutboundPayments.js +++ b/lib/resources/TestHelpers/Treasury/OutboundPayments.js @@ -3,17 +3,16 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/outbound_payments', fail: stripeMethod({ method: 'POST', - path: '/{id}/fail', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/fail', }), post: stripeMethod({ method: 'POST', - path: '/{id}/post', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/post', }), returnOutboundPayment: stripeMethod({ method: 'POST', - path: '/{id}/return', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/return', }), }); diff --git a/lib/resources/TestHelpers/Treasury/OutboundTransfers.js b/lib/resources/TestHelpers/Treasury/OutboundTransfers.js index 70c4282770..f38f2a6743 100644 --- a/lib/resources/TestHelpers/Treasury/OutboundTransfers.js +++ b/lib/resources/TestHelpers/Treasury/OutboundTransfers.js @@ -3,17 +3,19 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/outbound_transfers', fail: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/fail', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail', }), post: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/post', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post', }), returnOutboundTransfer: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/return', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return', }), }); diff --git a/lib/resources/TestHelpers/Treasury/ReceivedCredits.js b/lib/resources/TestHelpers/Treasury/ReceivedCredits.js index c13b41e601..3461023f91 100644 --- a/lib/resources/TestHelpers/Treasury/ReceivedCredits.js +++ b/lib/resources/TestHelpers/Treasury/ReceivedCredits.js @@ -3,9 +3,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/received_credits', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/test_helpers/treasury/received_credits', }), }); diff --git a/lib/resources/TestHelpers/Treasury/ReceivedDebits.js b/lib/resources/TestHelpers/Treasury/ReceivedDebits.js index 245ff75520..9d27e31246 100644 --- a/lib/resources/TestHelpers/Treasury/ReceivedDebits.js +++ b/lib/resources/TestHelpers/Treasury/ReceivedDebits.js @@ -3,9 +3,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/received_debits', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/test_helpers/treasury/received_debits', }), }); diff --git a/lib/resources/Tokens.js b/lib/resources/Tokens.js index d840debbf9..aba36dc673 100644 --- a/lib/resources/Tokens.js +++ b/lib/resources/Tokens.js @@ -3,13 +3,12 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'tokens', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/tokens', }), retrieve: stripeMethod({ method: 'GET', - path: '/{token}', + fullPath: '/v1/tokens/{token}', }), }); diff --git a/lib/resources/Topups.js b/lib/resources/Topups.js index e894b6f6b6..98a373ce13 100644 --- a/lib/resources/Topups.js +++ b/lib/resources/Topups.js @@ -3,26 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'topups', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/topups', }), retrieve: stripeMethod({ method: 'GET', - path: '/{topup}', + fullPath: '/v1/topups/{topup}', }), update: stripeMethod({ method: 'POST', - path: '/{topup}', + fullPath: '/v1/topups/{topup}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/topups', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{topup}/cancel', + fullPath: '/v1/topups/{topup}/cancel', }), }); diff --git a/lib/resources/Transfers.js b/lib/resources/Transfers.js index c45b376bd4..f046445237 100644 --- a/lib/resources/Transfers.js +++ b/lib/resources/Transfers.js @@ -3,39 +3,38 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'transfers', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/transfers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{transfer}', + fullPath: '/v1/transfers/{transfer}', }), update: stripeMethod({ method: 'POST', - path: '/{transfer}', + fullPath: '/v1/transfers/{transfer}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/transfers', methodType: 'list', }), createReversal: stripeMethod({ method: 'POST', - path: '/{id}/reversals', + fullPath: '/v1/transfers/{id}/reversals', }), retrieveReversal: stripeMethod({ method: 'GET', - path: '/{transfer}/reversals/{id}', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', }), updateReversal: stripeMethod({ method: 'POST', - path: '/{transfer}/reversals/{id}', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', }), listReversals: stripeMethod({ method: 'GET', - path: '/{id}/reversals', + fullPath: '/v1/transfers/{id}/reversals', methodType: 'list', }), }); diff --git a/lib/resources/Treasury/CreditReversals.js b/lib/resources/Treasury/CreditReversals.js index 58139a528d..39f5765ddc 100644 --- a/lib/resources/Treasury/CreditReversals.js +++ b/lib/resources/Treasury/CreditReversals.js @@ -3,18 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/credit_reversals', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/credit_reversals', }), retrieve: stripeMethod({ method: 'GET', - path: '/{creditReversal}', + fullPath: '/v1/treasury/credit_reversals/{credit_reversal}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/credit_reversals', methodType: 'list', }), }); diff --git a/lib/resources/Treasury/DebitReversals.js b/lib/resources/Treasury/DebitReversals.js index 4e1e252504..e0c91bc57e 100644 --- a/lib/resources/Treasury/DebitReversals.js +++ b/lib/resources/Treasury/DebitReversals.js @@ -3,18 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/debit_reversals', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/debit_reversals', }), retrieve: stripeMethod({ method: 'GET', - path: '/{debitReversal}', + fullPath: '/v1/treasury/debit_reversals/{debit_reversal}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/debit_reversals', methodType: 'list', }), }); diff --git a/lib/resources/Treasury/FinancialAccounts.js b/lib/resources/Treasury/FinancialAccounts.js index d52bbea9f1..370fab541e 100644 --- a/lib/resources/Treasury/FinancialAccounts.js +++ b/lib/resources/Treasury/FinancialAccounts.js @@ -3,30 +3,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/financial_accounts', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/financial_accounts', }), retrieve: stripeMethod({ method: 'GET', - path: '/{financialAccount}', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', }), update: stripeMethod({ method: 'POST', - path: '/{financialAccount}', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/financial_accounts', methodType: 'list', }), retrieveFeatures: stripeMethod({ method: 'GET', - path: '/{financialAccount}/features', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', }), updateFeatures: stripeMethod({ method: 'POST', - path: '/{financialAccount}/features', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', }), }); diff --git a/lib/resources/Treasury/InboundTransfers.js b/lib/resources/Treasury/InboundTransfers.js index ecb36ecf31..ef54bf4dca 100644 --- a/lib/resources/Treasury/InboundTransfers.js +++ b/lib/resources/Treasury/InboundTransfers.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/inbound_transfers', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/inbound_transfers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/inbound_transfers/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/inbound_transfers', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{inboundTransfer}/cancel', + fullPath: '/v1/treasury/inbound_transfers/{inbound_transfer}/cancel', }), }); diff --git a/lib/resources/Treasury/OutboundPayments.js b/lib/resources/Treasury/OutboundPayments.js index 9e707e38ec..2bab72b957 100644 --- a/lib/resources/Treasury/OutboundPayments.js +++ b/lib/resources/Treasury/OutboundPayments.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/outbound_payments', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/outbound_payments', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/outbound_payments/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/outbound_payments', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{id}/cancel', + fullPath: '/v1/treasury/outbound_payments/{id}/cancel', }), }); diff --git a/lib/resources/Treasury/OutboundTransfers.js b/lib/resources/Treasury/OutboundTransfers.js index b7f024445c..749b57f884 100644 --- a/lib/resources/Treasury/OutboundTransfers.js +++ b/lib/resources/Treasury/OutboundTransfers.js @@ -3,22 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/outbound_transfers', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/outbound_transfers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{outboundTransfer}', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/outbound_transfers', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/cancel', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}/cancel', }), }); diff --git a/lib/resources/Treasury/ReceivedCredits.js b/lib/resources/Treasury/ReceivedCredits.js index 23abb51d70..0c32c22d7d 100644 --- a/lib/resources/Treasury/ReceivedCredits.js +++ b/lib/resources/Treasury/ReceivedCredits.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/received_credits', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/received_credits/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/received_credits', methodType: 'list', }), }); diff --git a/lib/resources/Treasury/ReceivedDebits.js b/lib/resources/Treasury/ReceivedDebits.js index 38e197bee3..e4448c1173 100644 --- a/lib/resources/Treasury/ReceivedDebits.js +++ b/lib/resources/Treasury/ReceivedDebits.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/received_debits', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/received_debits/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/received_debits', methodType: 'list', }), }); diff --git a/lib/resources/Treasury/TransactionEntries.js b/lib/resources/Treasury/TransactionEntries.js index 8b64e41a80..9500b9f8fc 100644 --- a/lib/resources/Treasury/TransactionEntries.js +++ b/lib/resources/Treasury/TransactionEntries.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/transaction_entries', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/transaction_entries/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/transaction_entries', methodType: 'list', }), }); diff --git a/lib/resources/Treasury/Transactions.js b/lib/resources/Treasury/Transactions.js index bcf4143114..9896e74250 100644 --- a/lib/resources/Treasury/Transactions.js +++ b/lib/resources/Treasury/Transactions.js @@ -3,14 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/transactions', retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/transactions/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/transactions', methodType: 'list', }), }); diff --git a/lib/resources/WebhookEndpoints.js b/lib/resources/WebhookEndpoints.js index 3027842505..272a9ac078 100644 --- a/lib/resources/WebhookEndpoints.js +++ b/lib/resources/WebhookEndpoints.js @@ -3,26 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'webhook_endpoints', create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/webhook_endpoints', }), retrieve: stripeMethod({ method: 'GET', - path: '/{webhookEndpoint}', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', }), update: stripeMethod({ method: 'POST', - path: '/{webhookEndpoint}', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/webhook_endpoints', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{webhookEndpoint}', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', }), }); diff --git a/src/resources/AccountLinks.js b/src/resources/AccountLinks.js index 41e02b1ec5..713304f703 100644 --- a/src/resources/AccountLinks.js +++ b/src/resources/AccountLinks.js @@ -6,10 +6,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'account_links', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/account_links', }), }); diff --git a/src/resources/Accounts.js b/src/resources/Accounts.js index 351c055f23..9956629e30 100644 --- a/src/resources/Accounts.js +++ b/src/resources/Accounts.js @@ -7,11 +7,9 @@ const stripeMethod = StripeResource.method; // Since path can either be `account` or `accounts`, support both through stripeMethod path; module.exports = StripeResource.extend({ - path: '', - create: stripeMethod({ method: 'POST', - path: 'accounts', + fullPath: '/v1/accounts', }), retrieve(id) { @@ -20,7 +18,7 @@ module.exports = StripeResource.extend({ if (typeof id === 'string') { return stripeMethod({ method: 'GET', - path: 'accounts/{id}', + fullPath: '/v1/accounts/{id}', }).apply(this, arguments); } else { if (id === null || id === undefined) { @@ -29,102 +27,102 @@ module.exports = StripeResource.extend({ } return stripeMethod({ method: 'GET', - path: 'account', + fullPath: '/v1/account', }).apply(this, arguments); } }, update: stripeMethod({ method: 'POST', - path: 'accounts/{account}', + fullPath: '/v1/accounts/{account}', }), list: stripeMethod({ method: 'GET', - path: 'accounts', + fullPath: '/v1/accounts', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: 'accounts/{account}', + fullPath: '/v1/accounts/{account}', }), reject: stripeMethod({ method: 'POST', - path: 'accounts/{account}/reject', + fullPath: '/v1/accounts/{account}/reject', }), retrieveCapability: stripeMethod({ method: 'GET', - path: 'accounts/{account}/capabilities/{capability}', + fullPath: '/v1/accounts/{account}/capabilities/{capability}', }), updateCapability: stripeMethod({ method: 'POST', - path: 'accounts/{account}/capabilities/{capability}', + fullPath: '/v1/accounts/{account}/capabilities/{capability}', }), listCapabilities: stripeMethod({ method: 'GET', - path: 'accounts/{account}/capabilities', + fullPath: '/v1/accounts/{account}/capabilities', methodType: 'list', }), createExternalAccount: stripeMethod({ method: 'POST', - path: 'accounts/{account}/external_accounts', + fullPath: '/v1/accounts/{account}/external_accounts', }), retrieveExternalAccount: stripeMethod({ method: 'GET', - path: 'accounts/{account}/external_accounts/{id}', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', }), updateExternalAccount: stripeMethod({ method: 'POST', - path: 'accounts/{account}/external_accounts/{id}', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', }), listExternalAccounts: stripeMethod({ method: 'GET', - path: 'accounts/{account}/external_accounts', + fullPath: '/v1/accounts/{account}/external_accounts', methodType: 'list', }), deleteExternalAccount: stripeMethod({ method: 'DELETE', - path: 'accounts/{account}/external_accounts/{id}', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', }), createLoginLink: stripeMethod({ method: 'POST', - path: 'accounts/{account}/login_links', + fullPath: '/v1/accounts/{account}/login_links', }), createPerson: stripeMethod({ method: 'POST', - path: 'accounts/{account}/persons', + fullPath: '/v1/accounts/{account}/persons', }), retrievePerson: stripeMethod({ method: 'GET', - path: 'accounts/{account}/persons/{person}', + fullPath: '/v1/accounts/{account}/persons/{person}', }), updatePerson: stripeMethod({ method: 'POST', - path: 'accounts/{account}/persons/{person}', + fullPath: '/v1/accounts/{account}/persons/{person}', }), listPersons: stripeMethod({ method: 'GET', - path: 'accounts/{account}/persons', + fullPath: '/v1/accounts/{account}/persons', methodType: 'list', }), deletePerson: stripeMethod({ method: 'DELETE', - path: 'accounts/{account}/persons/{person}', + fullPath: '/v1/accounts/{account}/persons/{person}', }), }); diff --git a/src/resources/ApplePayDomains.js b/src/resources/ApplePayDomains.js index 76a8c59585..363e375f2e 100644 --- a/src/resources/ApplePayDomains.js +++ b/src/resources/ApplePayDomains.js @@ -6,26 +6,24 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'apple_pay/domains', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/apple_pay/domains', }), retrieve: stripeMethod({ method: 'GET', - path: '/{domain}', + fullPath: '/v1/apple_pay/domains/{domain}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/apple_pay/domains', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{domain}', + fullPath: '/v1/apple_pay/domains/{domain}', }), }); diff --git a/src/resources/ApplicationFees.js b/src/resources/ApplicationFees.js index ebd6372aca..21affd640b 100644 --- a/src/resources/ApplicationFees.js +++ b/src/resources/ApplicationFees.js @@ -6,37 +6,35 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'application_fees', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/application_fees/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/application_fees', methodType: 'list', }), createRefund: stripeMethod({ method: 'POST', - path: '/{id}/refunds', + fullPath: '/v1/application_fees/{id}/refunds', }), retrieveRefund: stripeMethod({ method: 'GET', - path: '/{fee}/refunds/{id}', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', }), updateRefund: stripeMethod({ method: 'POST', - path: '/{fee}/refunds/{id}', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', }), listRefunds: stripeMethod({ method: 'GET', - path: '/{id}/refunds', + fullPath: '/v1/application_fees/{id}/refunds', methodType: 'list', }), }); diff --git a/src/resources/Apps/Secrets.js b/src/resources/Apps/Secrets.js index 238037508f..7003cb2a43 100644 --- a/src/resources/Apps/Secrets.js +++ b/src/resources/Apps/Secrets.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'apps/secrets', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/apps/secrets', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/apps/secrets', methodType: 'list', }), deleteWhere: stripeMethod({ method: 'POST', - path: '/delete', + fullPath: '/v1/apps/secrets/delete', }), find: stripeMethod({ method: 'GET', - path: '/find', + fullPath: '/v1/apps/secrets/find', }), }); diff --git a/src/resources/Balance.js b/src/resources/Balance.js index ac7a9ae459..8cb2c44bd7 100644 --- a/src/resources/Balance.js +++ b/src/resources/Balance.js @@ -6,10 +6,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'balance', - retrieve: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/balance', }), }); diff --git a/src/resources/BalanceTransactions.js b/src/resources/BalanceTransactions.js index adbe3d41f9..4e0c9d0e88 100644 --- a/src/resources/BalanceTransactions.js +++ b/src/resources/BalanceTransactions.js @@ -6,16 +6,14 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'balance_transactions', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/balance_transactions/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/balance_transactions', methodType: 'list', }), }); diff --git a/src/resources/BillingPortal/Configurations.js b/src/resources/BillingPortal/Configurations.js index ff3200160a..cda7d157ff 100644 --- a/src/resources/BillingPortal/Configurations.js +++ b/src/resources/BillingPortal/Configurations.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'billing_portal/configurations', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/billing_portal/configurations', }), retrieve: stripeMethod({ method: 'GET', - path: '/{configuration}', + fullPath: '/v1/billing_portal/configurations/{configuration}', }), update: stripeMethod({ method: 'POST', - path: '/{configuration}', + fullPath: '/v1/billing_portal/configurations/{configuration}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/billing_portal/configurations', methodType: 'list', }), }); diff --git a/src/resources/BillingPortal/Sessions.js b/src/resources/BillingPortal/Sessions.js index 04f0ef6805..b2dbd1c963 100644 --- a/src/resources/BillingPortal/Sessions.js +++ b/src/resources/BillingPortal/Sessions.js @@ -6,10 +6,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'billing_portal/sessions', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/billing_portal/sessions', }), }); diff --git a/src/resources/Charges.js b/src/resources/Charges.js index f4546063f7..87b18dc1ac 100644 --- a/src/resources/Charges.js +++ b/src/resources/Charges.js @@ -6,37 +6,35 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'charges', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/charges', }), retrieve: stripeMethod({ method: 'GET', - path: '/{charge}', + fullPath: '/v1/charges/{charge}', }), update: stripeMethod({ method: 'POST', - path: '/{charge}', + fullPath: '/v1/charges/{charge}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/charges', methodType: 'list', }), capture: stripeMethod({ method: 'POST', - path: '/{charge}/capture', + fullPath: '/v1/charges/{charge}/capture', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/charges/search', methodType: 'search', }), }); diff --git a/src/resources/Checkout/Sessions.js b/src/resources/Checkout/Sessions.js index 1cef4d65d7..cf9bfb2489 100644 --- a/src/resources/Checkout/Sessions.js +++ b/src/resources/Checkout/Sessions.js @@ -6,32 +6,30 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'checkout/sessions', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/checkout/sessions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{session}', + fullPath: '/v1/checkout/sessions/{session}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/checkout/sessions', methodType: 'list', }), expire: stripeMethod({ method: 'POST', - path: '/{session}/expire', + fullPath: '/v1/checkout/sessions/{session}/expire', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{session}/line_items', + fullPath: '/v1/checkout/sessions/{session}/line_items', methodType: 'list', }), }); diff --git a/src/resources/CountrySpecs.js b/src/resources/CountrySpecs.js index 789f99054a..f21b9ab490 100644 --- a/src/resources/CountrySpecs.js +++ b/src/resources/CountrySpecs.js @@ -6,16 +6,14 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'country_specs', - retrieve: stripeMethod({ method: 'GET', - path: '/{country}', + fullPath: '/v1/country_specs/{country}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/country_specs', methodType: 'list', }), }); diff --git a/src/resources/Coupons.js b/src/resources/Coupons.js index 11bed027fe..3b62c60ece 100644 --- a/src/resources/Coupons.js +++ b/src/resources/Coupons.js @@ -6,31 +6,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'coupons', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/coupons', }), retrieve: stripeMethod({ method: 'GET', - path: '/{coupon}', + fullPath: '/v1/coupons/{coupon}', }), update: stripeMethod({ method: 'POST', - path: '/{coupon}', + fullPath: '/v1/coupons/{coupon}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/coupons', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{coupon}', + fullPath: '/v1/coupons/{coupon}', }), }); diff --git a/src/resources/CreditNotes.js b/src/resources/CreditNotes.js index e435282d00..eda7d9e29d 100644 --- a/src/resources/CreditNotes.js +++ b/src/resources/CreditNotes.js @@ -6,48 +6,46 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'credit_notes', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/credit_notes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/credit_notes/{id}', }), update: stripeMethod({ method: 'POST', - path: '/{id}', + fullPath: '/v1/credit_notes/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/credit_notes', methodType: 'list', }), listPreviewLineItems: stripeMethod({ method: 'GET', - path: '/preview/lines', + fullPath: '/v1/credit_notes/preview/lines', methodType: 'list', }), preview: stripeMethod({ method: 'GET', - path: '/preview', + fullPath: '/v1/credit_notes/preview', }), voidCreditNote: stripeMethod({ method: 'POST', - path: '/{id}/void', + fullPath: '/v1/credit_notes/{id}/void', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{creditNote}/lines', + fullPath: '/v1/credit_notes/{credit_note}/lines', methodType: 'list', }), }); diff --git a/src/resources/Customers.js b/src/resources/Customers.js index e3b8e8fab8..234e5573ba 100644 --- a/src/resources/Customers.js +++ b/src/resources/Customers.js @@ -6,152 +6,151 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'customers', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/customers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{customer}', + fullPath: '/v1/customers/{customer}', }), update: stripeMethod({ method: 'POST', - path: '/{customer}', + fullPath: '/v1/customers/{customer}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/customers', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{customer}', + fullPath: '/v1/customers/{customer}', }), createFundingInstructions: stripeMethod({ method: 'POST', - path: '/{customer}/funding_instructions', + fullPath: '/v1/customers/{customer}/funding_instructions', }), deleteDiscount: stripeMethod({ method: 'DELETE', - path: '/{customer}/discount', + fullPath: '/v1/customers/{customer}/discount', }), listPaymentMethods: stripeMethod({ method: 'GET', - path: '/{customer}/payment_methods', + fullPath: '/v1/customers/{customer}/payment_methods', methodType: 'list', }), retrievePaymentMethod: stripeMethod({ method: 'GET', - path: '/{customer}/payment_methods/{paymentMethod}', + fullPath: '/v1/customers/{customer}/payment_methods/{payment_method}', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/customers/search', methodType: 'search', }), retrieveCashBalance: stripeMethod({ method: 'GET', - path: '/{customer}/cash_balance', + fullPath: '/v1/customers/{customer}/cash_balance', }), updateCashBalance: stripeMethod({ method: 'POST', - path: '/{customer}/cash_balance', + fullPath: '/v1/customers/{customer}/cash_balance', }), createBalanceTransaction: stripeMethod({ method: 'POST', - path: '/{customer}/balance_transactions', + fullPath: '/v1/customers/{customer}/balance_transactions', }), retrieveBalanceTransaction: stripeMethod({ method: 'GET', - path: '/{customer}/balance_transactions/{transaction}', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', }), updateBalanceTransaction: stripeMethod({ method: 'POST', - path: '/{customer}/balance_transactions/{transaction}', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', }), listBalanceTransactions: stripeMethod({ method: 'GET', - path: '/{customer}/balance_transactions', + fullPath: '/v1/customers/{customer}/balance_transactions', methodType: 'list', }), retrieveCashBalanceTransaction: stripeMethod({ method: 'GET', - path: '/{customer}/cash_balance_transactions/{transaction}', + fullPath: + '/v1/customers/{customer}/cash_balance_transactions/{transaction}', }), listCashBalanceTransactions: stripeMethod({ method: 'GET', - path: '/{customer}/cash_balance_transactions', + fullPath: '/v1/customers/{customer}/cash_balance_transactions', methodType: 'list', }), createSource: stripeMethod({ method: 'POST', - path: '/{customer}/sources', + fullPath: '/v1/customers/{customer}/sources', }), retrieveSource: stripeMethod({ method: 'GET', - path: '/{customer}/sources/{id}', + fullPath: '/v1/customers/{customer}/sources/{id}', }), updateSource: stripeMethod({ method: 'POST', - path: '/{customer}/sources/{id}', + fullPath: '/v1/customers/{customer}/sources/{id}', }), listSources: stripeMethod({ method: 'GET', - path: '/{customer}/sources', + fullPath: '/v1/customers/{customer}/sources', methodType: 'list', }), deleteSource: stripeMethod({ method: 'DELETE', - path: '/{customer}/sources/{id}', + fullPath: '/v1/customers/{customer}/sources/{id}', }), verifySource: stripeMethod({ method: 'POST', - path: '/{customer}/sources/{id}/verify', + fullPath: '/v1/customers/{customer}/sources/{id}/verify', }), createTaxId: stripeMethod({ method: 'POST', - path: '/{customer}/tax_ids', + fullPath: '/v1/customers/{customer}/tax_ids', }), retrieveTaxId: stripeMethod({ method: 'GET', - path: '/{customer}/tax_ids/{id}', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', }), listTaxIds: stripeMethod({ method: 'GET', - path: '/{customer}/tax_ids', + fullPath: '/v1/customers/{customer}/tax_ids', methodType: 'list', }), deleteTaxId: stripeMethod({ method: 'DELETE', - path: '/{customer}/tax_ids/{id}', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', }), }); diff --git a/src/resources/Disputes.js b/src/resources/Disputes.js index 1318758949..d40c7a8fd8 100644 --- a/src/resources/Disputes.js +++ b/src/resources/Disputes.js @@ -6,26 +6,24 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'disputes', - retrieve: stripeMethod({ method: 'GET', - path: '/{dispute}', + fullPath: '/v1/disputes/{dispute}', }), update: stripeMethod({ method: 'POST', - path: '/{dispute}', + fullPath: '/v1/disputes/{dispute}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/disputes', methodType: 'list', }), close: stripeMethod({ method: 'POST', - path: '/{dispute}/close', + fullPath: '/v1/disputes/{dispute}/close', }), }); diff --git a/src/resources/EphemeralKeys.js b/src/resources/EphemeralKeys.js index 2f9b02694c..45c632b744 100644 --- a/src/resources/EphemeralKeys.js +++ b/src/resources/EphemeralKeys.js @@ -6,11 +6,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'ephemeral_keys', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/ephemeral_keys', validator: (data, options) => { if (!options.headers || !options.headers['Stripe-Version']) { throw new Error( @@ -22,6 +20,6 @@ module.exports = StripeResource.extend({ del: stripeMethod({ method: 'DELETE', - path: '/{key}', + fullPath: '/v1/ephemeral_keys/{key}', }), }); diff --git a/src/resources/Events.js b/src/resources/Events.js index 79ee31d45a..cb0b5ee931 100644 --- a/src/resources/Events.js +++ b/src/resources/Events.js @@ -6,16 +6,14 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'events', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/events/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/events', methodType: 'list', }), }); diff --git a/src/resources/ExchangeRates.js b/src/resources/ExchangeRates.js index 021e972336..bd6aec6ba9 100644 --- a/src/resources/ExchangeRates.js +++ b/src/resources/ExchangeRates.js @@ -6,16 +6,14 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'exchange_rates', - retrieve: stripeMethod({ method: 'GET', - path: '/{rateId}', + fullPath: '/v1/exchange_rates/{rate_id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/exchange_rates', methodType: 'list', }), }); diff --git a/src/resources/FileLinks.js b/src/resources/FileLinks.js index 7c7a6e117d..0cc3afe7c7 100644 --- a/src/resources/FileLinks.js +++ b/src/resources/FileLinks.js @@ -6,26 +6,24 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'file_links', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/file_links', }), retrieve: stripeMethod({ method: 'GET', - path: '/{link}', + fullPath: '/v1/file_links/{link}', }), update: stripeMethod({ method: 'POST', - path: '/{link}', + fullPath: '/v1/file_links/{link}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/file_links', methodType: 'list', }), }); diff --git a/src/resources/Files.js b/src/resources/Files.js index 5dee82d1d2..fbe9ce87b5 100644 --- a/src/resources/Files.js +++ b/src/resources/Files.js @@ -7,10 +7,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'files', - create: stripeMethod({ method: 'POST', + fullPath: '/v1/files', headers: { 'Content-Type': 'multipart/form-data', }, @@ -19,12 +18,12 @@ module.exports = StripeResource.extend({ retrieve: stripeMethod({ method: 'GET', - path: '/{file}', + fullPath: '/v1/files/{file}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/files', methodType: 'list', }), diff --git a/src/resources/FinancialConnections/Accounts.js b/src/resources/FinancialConnections/Accounts.js index 674f42ec48..e795b2283a 100644 --- a/src/resources/FinancialConnections/Accounts.js +++ b/src/resources/FinancialConnections/Accounts.js @@ -6,32 +6,30 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'financial_connections/accounts', - retrieve: stripeMethod({ method: 'GET', - path: '/{account}', + fullPath: '/v1/financial_connections/accounts/{account}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/financial_connections/accounts', methodType: 'list', }), disconnect: stripeMethod({ method: 'POST', - path: '/{account}/disconnect', + fullPath: '/v1/financial_connections/accounts/{account}/disconnect', }), listOwners: stripeMethod({ method: 'GET', - path: '/{account}/owners', + fullPath: '/v1/financial_connections/accounts/{account}/owners', methodType: 'list', }), refresh: stripeMethod({ method: 'POST', - path: '/{account}/refresh', + fullPath: '/v1/financial_connections/accounts/{account}/refresh', }), }); diff --git a/src/resources/FinancialConnections/Sessions.js b/src/resources/FinancialConnections/Sessions.js index 0e968a437b..077390c48d 100644 --- a/src/resources/FinancialConnections/Sessions.js +++ b/src/resources/FinancialConnections/Sessions.js @@ -6,15 +6,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'financial_connections/sessions', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/financial_connections/sessions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{session}', + fullPath: '/v1/financial_connections/sessions/{session}', }), }); diff --git a/src/resources/Identity/VerificationReports.js b/src/resources/Identity/VerificationReports.js index 6d78faa7a0..6c8734c889 100644 --- a/src/resources/Identity/VerificationReports.js +++ b/src/resources/Identity/VerificationReports.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'identity/verification_reports', - retrieve: stripeMethod({ method: 'GET', - path: '/{report}', + fullPath: '/v1/identity/verification_reports/{report}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/identity/verification_reports', methodType: 'list', }), }); diff --git a/src/resources/Identity/VerificationSessions.js b/src/resources/Identity/VerificationSessions.js index 02345e1210..47f442ba02 100644 --- a/src/resources/Identity/VerificationSessions.js +++ b/src/resources/Identity/VerificationSessions.js @@ -6,36 +6,34 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'identity/verification_sessions', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/identity/verification_sessions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{session}', + fullPath: '/v1/identity/verification_sessions/{session}', }), update: stripeMethod({ method: 'POST', - path: '/{session}', + fullPath: '/v1/identity/verification_sessions/{session}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/identity/verification_sessions', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{session}/cancel', + fullPath: '/v1/identity/verification_sessions/{session}/cancel', }), redact: stripeMethod({ method: 'POST', - path: '/{session}/redact', + fullPath: '/v1/identity/verification_sessions/{session}/redact', }), }); diff --git a/src/resources/InvoiceItems.js b/src/resources/InvoiceItems.js index c7cb5586be..715c07e8a3 100644 --- a/src/resources/InvoiceItems.js +++ b/src/resources/InvoiceItems.js @@ -6,31 +6,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'invoiceitems', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/invoiceitems', }), retrieve: stripeMethod({ method: 'GET', - path: '/{invoiceitem}', + fullPath: '/v1/invoiceitems/{invoiceitem}', }), update: stripeMethod({ method: 'POST', - path: '/{invoiceitem}', + fullPath: '/v1/invoiceitems/{invoiceitem}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/invoiceitems', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{invoiceitem}', + fullPath: '/v1/invoiceitems/{invoiceitem}', }), }); diff --git a/src/resources/Invoices.js b/src/resources/Invoices.js index 21543c1f3a..4e1866f0ac 100644 --- a/src/resources/Invoices.js +++ b/src/resources/Invoices.js @@ -6,79 +6,77 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'invoices', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/invoices', }), retrieve: stripeMethod({ method: 'GET', - path: '/{invoice}', + fullPath: '/v1/invoices/{invoice}', }), update: stripeMethod({ method: 'POST', - path: '/{invoice}', + fullPath: '/v1/invoices/{invoice}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/invoices', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{invoice}', + fullPath: '/v1/invoices/{invoice}', }), finalizeInvoice: stripeMethod({ method: 'POST', - path: '/{invoice}/finalize', + fullPath: '/v1/invoices/{invoice}/finalize', }), listUpcomingLines: stripeMethod({ method: 'GET', - path: '/upcoming/lines', + fullPath: '/v1/invoices/upcoming/lines', methodType: 'list', }), markUncollectible: stripeMethod({ method: 'POST', - path: '/{invoice}/mark_uncollectible', + fullPath: '/v1/invoices/{invoice}/mark_uncollectible', }), pay: stripeMethod({ method: 'POST', - path: '/{invoice}/pay', + fullPath: '/v1/invoices/{invoice}/pay', }), retrieveUpcoming: stripeMethod({ method: 'GET', - path: '/upcoming', + fullPath: '/v1/invoices/upcoming', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/invoices/search', methodType: 'search', }), sendInvoice: stripeMethod({ method: 'POST', - path: '/{invoice}/send', + fullPath: '/v1/invoices/{invoice}/send', }), voidInvoice: stripeMethod({ method: 'POST', - path: '/{invoice}/void', + fullPath: '/v1/invoices/{invoice}/void', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{invoice}/lines', + fullPath: '/v1/invoices/{invoice}/lines', methodType: 'list', }), }); diff --git a/src/resources/Issuing/Authorizations.js b/src/resources/Issuing/Authorizations.js index 5310d0ea8b..78afe9a49d 100644 --- a/src/resources/Issuing/Authorizations.js +++ b/src/resources/Issuing/Authorizations.js @@ -6,31 +6,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/authorizations', - retrieve: stripeMethod({ method: 'GET', - path: '/{authorization}', + fullPath: '/v1/issuing/authorizations/{authorization}', }), update: stripeMethod({ method: 'POST', - path: '/{authorization}', + fullPath: '/v1/issuing/authorizations/{authorization}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/authorizations', methodType: 'list', }), approve: stripeMethod({ method: 'POST', - path: '/{authorization}/approve', + fullPath: '/v1/issuing/authorizations/{authorization}/approve', }), decline: stripeMethod({ method: 'POST', - path: '/{authorization}/decline', + fullPath: '/v1/issuing/authorizations/{authorization}/decline', }), }); diff --git a/src/resources/Issuing/Cardholders.js b/src/resources/Issuing/Cardholders.js index 7b340e6912..bb00cde297 100644 --- a/src/resources/Issuing/Cardholders.js +++ b/src/resources/Issuing/Cardholders.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/cardholders', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/issuing/cardholders', }), retrieve: stripeMethod({ method: 'GET', - path: '/{cardholder}', + fullPath: '/v1/issuing/cardholders/{cardholder}', }), update: stripeMethod({ method: 'POST', - path: '/{cardholder}', + fullPath: '/v1/issuing/cardholders/{cardholder}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/cardholders', methodType: 'list', }), }); diff --git a/src/resources/Issuing/Cards.js b/src/resources/Issuing/Cards.js index efc2cbc10f..f197403f1b 100644 --- a/src/resources/Issuing/Cards.js +++ b/src/resources/Issuing/Cards.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/cards', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/issuing/cards', }), retrieve: stripeMethod({ method: 'GET', - path: '/{card}', + fullPath: '/v1/issuing/cards/{card}', }), update: stripeMethod({ method: 'POST', - path: '/{card}', + fullPath: '/v1/issuing/cards/{card}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/cards', methodType: 'list', }), }); diff --git a/src/resources/Issuing/Disputes.js b/src/resources/Issuing/Disputes.js index f62a2be96d..67eab915d3 100644 --- a/src/resources/Issuing/Disputes.js +++ b/src/resources/Issuing/Disputes.js @@ -6,31 +6,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/disputes', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/issuing/disputes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{dispute}', + fullPath: '/v1/issuing/disputes/{dispute}', }), update: stripeMethod({ method: 'POST', - path: '/{dispute}', + fullPath: '/v1/issuing/disputes/{dispute}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/disputes', methodType: 'list', }), submit: stripeMethod({ method: 'POST', - path: '/{dispute}/submit', + fullPath: '/v1/issuing/disputes/{dispute}/submit', }), }); diff --git a/src/resources/Issuing/Transactions.js b/src/resources/Issuing/Transactions.js index 22b438429d..eee0eb821a 100644 --- a/src/resources/Issuing/Transactions.js +++ b/src/resources/Issuing/Transactions.js @@ -6,21 +6,19 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'issuing/transactions', - retrieve: stripeMethod({ method: 'GET', - path: '/{transaction}', + fullPath: '/v1/issuing/transactions/{transaction}', }), update: stripeMethod({ method: 'POST', - path: '/{transaction}', + fullPath: '/v1/issuing/transactions/{transaction}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/issuing/transactions', methodType: 'list', }), }); diff --git a/src/resources/Mandates.js b/src/resources/Mandates.js index 6d9ced9f82..678e732d31 100644 --- a/src/resources/Mandates.js +++ b/src/resources/Mandates.js @@ -6,10 +6,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'mandates', - retrieve: stripeMethod({ method: 'GET', - path: '/{mandate}', + fullPath: '/v1/mandates/{mandate}', }), }); diff --git a/src/resources/PaymentIntents.js b/src/resources/PaymentIntents.js index d6addba0d3..a90d20f2ec 100644 --- a/src/resources/PaymentIntents.js +++ b/src/resources/PaymentIntents.js @@ -6,62 +6,60 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payment_intents', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payment_intents', }), retrieve: stripeMethod({ method: 'GET', - path: '/{intent}', + fullPath: '/v1/payment_intents/{intent}', }), update: stripeMethod({ method: 'POST', - path: '/{intent}', + fullPath: '/v1/payment_intents/{intent}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payment_intents', methodType: 'list', }), applyCustomerBalance: stripeMethod({ method: 'POST', - path: '/{intent}/apply_customer_balance', + fullPath: '/v1/payment_intents/{intent}/apply_customer_balance', }), cancel: stripeMethod({ method: 'POST', - path: '/{intent}/cancel', + fullPath: '/v1/payment_intents/{intent}/cancel', }), capture: stripeMethod({ method: 'POST', - path: '/{intent}/capture', + fullPath: '/v1/payment_intents/{intent}/capture', }), confirm: stripeMethod({ method: 'POST', - path: '/{intent}/confirm', + fullPath: '/v1/payment_intents/{intent}/confirm', }), incrementAuthorization: stripeMethod({ method: 'POST', - path: '/{intent}/increment_authorization', + fullPath: '/v1/payment_intents/{intent}/increment_authorization', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/payment_intents/search', methodType: 'search', }), verifyMicrodeposits: stripeMethod({ method: 'POST', - path: '/{intent}/verify_microdeposits', + fullPath: '/v1/payment_intents/{intent}/verify_microdeposits', }), }); diff --git a/src/resources/PaymentLinks.js b/src/resources/PaymentLinks.js index a357cedd89..2eb101ca69 100644 --- a/src/resources/PaymentLinks.js +++ b/src/resources/PaymentLinks.js @@ -6,32 +6,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payment_links', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payment_links', }), retrieve: stripeMethod({ method: 'GET', - path: '/{paymentLink}', + fullPath: '/v1/payment_links/{payment_link}', }), update: stripeMethod({ method: 'POST', - path: '/{paymentLink}', + fullPath: '/v1/payment_links/{payment_link}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payment_links', methodType: 'list', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{paymentLink}/line_items', + fullPath: '/v1/payment_links/{payment_link}/line_items', methodType: 'list', }), }); diff --git a/src/resources/PaymentMethods.js b/src/resources/PaymentMethods.js index bd74b2ee5f..682d1bae3b 100644 --- a/src/resources/PaymentMethods.js +++ b/src/resources/PaymentMethods.js @@ -6,36 +6,34 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payment_methods', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payment_methods', }), retrieve: stripeMethod({ method: 'GET', - path: '/{paymentMethod}', + fullPath: '/v1/payment_methods/{payment_method}', }), update: stripeMethod({ method: 'POST', - path: '/{paymentMethod}', + fullPath: '/v1/payment_methods/{payment_method}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payment_methods', methodType: 'list', }), attach: stripeMethod({ method: 'POST', - path: '/{paymentMethod}/attach', + fullPath: '/v1/payment_methods/{payment_method}/attach', }), detach: stripeMethod({ method: 'POST', - path: '/{paymentMethod}/detach', + fullPath: '/v1/payment_methods/{payment_method}/detach', }), }); diff --git a/src/resources/Payouts.js b/src/resources/Payouts.js index a3b8e0cd66..0fa971792f 100644 --- a/src/resources/Payouts.js +++ b/src/resources/Payouts.js @@ -6,36 +6,34 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'payouts', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/payouts', }), retrieve: stripeMethod({ method: 'GET', - path: '/{payout}', + fullPath: '/v1/payouts/{payout}', }), update: stripeMethod({ method: 'POST', - path: '/{payout}', + fullPath: '/v1/payouts/{payout}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/payouts', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{payout}/cancel', + fullPath: '/v1/payouts/{payout}/cancel', }), reverse: stripeMethod({ method: 'POST', - path: '/{payout}/reverse', + fullPath: '/v1/payouts/{payout}/reverse', }), }); diff --git a/src/resources/Plans.js b/src/resources/Plans.js index bd55a157da..c9032c1ab1 100644 --- a/src/resources/Plans.js +++ b/src/resources/Plans.js @@ -6,31 +6,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'plans', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/plans', }), retrieve: stripeMethod({ method: 'GET', - path: '/{plan}', + fullPath: '/v1/plans/{plan}', }), update: stripeMethod({ method: 'POST', - path: '/{plan}', + fullPath: '/v1/plans/{plan}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/plans', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{plan}', + fullPath: '/v1/plans/{plan}', }), }); diff --git a/src/resources/Prices.js b/src/resources/Prices.js index c509fdcbc0..e290429ecb 100644 --- a/src/resources/Prices.js +++ b/src/resources/Prices.js @@ -6,32 +6,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'prices', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/prices', }), retrieve: stripeMethod({ method: 'GET', - path: '/{price}', + fullPath: '/v1/prices/{price}', }), update: stripeMethod({ method: 'POST', - path: '/{price}', + fullPath: '/v1/prices/{price}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/prices', methodType: 'list', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/prices/search', methodType: 'search', }), }); diff --git a/src/resources/Products.js b/src/resources/Products.js index 3886020cf8..5a995c89f1 100644 --- a/src/resources/Products.js +++ b/src/resources/Products.js @@ -6,37 +6,35 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'products', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/products', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/products/{id}', }), update: stripeMethod({ method: 'POST', - path: '/{id}', + fullPath: '/v1/products/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/products', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{id}', + fullPath: '/v1/products/{id}', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/products/search', methodType: 'search', }), }); diff --git a/src/resources/PromotionCodes.js b/src/resources/PromotionCodes.js index c8afa0e478..be942e9999 100644 --- a/src/resources/PromotionCodes.js +++ b/src/resources/PromotionCodes.js @@ -6,26 +6,24 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'promotion_codes', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/promotion_codes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{promotionCode}', + fullPath: '/v1/promotion_codes/{promotion_code}', }), update: stripeMethod({ method: 'POST', - path: '/{promotionCode}', + fullPath: '/v1/promotion_codes/{promotion_code}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/promotion_codes', methodType: 'list', }), }); diff --git a/src/resources/Quotes.js b/src/resources/Quotes.js index 62aebb65a9..0631c6f116 100644 --- a/src/resources/Quotes.js +++ b/src/resources/Quotes.js @@ -6,60 +6,58 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'quotes', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/quotes', }), retrieve: stripeMethod({ method: 'GET', - path: '/{quote}', + fullPath: '/v1/quotes/{quote}', }), update: stripeMethod({ method: 'POST', - path: '/{quote}', + fullPath: '/v1/quotes/{quote}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/quotes', methodType: 'list', }), accept: stripeMethod({ method: 'POST', - path: '/{quote}/accept', + fullPath: '/v1/quotes/{quote}/accept', }), cancel: stripeMethod({ method: 'POST', - path: '/{quote}/cancel', + fullPath: '/v1/quotes/{quote}/cancel', }), finalizeQuote: stripeMethod({ method: 'POST', - path: '/{quote}/finalize', + fullPath: '/v1/quotes/{quote}/finalize', }), listComputedUpfrontLineItems: stripeMethod({ method: 'GET', - path: '/{quote}/computed_upfront_line_items', + fullPath: '/v1/quotes/{quote}/computed_upfront_line_items', methodType: 'list', }), listLineItems: stripeMethod({ method: 'GET', - path: '/{quote}/line_items', + fullPath: '/v1/quotes/{quote}/line_items', methodType: 'list', }), pdf: stripeMethod({ host: 'files.stripe.com', method: 'GET', - path: '/{quote}/pdf', + fullPath: '/v1/quotes/{quote}/pdf', streaming: true, }), }); diff --git a/src/resources/Radar/EarlyFraudWarnings.js b/src/resources/Radar/EarlyFraudWarnings.js index 9282648d86..4e38d1c655 100644 --- a/src/resources/Radar/EarlyFraudWarnings.js +++ b/src/resources/Radar/EarlyFraudWarnings.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'radar/early_fraud_warnings', - retrieve: stripeMethod({ method: 'GET', - path: '/{earlyFraudWarning}', + fullPath: '/v1/radar/early_fraud_warnings/{early_fraud_warning}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/radar/early_fraud_warnings', methodType: 'list', }), }); diff --git a/src/resources/Radar/ValueListItems.js b/src/resources/Radar/ValueListItems.js index 75bcb8947c..df0b8c9800 100644 --- a/src/resources/Radar/ValueListItems.js +++ b/src/resources/Radar/ValueListItems.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'radar/value_list_items', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/radar/value_list_items', }), retrieve: stripeMethod({ method: 'GET', - path: '/{item}', + fullPath: '/v1/radar/value_list_items/{item}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/radar/value_list_items', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{item}', + fullPath: '/v1/radar/value_list_items/{item}', }), }); diff --git a/src/resources/Radar/ValueLists.js b/src/resources/Radar/ValueLists.js index ace1edaa2d..68025810e3 100644 --- a/src/resources/Radar/ValueLists.js +++ b/src/resources/Radar/ValueLists.js @@ -6,31 +6,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'radar/value_lists', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/radar/value_lists', }), retrieve: stripeMethod({ method: 'GET', - path: '/{valueList}', + fullPath: '/v1/radar/value_lists/{value_list}', }), update: stripeMethod({ method: 'POST', - path: '/{valueList}', + fullPath: '/v1/radar/value_lists/{value_list}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/radar/value_lists', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{valueList}', + fullPath: '/v1/radar/value_lists/{value_list}', }), }); diff --git a/src/resources/Refunds.js b/src/resources/Refunds.js index c859fc577c..380688d9b0 100644 --- a/src/resources/Refunds.js +++ b/src/resources/Refunds.js @@ -6,31 +6,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'refunds', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/refunds', }), retrieve: stripeMethod({ method: 'GET', - path: '/{refund}', + fullPath: '/v1/refunds/{refund}', }), update: stripeMethod({ method: 'POST', - path: '/{refund}', + fullPath: '/v1/refunds/{refund}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/refunds', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{refund}/cancel', + fullPath: '/v1/refunds/{refund}/cancel', }), }); diff --git a/src/resources/Reporting/ReportRuns.js b/src/resources/Reporting/ReportRuns.js index 84eb179f90..c3ecf96c83 100644 --- a/src/resources/Reporting/ReportRuns.js +++ b/src/resources/Reporting/ReportRuns.js @@ -6,21 +6,19 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'reporting/report_runs', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/reporting/report_runs', }), retrieve: stripeMethod({ method: 'GET', - path: '/{reportRun}', + fullPath: '/v1/reporting/report_runs/{report_run}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/reporting/report_runs', methodType: 'list', }), }); diff --git a/src/resources/Reporting/ReportTypes.js b/src/resources/Reporting/ReportTypes.js index b4b25f8043..48e08548d9 100644 --- a/src/resources/Reporting/ReportTypes.js +++ b/src/resources/Reporting/ReportTypes.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'reporting/report_types', - retrieve: stripeMethod({ method: 'GET', - path: '/{reportType}', + fullPath: '/v1/reporting/report_types/{report_type}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/reporting/report_types', methodType: 'list', }), }); diff --git a/src/resources/Reviews.js b/src/resources/Reviews.js index 9400e8b89a..f9b515b464 100644 --- a/src/resources/Reviews.js +++ b/src/resources/Reviews.js @@ -6,21 +6,19 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'reviews', - retrieve: stripeMethod({ method: 'GET', - path: '/{review}', + fullPath: '/v1/reviews/{review}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/reviews', methodType: 'list', }), approve: stripeMethod({ method: 'POST', - path: '/{review}/approve', + fullPath: '/v1/reviews/{review}/approve', }), }); diff --git a/src/resources/SetupAttempts.js b/src/resources/SetupAttempts.js index 9bb8c1d3e3..7076944edf 100644 --- a/src/resources/SetupAttempts.js +++ b/src/resources/SetupAttempts.js @@ -6,11 +6,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'setup_attempts', - list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/setup_attempts', methodType: 'list', }), }); diff --git a/src/resources/SetupIntents.js b/src/resources/SetupIntents.js index 7aea8dcf75..507c8c9b13 100644 --- a/src/resources/SetupIntents.js +++ b/src/resources/SetupIntents.js @@ -6,41 +6,39 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'setup_intents', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/setup_intents', }), retrieve: stripeMethod({ method: 'GET', - path: '/{intent}', + fullPath: '/v1/setup_intents/{intent}', }), update: stripeMethod({ method: 'POST', - path: '/{intent}', + fullPath: '/v1/setup_intents/{intent}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/setup_intents', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{intent}/cancel', + fullPath: '/v1/setup_intents/{intent}/cancel', }), confirm: stripeMethod({ method: 'POST', - path: '/{intent}/confirm', + fullPath: '/v1/setup_intents/{intent}/confirm', }), verifyMicrodeposits: stripeMethod({ method: 'POST', - path: '/{intent}/verify_microdeposits', + fullPath: '/v1/setup_intents/{intent}/verify_microdeposits', }), }); diff --git a/src/resources/ShippingRates.js b/src/resources/ShippingRates.js index d7eb52ac16..a24e83468d 100644 --- a/src/resources/ShippingRates.js +++ b/src/resources/ShippingRates.js @@ -6,26 +6,24 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'shipping_rates', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/shipping_rates', }), retrieve: stripeMethod({ method: 'GET', - path: '/{shippingRateToken}', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', }), update: stripeMethod({ method: 'POST', - path: '/{shippingRateToken}', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/shipping_rates', methodType: 'list', }), }); diff --git a/src/resources/Sigma/ScheduledQueryRuns.js b/src/resources/Sigma/ScheduledQueryRuns.js index a8cb8e60a6..0396103a9b 100644 --- a/src/resources/Sigma/ScheduledQueryRuns.js +++ b/src/resources/Sigma/ScheduledQueryRuns.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'sigma/scheduled_query_runs', - retrieve: stripeMethod({ method: 'GET', - path: '/{scheduledQueryRun}', + fullPath: '/v1/sigma/scheduled_query_runs/{scheduled_query_run}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/sigma/scheduled_query_runs', methodType: 'list', }), }); diff --git a/src/resources/Sources.js b/src/resources/Sources.js index 5008001c5c..258245ce2a 100644 --- a/src/resources/Sources.js +++ b/src/resources/Sources.js @@ -6,31 +6,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'sources', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/sources', }), retrieve: stripeMethod({ method: 'GET', - path: '/{source}', + fullPath: '/v1/sources/{source}', }), update: stripeMethod({ method: 'POST', - path: '/{source}', + fullPath: '/v1/sources/{source}', }), listSourceTransactions: stripeMethod({ method: 'GET', - path: '/{source}/source_transactions', + fullPath: '/v1/sources/{source}/source_transactions', methodType: 'list', }), verify: stripeMethod({ method: 'POST', - path: '/{source}/verify', + fullPath: '/v1/sources/{source}/verify', }), }); diff --git a/src/resources/SubscriptionItems.js b/src/resources/SubscriptionItems.js index 62423a22cb..a58a6e45cb 100644 --- a/src/resources/SubscriptionItems.js +++ b/src/resources/SubscriptionItems.js @@ -6,42 +6,41 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscription_items', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/subscription_items', }), retrieve: stripeMethod({ method: 'GET', - path: '/{item}', + fullPath: '/v1/subscription_items/{item}', }), update: stripeMethod({ method: 'POST', - path: '/{item}', + fullPath: '/v1/subscription_items/{item}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/subscription_items', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{item}', + fullPath: '/v1/subscription_items/{item}', }), createUsageRecord: stripeMethod({ method: 'POST', - path: '/{subscriptionItem}/usage_records', + fullPath: '/v1/subscription_items/{subscription_item}/usage_records', }), listUsageRecordSummaries: stripeMethod({ method: 'GET', - path: '/{subscriptionItem}/usage_record_summaries', + fullPath: + '/v1/subscription_items/{subscription_item}/usage_record_summaries', methodType: 'list', }), }); diff --git a/src/resources/SubscriptionSchedules.js b/src/resources/SubscriptionSchedules.js index 9c9249e3d9..9932c3fa78 100644 --- a/src/resources/SubscriptionSchedules.js +++ b/src/resources/SubscriptionSchedules.js @@ -6,36 +6,34 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscription_schedules', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/subscription_schedules', }), retrieve: stripeMethod({ method: 'GET', - path: '/{schedule}', + fullPath: '/v1/subscription_schedules/{schedule}', }), update: stripeMethod({ method: 'POST', - path: '/{schedule}', + fullPath: '/v1/subscription_schedules/{schedule}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/subscription_schedules', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{schedule}/cancel', + fullPath: '/v1/subscription_schedules/{schedule}/cancel', }), release: stripeMethod({ method: 'POST', - path: '/{schedule}/release', + fullPath: '/v1/subscription_schedules/{schedule}/release', }), }); diff --git a/src/resources/Subscriptions.js b/src/resources/Subscriptions.js index bd0dc644c7..834abd3bd9 100644 --- a/src/resources/Subscriptions.js +++ b/src/resources/Subscriptions.js @@ -6,47 +6,45 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'subscriptions', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/subscriptions', }), retrieve: stripeMethod({ method: 'GET', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), update: stripeMethod({ method: 'POST', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/subscriptions', methodType: 'list', }), cancel: stripeMethod({ method: 'DELETE', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), del: stripeMethod({ method: 'DELETE', - path: '/{subscriptionExposedId}', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', }), deleteDiscount: stripeMethod({ method: 'DELETE', - path: '/{subscriptionExposedId}/discount', + fullPath: '/v1/subscriptions/{subscription_exposed_id}/discount', }), search: stripeMethod({ method: 'GET', - path: '/search', + fullPath: '/v1/subscriptions/search', methodType: 'search', }), }); diff --git a/src/resources/TaxCodes.js b/src/resources/TaxCodes.js index 57bf52ff3e..828617b2a8 100644 --- a/src/resources/TaxCodes.js +++ b/src/resources/TaxCodes.js @@ -6,16 +6,14 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'tax_codes', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/tax_codes/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/tax_codes', methodType: 'list', }), }); diff --git a/src/resources/TaxRates.js b/src/resources/TaxRates.js index e429895f7b..dbe45632e0 100644 --- a/src/resources/TaxRates.js +++ b/src/resources/TaxRates.js @@ -6,26 +6,24 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'tax_rates', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/tax_rates', }), retrieve: stripeMethod({ method: 'GET', - path: '/{taxRate}', + fullPath: '/v1/tax_rates/{tax_rate}', }), update: stripeMethod({ method: 'POST', - path: '/{taxRate}', + fullPath: '/v1/tax_rates/{tax_rate}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/tax_rates', methodType: 'list', }), }); diff --git a/src/resources/Terminal/Configurations.js b/src/resources/Terminal/Configurations.js index 4a7d069a8e..efdf67cc12 100644 --- a/src/resources/Terminal/Configurations.js +++ b/src/resources/Terminal/Configurations.js @@ -6,31 +6,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/configurations', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/configurations', }), retrieve: stripeMethod({ method: 'GET', - path: '/{configuration}', + fullPath: '/v1/terminal/configurations/{configuration}', }), update: stripeMethod({ method: 'POST', - path: '/{configuration}', + fullPath: '/v1/terminal/configurations/{configuration}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/terminal/configurations', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{configuration}', + fullPath: '/v1/terminal/configurations/{configuration}', }), }); diff --git a/src/resources/Terminal/ConnectionTokens.js b/src/resources/Terminal/ConnectionTokens.js index 2e1a1b5155..d210bb9388 100644 --- a/src/resources/Terminal/ConnectionTokens.js +++ b/src/resources/Terminal/ConnectionTokens.js @@ -6,10 +6,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/connection_tokens', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/connection_tokens', }), }); diff --git a/src/resources/Terminal/Locations.js b/src/resources/Terminal/Locations.js index 161e0dd014..3d87dce2a4 100644 --- a/src/resources/Terminal/Locations.js +++ b/src/resources/Terminal/Locations.js @@ -6,31 +6,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/locations', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/locations', }), retrieve: stripeMethod({ method: 'GET', - path: '/{location}', + fullPath: '/v1/terminal/locations/{location}', }), update: stripeMethod({ method: 'POST', - path: '/{location}', + fullPath: '/v1/terminal/locations/{location}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/terminal/locations', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{location}', + fullPath: '/v1/terminal/locations/{location}', }), }); diff --git a/src/resources/Terminal/Readers.js b/src/resources/Terminal/Readers.js index 05a8a53ef5..7f19d13d29 100644 --- a/src/resources/Terminal/Readers.js +++ b/src/resources/Terminal/Readers.js @@ -6,51 +6,49 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'terminal/readers', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/terminal/readers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{reader}', + fullPath: '/v1/terminal/readers/{reader}', }), update: stripeMethod({ method: 'POST', - path: '/{reader}', + fullPath: '/v1/terminal/readers/{reader}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/terminal/readers', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{reader}', + fullPath: '/v1/terminal/readers/{reader}', }), cancelAction: stripeMethod({ method: 'POST', - path: '/{reader}/cancel_action', + fullPath: '/v1/terminal/readers/{reader}/cancel_action', }), processPaymentIntent: stripeMethod({ method: 'POST', - path: '/{reader}/process_payment_intent', + fullPath: '/v1/terminal/readers/{reader}/process_payment_intent', }), processSetupIntent: stripeMethod({ method: 'POST', - path: '/{reader}/process_setup_intent', + fullPath: '/v1/terminal/readers/{reader}/process_setup_intent', }), setReaderDisplay: stripeMethod({ method: 'POST', - path: '/{reader}/set_reader_display', + fullPath: '/v1/terminal/readers/{reader}/set_reader_display', }), }); diff --git a/src/resources/TestHelpers/Customers.js b/src/resources/TestHelpers/Customers.js index 64796a11da..c0671f9b0a 100644 --- a/src/resources/TestHelpers/Customers.js +++ b/src/resources/TestHelpers/Customers.js @@ -6,10 +6,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/customers', - fundCashBalance: stripeMethod({ method: 'POST', - path: '/{customer}/fund_cash_balance', + fullPath: '/v1/test_helpers/customers/{customer}/fund_cash_balance', }), }); diff --git a/src/resources/TestHelpers/Issuing/Cards.js b/src/resources/TestHelpers/Issuing/Cards.js index 0f8c50f7d0..a814ff6503 100644 --- a/src/resources/TestHelpers/Issuing/Cards.js +++ b/src/resources/TestHelpers/Issuing/Cards.js @@ -6,25 +6,23 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/issuing/cards', - deliverCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/deliver', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/deliver', }), failCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/fail', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/fail', }), returnCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/return', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/return', }), shipCard: stripeMethod({ method: 'POST', - path: '/{card}/shipping/ship', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/ship', }), }); diff --git a/src/resources/TestHelpers/Refunds.js b/src/resources/TestHelpers/Refunds.js index 7aac415e77..5302e65277 100644 --- a/src/resources/TestHelpers/Refunds.js +++ b/src/resources/TestHelpers/Refunds.js @@ -6,10 +6,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/refunds', - expire: stripeMethod({ method: 'POST', - path: '/{refund}/expire', + fullPath: '/v1/test_helpers/refunds/{refund}/expire', }), }); diff --git a/src/resources/TestHelpers/Terminal/Readers.js b/src/resources/TestHelpers/Terminal/Readers.js index ab660b0f95..f303abc122 100644 --- a/src/resources/TestHelpers/Terminal/Readers.js +++ b/src/resources/TestHelpers/Terminal/Readers.js @@ -6,10 +6,9 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/terminal/readers', - presentPaymentMethod: stripeMethod({ method: 'POST', - path: '/{reader}/present_payment_method', + fullPath: + '/v1/test_helpers/terminal/readers/{reader}/present_payment_method', }), }); diff --git a/src/resources/TestHelpers/TestClocks.js b/src/resources/TestHelpers/TestClocks.js index adae9ae446..a0beacd365 100644 --- a/src/resources/TestHelpers/TestClocks.js +++ b/src/resources/TestHelpers/TestClocks.js @@ -6,31 +6,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/test_clocks', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/test_helpers/test_clocks', }), retrieve: stripeMethod({ method: 'GET', - path: '/{testClock}', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/test_helpers/test_clocks', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{testClock}', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', }), advance: stripeMethod({ method: 'POST', - path: '/{testClock}/advance', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}/advance', }), }); diff --git a/src/resources/TestHelpers/Treasury/InboundTransfers.js b/src/resources/TestHelpers/Treasury/InboundTransfers.js index 178816ad58..e1a55c0b80 100644 --- a/src/resources/TestHelpers/Treasury/InboundTransfers.js +++ b/src/resources/TestHelpers/Treasury/InboundTransfers.js @@ -6,20 +6,18 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/inbound_transfers', - fail: stripeMethod({ method: 'POST', - path: '/{id}/fail', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/fail', }), returnInboundTransfer: stripeMethod({ method: 'POST', - path: '/{id}/return', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/return', }), succeed: stripeMethod({ method: 'POST', - path: '/{id}/succeed', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/succeed', }), }); diff --git a/src/resources/TestHelpers/Treasury/OutboundPayments.js b/src/resources/TestHelpers/Treasury/OutboundPayments.js index 3a1b4d6516..b7da93e659 100644 --- a/src/resources/TestHelpers/Treasury/OutboundPayments.js +++ b/src/resources/TestHelpers/Treasury/OutboundPayments.js @@ -6,20 +6,18 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/outbound_payments', - fail: stripeMethod({ method: 'POST', - path: '/{id}/fail', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/fail', }), post: stripeMethod({ method: 'POST', - path: '/{id}/post', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/post', }), returnOutboundPayment: stripeMethod({ method: 'POST', - path: '/{id}/return', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/return', }), }); diff --git a/src/resources/TestHelpers/Treasury/OutboundTransfers.js b/src/resources/TestHelpers/Treasury/OutboundTransfers.js index 90d7d6236b..55b1a25064 100644 --- a/src/resources/TestHelpers/Treasury/OutboundTransfers.js +++ b/src/resources/TestHelpers/Treasury/OutboundTransfers.js @@ -6,20 +6,21 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/outbound_transfers', - fail: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/fail', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail', }), post: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/post', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post', }), returnOutboundTransfer: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/return', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return', }), }); diff --git a/src/resources/TestHelpers/Treasury/ReceivedCredits.js b/src/resources/TestHelpers/Treasury/ReceivedCredits.js index 8c3e5f0286..53614059ca 100644 --- a/src/resources/TestHelpers/Treasury/ReceivedCredits.js +++ b/src/resources/TestHelpers/Treasury/ReceivedCredits.js @@ -6,10 +6,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/received_credits', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/test_helpers/treasury/received_credits', }), }); diff --git a/src/resources/TestHelpers/Treasury/ReceivedDebits.js b/src/resources/TestHelpers/Treasury/ReceivedDebits.js index e25dc03bd2..e19cf15581 100644 --- a/src/resources/TestHelpers/Treasury/ReceivedDebits.js +++ b/src/resources/TestHelpers/Treasury/ReceivedDebits.js @@ -6,10 +6,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'test_helpers/treasury/received_debits', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/test_helpers/treasury/received_debits', }), }); diff --git a/src/resources/Tokens.js b/src/resources/Tokens.js index 76e4d33774..b1a5ae070f 100644 --- a/src/resources/Tokens.js +++ b/src/resources/Tokens.js @@ -6,15 +6,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'tokens', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/tokens', }), retrieve: stripeMethod({ method: 'GET', - path: '/{token}', + fullPath: '/v1/tokens/{token}', }), }); diff --git a/src/resources/Topups.js b/src/resources/Topups.js index e65fe5d14a..31c005d946 100644 --- a/src/resources/Topups.js +++ b/src/resources/Topups.js @@ -6,31 +6,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'topups', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/topups', }), retrieve: stripeMethod({ method: 'GET', - path: '/{topup}', + fullPath: '/v1/topups/{topup}', }), update: stripeMethod({ method: 'POST', - path: '/{topup}', + fullPath: '/v1/topups/{topup}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/topups', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{topup}/cancel', + fullPath: '/v1/topups/{topup}/cancel', }), }); diff --git a/src/resources/Transfers.js b/src/resources/Transfers.js index 656128c392..743c887335 100644 --- a/src/resources/Transfers.js +++ b/src/resources/Transfers.js @@ -6,47 +6,45 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'transfers', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/transfers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{transfer}', + fullPath: '/v1/transfers/{transfer}', }), update: stripeMethod({ method: 'POST', - path: '/{transfer}', + fullPath: '/v1/transfers/{transfer}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/transfers', methodType: 'list', }), createReversal: stripeMethod({ method: 'POST', - path: '/{id}/reversals', + fullPath: '/v1/transfers/{id}/reversals', }), retrieveReversal: stripeMethod({ method: 'GET', - path: '/{transfer}/reversals/{id}', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', }), updateReversal: stripeMethod({ method: 'POST', - path: '/{transfer}/reversals/{id}', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', }), listReversals: stripeMethod({ method: 'GET', - path: '/{id}/reversals', + fullPath: '/v1/transfers/{id}/reversals', methodType: 'list', }), }); diff --git a/src/resources/Treasury/CreditReversals.js b/src/resources/Treasury/CreditReversals.js index 9039b816a2..952693666c 100644 --- a/src/resources/Treasury/CreditReversals.js +++ b/src/resources/Treasury/CreditReversals.js @@ -6,21 +6,19 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/credit_reversals', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/credit_reversals', }), retrieve: stripeMethod({ method: 'GET', - path: '/{creditReversal}', + fullPath: '/v1/treasury/credit_reversals/{credit_reversal}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/credit_reversals', methodType: 'list', }), }); diff --git a/src/resources/Treasury/DebitReversals.js b/src/resources/Treasury/DebitReversals.js index f95bfe5372..abbab8694b 100644 --- a/src/resources/Treasury/DebitReversals.js +++ b/src/resources/Treasury/DebitReversals.js @@ -6,21 +6,19 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/debit_reversals', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/debit_reversals', }), retrieve: stripeMethod({ method: 'GET', - path: '/{debitReversal}', + fullPath: '/v1/treasury/debit_reversals/{debit_reversal}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/debit_reversals', methodType: 'list', }), }); diff --git a/src/resources/Treasury/FinancialAccounts.js b/src/resources/Treasury/FinancialAccounts.js index a30b1273b6..0a1a47ba14 100644 --- a/src/resources/Treasury/FinancialAccounts.js +++ b/src/resources/Treasury/FinancialAccounts.js @@ -6,36 +6,34 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/financial_accounts', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/financial_accounts', }), retrieve: stripeMethod({ method: 'GET', - path: '/{financialAccount}', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', }), update: stripeMethod({ method: 'POST', - path: '/{financialAccount}', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/financial_accounts', methodType: 'list', }), retrieveFeatures: stripeMethod({ method: 'GET', - path: '/{financialAccount}/features', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', }), updateFeatures: stripeMethod({ method: 'POST', - path: '/{financialAccount}/features', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', }), }); diff --git a/src/resources/Treasury/InboundTransfers.js b/src/resources/Treasury/InboundTransfers.js index 468adba0e7..84ecb300f7 100644 --- a/src/resources/Treasury/InboundTransfers.js +++ b/src/resources/Treasury/InboundTransfers.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/inbound_transfers', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/inbound_transfers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/inbound_transfers/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/inbound_transfers', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{inboundTransfer}/cancel', + fullPath: '/v1/treasury/inbound_transfers/{inbound_transfer}/cancel', }), }); diff --git a/src/resources/Treasury/OutboundPayments.js b/src/resources/Treasury/OutboundPayments.js index 5d08eaad0d..b4c6191816 100644 --- a/src/resources/Treasury/OutboundPayments.js +++ b/src/resources/Treasury/OutboundPayments.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/outbound_payments', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/outbound_payments', }), retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/outbound_payments/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/outbound_payments', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{id}/cancel', + fullPath: '/v1/treasury/outbound_payments/{id}/cancel', }), }); diff --git a/src/resources/Treasury/OutboundTransfers.js b/src/resources/Treasury/OutboundTransfers.js index 40d72465dd..b5dfa874e9 100644 --- a/src/resources/Treasury/OutboundTransfers.js +++ b/src/resources/Treasury/OutboundTransfers.js @@ -6,26 +6,24 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/outbound_transfers', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/treasury/outbound_transfers', }), retrieve: stripeMethod({ method: 'GET', - path: '/{outboundTransfer}', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/outbound_transfers', methodType: 'list', }), cancel: stripeMethod({ method: 'POST', - path: '/{outboundTransfer}/cancel', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}/cancel', }), }); diff --git a/src/resources/Treasury/ReceivedCredits.js b/src/resources/Treasury/ReceivedCredits.js index 98b11b1699..160f659c19 100644 --- a/src/resources/Treasury/ReceivedCredits.js +++ b/src/resources/Treasury/ReceivedCredits.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/received_credits', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/received_credits/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/received_credits', methodType: 'list', }), }); diff --git a/src/resources/Treasury/ReceivedDebits.js b/src/resources/Treasury/ReceivedDebits.js index c472144aa9..b946b42ee9 100644 --- a/src/resources/Treasury/ReceivedDebits.js +++ b/src/resources/Treasury/ReceivedDebits.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/received_debits', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/received_debits/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/received_debits', methodType: 'list', }), }); diff --git a/src/resources/Treasury/TransactionEntries.js b/src/resources/Treasury/TransactionEntries.js index a52c432d68..067109bd81 100644 --- a/src/resources/Treasury/TransactionEntries.js +++ b/src/resources/Treasury/TransactionEntries.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/transaction_entries', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/transaction_entries/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/transaction_entries', methodType: 'list', }), }); diff --git a/src/resources/Treasury/Transactions.js b/src/resources/Treasury/Transactions.js index a810413116..db1c5788f3 100644 --- a/src/resources/Treasury/Transactions.js +++ b/src/resources/Treasury/Transactions.js @@ -6,16 +6,14 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'treasury/transactions', - retrieve: stripeMethod({ method: 'GET', - path: '/{id}', + fullPath: '/v1/treasury/transactions/{id}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/treasury/transactions', methodType: 'list', }), }); diff --git a/src/resources/WebhookEndpoints.js b/src/resources/WebhookEndpoints.js index 2f73d65031..b98d09e906 100644 --- a/src/resources/WebhookEndpoints.js +++ b/src/resources/WebhookEndpoints.js @@ -6,31 +6,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - path: 'webhook_endpoints', - create: stripeMethod({ method: 'POST', - path: '', + fullPath: '/v1/webhook_endpoints', }), retrieve: stripeMethod({ method: 'GET', - path: '/{webhookEndpoint}', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', }), update: stripeMethod({ method: 'POST', - path: '/{webhookEndpoint}', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', }), list: stripeMethod({ method: 'GET', - path: '', + fullPath: '/v1/webhook_endpoints', methodType: 'list', }), del: stripeMethod({ method: 'DELETE', - path: '/{webhookEndpoint}', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', }), }); diff --git a/test/StripeResource.spec.js b/test/StripeResource.spec.js index 5b7217d2f2..d852c9f95f 100644 --- a/test/StripeResource.spec.js +++ b/test/StripeResource.spec.js @@ -22,23 +22,33 @@ const { describe('StripeResource', () => { describe('createResourcePathWithSymbols', () => { + let testResource; + before(() => { + testResource = new (StripeResource.extend({ + path: 'widgets', + create: stripeMethod({ + method: 'POST', + path: '', + }), + }))(stripe); + }); it('Generates a path when there is a symbol', () => { - stripe.invoices.create({}); - const path = stripe.invoices.createResourcePathWithSymbols('{id}'); - expect(path).to.equal('/invoices/{id}'); + testResource.create({}); + const path = testResource.createResourcePathWithSymbols('{id}'); + expect(path).to.equal('/widgets/{id}'); }); it('Generates a path when there is nothing beyond the resource path', () => { - stripe.invoices.create({}); - const path = stripe.invoices.createResourcePathWithSymbols(''); + testResource.create({}); + const path = testResource.createResourcePathWithSymbols(''); // This explicitly shouldn't have a trailing slash. - expect(path).to.equal('/invoices'); + expect(path).to.equal('/widgets'); }); it('Handles accidental double slashes', () => { - stripe.invoices.create({}); - const path = stripe.invoices.createResourcePathWithSymbols('/{id}'); - expect(path).to.equal('/invoices/{id}'); + testResource.create({}); + const path = testResource.createResourcePathWithSymbols('/{id}'); + expect(path).to.equal('/widgets/{id}'); }); }); diff --git a/types/2022-08-01/Checkout/Sessions.d.ts b/types/2022-08-01/Checkout/Sessions.d.ts index 4cb6608e7b..2889b800a6 100644 --- a/types/2022-08-01/Checkout/Sessions.d.ts +++ b/types/2022-08-01/Checkout/Sessions.d.ts @@ -379,7 +379,7 @@ declare module 'stripe' { interface TaxId { /** - * The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `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`, `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`, or `unknown` + * The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `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`, `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`, or `unknown` */ type: TaxId.Type; @@ -405,6 +405,7 @@ declare module 'stripe' { | 'ca_qst' | 'ch_vat' | 'cl_tin' + | 'eg_tin' | 'es_cif' | 'eu_oss_vat' | 'eu_vat' @@ -428,6 +429,7 @@ declare module 'stripe' { | 'my_sst' | 'no_vat' | 'nz_gst' + | 'ph_tin' | 'ru_inn' | 'ru_kpp' | 'sa_vat' @@ -435,6 +437,7 @@ declare module 'stripe' { | 'sg_uen' | 'si_tin' | 'th_vat' + | 'tr_tin' | 'tw_vat' | 'ua_vat' | 'unknown' diff --git a/types/2022-08-01/Customers.d.ts b/types/2022-08-01/Customers.d.ts index eef4074b44..8af9d27b91 100644 --- a/types/2022-08-01/Customers.d.ts +++ b/types/2022-08-01/Customers.d.ts @@ -496,7 +496,7 @@ declare module 'stripe' { interface TaxIdDatum { /** - * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` + * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ph_tin`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` */ type: TaxIdDatum.Type; @@ -522,6 +522,7 @@ declare module 'stripe' { | 'ca_qst' | 'ch_vat' | 'cl_tin' + | 'eg_tin' | 'es_cif' | 'eu_oss_vat' | 'eu_vat' @@ -545,6 +546,7 @@ declare module 'stripe' { | 'my_sst' | 'no_vat' | 'nz_gst' + | 'ph_tin' | 'ru_inn' | 'ru_kpp' | 'sa_vat' @@ -552,6 +554,7 @@ declare module 'stripe' { | 'sg_uen' | 'si_tin' | 'th_vat' + | 'tr_tin' | 'tw_vat' | 'ua_vat' | 'us_ein' diff --git a/types/2022-08-01/Invoices.d.ts b/types/2022-08-01/Invoices.d.ts index 07bc5b551d..90cb2573a5 100644 --- a/types/2022-08-01/Invoices.d.ts +++ b/types/2022-08-01/Invoices.d.ts @@ -474,7 +474,7 @@ declare module 'stripe' { interface CustomerTaxId { /** - * The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `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`, `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`, or `unknown` + * The type of the tax ID, one of `eu_vat`, `br_cnpj`, `br_cpf`, `eu_oss_vat`, `gb_vat`, `nz_gst`, `au_abn`, `au_arn`, `in_gst`, `no_vat`, `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`, `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`, or `unknown` */ type: CustomerTaxId.Type; @@ -500,6 +500,7 @@ declare module 'stripe' { | 'ca_qst' | 'ch_vat' | 'cl_tin' + | 'eg_tin' | 'es_cif' | 'eu_oss_vat' | 'eu_vat' @@ -523,6 +524,7 @@ declare module 'stripe' { | 'my_sst' | 'no_vat' | 'nz_gst' + | 'ph_tin' | 'ru_inn' | 'ru_kpp' | 'sa_vat' @@ -530,6 +532,7 @@ declare module 'stripe' { | 'sg_uen' | 'si_tin' | 'th_vat' + | 'tr_tin' | 'tw_vat' | 'ua_vat' | 'unknown' @@ -2079,7 +2082,7 @@ declare module 'stripe' { interface TaxId { /** - * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` + * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ph_tin`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` */ type: TaxId.Type; @@ -2105,6 +2108,7 @@ declare module 'stripe' { | 'ca_qst' | 'ch_vat' | 'cl_tin' + | 'eg_tin' | 'es_cif' | 'eu_oss_vat' | 'eu_vat' @@ -2128,6 +2132,7 @@ declare module 'stripe' { | 'my_sst' | 'no_vat' | 'nz_gst' + | 'ph_tin' | 'ru_inn' | 'ru_kpp' | 'sa_vat' @@ -2135,6 +2140,7 @@ declare module 'stripe' { | 'sg_uen' | 'si_tin' | 'th_vat' + | 'tr_tin' | 'tw_vat' | 'ua_vat' | 'us_ein' @@ -2641,7 +2647,7 @@ declare module 'stripe' { interface TaxId { /** - * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` + * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ph_tin`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` */ type: TaxId.Type; @@ -2667,6 +2673,7 @@ declare module 'stripe' { | 'ca_qst' | 'ch_vat' | 'cl_tin' + | 'eg_tin' | 'es_cif' | 'eu_oss_vat' | 'eu_vat' @@ -2690,6 +2697,7 @@ declare module 'stripe' { | 'my_sst' | 'no_vat' | 'nz_gst' + | 'ph_tin' | 'ru_inn' | 'ru_kpp' | 'sa_vat' @@ -2697,6 +2705,7 @@ declare module 'stripe' { | 'sg_uen' | 'si_tin' | 'th_vat' + | 'tr_tin' | 'tw_vat' | 'ua_vat' | 'us_ein' diff --git a/types/2022-08-01/PaymentIntents.d.ts b/types/2022-08-01/PaymentIntents.d.ts index c21e878aff..83b8bd9406 100644 --- a/types/2022-08-01/PaymentIntents.d.ts +++ b/types/2022-08-01/PaymentIntents.d.ts @@ -76,7 +76,7 @@ declare module 'stripe' { /** * Charges that were created by this PaymentIntent, if any. */ - charges: ApiList; + charges?: ApiList; /** * The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key. diff --git a/types/2022-08-01/TaxIds.d.ts b/types/2022-08-01/TaxIds.d.ts index 9632015906..dbaae1a0e2 100644 --- a/types/2022-08-01/TaxIds.d.ts +++ b/types/2022-08-01/TaxIds.d.ts @@ -42,7 +42,7 @@ declare module 'stripe' { livemode: boolean; /** - * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat`. Note that some legacy tax IDs have type `unknown` + * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ph_tin`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat`. Note that some legacy tax IDs have type `unknown` */ type: TaxId.Type; @@ -73,6 +73,7 @@ declare module 'stripe' { | 'ca_qst' | 'ch_vat' | 'cl_tin' + | 'eg_tin' | 'es_cif' | 'eu_oss_vat' | 'eu_vat' @@ -96,6 +97,7 @@ declare module 'stripe' { | 'my_sst' | 'no_vat' | 'nz_gst' + | 'ph_tin' | 'ru_inn' | 'ru_kpp' | 'sa_vat' @@ -103,6 +105,7 @@ declare module 'stripe' { | 'sg_uen' | 'si_tin' | 'th_vat' + | 'tr_tin' | 'tw_vat' | 'ua_vat' | 'unknown' @@ -153,7 +156,7 @@ declare module 'stripe' { interface TaxIdCreateParams { /** - * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` + * Type of the tax ID, one of `ae_trn`, `au_abn`, `au_arn`, `bg_uic`, `br_cnpj`, `br_cpf`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `ch_vat`, `cl_tin`, `eg_tin`, `es_cif`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `hk_br`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kr_brn`, `li_uid`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `no_vat`, `nz_gst`, `ph_tin`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `th_vat`, `tr_tin`, `tw_vat`, `ua_vat`, `us_ein`, or `za_vat` */ type: TaxIdCreateParams.Type; @@ -184,6 +187,7 @@ declare module 'stripe' { | 'ca_qst' | 'ch_vat' | 'cl_tin' + | 'eg_tin' | 'es_cif' | 'eu_oss_vat' | 'eu_vat' @@ -207,6 +211,7 @@ declare module 'stripe' { | 'my_sst' | 'no_vat' | 'nz_gst' + | 'ph_tin' | 'ru_inn' | 'ru_kpp' | 'sa_vat' @@ -214,6 +219,7 @@ declare module 'stripe' { | 'sg_uen' | 'si_tin' | 'th_vat' + | 'tr_tin' | 'tw_vat' | 'ua_vat' | 'us_ein' diff --git a/types/2022-08-01/index.d.ts b/types/2022-08-01/index.d.ts index 57f7591dde..d53f23723c 100644 --- a/types/2022-08-01/index.d.ts +++ b/types/2022-08-01/index.d.ts @@ -132,7 +132,7 @@ declare module 'stripe' { export class Stripe { static Stripe: typeof Stripe; - constructor(apiKey: string, config?: Stripe.StripeConfig); + constructor(apiKey: string, config: Stripe.StripeConfig); StripeResource: Stripe.StripeResource; From c31c07ed61dfd7135e89401aecdb5346f06fd2b4 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Mon, 7 Nov 2022 10:41:21 -0800 Subject: [PATCH 10/16] Update LatestApiVersion and types reference --- types/lib.d.ts | 2 +- types/test/typescriptTest.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/lib.d.ts b/types/lib.d.ts index cf4b19e211..0cc5e43bfd 100644 --- a/types/lib.d.ts +++ b/types/lib.d.ts @@ -52,7 +52,7 @@ declare module 'stripe' { }; static MAX_BUFFERED_REQUEST_METRICS: number; } - export type LatestApiVersion = '2022-08-01'; + export type LatestApiVersion = '2022-11-09'; export type HttpAgent = Agent; export type HttpProtocol = 'http' | 'https'; diff --git a/types/test/typescriptTest.ts b/types/test/typescriptTest.ts index 42d0fec726..63a08d306b 100644 --- a/types/test/typescriptTest.ts +++ b/types/test/typescriptTest.ts @@ -5,11 +5,11 @@ * and to perform a basic sanity check that types are exported as intended. */ -/// +/// import Stripe from 'stripe'; let stripe = new Stripe('sk_test_123', { - apiVersion: '2022-08-01', + apiVersion: '2022-11-09', }); // @ts-ignore lazily ignore apiVersion requirement. @@ -27,7 +27,7 @@ stripe = new Stripe('sk_test_123', { // Check config object. stripe = new Stripe('sk_test_123', { - apiVersion: '2022-08-01', + apiVersion: '2022-11-09', typescript: true, maxNetworkRetries: 1, timeout: 1000, From c26c02b050c8a98bd79442a071b228230ba3fbfd Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 8 Nov 2022 11:54:12 -0800 Subject: [PATCH 11/16] Update all references to latest API version --- API_VERSION | 2 +- README.md | 2 +- examples/webhook-signing/typescript-node-express/express-ts.ts | 2 +- lib/apiVersion.js | 2 +- package.json | 2 +- src/apiVersion.js | 2 +- types/test/typescriptTest.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/API_VERSION b/API_VERSION index 0366ceb901..439033dac5 100644 --- a/API_VERSION +++ b/API_VERSION @@ -1 +1 @@ -2022-08-01 +2022-11-09 diff --git a/README.md b/README.md index cfaeab81ab..e335a74a93 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ and instantiate it as `new Stripe()` with the latest API version. ```ts import Stripe from 'stripe'; const stripe = new Stripe('sk_test_...', { - apiVersion: '2022-08-01', + apiVersion: '2022-11-09', }); const createCustomer = async () => { diff --git a/examples/webhook-signing/typescript-node-express/express-ts.ts b/examples/webhook-signing/typescript-node-express/express-ts.ts index c0a4c1d4b7..f3d901e75b 100644 --- a/examples/webhook-signing/typescript-node-express/express-ts.ts +++ b/examples/webhook-signing/typescript-node-express/express-ts.ts @@ -5,7 +5,7 @@ import env from 'dotenv'; env.config(); const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { - apiVersion: '2022-08-01', + apiVersion: '2022-11-09', }); const webhookSecret: string = process.env.STRIPE_WEBHOOK_SECRET; diff --git a/lib/apiVersion.js b/lib/apiVersion.js index 518f4476ab..eab32ae80a 100644 --- a/lib/apiVersion.js +++ b/lib/apiVersion.js @@ -1,3 +1,3 @@ 'use strict'; // File generated from our OpenAPI spec -module.exports = {ApiVersion: '2022-08-01'}; +module.exports = {ApiVersion: '2022-11-09'}; diff --git a/package.json b/package.json index 8d72bfb3a8..6864ef8527 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node": ">=12.*" }, "main": "lib/stripe.js", - "types": "types/2022-08-01/index.d.ts", + "types": "types/2022-11-09/index.d.ts", "devDependencies": { "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", diff --git a/src/apiVersion.js b/src/apiVersion.js index 704a3619eb..8c1d730e34 100644 --- a/src/apiVersion.js +++ b/src/apiVersion.js @@ -1,3 +1,3 @@ // File generated from our OpenAPI spec -module.exports = {ApiVersion: '2022-08-01'}; +module.exports = {ApiVersion: '2022-11-09'}; diff --git a/types/test/typescriptTest.ts b/types/test/typescriptTest.ts index 63a08d306b..10d483e74a 100644 --- a/types/test/typescriptTest.ts +++ b/types/test/typescriptTest.ts @@ -45,7 +45,7 @@ stripe = new Stripe('sk_test_123', { description: 'test', }; const opts: Stripe.RequestOptions = { - apiVersion: '2022-08-01', + apiVersion: '2022-11-09', }; const customer: Stripe.Customer = await stripe.customers.create(params, opts); From 009b592b7dcd27b72ecab718f96f4637317fe4be Mon Sep 17 00:00:00 2001 From: Annie Li Date: Wed, 9 Nov 2022 13:07:17 -0800 Subject: [PATCH 12/16] Regenerate --- lib/apiVersion.js | 2 +- src/apiVersion.js | 2 +- types/{2022-08-01 => 2022-11-09}/AccountLinks.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Accounts.d.ts | 0 types/{2022-08-01 => 2022-11-09}/ApplePayDomains.d.ts | 0 types/{2022-08-01 => 2022-11-09}/ApplicationFees.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Applications.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Apps/Secrets.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Balance.d.ts | 0 .../BalanceTransactions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/BankAccounts.d.ts | 0 .../BillingPortal/Configurations.d.ts | 0 .../BillingPortal/Sessions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Capabilities.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Cards.d.ts | 0 types/{2022-08-01 => 2022-11-09}/CashBalances.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Charges.d.ts | 2 +- .../{2022-08-01 => 2022-11-09}/Checkout/Sessions.d.ts | 10 ---------- .../ConnectCollectionTransfers.d.ts | 0 types/{2022-08-01 => 2022-11-09}/CountrySpecs.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Coupons.d.ts | 0 .../CreditNoteLineItems.d.ts | 0 types/{2022-08-01 => 2022-11-09}/CreditNotes.d.ts | 0 .../CustomerBalanceTransactions.d.ts | 0 .../CustomerCashBalanceTransactions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/CustomerSources.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Customers.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Discounts.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Disputes.d.ts | 0 types/{2022-08-01 => 2022-11-09}/EphemeralKeys.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Events.d.ts | 0 types/{2022-08-01 => 2022-11-09}/ExchangeRates.d.ts | 0 types/{2022-08-01 => 2022-11-09}/ExternalAccounts.d.ts | 0 types/{2022-08-01 => 2022-11-09}/FeeRefunds.d.ts | 0 types/{2022-08-01 => 2022-11-09}/FileLinks.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Files.d.ts | 0 .../FinancialConnections/AccountOwners.d.ts | 0 .../FinancialConnections/AccountOwnerships.d.ts | 0 .../FinancialConnections/Accounts.d.ts | 0 .../FinancialConnections/Sessions.d.ts | 0 .../FundingInstructions.d.ts | 0 .../Identity/VerificationReports.d.ts | 0 .../Identity/VerificationSessions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/InvoiceItems.d.ts | 0 types/{2022-08-01 => 2022-11-09}/InvoiceLineItems.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Invoices.d.ts | 0 .../Issuing/Authorizations.d.ts | 0 .../Issuing/Cardholders.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Issuing/Cards.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Issuing/Disputes.d.ts | 0 .../Issuing/Transactions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/LineItems.d.ts | 0 types/{2022-08-01 => 2022-11-09}/LoginLinks.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Mandates.d.ts | 0 types/{2022-08-01 => 2022-11-09}/PaymentIntents.d.ts | 10 +++++----- types/{2022-08-01 => 2022-11-09}/PaymentLinks.d.ts | 0 types/{2022-08-01 => 2022-11-09}/PaymentMethods.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Payouts.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Persons.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Plans.d.ts | 0 types/{2022-08-01 => 2022-11-09}/PlatformTaxFees.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Prices.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Products.d.ts | 0 types/{2022-08-01 => 2022-11-09}/PromotionCodes.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Quotes.d.ts | 0 .../Radar/EarlyFraudWarnings.d.ts | 0 .../Radar/ValueListItems.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Radar/ValueLists.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Refunds.d.ts | 0 .../Reporting/ReportRuns.d.ts | 0 .../Reporting/ReportTypes.d.ts | 0 .../ReserveTransactions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Reviews.d.ts | 0 types/{2022-08-01 => 2022-11-09}/SetupAttempts.d.ts | 0 types/{2022-08-01 => 2022-11-09}/SetupIntents.d.ts | 0 types/{2022-08-01 => 2022-11-09}/ShippingRates.d.ts | 0 .../Sigma/ScheduledQueryRuns.d.ts | 0 .../SourceMandateNotifications.d.ts | 0 .../{2022-08-01 => 2022-11-09}/SourceTransactions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Sources.d.ts | 0 .../{2022-08-01 => 2022-11-09}/SubscriptionItems.d.ts | 0 .../SubscriptionSchedules.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Subscriptions.d.ts | 0 types/{2022-08-01 => 2022-11-09}/TaxCodes.d.ts | 0 .../TaxDeductedAtSources.d.ts | 0 types/{2022-08-01 => 2022-11-09}/TaxIds.d.ts | 0 types/{2022-08-01 => 2022-11-09}/TaxRates.d.ts | 0 .../Terminal/Configurations.d.ts | 0 .../Terminal/ConnectionTokens.d.ts | 0 .../{2022-08-01 => 2022-11-09}/Terminal/Locations.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Terminal/Readers.d.ts | 0 .../TestHelpers/Customers.d.ts | 0 .../TestHelpers/Issuing/Cards.d.ts | 0 .../TestHelpers/Refunds.d.ts | 0 .../TestHelpers/Terminal/Readers.d.ts | 0 .../TestHelpers/TestClocks.d.ts | 0 .../TestHelpers/Treasury/InboundTransfers.d.ts | 0 .../TestHelpers/Treasury/OutboundPayments.d.ts | 0 .../TestHelpers/Treasury/OutboundTransfers.d.ts | 0 .../TestHelpers/Treasury/ReceivedCredits.d.ts | 0 .../TestHelpers/Treasury/ReceivedDebits.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Tokens.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Topups.d.ts | 0 .../{2022-08-01 => 2022-11-09}/TransferReversals.d.ts | 0 types/{2022-08-01 => 2022-11-09}/Transfers.d.ts | 0 .../Treasury/CreditReversals.d.ts | 0 .../Treasury/DebitReversals.d.ts | 0 .../Treasury/FinancialAccountFeatures.d.ts | 0 .../Treasury/FinancialAccounts.d.ts | 0 .../Treasury/InboundTransfers.d.ts | 0 .../Treasury/OutboundPayments.d.ts | 0 .../Treasury/OutboundTransfers.d.ts | 0 .../Treasury/ReceivedCredits.d.ts | 0 .../Treasury/ReceivedDebits.d.ts | 0 .../Treasury/TransactionEntries.d.ts | 0 .../Treasury/Transactions.d.ts | 0 .../UsageRecordSummaries.d.ts | 0 types/{2022-08-01 => 2022-11-09}/UsageRecords.d.ts | 0 types/{2022-08-01 => 2022-11-09}/WebhookEndpoints.d.ts | 3 ++- types/{2022-08-01 => 2022-11-09}/index.d.ts | 0 120 files changed, 10 insertions(+), 19 deletions(-) rename types/{2022-08-01 => 2022-11-09}/AccountLinks.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Accounts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/ApplePayDomains.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/ApplicationFees.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Applications.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Apps/Secrets.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Balance.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/BalanceTransactions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/BankAccounts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/BillingPortal/Configurations.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/BillingPortal/Sessions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Capabilities.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Cards.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/CashBalances.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Charges.d.ts (99%) rename types/{2022-08-01 => 2022-11-09}/Checkout/Sessions.d.ts (99%) rename types/{2022-08-01 => 2022-11-09}/ConnectCollectionTransfers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/CountrySpecs.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Coupons.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/CreditNoteLineItems.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/CreditNotes.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/CustomerBalanceTransactions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/CustomerCashBalanceTransactions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/CustomerSources.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Customers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Discounts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Disputes.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/EphemeralKeys.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Events.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/ExchangeRates.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/ExternalAccounts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/FeeRefunds.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/FileLinks.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Files.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/FinancialConnections/AccountOwners.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/FinancialConnections/AccountOwnerships.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/FinancialConnections/Accounts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/FinancialConnections/Sessions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/FundingInstructions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Identity/VerificationReports.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Identity/VerificationSessions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/InvoiceItems.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/InvoiceLineItems.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Invoices.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Issuing/Authorizations.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Issuing/Cardholders.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Issuing/Cards.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Issuing/Disputes.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Issuing/Transactions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/LineItems.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/LoginLinks.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Mandates.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/PaymentIntents.d.ts (99%) rename types/{2022-08-01 => 2022-11-09}/PaymentLinks.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/PaymentMethods.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Payouts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Persons.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Plans.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/PlatformTaxFees.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Prices.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Products.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/PromotionCodes.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Quotes.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Radar/EarlyFraudWarnings.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Radar/ValueListItems.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Radar/ValueLists.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Refunds.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Reporting/ReportRuns.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Reporting/ReportTypes.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/ReserveTransactions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Reviews.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/SetupAttempts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/SetupIntents.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/ShippingRates.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Sigma/ScheduledQueryRuns.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/SourceMandateNotifications.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/SourceTransactions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Sources.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/SubscriptionItems.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/SubscriptionSchedules.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Subscriptions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TaxCodes.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TaxDeductedAtSources.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TaxIds.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TaxRates.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Terminal/Configurations.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Terminal/ConnectionTokens.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Terminal/Locations.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Terminal/Readers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Customers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Issuing/Cards.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Refunds.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Terminal/Readers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/TestClocks.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Treasury/InboundTransfers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Treasury/OutboundPayments.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Treasury/OutboundTransfers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Treasury/ReceivedCredits.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TestHelpers/Treasury/ReceivedDebits.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Tokens.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Topups.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/TransferReversals.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Transfers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/CreditReversals.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/DebitReversals.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/FinancialAccountFeatures.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/FinancialAccounts.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/InboundTransfers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/OutboundPayments.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/OutboundTransfers.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/ReceivedCredits.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/ReceivedDebits.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/TransactionEntries.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/Treasury/Transactions.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/UsageRecordSummaries.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/UsageRecords.d.ts (100%) rename types/{2022-08-01 => 2022-11-09}/WebhookEndpoints.d.ts (99%) rename types/{2022-08-01 => 2022-11-09}/index.d.ts (100%) diff --git a/lib/apiVersion.js b/lib/apiVersion.js index 518f4476ab..eab32ae80a 100644 --- a/lib/apiVersion.js +++ b/lib/apiVersion.js @@ -1,3 +1,3 @@ 'use strict'; // File generated from our OpenAPI spec -module.exports = {ApiVersion: '2022-08-01'}; +module.exports = {ApiVersion: '2022-11-09'}; diff --git a/src/apiVersion.js b/src/apiVersion.js index 704a3619eb..8c1d730e34 100644 --- a/src/apiVersion.js +++ b/src/apiVersion.js @@ -1,3 +1,3 @@ // File generated from our OpenAPI spec -module.exports = {ApiVersion: '2022-08-01'}; +module.exports = {ApiVersion: '2022-11-09'}; diff --git a/types/2022-08-01/AccountLinks.d.ts b/types/2022-11-09/AccountLinks.d.ts similarity index 100% rename from types/2022-08-01/AccountLinks.d.ts rename to types/2022-11-09/AccountLinks.d.ts diff --git a/types/2022-08-01/Accounts.d.ts b/types/2022-11-09/Accounts.d.ts similarity index 100% rename from types/2022-08-01/Accounts.d.ts rename to types/2022-11-09/Accounts.d.ts diff --git a/types/2022-08-01/ApplePayDomains.d.ts b/types/2022-11-09/ApplePayDomains.d.ts similarity index 100% rename from types/2022-08-01/ApplePayDomains.d.ts rename to types/2022-11-09/ApplePayDomains.d.ts diff --git a/types/2022-08-01/ApplicationFees.d.ts b/types/2022-11-09/ApplicationFees.d.ts similarity index 100% rename from types/2022-08-01/ApplicationFees.d.ts rename to types/2022-11-09/ApplicationFees.d.ts diff --git a/types/2022-08-01/Applications.d.ts b/types/2022-11-09/Applications.d.ts similarity index 100% rename from types/2022-08-01/Applications.d.ts rename to types/2022-11-09/Applications.d.ts diff --git a/types/2022-08-01/Apps/Secrets.d.ts b/types/2022-11-09/Apps/Secrets.d.ts similarity index 100% rename from types/2022-08-01/Apps/Secrets.d.ts rename to types/2022-11-09/Apps/Secrets.d.ts diff --git a/types/2022-08-01/Balance.d.ts b/types/2022-11-09/Balance.d.ts similarity index 100% rename from types/2022-08-01/Balance.d.ts rename to types/2022-11-09/Balance.d.ts diff --git a/types/2022-08-01/BalanceTransactions.d.ts b/types/2022-11-09/BalanceTransactions.d.ts similarity index 100% rename from types/2022-08-01/BalanceTransactions.d.ts rename to types/2022-11-09/BalanceTransactions.d.ts diff --git a/types/2022-08-01/BankAccounts.d.ts b/types/2022-11-09/BankAccounts.d.ts similarity index 100% rename from types/2022-08-01/BankAccounts.d.ts rename to types/2022-11-09/BankAccounts.d.ts diff --git a/types/2022-08-01/BillingPortal/Configurations.d.ts b/types/2022-11-09/BillingPortal/Configurations.d.ts similarity index 100% rename from types/2022-08-01/BillingPortal/Configurations.d.ts rename to types/2022-11-09/BillingPortal/Configurations.d.ts diff --git a/types/2022-08-01/BillingPortal/Sessions.d.ts b/types/2022-11-09/BillingPortal/Sessions.d.ts similarity index 100% rename from types/2022-08-01/BillingPortal/Sessions.d.ts rename to types/2022-11-09/BillingPortal/Sessions.d.ts diff --git a/types/2022-08-01/Capabilities.d.ts b/types/2022-11-09/Capabilities.d.ts similarity index 100% rename from types/2022-08-01/Capabilities.d.ts rename to types/2022-11-09/Capabilities.d.ts diff --git a/types/2022-08-01/Cards.d.ts b/types/2022-11-09/Cards.d.ts similarity index 100% rename from types/2022-08-01/Cards.d.ts rename to types/2022-11-09/Cards.d.ts diff --git a/types/2022-08-01/CashBalances.d.ts b/types/2022-11-09/CashBalances.d.ts similarity index 100% rename from types/2022-08-01/CashBalances.d.ts rename to types/2022-11-09/CashBalances.d.ts diff --git a/types/2022-08-01/Charges.d.ts b/types/2022-11-09/Charges.d.ts similarity index 99% rename from types/2022-08-01/Charges.d.ts rename to types/2022-11-09/Charges.d.ts index 752f3b41ca..177f810fa7 100644 --- a/types/2022-08-01/Charges.d.ts +++ b/types/2022-11-09/Charges.d.ts @@ -204,7 +204,7 @@ declare module 'stripe' { /** * A list of refunds that have been applied to the charge. */ - refunds?: ApiList; + refunds: ApiList | null; /** * ID of the review associated with this charge if one exists. diff --git a/types/2022-08-01/Checkout/Sessions.d.ts b/types/2022-11-09/Checkout/Sessions.d.ts similarity index 99% rename from types/2022-08-01/Checkout/Sessions.d.ts rename to types/2022-11-09/Checkout/Sessions.d.ts index 2889b800a6..dc63b7c02a 100644 --- a/types/2022-08-01/Checkout/Sessions.d.ts +++ b/types/2022-11-09/Checkout/Sessions.d.ts @@ -1728,11 +1728,6 @@ declare module 'stripe' { */ adjustable_quantity?: LineItem.AdjustableQuantity; - /** - * [Deprecated] The amount to be collected per unit of the line item. If specified, must also pass `currency` and `name`. - */ - amount?: number; - /** * The [tax rates](https://stripe.com/docs/api/tax_rates) that will be applied to this line item depending on the customer's billing/shipping address. We currently support the following countries: US, GB, AU, and all countries in the EU. */ @@ -2560,11 +2555,6 @@ declare module 'stripe' { * When processing card payments, Stripe also uses `setup_future_usage` to dynamically optimize your payment flow and comply with regional legislation and network rules, such as [SCA](https://stripe.com/docs/strong-customer-authentication). */ setup_future_usage?: 'none'; - - /** - * Confirm that the payer has accepted the P24 terms and conditions. - */ - tos_shown_and_accepted?: boolean; } interface Pix { diff --git a/types/2022-08-01/ConnectCollectionTransfers.d.ts b/types/2022-11-09/ConnectCollectionTransfers.d.ts similarity index 100% rename from types/2022-08-01/ConnectCollectionTransfers.d.ts rename to types/2022-11-09/ConnectCollectionTransfers.d.ts diff --git a/types/2022-08-01/CountrySpecs.d.ts b/types/2022-11-09/CountrySpecs.d.ts similarity index 100% rename from types/2022-08-01/CountrySpecs.d.ts rename to types/2022-11-09/CountrySpecs.d.ts diff --git a/types/2022-08-01/Coupons.d.ts b/types/2022-11-09/Coupons.d.ts similarity index 100% rename from types/2022-08-01/Coupons.d.ts rename to types/2022-11-09/Coupons.d.ts diff --git a/types/2022-08-01/CreditNoteLineItems.d.ts b/types/2022-11-09/CreditNoteLineItems.d.ts similarity index 100% rename from types/2022-08-01/CreditNoteLineItems.d.ts rename to types/2022-11-09/CreditNoteLineItems.d.ts diff --git a/types/2022-08-01/CreditNotes.d.ts b/types/2022-11-09/CreditNotes.d.ts similarity index 100% rename from types/2022-08-01/CreditNotes.d.ts rename to types/2022-11-09/CreditNotes.d.ts diff --git a/types/2022-08-01/CustomerBalanceTransactions.d.ts b/types/2022-11-09/CustomerBalanceTransactions.d.ts similarity index 100% rename from types/2022-08-01/CustomerBalanceTransactions.d.ts rename to types/2022-11-09/CustomerBalanceTransactions.d.ts diff --git a/types/2022-08-01/CustomerCashBalanceTransactions.d.ts b/types/2022-11-09/CustomerCashBalanceTransactions.d.ts similarity index 100% rename from types/2022-08-01/CustomerCashBalanceTransactions.d.ts rename to types/2022-11-09/CustomerCashBalanceTransactions.d.ts diff --git a/types/2022-08-01/CustomerSources.d.ts b/types/2022-11-09/CustomerSources.d.ts similarity index 100% rename from types/2022-08-01/CustomerSources.d.ts rename to types/2022-11-09/CustomerSources.d.ts diff --git a/types/2022-08-01/Customers.d.ts b/types/2022-11-09/Customers.d.ts similarity index 100% rename from types/2022-08-01/Customers.d.ts rename to types/2022-11-09/Customers.d.ts diff --git a/types/2022-08-01/Discounts.d.ts b/types/2022-11-09/Discounts.d.ts similarity index 100% rename from types/2022-08-01/Discounts.d.ts rename to types/2022-11-09/Discounts.d.ts diff --git a/types/2022-08-01/Disputes.d.ts b/types/2022-11-09/Disputes.d.ts similarity index 100% rename from types/2022-08-01/Disputes.d.ts rename to types/2022-11-09/Disputes.d.ts diff --git a/types/2022-08-01/EphemeralKeys.d.ts b/types/2022-11-09/EphemeralKeys.d.ts similarity index 100% rename from types/2022-08-01/EphemeralKeys.d.ts rename to types/2022-11-09/EphemeralKeys.d.ts diff --git a/types/2022-08-01/Events.d.ts b/types/2022-11-09/Events.d.ts similarity index 100% rename from types/2022-08-01/Events.d.ts rename to types/2022-11-09/Events.d.ts diff --git a/types/2022-08-01/ExchangeRates.d.ts b/types/2022-11-09/ExchangeRates.d.ts similarity index 100% rename from types/2022-08-01/ExchangeRates.d.ts rename to types/2022-11-09/ExchangeRates.d.ts diff --git a/types/2022-08-01/ExternalAccounts.d.ts b/types/2022-11-09/ExternalAccounts.d.ts similarity index 100% rename from types/2022-08-01/ExternalAccounts.d.ts rename to types/2022-11-09/ExternalAccounts.d.ts diff --git a/types/2022-08-01/FeeRefunds.d.ts b/types/2022-11-09/FeeRefunds.d.ts similarity index 100% rename from types/2022-08-01/FeeRefunds.d.ts rename to types/2022-11-09/FeeRefunds.d.ts diff --git a/types/2022-08-01/FileLinks.d.ts b/types/2022-11-09/FileLinks.d.ts similarity index 100% rename from types/2022-08-01/FileLinks.d.ts rename to types/2022-11-09/FileLinks.d.ts diff --git a/types/2022-08-01/Files.d.ts b/types/2022-11-09/Files.d.ts similarity index 100% rename from types/2022-08-01/Files.d.ts rename to types/2022-11-09/Files.d.ts diff --git a/types/2022-08-01/FinancialConnections/AccountOwners.d.ts b/types/2022-11-09/FinancialConnections/AccountOwners.d.ts similarity index 100% rename from types/2022-08-01/FinancialConnections/AccountOwners.d.ts rename to types/2022-11-09/FinancialConnections/AccountOwners.d.ts diff --git a/types/2022-08-01/FinancialConnections/AccountOwnerships.d.ts b/types/2022-11-09/FinancialConnections/AccountOwnerships.d.ts similarity index 100% rename from types/2022-08-01/FinancialConnections/AccountOwnerships.d.ts rename to types/2022-11-09/FinancialConnections/AccountOwnerships.d.ts diff --git a/types/2022-08-01/FinancialConnections/Accounts.d.ts b/types/2022-11-09/FinancialConnections/Accounts.d.ts similarity index 100% rename from types/2022-08-01/FinancialConnections/Accounts.d.ts rename to types/2022-11-09/FinancialConnections/Accounts.d.ts diff --git a/types/2022-08-01/FinancialConnections/Sessions.d.ts b/types/2022-11-09/FinancialConnections/Sessions.d.ts similarity index 100% rename from types/2022-08-01/FinancialConnections/Sessions.d.ts rename to types/2022-11-09/FinancialConnections/Sessions.d.ts diff --git a/types/2022-08-01/FundingInstructions.d.ts b/types/2022-11-09/FundingInstructions.d.ts similarity index 100% rename from types/2022-08-01/FundingInstructions.d.ts rename to types/2022-11-09/FundingInstructions.d.ts diff --git a/types/2022-08-01/Identity/VerificationReports.d.ts b/types/2022-11-09/Identity/VerificationReports.d.ts similarity index 100% rename from types/2022-08-01/Identity/VerificationReports.d.ts rename to types/2022-11-09/Identity/VerificationReports.d.ts diff --git a/types/2022-08-01/Identity/VerificationSessions.d.ts b/types/2022-11-09/Identity/VerificationSessions.d.ts similarity index 100% rename from types/2022-08-01/Identity/VerificationSessions.d.ts rename to types/2022-11-09/Identity/VerificationSessions.d.ts diff --git a/types/2022-08-01/InvoiceItems.d.ts b/types/2022-11-09/InvoiceItems.d.ts similarity index 100% rename from types/2022-08-01/InvoiceItems.d.ts rename to types/2022-11-09/InvoiceItems.d.ts diff --git a/types/2022-08-01/InvoiceLineItems.d.ts b/types/2022-11-09/InvoiceLineItems.d.ts similarity index 100% rename from types/2022-08-01/InvoiceLineItems.d.ts rename to types/2022-11-09/InvoiceLineItems.d.ts diff --git a/types/2022-08-01/Invoices.d.ts b/types/2022-11-09/Invoices.d.ts similarity index 100% rename from types/2022-08-01/Invoices.d.ts rename to types/2022-11-09/Invoices.d.ts diff --git a/types/2022-08-01/Issuing/Authorizations.d.ts b/types/2022-11-09/Issuing/Authorizations.d.ts similarity index 100% rename from types/2022-08-01/Issuing/Authorizations.d.ts rename to types/2022-11-09/Issuing/Authorizations.d.ts diff --git a/types/2022-08-01/Issuing/Cardholders.d.ts b/types/2022-11-09/Issuing/Cardholders.d.ts similarity index 100% rename from types/2022-08-01/Issuing/Cardholders.d.ts rename to types/2022-11-09/Issuing/Cardholders.d.ts diff --git a/types/2022-08-01/Issuing/Cards.d.ts b/types/2022-11-09/Issuing/Cards.d.ts similarity index 100% rename from types/2022-08-01/Issuing/Cards.d.ts rename to types/2022-11-09/Issuing/Cards.d.ts diff --git a/types/2022-08-01/Issuing/Disputes.d.ts b/types/2022-11-09/Issuing/Disputes.d.ts similarity index 100% rename from types/2022-08-01/Issuing/Disputes.d.ts rename to types/2022-11-09/Issuing/Disputes.d.ts diff --git a/types/2022-08-01/Issuing/Transactions.d.ts b/types/2022-11-09/Issuing/Transactions.d.ts similarity index 100% rename from types/2022-08-01/Issuing/Transactions.d.ts rename to types/2022-11-09/Issuing/Transactions.d.ts diff --git a/types/2022-08-01/LineItems.d.ts b/types/2022-11-09/LineItems.d.ts similarity index 100% rename from types/2022-08-01/LineItems.d.ts rename to types/2022-11-09/LineItems.d.ts diff --git a/types/2022-08-01/LoginLinks.d.ts b/types/2022-11-09/LoginLinks.d.ts similarity index 100% rename from types/2022-08-01/LoginLinks.d.ts rename to types/2022-11-09/LoginLinks.d.ts diff --git a/types/2022-08-01/Mandates.d.ts b/types/2022-11-09/Mandates.d.ts similarity index 100% rename from types/2022-08-01/Mandates.d.ts rename to types/2022-11-09/Mandates.d.ts diff --git a/types/2022-08-01/PaymentIntents.d.ts b/types/2022-11-09/PaymentIntents.d.ts similarity index 99% rename from types/2022-08-01/PaymentIntents.d.ts rename to types/2022-11-09/PaymentIntents.d.ts index 83b8bd9406..d9af3bb497 100644 --- a/types/2022-08-01/PaymentIntents.d.ts +++ b/types/2022-11-09/PaymentIntents.d.ts @@ -73,11 +73,6 @@ declare module 'stripe' { */ capture_method: PaymentIntent.CaptureMethod; - /** - * Charges that were created by this PaymentIntent, if any. - */ - charges?: ApiList; - /** * The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key. * @@ -123,6 +118,11 @@ declare module 'stripe' { */ last_payment_error: PaymentIntent.LastPaymentError | null; + /** + * The latest charge created by this payment intent. + */ + latest_charge?: string | Stripe.Charge | null; + /** * Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. */ diff --git a/types/2022-08-01/PaymentLinks.d.ts b/types/2022-11-09/PaymentLinks.d.ts similarity index 100% rename from types/2022-08-01/PaymentLinks.d.ts rename to types/2022-11-09/PaymentLinks.d.ts diff --git a/types/2022-08-01/PaymentMethods.d.ts b/types/2022-11-09/PaymentMethods.d.ts similarity index 100% rename from types/2022-08-01/PaymentMethods.d.ts rename to types/2022-11-09/PaymentMethods.d.ts diff --git a/types/2022-08-01/Payouts.d.ts b/types/2022-11-09/Payouts.d.ts similarity index 100% rename from types/2022-08-01/Payouts.d.ts rename to types/2022-11-09/Payouts.d.ts diff --git a/types/2022-08-01/Persons.d.ts b/types/2022-11-09/Persons.d.ts similarity index 100% rename from types/2022-08-01/Persons.d.ts rename to types/2022-11-09/Persons.d.ts diff --git a/types/2022-08-01/Plans.d.ts b/types/2022-11-09/Plans.d.ts similarity index 100% rename from types/2022-08-01/Plans.d.ts rename to types/2022-11-09/Plans.d.ts diff --git a/types/2022-08-01/PlatformTaxFees.d.ts b/types/2022-11-09/PlatformTaxFees.d.ts similarity index 100% rename from types/2022-08-01/PlatformTaxFees.d.ts rename to types/2022-11-09/PlatformTaxFees.d.ts diff --git a/types/2022-08-01/Prices.d.ts b/types/2022-11-09/Prices.d.ts similarity index 100% rename from types/2022-08-01/Prices.d.ts rename to types/2022-11-09/Prices.d.ts diff --git a/types/2022-08-01/Products.d.ts b/types/2022-11-09/Products.d.ts similarity index 100% rename from types/2022-08-01/Products.d.ts rename to types/2022-11-09/Products.d.ts diff --git a/types/2022-08-01/PromotionCodes.d.ts b/types/2022-11-09/PromotionCodes.d.ts similarity index 100% rename from types/2022-08-01/PromotionCodes.d.ts rename to types/2022-11-09/PromotionCodes.d.ts diff --git a/types/2022-08-01/Quotes.d.ts b/types/2022-11-09/Quotes.d.ts similarity index 100% rename from types/2022-08-01/Quotes.d.ts rename to types/2022-11-09/Quotes.d.ts diff --git a/types/2022-08-01/Radar/EarlyFraudWarnings.d.ts b/types/2022-11-09/Radar/EarlyFraudWarnings.d.ts similarity index 100% rename from types/2022-08-01/Radar/EarlyFraudWarnings.d.ts rename to types/2022-11-09/Radar/EarlyFraudWarnings.d.ts diff --git a/types/2022-08-01/Radar/ValueListItems.d.ts b/types/2022-11-09/Radar/ValueListItems.d.ts similarity index 100% rename from types/2022-08-01/Radar/ValueListItems.d.ts rename to types/2022-11-09/Radar/ValueListItems.d.ts diff --git a/types/2022-08-01/Radar/ValueLists.d.ts b/types/2022-11-09/Radar/ValueLists.d.ts similarity index 100% rename from types/2022-08-01/Radar/ValueLists.d.ts rename to types/2022-11-09/Radar/ValueLists.d.ts diff --git a/types/2022-08-01/Refunds.d.ts b/types/2022-11-09/Refunds.d.ts similarity index 100% rename from types/2022-08-01/Refunds.d.ts rename to types/2022-11-09/Refunds.d.ts diff --git a/types/2022-08-01/Reporting/ReportRuns.d.ts b/types/2022-11-09/Reporting/ReportRuns.d.ts similarity index 100% rename from types/2022-08-01/Reporting/ReportRuns.d.ts rename to types/2022-11-09/Reporting/ReportRuns.d.ts diff --git a/types/2022-08-01/Reporting/ReportTypes.d.ts b/types/2022-11-09/Reporting/ReportTypes.d.ts similarity index 100% rename from types/2022-08-01/Reporting/ReportTypes.d.ts rename to types/2022-11-09/Reporting/ReportTypes.d.ts diff --git a/types/2022-08-01/ReserveTransactions.d.ts b/types/2022-11-09/ReserveTransactions.d.ts similarity index 100% rename from types/2022-08-01/ReserveTransactions.d.ts rename to types/2022-11-09/ReserveTransactions.d.ts diff --git a/types/2022-08-01/Reviews.d.ts b/types/2022-11-09/Reviews.d.ts similarity index 100% rename from types/2022-08-01/Reviews.d.ts rename to types/2022-11-09/Reviews.d.ts diff --git a/types/2022-08-01/SetupAttempts.d.ts b/types/2022-11-09/SetupAttempts.d.ts similarity index 100% rename from types/2022-08-01/SetupAttempts.d.ts rename to types/2022-11-09/SetupAttempts.d.ts diff --git a/types/2022-08-01/SetupIntents.d.ts b/types/2022-11-09/SetupIntents.d.ts similarity index 100% rename from types/2022-08-01/SetupIntents.d.ts rename to types/2022-11-09/SetupIntents.d.ts diff --git a/types/2022-08-01/ShippingRates.d.ts b/types/2022-11-09/ShippingRates.d.ts similarity index 100% rename from types/2022-08-01/ShippingRates.d.ts rename to types/2022-11-09/ShippingRates.d.ts diff --git a/types/2022-08-01/Sigma/ScheduledQueryRuns.d.ts b/types/2022-11-09/Sigma/ScheduledQueryRuns.d.ts similarity index 100% rename from types/2022-08-01/Sigma/ScheduledQueryRuns.d.ts rename to types/2022-11-09/Sigma/ScheduledQueryRuns.d.ts diff --git a/types/2022-08-01/SourceMandateNotifications.d.ts b/types/2022-11-09/SourceMandateNotifications.d.ts similarity index 100% rename from types/2022-08-01/SourceMandateNotifications.d.ts rename to types/2022-11-09/SourceMandateNotifications.d.ts diff --git a/types/2022-08-01/SourceTransactions.d.ts b/types/2022-11-09/SourceTransactions.d.ts similarity index 100% rename from types/2022-08-01/SourceTransactions.d.ts rename to types/2022-11-09/SourceTransactions.d.ts diff --git a/types/2022-08-01/Sources.d.ts b/types/2022-11-09/Sources.d.ts similarity index 100% rename from types/2022-08-01/Sources.d.ts rename to types/2022-11-09/Sources.d.ts diff --git a/types/2022-08-01/SubscriptionItems.d.ts b/types/2022-11-09/SubscriptionItems.d.ts similarity index 100% rename from types/2022-08-01/SubscriptionItems.d.ts rename to types/2022-11-09/SubscriptionItems.d.ts diff --git a/types/2022-08-01/SubscriptionSchedules.d.ts b/types/2022-11-09/SubscriptionSchedules.d.ts similarity index 100% rename from types/2022-08-01/SubscriptionSchedules.d.ts rename to types/2022-11-09/SubscriptionSchedules.d.ts diff --git a/types/2022-08-01/Subscriptions.d.ts b/types/2022-11-09/Subscriptions.d.ts similarity index 100% rename from types/2022-08-01/Subscriptions.d.ts rename to types/2022-11-09/Subscriptions.d.ts diff --git a/types/2022-08-01/TaxCodes.d.ts b/types/2022-11-09/TaxCodes.d.ts similarity index 100% rename from types/2022-08-01/TaxCodes.d.ts rename to types/2022-11-09/TaxCodes.d.ts diff --git a/types/2022-08-01/TaxDeductedAtSources.d.ts b/types/2022-11-09/TaxDeductedAtSources.d.ts similarity index 100% rename from types/2022-08-01/TaxDeductedAtSources.d.ts rename to types/2022-11-09/TaxDeductedAtSources.d.ts diff --git a/types/2022-08-01/TaxIds.d.ts b/types/2022-11-09/TaxIds.d.ts similarity index 100% rename from types/2022-08-01/TaxIds.d.ts rename to types/2022-11-09/TaxIds.d.ts diff --git a/types/2022-08-01/TaxRates.d.ts b/types/2022-11-09/TaxRates.d.ts similarity index 100% rename from types/2022-08-01/TaxRates.d.ts rename to types/2022-11-09/TaxRates.d.ts diff --git a/types/2022-08-01/Terminal/Configurations.d.ts b/types/2022-11-09/Terminal/Configurations.d.ts similarity index 100% rename from types/2022-08-01/Terminal/Configurations.d.ts rename to types/2022-11-09/Terminal/Configurations.d.ts diff --git a/types/2022-08-01/Terminal/ConnectionTokens.d.ts b/types/2022-11-09/Terminal/ConnectionTokens.d.ts similarity index 100% rename from types/2022-08-01/Terminal/ConnectionTokens.d.ts rename to types/2022-11-09/Terminal/ConnectionTokens.d.ts diff --git a/types/2022-08-01/Terminal/Locations.d.ts b/types/2022-11-09/Terminal/Locations.d.ts similarity index 100% rename from types/2022-08-01/Terminal/Locations.d.ts rename to types/2022-11-09/Terminal/Locations.d.ts diff --git a/types/2022-08-01/Terminal/Readers.d.ts b/types/2022-11-09/Terminal/Readers.d.ts similarity index 100% rename from types/2022-08-01/Terminal/Readers.d.ts rename to types/2022-11-09/Terminal/Readers.d.ts diff --git a/types/2022-08-01/TestHelpers/Customers.d.ts b/types/2022-11-09/TestHelpers/Customers.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Customers.d.ts rename to types/2022-11-09/TestHelpers/Customers.d.ts diff --git a/types/2022-08-01/TestHelpers/Issuing/Cards.d.ts b/types/2022-11-09/TestHelpers/Issuing/Cards.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Issuing/Cards.d.ts rename to types/2022-11-09/TestHelpers/Issuing/Cards.d.ts diff --git a/types/2022-08-01/TestHelpers/Refunds.d.ts b/types/2022-11-09/TestHelpers/Refunds.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Refunds.d.ts rename to types/2022-11-09/TestHelpers/Refunds.d.ts diff --git a/types/2022-08-01/TestHelpers/Terminal/Readers.d.ts b/types/2022-11-09/TestHelpers/Terminal/Readers.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Terminal/Readers.d.ts rename to types/2022-11-09/TestHelpers/Terminal/Readers.d.ts diff --git a/types/2022-08-01/TestHelpers/TestClocks.d.ts b/types/2022-11-09/TestHelpers/TestClocks.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/TestClocks.d.ts rename to types/2022-11-09/TestHelpers/TestClocks.d.ts diff --git a/types/2022-08-01/TestHelpers/Treasury/InboundTransfers.d.ts b/types/2022-11-09/TestHelpers/Treasury/InboundTransfers.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Treasury/InboundTransfers.d.ts rename to types/2022-11-09/TestHelpers/Treasury/InboundTransfers.d.ts diff --git a/types/2022-08-01/TestHelpers/Treasury/OutboundPayments.d.ts b/types/2022-11-09/TestHelpers/Treasury/OutboundPayments.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Treasury/OutboundPayments.d.ts rename to types/2022-11-09/TestHelpers/Treasury/OutboundPayments.d.ts diff --git a/types/2022-08-01/TestHelpers/Treasury/OutboundTransfers.d.ts b/types/2022-11-09/TestHelpers/Treasury/OutboundTransfers.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Treasury/OutboundTransfers.d.ts rename to types/2022-11-09/TestHelpers/Treasury/OutboundTransfers.d.ts diff --git a/types/2022-08-01/TestHelpers/Treasury/ReceivedCredits.d.ts b/types/2022-11-09/TestHelpers/Treasury/ReceivedCredits.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Treasury/ReceivedCredits.d.ts rename to types/2022-11-09/TestHelpers/Treasury/ReceivedCredits.d.ts diff --git a/types/2022-08-01/TestHelpers/Treasury/ReceivedDebits.d.ts b/types/2022-11-09/TestHelpers/Treasury/ReceivedDebits.d.ts similarity index 100% rename from types/2022-08-01/TestHelpers/Treasury/ReceivedDebits.d.ts rename to types/2022-11-09/TestHelpers/Treasury/ReceivedDebits.d.ts diff --git a/types/2022-08-01/Tokens.d.ts b/types/2022-11-09/Tokens.d.ts similarity index 100% rename from types/2022-08-01/Tokens.d.ts rename to types/2022-11-09/Tokens.d.ts diff --git a/types/2022-08-01/Topups.d.ts b/types/2022-11-09/Topups.d.ts similarity index 100% rename from types/2022-08-01/Topups.d.ts rename to types/2022-11-09/Topups.d.ts diff --git a/types/2022-08-01/TransferReversals.d.ts b/types/2022-11-09/TransferReversals.d.ts similarity index 100% rename from types/2022-08-01/TransferReversals.d.ts rename to types/2022-11-09/TransferReversals.d.ts diff --git a/types/2022-08-01/Transfers.d.ts b/types/2022-11-09/Transfers.d.ts similarity index 100% rename from types/2022-08-01/Transfers.d.ts rename to types/2022-11-09/Transfers.d.ts diff --git a/types/2022-08-01/Treasury/CreditReversals.d.ts b/types/2022-11-09/Treasury/CreditReversals.d.ts similarity index 100% rename from types/2022-08-01/Treasury/CreditReversals.d.ts rename to types/2022-11-09/Treasury/CreditReversals.d.ts diff --git a/types/2022-08-01/Treasury/DebitReversals.d.ts b/types/2022-11-09/Treasury/DebitReversals.d.ts similarity index 100% rename from types/2022-08-01/Treasury/DebitReversals.d.ts rename to types/2022-11-09/Treasury/DebitReversals.d.ts diff --git a/types/2022-08-01/Treasury/FinancialAccountFeatures.d.ts b/types/2022-11-09/Treasury/FinancialAccountFeatures.d.ts similarity index 100% rename from types/2022-08-01/Treasury/FinancialAccountFeatures.d.ts rename to types/2022-11-09/Treasury/FinancialAccountFeatures.d.ts diff --git a/types/2022-08-01/Treasury/FinancialAccounts.d.ts b/types/2022-11-09/Treasury/FinancialAccounts.d.ts similarity index 100% rename from types/2022-08-01/Treasury/FinancialAccounts.d.ts rename to types/2022-11-09/Treasury/FinancialAccounts.d.ts diff --git a/types/2022-08-01/Treasury/InboundTransfers.d.ts b/types/2022-11-09/Treasury/InboundTransfers.d.ts similarity index 100% rename from types/2022-08-01/Treasury/InboundTransfers.d.ts rename to types/2022-11-09/Treasury/InboundTransfers.d.ts diff --git a/types/2022-08-01/Treasury/OutboundPayments.d.ts b/types/2022-11-09/Treasury/OutboundPayments.d.ts similarity index 100% rename from types/2022-08-01/Treasury/OutboundPayments.d.ts rename to types/2022-11-09/Treasury/OutboundPayments.d.ts diff --git a/types/2022-08-01/Treasury/OutboundTransfers.d.ts b/types/2022-11-09/Treasury/OutboundTransfers.d.ts similarity index 100% rename from types/2022-08-01/Treasury/OutboundTransfers.d.ts rename to types/2022-11-09/Treasury/OutboundTransfers.d.ts diff --git a/types/2022-08-01/Treasury/ReceivedCredits.d.ts b/types/2022-11-09/Treasury/ReceivedCredits.d.ts similarity index 100% rename from types/2022-08-01/Treasury/ReceivedCredits.d.ts rename to types/2022-11-09/Treasury/ReceivedCredits.d.ts diff --git a/types/2022-08-01/Treasury/ReceivedDebits.d.ts b/types/2022-11-09/Treasury/ReceivedDebits.d.ts similarity index 100% rename from types/2022-08-01/Treasury/ReceivedDebits.d.ts rename to types/2022-11-09/Treasury/ReceivedDebits.d.ts diff --git a/types/2022-08-01/Treasury/TransactionEntries.d.ts b/types/2022-11-09/Treasury/TransactionEntries.d.ts similarity index 100% rename from types/2022-08-01/Treasury/TransactionEntries.d.ts rename to types/2022-11-09/Treasury/TransactionEntries.d.ts diff --git a/types/2022-08-01/Treasury/Transactions.d.ts b/types/2022-11-09/Treasury/Transactions.d.ts similarity index 100% rename from types/2022-08-01/Treasury/Transactions.d.ts rename to types/2022-11-09/Treasury/Transactions.d.ts diff --git a/types/2022-08-01/UsageRecordSummaries.d.ts b/types/2022-11-09/UsageRecordSummaries.d.ts similarity index 100% rename from types/2022-08-01/UsageRecordSummaries.d.ts rename to types/2022-11-09/UsageRecordSummaries.d.ts diff --git a/types/2022-08-01/UsageRecords.d.ts b/types/2022-11-09/UsageRecords.d.ts similarity index 100% rename from types/2022-08-01/UsageRecords.d.ts rename to types/2022-11-09/UsageRecords.d.ts diff --git a/types/2022-08-01/WebhookEndpoints.d.ts b/types/2022-11-09/WebhookEndpoints.d.ts similarity index 99% rename from types/2022-08-01/WebhookEndpoints.d.ts rename to types/2022-11-09/WebhookEndpoints.d.ts index 17d2b739e1..1d5cfdc5f7 100644 --- a/types/2022-08-01/WebhookEndpoints.d.ts +++ b/types/2022-11-09/WebhookEndpoints.d.ts @@ -230,7 +230,8 @@ declare module 'stripe' { | '2019-12-03' | '2020-03-02' | '2020-08-27' - | '2022-08-01'; + | '2022-08-01' + | '2022-11-09'; type EnabledEvent = | '*' diff --git a/types/2022-08-01/index.d.ts b/types/2022-11-09/index.d.ts similarity index 100% rename from types/2022-08-01/index.d.ts rename to types/2022-11-09/index.d.ts From 528726094dc6a9e43f47f92f4a41b537f04dac09 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 15 Nov 2022 13:34:57 -0800 Subject: [PATCH 13/16] Latest API version --- lib/Error.js | 156 +-- lib/ResourceNamespace.js | 20 +- lib/StripeMethod.js | 46 +- lib/StripeResource.js | 904 ++++++++---------- lib/Webhooks.js | 334 +++---- lib/apiVersion.js | 4 +- lib/autoPagination.js | 389 ++++---- lib/crypto/CryptoProvider.js | 52 +- lib/crypto/NodeCryptoProvider.js | 30 +- lib/crypto/SubtleCryptoProvider.js | 74 +- lib/makeRequest.js | 180 ++-- lib/multipart.js | 136 ++- lib/net/FetchHttpClient.js | 200 ++-- lib/net/HttpClient.js | 77 +- lib/net/NodeHttpClient.js | 186 ++-- lib/resources.js | 228 ++--- lib/resources/AccountLinks.js | 8 +- lib/resources/Accounts.js | 195 ++-- lib/resources/ApplePayDomains.js | 34 +- lib/resources/ApplicationFees.js | 52 +- lib/resources/Apps/Secrets.js | 34 +- lib/resources/Balance.js | 8 +- lib/resources/BalanceTransactions.js | 18 +- lib/resources/BillingPortal/Configurations.js | 34 +- lib/resources/BillingPortal/Sessions.js | 8 +- lib/resources/Charges.js | 52 +- lib/resources/Checkout/Sessions.js | 44 +- lib/resources/CountrySpecs.js | 18 +- lib/resources/Coupons.js | 42 +- lib/resources/CreditNotes.js | 70 +- lib/resources/Customers.js | 239 +++-- lib/resources/Disputes.js | 34 +- lib/resources/EphemeralKeys.js | 28 +- lib/resources/Events.js | 18 +- lib/resources/ExchangeRates.js | 18 +- lib/resources/FileLinks.js | 34 +- lib/resources/Files.js | 38 +- .../FinancialConnections/Accounts.js | 44 +- .../FinancialConnections/Sessions.js | 16 +- lib/resources/Identity/VerificationReports.js | 18 +- .../Identity/VerificationSessions.js | 50 +- lib/resources/InvoiceItems.js | 42 +- lib/resources/Invoices.js | 120 +-- lib/resources/Issuing/Authorizations.js | 42 +- lib/resources/Issuing/Cardholders.js | 34 +- lib/resources/Issuing/Cards.js | 34 +- lib/resources/Issuing/Disputes.js | 42 +- lib/resources/Issuing/Transactions.js | 26 +- lib/resources/Mandates.js | 8 +- lib/resources/OAuth.js | 70 +- lib/resources/PaymentIntents.js | 92 +- lib/resources/PaymentLinks.js | 44 +- lib/resources/PaymentMethods.js | 50 +- lib/resources/Payouts.js | 50 +- lib/resources/Plans.js | 42 +- lib/resources/Prices.js | 44 +- lib/resources/Products.js | 52 +- lib/resources/PromotionCodes.js | 34 +- lib/resources/Quotes.js | 90 +- lib/resources/Radar/EarlyFraudWarnings.js | 18 +- lib/resources/Radar/ValueListItems.js | 34 +- lib/resources/Radar/ValueLists.js | 42 +- lib/resources/Refunds.js | 42 +- lib/resources/Reporting/ReportRuns.js | 26 +- lib/resources/Reporting/ReportTypes.js | 18 +- lib/resources/Reviews.js | 26 +- lib/resources/SetupAttempts.js | 10 +- lib/resources/SetupIntents.js | 58 +- lib/resources/ShippingRates.js | 34 +- lib/resources/Sigma/ScheduledQueryRuns.js | 18 +- lib/resources/Sources.js | 42 +- lib/resources/SubscriptionItems.js | 61 +- lib/resources/SubscriptionSchedules.js | 50 +- lib/resources/Subscriptions.js | 68 +- lib/resources/TaxCodes.js | 18 +- lib/resources/TaxRates.js | 34 +- lib/resources/Terminal/Configurations.js | 42 +- lib/resources/Terminal/ConnectionTokens.js | 8 +- lib/resources/Terminal/Locations.js | 42 +- lib/resources/Terminal/Readers.js | 74 +- lib/resources/TestHelpers/Customers.js | 8 +- lib/resources/TestHelpers/Issuing/Cards.js | 32 +- lib/resources/TestHelpers/Refunds.js | 8 +- lib/resources/TestHelpers/Terminal/Readers.js | 9 +- lib/resources/TestHelpers/TestClocks.js | 42 +- .../TestHelpers/Treasury/InboundTransfers.js | 24 +- .../TestHelpers/Treasury/OutboundPayments.js | 24 +- .../TestHelpers/Treasury/OutboundTransfers.js | 27 +- .../TestHelpers/Treasury/ReceivedCredits.js | 8 +- .../TestHelpers/Treasury/ReceivedDebits.js | 8 +- lib/resources/Tokens.js | 16 +- lib/resources/Topups.js | 42 +- lib/resources/Transfers.js | 68 +- lib/resources/Treasury/CreditReversals.js | 26 +- lib/resources/Treasury/DebitReversals.js | 26 +- lib/resources/Treasury/FinancialAccounts.js | 50 +- lib/resources/Treasury/InboundTransfers.js | 34 +- lib/resources/Treasury/OutboundPayments.js | 34 +- lib/resources/Treasury/OutboundTransfers.js | 34 +- lib/resources/Treasury/ReceivedCredits.js | 18 +- lib/resources/Treasury/ReceivedDebits.js | 18 +- lib/resources/Treasury/TransactionEntries.js | 18 +- lib/resources/Treasury/Transactions.js | 18 +- lib/resources/WebhookEndpoints.js | 42 +- lib/stripe.js | 626 ++++++------ lib/utils.js | 687 +++++++------ src/apiVersion.js | 2 +- .../AccountLinks.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Accounts.d.ts | 0 .../ApplePayDomains.d.ts | 0 .../ApplicationFees.d.ts | 0 .../Applications.d.ts | 0 .../Apps/Secrets.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Balance.d.ts | 0 .../BalanceTransactions.d.ts | 0 .../BankAccounts.d.ts | 0 .../BillingPortal/Configurations.d.ts | 0 .../BillingPortal/Sessions.d.ts | 0 .../Capabilities.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Cards.d.ts | 0 .../CashBalances.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Charges.d.ts | 0 .../Checkout/Sessions.d.ts | 0 .../ConnectCollectionTransfers.d.ts | 0 .../CountrySpecs.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Coupons.d.ts | 0 .../CreditNoteLineItems.d.ts | 0 .../CreditNotes.d.ts | 0 .../CustomerBalanceTransactions.d.ts | 0 .../CustomerCashBalanceTransactions.d.ts | 0 .../CustomerSources.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Customers.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Discounts.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Disputes.d.ts | 0 .../EphemeralKeys.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Events.d.ts | 0 .../ExchangeRates.d.ts | 0 .../ExternalAccounts.d.ts | 0 .../FeeRefunds.d.ts | 0 .../{2022-11-09 => 2022-11-15}/FileLinks.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Files.d.ts | 0 .../FinancialConnections/AccountOwners.d.ts | 0 .../AccountOwnerships.d.ts | 0 .../FinancialConnections/Accounts.d.ts | 0 .../FinancialConnections/Sessions.d.ts | 0 .../FundingInstructions.d.ts | 0 .../Identity/VerificationReports.d.ts | 0 .../Identity/VerificationSessions.d.ts | 0 .../InvoiceItems.d.ts | 0 .../InvoiceLineItems.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Invoices.d.ts | 0 .../Issuing/Authorizations.d.ts | 0 .../Issuing/Cardholders.d.ts | 0 .../Issuing/Cards.d.ts | 0 .../Issuing/Disputes.d.ts | 0 .../Issuing/Transactions.d.ts | 0 .../{2022-11-09 => 2022-11-15}/LineItems.d.ts | 0 .../LoginLinks.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Mandates.d.ts | 0 .../PaymentIntents.d.ts | 0 .../PaymentLinks.d.ts | 0 .../PaymentMethods.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Payouts.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Persons.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Plans.d.ts | 0 .../PlatformTaxFees.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Prices.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Products.d.ts | 0 .../PromotionCodes.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Quotes.d.ts | 0 .../Radar/EarlyFraudWarnings.d.ts | 0 .../Radar/ValueListItems.d.ts | 0 .../Radar/ValueLists.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Refunds.d.ts | 4 - .../Reporting/ReportRuns.d.ts | 0 .../Reporting/ReportTypes.d.ts | 0 .../ReserveTransactions.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Reviews.d.ts | 0 .../SetupAttempts.d.ts | 0 .../SetupIntents.d.ts | 0 .../ShippingRates.d.ts | 0 .../Sigma/ScheduledQueryRuns.d.ts | 0 .../SourceMandateNotifications.d.ts | 0 .../SourceTransactions.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Sources.d.ts | 0 .../SubscriptionItems.d.ts | 0 .../SubscriptionSchedules.d.ts | 0 .../Subscriptions.d.ts | 0 .../{2022-11-09 => 2022-11-15}/TaxCodes.d.ts | 0 .../TaxDeductedAtSources.d.ts | 0 types/{2022-11-09 => 2022-11-15}/TaxIds.d.ts | 0 .../{2022-11-09 => 2022-11-15}/TaxRates.d.ts | 0 .../Terminal/Configurations.d.ts | 0 .../Terminal/ConnectionTokens.d.ts | 0 .../Terminal/Locations.d.ts | 0 .../Terminal/Readers.d.ts | 0 .../TestHelpers/Customers.d.ts | 0 .../TestHelpers/Issuing/Cards.d.ts | 0 .../TestHelpers/Refunds.d.ts | 0 .../TestHelpers/Terminal/Readers.d.ts | 0 .../TestHelpers/TestClocks.d.ts | 0 .../Treasury/InboundTransfers.d.ts | 0 .../Treasury/OutboundPayments.d.ts | 0 .../Treasury/OutboundTransfers.d.ts | 0 .../TestHelpers/Treasury/ReceivedCredits.d.ts | 0 .../TestHelpers/Treasury/ReceivedDebits.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Tokens.d.ts | 0 types/{2022-11-09 => 2022-11-15}/Topups.d.ts | 0 .../TransferReversals.d.ts | 0 .../{2022-11-09 => 2022-11-15}/Transfers.d.ts | 0 .../Treasury/CreditReversals.d.ts | 0 .../Treasury/DebitReversals.d.ts | 0 .../Treasury/FinancialAccountFeatures.d.ts | 0 .../Treasury/FinancialAccounts.d.ts | 0 .../Treasury/InboundTransfers.d.ts | 0 .../Treasury/OutboundPayments.d.ts | 0 .../Treasury/OutboundTransfers.d.ts | 0 .../Treasury/ReceivedCredits.d.ts | 0 .../Treasury/ReceivedDebits.d.ts | 0 .../Treasury/TransactionEntries.d.ts | 0 .../Treasury/Transactions.d.ts | 0 .../UsageRecordSummaries.d.ts | 0 .../UsageRecords.d.ts | 0 .../WebhookEndpoints.d.ts | 2 +- types/{2022-11-09 => 2022-11-15}/index.d.ts | 0 225 files changed, 3746 insertions(+), 4060 deletions(-) rename types/{2022-11-09 => 2022-11-15}/AccountLinks.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Accounts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/ApplePayDomains.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/ApplicationFees.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Applications.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Apps/Secrets.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Balance.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/BalanceTransactions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/BankAccounts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/BillingPortal/Configurations.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/BillingPortal/Sessions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Capabilities.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Cards.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/CashBalances.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Charges.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Checkout/Sessions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/ConnectCollectionTransfers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/CountrySpecs.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Coupons.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/CreditNoteLineItems.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/CreditNotes.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/CustomerBalanceTransactions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/CustomerCashBalanceTransactions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/CustomerSources.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Customers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Discounts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Disputes.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/EphemeralKeys.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Events.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/ExchangeRates.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/ExternalAccounts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/FeeRefunds.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/FileLinks.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Files.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/FinancialConnections/AccountOwners.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/FinancialConnections/AccountOwnerships.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/FinancialConnections/Accounts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/FinancialConnections/Sessions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/FundingInstructions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Identity/VerificationReports.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Identity/VerificationSessions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/InvoiceItems.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/InvoiceLineItems.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Invoices.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Issuing/Authorizations.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Issuing/Cardholders.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Issuing/Cards.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Issuing/Disputes.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Issuing/Transactions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/LineItems.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/LoginLinks.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Mandates.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/PaymentIntents.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/PaymentLinks.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/PaymentMethods.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Payouts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Persons.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Plans.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/PlatformTaxFees.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Prices.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Products.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/PromotionCodes.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Quotes.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Radar/EarlyFraudWarnings.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Radar/ValueListItems.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Radar/ValueLists.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Refunds.d.ts (97%) rename types/{2022-11-09 => 2022-11-15}/Reporting/ReportRuns.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Reporting/ReportTypes.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/ReserveTransactions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Reviews.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/SetupAttempts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/SetupIntents.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/ShippingRates.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Sigma/ScheduledQueryRuns.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/SourceMandateNotifications.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/SourceTransactions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Sources.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/SubscriptionItems.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/SubscriptionSchedules.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Subscriptions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TaxCodes.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TaxDeductedAtSources.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TaxIds.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TaxRates.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Terminal/Configurations.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Terminal/ConnectionTokens.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Terminal/Locations.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Terminal/Readers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Customers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Issuing/Cards.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Refunds.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Terminal/Readers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/TestClocks.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Treasury/InboundTransfers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Treasury/OutboundPayments.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Treasury/OutboundTransfers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Treasury/ReceivedCredits.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TestHelpers/Treasury/ReceivedDebits.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Tokens.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Topups.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/TransferReversals.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Transfers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/CreditReversals.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/DebitReversals.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/FinancialAccountFeatures.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/FinancialAccounts.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/InboundTransfers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/OutboundPayments.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/OutboundTransfers.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/ReceivedCredits.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/ReceivedDebits.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/TransactionEntries.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/Treasury/Transactions.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/UsageRecordSummaries.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/UsageRecords.d.ts (100%) rename types/{2022-11-09 => 2022-11-15}/WebhookEndpoints.d.ts (99%) rename types/{2022-11-09 => 2022-11-15}/index.d.ts (100%) diff --git a/lib/Error.js b/lib/Error.js index dfdfb447fd..68d6a0b521 100644 --- a/lib/Error.js +++ b/lib/Error.js @@ -1,135 +1,145 @@ -'use strict'; +"use strict"; /* eslint-disable camelcase */ /** * StripeError is the base error from which all other more specific Stripe errors derive. * Specifically for errors returned from Stripe's REST API. */ class StripeError extends Error { - constructor(raw = {}) { - super(raw.message); - this.type = this.constructor.name; - this.raw = raw; - this.rawType = raw.type; - this.code = raw.code; - this.doc_url = raw.doc_url; - this.param = raw.param; - this.detail = raw.detail; - this.headers = raw.headers; - this.requestId = raw.requestId; - this.statusCode = raw.statusCode; - // @ts-ignore - this.message = raw.message; - this.charge = raw.charge; - this.decline_code = raw.decline_code; - this.payment_intent = raw.payment_intent; - this.payment_method = raw.payment_method; - this.payment_method_type = raw.payment_method_type; - this.setup_intent = raw.setup_intent; - this.source = raw.source; - } - /** - * Helper factory which takes raw stripe errors and outputs wrapping instances - */ - static generate(rawStripeError) { - switch (rawStripeError.type) { - case 'card_error': - return new StripeCardError(rawStripeError); - case 'invalid_request_error': - return new StripeInvalidRequestError(rawStripeError); - case 'api_error': - return new StripeAPIError(rawStripeError); - case 'authentication_error': - return new StripeAuthenticationError(rawStripeError); - case 'rate_limit_error': - return new StripeRateLimitError(rawStripeError); - case 'idempotency_error': - return new StripeIdempotencyError(rawStripeError); - case 'invalid_grant': - return new StripeInvalidGrantError(rawStripeError); - default: - return new StripeUnknownError(rawStripeError); + constructor(raw = {}) { + super(raw.message); + this.type = this.constructor.name; + this.raw = raw; + this.rawType = raw.type; + this.code = raw.code; + this.doc_url = raw.doc_url; + this.param = raw.param; + this.detail = raw.detail; + this.headers = raw.headers; + this.requestId = raw.requestId; + this.statusCode = raw.statusCode; + // @ts-ignore + this.message = raw.message; + this.charge = raw.charge; + this.decline_code = raw.decline_code; + this.payment_intent = raw.payment_intent; + this.payment_method = raw.payment_method; + this.payment_method_type = raw.payment_method_type; + this.setup_intent = raw.setup_intent; + this.source = raw.source; + } + /** + * Helper factory which takes raw stripe errors and outputs wrapping instances + */ + static generate(rawStripeError) { + switch (rawStripeError.type) { + case 'card_error': + return new StripeCardError(rawStripeError); + case 'invalid_request_error': + return new StripeInvalidRequestError(rawStripeError); + case 'api_error': + return new StripeAPIError(rawStripeError); + case 'authentication_error': + return new StripeAuthenticationError(rawStripeError); + case 'rate_limit_error': + return new StripeRateLimitError(rawStripeError); + case 'idempotency_error': + return new StripeIdempotencyError(rawStripeError); + case 'invalid_grant': + return new StripeInvalidGrantError(rawStripeError); + default: + return new StripeUnknownError(rawStripeError); + } } - } } // Specific Stripe Error types: /** * CardError is raised when a user enters a card that can't be charged for * some reason. */ -class StripeCardError extends StripeError {} +class StripeCardError extends StripeError { +} /** * InvalidRequestError is raised when a request is initiated with invalid * parameters. */ -class StripeInvalidRequestError extends StripeError {} +class StripeInvalidRequestError extends StripeError { +} /** * APIError is a generic error that may be raised in cases where none of the * other named errors cover the problem. It could also be raised in the case * that a new error has been introduced in the API, but this version of the * Node.JS SDK doesn't know how to handle it. */ -class StripeAPIError extends StripeError {} +class StripeAPIError extends StripeError { +} /** * AuthenticationError is raised when invalid credentials are used to connect * to Stripe's servers. */ -class StripeAuthenticationError extends StripeError {} +class StripeAuthenticationError extends StripeError { +} /** * PermissionError is raised in cases where access was attempted on a resource * that wasn't allowed. */ -class StripePermissionError extends StripeError {} +class StripePermissionError extends StripeError { +} /** * RateLimitError is raised in cases where an account is putting too much load * on Stripe's API servers (usually by performing too many requests). Please * back off on request rate. */ -class StripeRateLimitError extends StripeError {} +class StripeRateLimitError extends StripeError { +} /** * StripeConnectionError is raised in the event that the SDK can't connect to * Stripe's servers. That can be for a variety of different reasons from a * downed network to a bad TLS certificate. */ -class StripeConnectionError extends StripeError {} +class StripeConnectionError extends StripeError { +} /** * SignatureVerificationError is raised when the signature verification for a * webhook fails */ class StripeSignatureVerificationError extends StripeError { - constructor(header, payload, raw = {}) { - super(raw); - this.header = header; - this.payload = payload; - } + constructor(header, payload, raw = {}) { + super(raw); + this.header = header; + this.payload = payload; + } } /** * IdempotencyError is raised in cases where an idempotency key was used * improperly. */ -class StripeIdempotencyError extends StripeError {} +class StripeIdempotencyError extends StripeError { +} /** * InvalidGrantError is raised when a specified code doesn't exist, is * expired, has been used, or doesn't belong to you; a refresh token doesn't * exist, or doesn't belong to you; or if an API key's mode (live or test) * doesn't match the mode of a code or refresh token. */ -class StripeInvalidGrantError extends StripeError {} +class StripeInvalidGrantError extends StripeError { +} /** * Any other error from Stripe not specifically captured above */ -class StripeUnknownError extends StripeError {} +class StripeUnknownError extends StripeError { +} module.exports = { - generate: StripeError.generate, - StripeError: StripeError, - StripeCardError: StripeCardError, - StripeInvalidRequestError: StripeInvalidRequestError, - StripeAPIError: StripeAPIError, - StripeAuthenticationError: StripeAuthenticationError, - StripePermissionError: StripePermissionError, - StripeRateLimitError: StripeRateLimitError, - StripeConnectionError: StripeConnectionError, - StripeSignatureVerificationError: StripeSignatureVerificationError, - StripeIdempotencyError: StripeIdempotencyError, - StripeInvalidGrantError: StripeInvalidGrantError, - StripeUnknownError: StripeUnknownError, + generate: StripeError.generate, + StripeError: StripeError, + StripeCardError: StripeCardError, + StripeInvalidRequestError: StripeInvalidRequestError, + StripeAPIError: StripeAPIError, + StripeAuthenticationError: StripeAuthenticationError, + StripePermissionError: StripePermissionError, + StripeRateLimitError: StripeRateLimitError, + StripeConnectionError: StripeConnectionError, + StripeSignatureVerificationError: StripeSignatureVerificationError, + StripeIdempotencyError: StripeIdempotencyError, + StripeInvalidGrantError: StripeInvalidGrantError, + StripeUnknownError: StripeUnknownError, }; diff --git a/lib/ResourceNamespace.js b/lib/ResourceNamespace.js index 8267a0fa8b..5d7f0e7e09 100644 --- a/lib/ResourceNamespace.js +++ b/lib/ResourceNamespace.js @@ -1,16 +1,16 @@ -'use strict'; +"use strict"; // ResourceNamespace allows you to create nested resources, i.e. `stripe.issuing.cards`. // It also works recursively, so you could do i.e. `stripe.billing.invoicing.pay`. function ResourceNamespace(stripe, resources) { - for (const name in resources) { - const camelCaseName = name[0].toLowerCase() + name.substring(1); - const resource = new resources[name](stripe); - this[camelCaseName] = resource; - } + for (const name in resources) { + const camelCaseName = name[0].toLowerCase() + name.substring(1); + const resource = new resources[name](stripe); + this[camelCaseName] = resource; + } } -module.exports = function(namespace, resources) { - return function(stripe) { - return new ResourceNamespace(stripe, resources); - }; +module.exports = function (namespace, resources) { + return function (stripe) { + return new ResourceNamespace(stripe, resources); + }; }; module.exports.ResourceNamespace = ResourceNamespace; diff --git a/lib/StripeMethod.js b/lib/StripeMethod.js index f4e9ada721..f233e26acc 100644 --- a/lib/StripeMethod.js +++ b/lib/StripeMethod.js @@ -1,7 +1,7 @@ -'use strict'; +"use strict"; const utils = require('./utils'); -const makeRequest = require('./makeRequest'); -const autoPagination = require('./autoPagination'); +const makeRequest = require("./makeRequest"); +const autoPagination = require("./autoPagination"); const makeAutoPaginationMethods = autoPagination.makeAutoPaginationMethods; /** * Create an API method from the declared spec. @@ -20,32 +20,20 @@ const makeAutoPaginationMethods = autoPagination.makeAutoPaginationMethods; * @param [spec.host] Hostname for the request. */ function stripeMethod(spec) { - if (spec.path !== undefined && spec.fullPath !== undefined) { - throw new Error( - `Method spec specified both a 'path' (${spec.path}) and a 'fullPath' (${spec.fullPath}).` - ); - } - return function(...args) { - const callback = typeof args[args.length - 1] == 'function' && args.pop(); - spec.urlParams = utils.extractUrlParams( - spec.fullPath || this.createResourcePathWithSymbols(spec.path || '') - ); - const requestPromise = utils.callbackifyPromiseWithTimeout( - makeRequest(this, args, spec, {}), - callback - ); - // Please note `spec.methodType === 'search'` is beta functionality and this - // interface is subject to change/removal at any time. - if (spec.methodType === 'list' || spec.methodType === 'search') { - const autoPaginationMethods = makeAutoPaginationMethods( - this, - args, - spec, - requestPromise - ); - Object.assign(requestPromise, autoPaginationMethods); + if (spec.path !== undefined && spec.fullPath !== undefined) { + throw new Error(`Method spec specified both a 'path' (${spec.path}) and a 'fullPath' (${spec.fullPath}).`); } - return requestPromise; - }; + return function (...args) { + const callback = typeof args[args.length - 1] == 'function' && args.pop(); + spec.urlParams = utils.extractUrlParams(spec.fullPath || this.createResourcePathWithSymbols(spec.path || '')); + const requestPromise = utils.callbackifyPromiseWithTimeout(makeRequest(this, args, spec, {}), callback); + // Please note `spec.methodType === 'search'` is beta functionality and this + // interface is subject to change/removal at any time. + if (spec.methodType === 'list' || spec.methodType === 'search') { + const autoPaginationMethods = makeAutoPaginationMethods(this, args, spec, requestPromise); + Object.assign(requestPromise, autoPaginationMethods); + } + return requestPromise; + }; } module.exports = stripeMethod; diff --git a/lib/StripeResource.js b/lib/StripeResource.js index 69ee701b92..458b9d5e33 100644 --- a/lib/StripeResource.js +++ b/lib/StripeResource.js @@ -1,15 +1,8 @@ -'use strict'; -const utils = require('./utils'); -const _Error = require('./Error'); -const { - StripeAPIError, - StripeAuthenticationError, - StripeConnectionError, - StripeError, - StripePermissionError, - StripeRateLimitError, -} = _Error; -const {HttpClient} = require('./net/HttpClient'); +"use strict"; +const utils = require("./utils"); +const _Error = require("./Error"); +const { StripeAPIError, StripeAuthenticationError, StripeConnectionError, StripeError, StripePermissionError, StripeRateLimitError, } = _Error; +const { HttpClient } = require('./net/HttpClient'); // Provide extension mechanism for Stripe Resource Sub-Classes StripeResource.extend = utils.protoExtend; // Expose method-creator @@ -20,499 +13,410 @@ const MAX_RETRY_AFTER_WAIT = 60; * Encapsulates request logic for a Stripe Resource */ function StripeResource(stripe, deprecatedUrlData) { - this._stripe = stripe; - if (deprecatedUrlData) { - throw new Error( - 'Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.' - ); - } - this.basePath = utils.makeURLInterpolator( + this._stripe = stripe; + if (deprecatedUrlData) { + throw new Error('Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.'); + } + this.basePath = utils.makeURLInterpolator( // @ts-ignore changing type of basePath - this.basePath || stripe.getApiField('basePath') - ); - // @ts-ignore changing type of path - this.resourcePath = this.path; - // @ts-ignore changing type of path - this.path = utils.makeURLInterpolator(this.path); - this.initialize(...arguments); + this.basePath || stripe.getApiField('basePath')); + // @ts-ignore changing type of path + this.resourcePath = this.path; + // @ts-ignore changing type of path + this.path = utils.makeURLInterpolator(this.path); + this.initialize(...arguments); } StripeResource.prototype = { - _stripe: null, - // @ts-ignore the type of path changes in ctor - path: '', - resourcePath: '', - // Methods that don't use the API's default '/v1' path can override it with this setting. - basePath: null, - initialize() {}, - // Function to override the default data processor. This allows full control - // over how a StripeResource's request data will get converted into an HTTP - // body. This is useful for non-standard HTTP requests. The function should - // take method name, data, and headers as arguments. - requestDataProcessor: null, - // Function to add a validation checks before sending the request, errors should - // be thrown, and they will be passed to the callback/promise. - validateRequest: null, - createFullPath(commandPath, urlData) { - const urlParts = [this.basePath(urlData), this.path(urlData)]; - if (typeof commandPath === 'function') { - const computedCommandPath = commandPath(urlData); - // If we have no actual command path, we just omit it to avoid adding a - // trailing slash. This is important for top-level listing requests, which - // do not have a command path. - if (computedCommandPath) { - urlParts.push(computedCommandPath); - } - } else { - urlParts.push(commandPath); - } - return this._joinUrlParts(urlParts); - }, - // Creates a relative resource path with symbols left in (unlike - // createFullPath which takes some data to replace them with). For example it - // might produce: /invoices/{id} - createResourcePathWithSymbols(pathWithSymbols) { - // If there is no path beyond the resource path, we want to produce just - // / rather than //. - if (pathWithSymbols) { - return `/${this._joinUrlParts([this.resourcePath, pathWithSymbols])}`; - } else { - return `/${this.resourcePath}`; - } - }, - _joinUrlParts(parts) { - // Replace any accidentally doubled up slashes. This previously used - // path.join, which would do this as well. Unfortunately we need to do this - // as the functions for creating paths are technically part of the public - // interface and so we need to preserve backwards compatibility. - return parts.join('/').replace(/\/{2,}/g, '/'); - }, - // DEPRECATED: Here for backcompat in case users relied on this. - wrapTimeout: utils.callbackifyPromiseWithTimeout, - _addHeadersDirectlyToObject(obj, headers) { - // For convenience, make some headers easily accessible on - // lastResponse. - // NOTE: Stripe responds with lowercase header names/keys. - obj.requestId = headers['request-id']; - obj.stripeAccount = obj.stripeAccount || headers['stripe-account']; - obj.apiVersion = obj.apiVersion || headers['stripe-version']; - obj.idempotencyKey = obj.idempotencyKey || headers['idempotency-key']; - }, - _makeResponseEvent(requestEvent, statusCode, headers) { - const requestEndTime = Date.now(); - const requestDurationMs = requestEndTime - requestEvent.request_start_time; - return utils.removeNullish({ - api_version: headers['stripe-version'], - account: headers['stripe-account'], - idempotency_key: headers['idempotency-key'], - method: requestEvent.method, - path: requestEvent.path, - status: statusCode, - request_id: this._getRequestId(headers), - elapsed: requestDurationMs, - request_start_time: requestEvent.request_start_time, - request_end_time: requestEndTime, - }); - }, - _getRequestId(headers) { - return headers['request-id']; - }, - /** - * Used by methods with spec.streaming === true. For these methods, we do not - * buffer successful responses into memory or do parse them into stripe - * objects, we delegate that all of that to the user and pass back the raw - * http.Response object to the callback. - * - * (Unsuccessful responses shouldn't make it here, they should - * still be buffered/parsed and handled by _jsonResponseHandler -- see - * makeRequest) - */ - _streamingResponseHandler(requestEvent, callback) { - return (res) => { - const headers = res.getHeaders(); - const streamCompleteCallback = () => { - const responseEvent = this._makeResponseEvent( - requestEvent, - res.getStatusCode(), - headers - ); - this._stripe._emitter.emit('response', responseEvent); - this._recordRequestMetrics( - this._getRequestId(headers), - responseEvent.elapsed - ); - }; - const stream = res.toStream(streamCompleteCallback); - // This is here for backwards compatibility, as the stream is a raw - // HTTP response in Node and the legacy behavior was to mutate this - // response. - this._addHeadersDirectlyToObject(stream, headers); - return callback(null, stream); - }; - }, - /** - * Default handler for Stripe responses. Buffers the response into memory, - * parses the JSON and returns it (i.e. passes it to the callback) if there - * is no "error" field. Otherwise constructs/passes an appropriate Error. - */ - _jsonResponseHandler(requestEvent, callback) { - return (res) => { - const headers = res.getHeaders(); - const requestId = this._getRequestId(headers); - const statusCode = res.getStatusCode(); - const responseEvent = this._makeResponseEvent( - requestEvent, - statusCode, - headers - ); - this._stripe._emitter.emit('response', responseEvent); - res - .toJSON() - .then( - (jsonResponse) => { - if (jsonResponse.error) { - let err; - // Convert OAuth error responses into a standard format - // so that the rest of the error logic can be shared - if (typeof jsonResponse.error === 'string') { - jsonResponse.error = { - type: jsonResponse.error, - message: jsonResponse.error_description, - }; - } - jsonResponse.error.headers = headers; - jsonResponse.error.statusCode = statusCode; - jsonResponse.error.requestId = requestId; - if (statusCode === 401) { - err = new StripeAuthenticationError(jsonResponse.error); - } else if (statusCode === 403) { - err = new StripePermissionError(jsonResponse.error); - } else if (statusCode === 429) { - err = new StripeRateLimitError(jsonResponse.error); - } else { - err = StripeError.generate(jsonResponse.error); - } - throw err; + _stripe: null, + // @ts-ignore the type of path changes in ctor + path: '', + resourcePath: '', + // Methods that don't use the API's default '/v1' path can override it with this setting. + basePath: null, + initialize() { }, + // Function to override the default data processor. This allows full control + // over how a StripeResource's request data will get converted into an HTTP + // body. This is useful for non-standard HTTP requests. The function should + // take method name, data, and headers as arguments. + requestDataProcessor: null, + // Function to add a validation checks before sending the request, errors should + // be thrown, and they will be passed to the callback/promise. + validateRequest: null, + createFullPath(commandPath, urlData) { + const urlParts = [this.basePath(urlData), this.path(urlData)]; + if (typeof commandPath === 'function') { + const computedCommandPath = commandPath(urlData); + // If we have no actual command path, we just omit it to avoid adding a + // trailing slash. This is important for top-level listing requests, which + // do not have a command path. + if (computedCommandPath) { + urlParts.push(computedCommandPath); } - return jsonResponse; - }, - (e) => { - throw new StripeAPIError({ - message: 'Invalid JSON received from the Stripe API', - exception: e, - requestId: headers['request-id'], + } + else { + urlParts.push(commandPath); + } + return this._joinUrlParts(urlParts); + }, + // Creates a relative resource path with symbols left in (unlike + // createFullPath which takes some data to replace them with). For example it + // might produce: /invoices/{id} + createResourcePathWithSymbols(pathWithSymbols) { + // If there is no path beyond the resource path, we want to produce just + // / rather than //. + if (pathWithSymbols) { + return `/${this._joinUrlParts([this.resourcePath, pathWithSymbols])}`; + } + else { + return `/${this.resourcePath}`; + } + }, + _joinUrlParts(parts) { + // Replace any accidentally doubled up slashes. This previously used + // path.join, which would do this as well. Unfortunately we need to do this + // as the functions for creating paths are technically part of the public + // interface and so we need to preserve backwards compatibility. + return parts.join('/').replace(/\/{2,}/g, '/'); + }, + // DEPRECATED: Here for backcompat in case users relied on this. + wrapTimeout: utils.callbackifyPromiseWithTimeout, + _addHeadersDirectlyToObject(obj, headers) { + // For convenience, make some headers easily accessible on + // lastResponse. + // NOTE: Stripe responds with lowercase header names/keys. + obj.requestId = headers['request-id']; + obj.stripeAccount = obj.stripeAccount || headers['stripe-account']; + obj.apiVersion = obj.apiVersion || headers['stripe-version']; + obj.idempotencyKey = obj.idempotencyKey || headers['idempotency-key']; + }, + _makeResponseEvent(requestEvent, statusCode, headers) { + const requestEndTime = Date.now(); + const requestDurationMs = requestEndTime - requestEvent.request_start_time; + return utils.removeNullish({ + api_version: headers['stripe-version'], + account: headers['stripe-account'], + idempotency_key: headers['idempotency-key'], + method: requestEvent.method, + path: requestEvent.path, + status: statusCode, + request_id: this._getRequestId(headers), + elapsed: requestDurationMs, + request_start_time: requestEvent.request_start_time, + request_end_time: requestEndTime, + }); + }, + _getRequestId(headers) { + return headers['request-id']; + }, + /** + * Used by methods with spec.streaming === true. For these methods, we do not + * buffer successful responses into memory or do parse them into stripe + * objects, we delegate that all of that to the user and pass back the raw + * http.Response object to the callback. + * + * (Unsuccessful responses shouldn't make it here, they should + * still be buffered/parsed and handled by _jsonResponseHandler -- see + * makeRequest) + */ + _streamingResponseHandler(requestEvent, callback) { + return (res) => { + const headers = res.getHeaders(); + const streamCompleteCallback = () => { + const responseEvent = this._makeResponseEvent(requestEvent, res.getStatusCode(), headers); + this._stripe._emitter.emit('response', responseEvent); + this._recordRequestMetrics(this._getRequestId(headers), responseEvent.elapsed); + }; + const stream = res.toStream(streamCompleteCallback); + // This is here for backwards compatibility, as the stream is a raw + // HTTP response in Node and the legacy behavior was to mutate this + // response. + this._addHeadersDirectlyToObject(stream, headers); + return callback(null, stream); + }; + }, + /** + * Default handler for Stripe responses. Buffers the response into memory, + * parses the JSON and returns it (i.e. passes it to the callback) if there + * is no "error" field. Otherwise constructs/passes an appropriate Error. + */ + _jsonResponseHandler(requestEvent, callback) { + return (res) => { + const headers = res.getHeaders(); + const requestId = this._getRequestId(headers); + const statusCode = res.getStatusCode(); + const responseEvent = this._makeResponseEvent(requestEvent, statusCode, headers); + this._stripe._emitter.emit('response', responseEvent); + res + .toJSON() + .then((jsonResponse) => { + if (jsonResponse.error) { + let err; + // Convert OAuth error responses into a standard format + // so that the rest of the error logic can be shared + if (typeof jsonResponse.error === 'string') { + jsonResponse.error = { + type: jsonResponse.error, + message: jsonResponse.error_description, + }; + } + jsonResponse.error.headers = headers; + jsonResponse.error.statusCode = statusCode; + jsonResponse.error.requestId = requestId; + if (statusCode === 401) { + err = new StripeAuthenticationError(jsonResponse.error); + } + else if (statusCode === 403) { + err = new StripePermissionError(jsonResponse.error); + } + else if (statusCode === 429) { + err = new StripeRateLimitError(jsonResponse.error); + } + else { + err = StripeError.generate(jsonResponse.error); + } + throw err; + } + return jsonResponse; + }, (e) => { + throw new StripeAPIError({ + message: 'Invalid JSON received from the Stripe API', + exception: e, + requestId: headers['request-id'], + }); + }) + .then((jsonResponse) => { + this._recordRequestMetrics(requestId, responseEvent.elapsed); + // Expose raw response object. + const rawResponse = res.getRawResponse(); + this._addHeadersDirectlyToObject(rawResponse, headers); + Object.defineProperty(jsonResponse, 'lastResponse', { + enumerable: false, + writable: false, + value: rawResponse, + }); + callback.call(this, null, jsonResponse); + }, (e) => callback.call(this, e, null)); + }; + }, + _generateConnectionErrorMessage(requestRetries) { + return `An error occurred with our connection to Stripe.${requestRetries > 0 ? ` Request was retried ${requestRetries} times.` : ''}`; + }, + // For more on when and how to retry API requests, see https://stripe.com/docs/error-handling#safely-retrying-requests-with-idempotency + _shouldRetry(res, numRetries, maxRetries, error) { + if (error && + numRetries === 0 && + HttpClient.CONNECTION_CLOSED_ERROR_CODES.includes(error.code)) { + return true; + } + // Do not retry if we are out of retries. + if (numRetries >= maxRetries) { + return false; + } + // Retry on connection error. + if (!res) { + return true; + } + // The API may ask us not to retry (e.g., if doing so would be a no-op) + // or advise us to retry (e.g., in cases of lock timeouts); we defer to that. + if (res.getHeaders()['stripe-should-retry'] === 'false') { + return false; + } + if (res.getHeaders()['stripe-should-retry'] === 'true') { + return true; + } + // Retry on conflict errors. + if (res.getStatusCode() === 409) { + return true; + } + // Retry on 500, 503, and other internal errors. + // + // Note that we expect the stripe-should-retry header to be false + // in most cases when a 500 is returned, since our idempotency framework + // would typically replay it anyway. + if (res.getStatusCode() >= 500) { + return true; + } + return false; + }, + _getSleepTimeInMS(numRetries, retryAfter = null) { + const initialNetworkRetryDelay = this._stripe.getInitialNetworkRetryDelay(); + const maxNetworkRetryDelay = this._stripe.getMaxNetworkRetryDelay(); + // Apply exponential backoff with initialNetworkRetryDelay on the + // number of numRetries so far as inputs. Do not allow the number to exceed + // maxNetworkRetryDelay. + let sleepSeconds = Math.min(initialNetworkRetryDelay * Math.pow(numRetries - 1, 2), maxNetworkRetryDelay); + // Apply some jitter by randomizing the value in the range of + // (sleepSeconds / 2) to (sleepSeconds). + sleepSeconds *= 0.5 * (1 + Math.random()); + // But never sleep less than the base sleep seconds. + sleepSeconds = Math.max(initialNetworkRetryDelay, sleepSeconds); + // And never sleep less than the time the API asks us to wait, assuming it's a reasonable ask. + if (Number.isInteger(retryAfter) && retryAfter <= MAX_RETRY_AFTER_WAIT) { + sleepSeconds = Math.max(sleepSeconds, retryAfter); + } + return sleepSeconds * 1000; + }, + // Max retries can be set on a per request basis. Favor those over the global setting + _getMaxNetworkRetries(settings = {}) { + return settings.maxNetworkRetries && + Number.isInteger(settings.maxNetworkRetries) + ? settings.maxNetworkRetries + : this._stripe.getMaxNetworkRetries(); + }, + _defaultIdempotencyKey(method, settings) { + // If this is a POST and we allow multiple retries, ensure an idempotency key. + const maxRetries = this._getMaxNetworkRetries(settings); + if (method === 'POST' && maxRetries > 0) { + return `stripe-node-retry-${utils.uuid4()}`; + } + return null; + }, + _makeHeaders(auth, contentLength, apiVersion, clientUserAgent, method, userSuppliedHeaders, userSuppliedSettings) { + const defaultHeaders = { + // Use specified auth token or use default from this stripe instance: + Authorization: auth ? `Bearer ${auth}` : this._stripe.getApiField('auth'), + Accept: 'application/json', + 'Content-Type': 'application/x-www-form-urlencoded', + 'User-Agent': this._getUserAgentString(), + 'X-Stripe-Client-User-Agent': clientUserAgent, + 'X-Stripe-Client-Telemetry': this._getTelemetryHeader(), + 'Stripe-Version': apiVersion, + 'Stripe-Account': this._stripe.getApiField('stripeAccount'), + 'Idempotency-Key': this._defaultIdempotencyKey(method, userSuppliedSettings), + }; + // As per https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2: + // A user agent SHOULD send a Content-Length in a request message when + // no Transfer-Encoding is sent and the request method defines a meaning + // for an enclosed payload body. For example, a Content-Length header + // field is normally sent in a POST request even when the value is 0 + // (indicating an empty payload body). A user agent SHOULD NOT send a + // Content-Length header field when the request message does not contain + // a payload body and the method semantics do not anticipate such a + // body. + // + // These method types are expected to have bodies and so we should always + // include a Content-Length. + const methodHasPayload = method == 'POST' || method == 'PUT' || method == 'PATCH'; + // If a content length was specified, we always include it regardless of + // whether the method semantics anticipate such a body. This keeps us + // consistent with historical behavior. We do however want to warn on this + // and fix these cases as they are semantically incorrect. + if (methodHasPayload || contentLength) { + if (!methodHasPayload) { + utils.emitWarning(`${method} method had non-zero contentLength but no payload is expected for this verb`); + } + defaultHeaders['Content-Length'] = contentLength; + } + return Object.assign(utils.removeNullish(defaultHeaders), + // If the user supplied, say 'idempotency-key', override instead of appending by ensuring caps are the same. + utils.normalizeHeaders(userSuppliedHeaders)); + }, + _getUserAgentString() { + const packageVersion = this._stripe.getConstant('PACKAGE_VERSION'); + const appInfo = this._stripe._appInfo + ? this._stripe.getAppInfoAsString() + : ''; + return `Stripe/v1 NodeBindings/${packageVersion} ${appInfo}`.trim(); + }, + _getTelemetryHeader() { + if (this._stripe.getTelemetryEnabled() && + this._stripe._prevRequestMetrics.length > 0) { + const metrics = this._stripe._prevRequestMetrics.shift(); + return JSON.stringify({ + last_request_metrics: metrics, }); - } - ) - .then( - (jsonResponse) => { - this._recordRequestMetrics(requestId, responseEvent.elapsed); - // Expose raw response object. - const rawResponse = res.getRawResponse(); - this._addHeadersDirectlyToObject(rawResponse, headers); - Object.defineProperty(jsonResponse, 'lastResponse', { - enumerable: false, - writable: false, - value: rawResponse, + } + }, + _recordRequestMetrics(requestId, requestDurationMs) { + if (this._stripe.getTelemetryEnabled() && requestId) { + if (this._stripe._prevRequestMetrics.length > + StripeResource.MAX_BUFFERED_REQUEST_METRICS) { + utils.emitWarning('Request metrics buffer is full, dropping telemetry message.'); + } + else { + this._stripe._prevRequestMetrics.push({ + request_id: requestId, + request_duration_ms: requestDurationMs, + }); + } + } + }, + _request(method, host, path, data, auth, options = {}, callback) { + let requestData; + const retryRequest = (requestFn, apiVersion, headers, requestRetries, retryAfter) => { + return setTimeout(requestFn, this._getSleepTimeInMS(requestRetries, retryAfter), apiVersion, headers, requestRetries + 1); + }; + const makeRequest = (apiVersion, headers, numRetries) => { + // timeout can be set on a per-request basis. Favor that over the global setting + const timeout = options.settings && + options.settings.timeout && + Number.isInteger(options.settings.timeout) && + options.settings.timeout >= 0 + ? options.settings.timeout + : this._stripe.getApiField('timeout'); + const req = this._stripe + .getApiField('httpClient') + .makeRequest(host || this._stripe.getApiField('host'), this._stripe.getApiField('port'), path, method, headers, requestData, this._stripe.getApiField('protocol'), timeout); + const requestStartTime = Date.now(); + // @ts-ignore + const requestEvent = utils.removeNullish({ + api_version: apiVersion, + account: headers['Stripe-Account'], + idempotency_key: headers['Idempotency-Key'], + method, + path, + request_start_time: requestStartTime, }); - callback.call(this, null, jsonResponse); - }, - (e) => callback.call(this, e, null) - ); - }; - }, - _generateConnectionErrorMessage(requestRetries) { - return `An error occurred with our connection to Stripe.${ - requestRetries > 0 ? ` Request was retried ${requestRetries} times.` : '' - }`; - }, - // For more on when and how to retry API requests, see https://stripe.com/docs/error-handling#safely-retrying-requests-with-idempotency - _shouldRetry(res, numRetries, maxRetries, error) { - if ( - error && - numRetries === 0 && - HttpClient.CONNECTION_CLOSED_ERROR_CODES.includes(error.code) - ) { - return true; - } - // Do not retry if we are out of retries. - if (numRetries >= maxRetries) { - return false; - } - // Retry on connection error. - if (!res) { - return true; - } - // The API may ask us not to retry (e.g., if doing so would be a no-op) - // or advise us to retry (e.g., in cases of lock timeouts); we defer to that. - if (res.getHeaders()['stripe-should-retry'] === 'false') { - return false; - } - if (res.getHeaders()['stripe-should-retry'] === 'true') { - return true; - } - // Retry on conflict errors. - if (res.getStatusCode() === 409) { - return true; - } - // Retry on 500, 503, and other internal errors. - // - // Note that we expect the stripe-should-retry header to be false - // in most cases when a 500 is returned, since our idempotency framework - // would typically replay it anyway. - if (res.getStatusCode() >= 500) { - return true; - } - return false; - }, - _getSleepTimeInMS(numRetries, retryAfter = null) { - const initialNetworkRetryDelay = this._stripe.getInitialNetworkRetryDelay(); - const maxNetworkRetryDelay = this._stripe.getMaxNetworkRetryDelay(); - // Apply exponential backoff with initialNetworkRetryDelay on the - // number of numRetries so far as inputs. Do not allow the number to exceed - // maxNetworkRetryDelay. - let sleepSeconds = Math.min( - initialNetworkRetryDelay * Math.pow(numRetries - 1, 2), - maxNetworkRetryDelay - ); - // Apply some jitter by randomizing the value in the range of - // (sleepSeconds / 2) to (sleepSeconds). - sleepSeconds *= 0.5 * (1 + Math.random()); - // But never sleep less than the base sleep seconds. - sleepSeconds = Math.max(initialNetworkRetryDelay, sleepSeconds); - // And never sleep less than the time the API asks us to wait, assuming it's a reasonable ask. - if (Number.isInteger(retryAfter) && retryAfter <= MAX_RETRY_AFTER_WAIT) { - sleepSeconds = Math.max(sleepSeconds, retryAfter); - } - return sleepSeconds * 1000; - }, - // Max retries can be set on a per request basis. Favor those over the global setting - _getMaxNetworkRetries(settings = {}) { - return settings.maxNetworkRetries && - Number.isInteger(settings.maxNetworkRetries) - ? settings.maxNetworkRetries - : this._stripe.getMaxNetworkRetries(); - }, - _defaultIdempotencyKey(method, settings) { - // If this is a POST and we allow multiple retries, ensure an idempotency key. - const maxRetries = this._getMaxNetworkRetries(settings); - if (method === 'POST' && maxRetries > 0) { - return `stripe-node-retry-${utils.uuid4()}`; - } - return null; - }, - _makeHeaders( - auth, - contentLength, - apiVersion, - clientUserAgent, - method, - userSuppliedHeaders, - userSuppliedSettings - ) { - const defaultHeaders = { - // Use specified auth token or use default from this stripe instance: - Authorization: auth ? `Bearer ${auth}` : this._stripe.getApiField('auth'), - Accept: 'application/json', - 'Content-Type': 'application/x-www-form-urlencoded', - 'User-Agent': this._getUserAgentString(), - 'X-Stripe-Client-User-Agent': clientUserAgent, - 'X-Stripe-Client-Telemetry': this._getTelemetryHeader(), - 'Stripe-Version': apiVersion, - 'Stripe-Account': this._stripe.getApiField('stripeAccount'), - 'Idempotency-Key': this._defaultIdempotencyKey( - method, - userSuppliedSettings - ), - }; - // As per https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2: - // A user agent SHOULD send a Content-Length in a request message when - // no Transfer-Encoding is sent and the request method defines a meaning - // for an enclosed payload body. For example, a Content-Length header - // field is normally sent in a POST request even when the value is 0 - // (indicating an empty payload body). A user agent SHOULD NOT send a - // Content-Length header field when the request message does not contain - // a payload body and the method semantics do not anticipate such a - // body. - // - // These method types are expected to have bodies and so we should always - // include a Content-Length. - const methodHasPayload = - method == 'POST' || method == 'PUT' || method == 'PATCH'; - // If a content length was specified, we always include it regardless of - // whether the method semantics anticipate such a body. This keeps us - // consistent with historical behavior. We do however want to warn on this - // and fix these cases as they are semantically incorrect. - if (methodHasPayload || contentLength) { - if (!methodHasPayload) { - utils.emitWarning( - `${method} method had non-zero contentLength but no payload is expected for this verb` - ); - } - defaultHeaders['Content-Length'] = contentLength; - } - return Object.assign( - utils.removeNullish(defaultHeaders), - // If the user supplied, say 'idempotency-key', override instead of appending by ensuring caps are the same. - utils.normalizeHeaders(userSuppliedHeaders) - ); - }, - _getUserAgentString() { - const packageVersion = this._stripe.getConstant('PACKAGE_VERSION'); - const appInfo = this._stripe._appInfo - ? this._stripe.getAppInfoAsString() - : ''; - return `Stripe/v1 NodeBindings/${packageVersion} ${appInfo}`.trim(); - }, - _getTelemetryHeader() { - if ( - this._stripe.getTelemetryEnabled() && - this._stripe._prevRequestMetrics.length > 0 - ) { - const metrics = this._stripe._prevRequestMetrics.shift(); - return JSON.stringify({ - last_request_metrics: metrics, - }); - } - }, - _recordRequestMetrics(requestId, requestDurationMs) { - if (this._stripe.getTelemetryEnabled() && requestId) { - if ( - this._stripe._prevRequestMetrics.length > - StripeResource.MAX_BUFFERED_REQUEST_METRICS - ) { - utils.emitWarning( - 'Request metrics buffer is full, dropping telemetry message.' - ); - } else { - this._stripe._prevRequestMetrics.push({ - request_id: requestId, - request_duration_ms: requestDurationMs, - }); - } - } - }, - _request(method, host, path, data, auth, options = {}, callback) { - let requestData; - const retryRequest = ( - requestFn, - apiVersion, - headers, - requestRetries, - retryAfter - ) => { - return setTimeout( - requestFn, - this._getSleepTimeInMS(requestRetries, retryAfter), - apiVersion, - headers, - requestRetries + 1 - ); - }; - const makeRequest = (apiVersion, headers, numRetries) => { - // timeout can be set on a per-request basis. Favor that over the global setting - const timeout = - options.settings && - options.settings.timeout && - Number.isInteger(options.settings.timeout) && - options.settings.timeout >= 0 - ? options.settings.timeout - : this._stripe.getApiField('timeout'); - const req = this._stripe - .getApiField('httpClient') - .makeRequest( - host || this._stripe.getApiField('host'), - this._stripe.getApiField('port'), - path, - method, - headers, - requestData, - this._stripe.getApiField('protocol'), - timeout - ); - const requestStartTime = Date.now(); - // @ts-ignore - const requestEvent = utils.removeNullish({ - api_version: apiVersion, - account: headers['Stripe-Account'], - idempotency_key: headers['Idempotency-Key'], - method, - path, - request_start_time: requestStartTime, - }); - const requestRetries = numRetries || 0; - const maxRetries = this._getMaxNetworkRetries(options.settings || {}); - this._stripe._emitter.emit('request', requestEvent); - req - .then((res) => { - if (this._shouldRetry(res, requestRetries, maxRetries)) { - return retryRequest( - makeRequest, - apiVersion, - headers, - requestRetries, - // @ts-ignore - res.getHeaders()['retry-after'] - ); - } else if (options.streaming && res.getStatusCode() < 400) { - return this._streamingResponseHandler(requestEvent, callback)(res); - } else { - return this._jsonResponseHandler(requestEvent, callback)(res); - } - }) - .catch((error) => { - if (this._shouldRetry(null, requestRetries, maxRetries, error)) { - return retryRequest( - makeRequest, - apiVersion, - headers, - requestRetries, - null - ); - } else { - const isTimeoutError = - error.code && error.code === HttpClient.TIMEOUT_ERROR_CODE; - return callback.call( - this, - new StripeConnectionError({ - message: isTimeoutError - ? `Request aborted due to timeout being reached (${timeout}ms)` - : this._generateConnectionErrorMessage(requestRetries), - // @ts-ignore - detail: error, - }) - ); - } - }); - }; - const prepareAndMakeRequest = (error, data) => { - if (error) { - return callback(error); - } - requestData = data; - this._stripe.getClientUserAgent((clientUserAgent) => { - const apiVersion = this._stripe.getApiField('version'); - const headers = this._makeHeaders( - auth, - requestData.length, - apiVersion, - clientUserAgent, - method, - options.headers, - options.settings - ); - makeRequest(apiVersion, headers, 0); - }); - }; - if (this.requestDataProcessor) { - this.requestDataProcessor( - method, - data, - options.headers, - prepareAndMakeRequest - ); - } else { - prepareAndMakeRequest(null, utils.stringifyRequestData(data || {})); - } - }, + const requestRetries = numRetries || 0; + const maxRetries = this._getMaxNetworkRetries(options.settings || {}); + this._stripe._emitter.emit('request', requestEvent); + req + .then((res) => { + if (this._shouldRetry(res, requestRetries, maxRetries)) { + return retryRequest(makeRequest, apiVersion, headers, requestRetries, + // @ts-ignore + res.getHeaders()['retry-after']); + } + else if (options.streaming && res.getStatusCode() < 400) { + return this._streamingResponseHandler(requestEvent, callback)(res); + } + else { + return this._jsonResponseHandler(requestEvent, callback)(res); + } + }) + .catch((error) => { + if (this._shouldRetry(null, requestRetries, maxRetries, error)) { + return retryRequest(makeRequest, apiVersion, headers, requestRetries, null); + } + else { + const isTimeoutError = error.code && error.code === HttpClient.TIMEOUT_ERROR_CODE; + return callback.call(this, new StripeConnectionError({ + message: isTimeoutError + ? `Request aborted due to timeout being reached (${timeout}ms)` + : this._generateConnectionErrorMessage(requestRetries), + // @ts-ignore + detail: error, + })); + } + }); + }; + const prepareAndMakeRequest = (error, data) => { + if (error) { + return callback(error); + } + requestData = data; + this._stripe.getClientUserAgent((clientUserAgent) => { + const apiVersion = this._stripe.getApiField('version'); + const headers = this._makeHeaders(auth, requestData.length, apiVersion, clientUserAgent, method, options.headers, options.settings); + makeRequest(apiVersion, headers, 0); + }); + }; + if (this.requestDataProcessor) { + this.requestDataProcessor(method, data, options.headers, prepareAndMakeRequest); + } + else { + prepareAndMakeRequest(null, utils.stringifyRequestData(data || {})); + } + }, }; module.exports = StripeResource; diff --git a/lib/Webhooks.js b/lib/Webhooks.js index 23690d44a3..e7ea5fc81f 100644 --- a/lib/Webhooks.js +++ b/lib/Webhooks.js @@ -1,214 +1,142 @@ -'use strict'; -const utils = require('./utils'); -const _Error = require('./Error'); -const {StripeError, StripeSignatureVerificationError} = _Error; +"use strict"; +const utils = require("./utils"); +const _Error = require("./Error"); +const { StripeError, StripeSignatureVerificationError } = _Error; const Webhook = { - DEFAULT_TOLERANCE: 300, - // @ts-ignore - signature: null, - constructEvent(payload, header, secret, tolerance, cryptoProvider) { - this.signature.verifyHeader( - payload, - header, - secret, - tolerance || Webhook.DEFAULT_TOLERANCE, - cryptoProvider - ); + DEFAULT_TOLERANCE: 300, // @ts-ignore - const jsonPayload = JSON.parse(payload); - return jsonPayload; - }, - async constructEventAsync( - payload, - header, - secret, - tolerance, - cryptoProvider - ) { - await this.signature.verifyHeaderAsync( - payload, - header, - secret, - tolerance || Webhook.DEFAULT_TOLERANCE, - cryptoProvider - ); - // @ts-ignore - const jsonPayload = JSON.parse(payload); - return jsonPayload; - }, - /** - * Generates a header to be used for webhook mocking - * - * @typedef {object} opts - * @property {number} timestamp - Timestamp of the header. Defaults to Date.now() - * @property {string} payload - JSON stringified payload object, containing the 'id' and 'object' parameters - * @property {string} secret - Stripe webhook secret 'whsec_...' - * @property {string} scheme - Version of API to hit. Defaults to 'v1'. - * @property {string} signature - Computed webhook signature - * @property {CryptoProvider} cryptoProvider - Crypto provider to use for computing the signature if none was provided. Defaults to NodeCryptoProvider. - */ - generateTestHeaderString: function(opts) { - if (!opts) { - throw new StripeError({ - message: 'Options are required', - }); - } - opts.timestamp = - Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000); - opts.scheme = opts.scheme || signature.EXPECTED_SCHEME; - opts.cryptoProvider = opts.cryptoProvider || getNodeCryptoProvider(); - opts.signature = - opts.signature || - opts.cryptoProvider.computeHMACSignature( - opts.timestamp + '.' + opts.payload, - opts.secret - ); - const generatedHeader = [ - 't=' + opts.timestamp, - opts.scheme + '=' + opts.signature, - ].join(','); - return generatedHeader; - }, + signature: null, + constructEvent(payload, header, secret, tolerance, cryptoProvider) { + this.signature.verifyHeader(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider); + // @ts-ignore + const jsonPayload = JSON.parse(payload); + return jsonPayload; + }, + async constructEventAsync(payload, header, secret, tolerance, cryptoProvider) { + await this.signature.verifyHeaderAsync(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider); + // @ts-ignore + const jsonPayload = JSON.parse(payload); + return jsonPayload; + }, + /** + * Generates a header to be used for webhook mocking + * + * @typedef {object} opts + * @property {number} timestamp - Timestamp of the header. Defaults to Date.now() + * @property {string} payload - JSON stringified payload object, containing the 'id' and 'object' parameters + * @property {string} secret - Stripe webhook secret 'whsec_...' + * @property {string} scheme - Version of API to hit. Defaults to 'v1'. + * @property {string} signature - Computed webhook signature + * @property {CryptoProvider} cryptoProvider - Crypto provider to use for computing the signature if none was provided. Defaults to NodeCryptoProvider. + */ + generateTestHeaderString: function (opts) { + if (!opts) { + throw new StripeError({ + message: 'Options are required', + }); + } + opts.timestamp = + Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000); + opts.scheme = opts.scheme || signature.EXPECTED_SCHEME; + opts.cryptoProvider = opts.cryptoProvider || getNodeCryptoProvider(); + opts.signature = + opts.signature || + opts.cryptoProvider.computeHMACSignature(opts.timestamp + '.' + opts.payload, opts.secret); + const generatedHeader = [ + 't=' + opts.timestamp, + opts.scheme + '=' + opts.signature, + ].join(','); + return generatedHeader; + }, }; const signature = { - EXPECTED_SCHEME: 'v1', - verifyHeader( - encodedPayload, - encodedHeader, - secret, - tolerance, - cryptoProvider - ) { - const { - decodedHeader: header, - decodedPayload: payload, - details, - } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); - cryptoProvider = cryptoProvider || getNodeCryptoProvider(); - const expectedSignature = cryptoProvider.computeHMACSignature( - makeHMACContent(payload, details), - secret - ); - validateComputedSignature( - payload, - header, - details, - expectedSignature, - tolerance - ); - return true; - }, - async verifyHeaderAsync( - encodedPayload, - encodedHeader, - secret, - tolerance, - cryptoProvider - ) { - const { - decodedHeader: header, - decodedPayload: payload, - details, - } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); - cryptoProvider = cryptoProvider || getNodeCryptoProvider(); - const expectedSignature = await cryptoProvider.computeHMACSignatureAsync( - makeHMACContent(payload, details), - secret - ); - return validateComputedSignature( - payload, - header, - details, - expectedSignature, - tolerance - ); - }, + EXPECTED_SCHEME: 'v1', + verifyHeader(encodedPayload, encodedHeader, secret, tolerance, cryptoProvider) { + const { decodedHeader: header, decodedPayload: payload, details, } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); + cryptoProvider = cryptoProvider || getNodeCryptoProvider(); + const expectedSignature = cryptoProvider.computeHMACSignature(makeHMACContent(payload, details), secret); + validateComputedSignature(payload, header, details, expectedSignature, tolerance); + return true; + }, + async verifyHeaderAsync(encodedPayload, encodedHeader, secret, tolerance, cryptoProvider) { + const { decodedHeader: header, decodedPayload: payload, details, } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); + cryptoProvider = cryptoProvider || getNodeCryptoProvider(); + const expectedSignature = await cryptoProvider.computeHMACSignatureAsync(makeHMACContent(payload, details), secret); + return validateComputedSignature(payload, header, details, expectedSignature, tolerance); + }, }; function makeHMACContent(payload, details) { - return `${details.timestamp}.${payload}`; + return `${details.timestamp}.${payload}`; } function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) { - const decodedPayload = Buffer.isBuffer(encodedPayload) - ? encodedPayload.toString('utf8') - : encodedPayload; - // Express's type for `Request#headers` is `string | []string` - // which is because the `set-cookie` header is an array, - // but no other headers are an array (docs: https://nodejs.org/api/http.html#http_message_headers) - // (Express's Request class is an extension of http.IncomingMessage, and doesn't appear to be relevantly modified: https://github.com/expressjs/express/blob/master/lib/request.js#L31) - if (Array.isArray(encodedHeader)) { - throw new Error( - 'Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.' - ); - } - const decodedHeader = Buffer.isBuffer(encodedHeader) - ? encodedHeader.toString('utf8') - : encodedHeader; - const details = parseHeader(decodedHeader, expectedScheme); - if (!details || details.timestamp === -1) { - throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { - message: 'Unable to extract timestamp and signatures from header', - }); - } - if (!details.signatures.length) { - throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { - message: 'No signatures found with expected scheme', - }); - } - return { - decodedPayload, - decodedHeader, - details, - }; + const decodedPayload = Buffer.isBuffer(encodedPayload) + ? encodedPayload.toString('utf8') + : encodedPayload; + // Express's type for `Request#headers` is `string | []string` + // which is because the `set-cookie` header is an array, + // but no other headers are an array (docs: https://nodejs.org/api/http.html#http_message_headers) + // (Express's Request class is an extension of http.IncomingMessage, and doesn't appear to be relevantly modified: https://github.com/expressjs/express/blob/master/lib/request.js#L31) + if (Array.isArray(encodedHeader)) { + throw new Error('Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.'); + } + const decodedHeader = Buffer.isBuffer(encodedHeader) + ? encodedHeader.toString('utf8') + : encodedHeader; + const details = parseHeader(decodedHeader, expectedScheme); + if (!details || details.timestamp === -1) { + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { + message: 'Unable to extract timestamp and signatures from header', + }); + } + if (!details.signatures.length) { + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { + message: 'No signatures found with expected scheme', + }); + } + return { + decodedPayload, + decodedHeader, + details, + }; } -function validateComputedSignature( - payload, - header, - details, - expectedSignature, - tolerance -) { - const signatureFound = !!details.signatures.filter( - // @ts-ignore - utils.secureCompare.bind(utils, expectedSignature) - ).length; - if (!signatureFound) { - // @ts-ignore - throw new StripeSignatureVerificationError(header, payload, { - message: - 'No signatures found matching the expected signature for payload.' + - ' Are you passing the raw request body you received from Stripe?' + - ' https://github.com/stripe/stripe-node#webhook-signing', - }); - } - const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; - if (tolerance > 0 && timestampAge > tolerance) { +function validateComputedSignature(payload, header, details, expectedSignature, tolerance) { + const signatureFound = !!details.signatures.filter( // @ts-ignore - throw new StripeSignatureVerificationError(header, payload, { - message: 'Timestamp outside the tolerance zone', - }); - } - return true; + utils.secureCompare.bind(utils, expectedSignature)).length; + if (!signatureFound) { + // @ts-ignore + throw new StripeSignatureVerificationError(header, payload, { + message: 'No signatures found matching the expected signature for payload.' + + ' Are you passing the raw request body you received from Stripe?' + + ' https://github.com/stripe/stripe-node#webhook-signing', + }); + } + const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; + if (tolerance > 0 && timestampAge > tolerance) { + // @ts-ignore + throw new StripeSignatureVerificationError(header, payload, { + message: 'Timestamp outside the tolerance zone', + }); + } + return true; } function parseHeader(header, scheme) { - if (typeof header !== 'string') { - return null; - } - return header.split(',').reduce( - (accum, item) => { - const kv = item.split('='); - if (kv[0] === 't') { - accum.timestamp = parseInt(kv[1], 10); - } - if (kv[0] === scheme) { - accum.signatures.push(kv[1]); - } - return accum; - }, - { - timestamp: -1, - signatures: [], + if (typeof header !== 'string') { + return null; } - ); + return header.split(',').reduce((accum, item) => { + const kv = item.split('='); + if (kv[0] === 't') { + accum.timestamp = parseInt(kv[1], 10); + } + if (kv[0] === scheme) { + accum.signatures.push(kv[1]); + } + return accum; + }, { + timestamp: -1, + signatures: [], + }); } let webhooksNodeCryptoProviderInstance = null; /** @@ -216,11 +144,11 @@ let webhooksNodeCryptoProviderInstance = null; * so a singleton can be used here. */ function getNodeCryptoProvider() { - if (!webhooksNodeCryptoProviderInstance) { - const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); - webhooksNodeCryptoProviderInstance = new NodeCryptoProvider(); - } - return webhooksNodeCryptoProviderInstance; + if (!webhooksNodeCryptoProviderInstance) { + const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); + webhooksNodeCryptoProviderInstance = new NodeCryptoProvider(); + } + return webhooksNodeCryptoProviderInstance; } Webhook.signature = signature; module.exports = Webhook; diff --git a/lib/apiVersion.js b/lib/apiVersion.js index eab32ae80a..12993d017c 100644 --- a/lib/apiVersion.js +++ b/lib/apiVersion.js @@ -1,3 +1,3 @@ -'use strict'; +"use strict"; // File generated from our OpenAPI spec -module.exports = {ApiVersion: '2022-11-09'}; +module.exports = { ApiVersion: '2022-11-15' }; diff --git a/lib/autoPagination.js b/lib/autoPagination.js index 3626ffeae3..ed7352c866 100644 --- a/lib/autoPagination.js +++ b/lib/autoPagination.js @@ -1,87 +1,81 @@ -'use strict'; -const makeRequest = require('./makeRequest'); +"use strict"; +const makeRequest = require("./makeRequest"); const utils = require('./utils'); function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { - const promiseCache = {currentPromise: null}; - const reverseIteration = isReverseIteration(requestArgs); - let pagePromise = firstPagePromise; - let i = 0; - // Search and List methods iterate differently. - // Search relies on a `next_page` token and can only iterate in one direction. - // List relies on either an `ending_before` or `starting_after` field with - // an item ID to paginate and is bi-directional. - // - // Please note: spec.methodType === 'search' is beta functionality and is - // subject to change/removal at any time. - let getNextPagePromise; - if (spec.methodType === 'search') { - getNextPagePromise = (pageResult) => { - if (!pageResult.next_page) { - throw Error( - 'Unexpected: Stripe API response does not have a well-formed `next_page` field, but `has_more` was true.' - ); - } - return makeRequest(self, requestArgs, spec, { - page: pageResult.next_page, - }); - }; - } else { - getNextPagePromise = (pageResult) => { - const lastId = getLastId(pageResult, reverseIteration); - return makeRequest(self, requestArgs, spec, { - [reverseIteration ? 'ending_before' : 'starting_after']: lastId, - }); - }; - } - function iterate(pageResult) { - if ( - !( - pageResult && - pageResult.data && - typeof pageResult.data.length === 'number' - ) - ) { - throw Error( - 'Unexpected: Stripe API response does not have a well-formed `data` array.' - ); + const promiseCache = { currentPromise: null }; + const reverseIteration = isReverseIteration(requestArgs); + let pagePromise = firstPagePromise; + let i = 0; + // Search and List methods iterate differently. + // Search relies on a `next_page` token and can only iterate in one direction. + // List relies on either an `ending_before` or `starting_after` field with + // an item ID to paginate and is bi-directional. + // + // Please note: spec.methodType === 'search' is beta functionality and is + // subject to change/removal at any time. + let getNextPagePromise; + if (spec.methodType === 'search') { + getNextPagePromise = (pageResult) => { + if (!pageResult.next_page) { + throw Error('Unexpected: Stripe API response does not have a well-formed `next_page` field, but `has_more` was true.'); + } + return makeRequest(self, requestArgs, spec, { + page: pageResult.next_page, + }); + }; } - if (i < pageResult.data.length) { - const idx = reverseIteration ? pageResult.data.length - 1 - i : i; - const value = pageResult.data[idx]; - i += 1; - return {value, done: false}; - } else if (pageResult.has_more) { - // Reset counter, request next page, and recurse. - i = 0; - pagePromise = getNextPagePromise(pageResult); - return pagePromise.then(iterate); + else { + getNextPagePromise = (pageResult) => { + const lastId = getLastId(pageResult, reverseIteration); + return makeRequest(self, requestArgs, spec, { + [reverseIteration ? 'ending_before' : 'starting_after']: lastId, + }); + }; } - return {value: undefined, done: true}; - } - function asyncIteratorNext() { - return memoizedPromise(promiseCache, (resolve, reject) => { - return pagePromise - .then(iterate) - .then(resolve) - .catch(reject); - }); - } - const autoPagingEach = makeAutoPagingEach(asyncIteratorNext); - const autoPagingToArray = makeAutoPagingToArray(autoPagingEach); - const autoPaginationMethods = { - autoPagingEach, - autoPagingToArray, - // Async iterator functions: - next: asyncIteratorNext, - return: () => { - // This is required for `break`. - return {}; - }, - [getAsyncIteratorSymbol()]: () => { - return autoPaginationMethods; - }, - }; - return autoPaginationMethods; + function iterate(pageResult) { + if (!(pageResult && + pageResult.data && + typeof pageResult.data.length === 'number')) { + throw Error('Unexpected: Stripe API response does not have a well-formed `data` array.'); + } + if (i < pageResult.data.length) { + const idx = reverseIteration ? pageResult.data.length - 1 - i : i; + const value = pageResult.data[idx]; + i += 1; + return { value, done: false }; + } + else if (pageResult.has_more) { + // Reset counter, request next page, and recurse. + i = 0; + pagePromise = getNextPagePromise(pageResult); + return pagePromise.then(iterate); + } + return { value: undefined, done: true }; + } + function asyncIteratorNext() { + return memoizedPromise(promiseCache, (resolve, reject) => { + return pagePromise + .then(iterate) + .then(resolve) + .catch(reject); + }); + } + const autoPagingEach = makeAutoPagingEach(asyncIteratorNext); + const autoPagingToArray = makeAutoPagingToArray(autoPagingEach); + const autoPaginationMethods = { + autoPagingEach, + autoPagingToArray, + // Async iterator functions: + next: asyncIteratorNext, + return: () => { + // This is required for `break`. + return {}; + }, + [getAsyncIteratorSymbol()]: () => { + return autoPaginationMethods; + }, + }; + return autoPaginationMethods; } /** * ---------------- @@ -89,23 +83,21 @@ function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { * ---------------- */ function getAsyncIteratorSymbol() { - if (typeof Symbol !== 'undefined' && Symbol.asyncIterator) { - return Symbol.asyncIterator; - } - // Follow the convention from libraries like iterall: https://github.com/leebyron/iterall#asynciterator-1 - return '@@asyncIterator'; + if (typeof Symbol !== 'undefined' && Symbol.asyncIterator) { + return Symbol.asyncIterator; + } + // Follow the convention from libraries like iterall: https://github.com/leebyron/iterall#asynciterator-1 + return '@@asyncIterator'; } function getDoneCallback(args) { - if (args.length < 2) { - return undefined; - } - const onDone = args[1]; - if (typeof onDone !== 'function') { - throw Error( - `The second argument to autoPagingEach, if present, must be a callback function; received ${typeof onDone}` - ); - } - return onDone; + if (args.length < 2) { + return undefined; + } + const onDone = args[1]; + if (typeof onDone !== 'function') { + throw Error(`The second argument to autoPagingEach, if present, must be a callback function; received ${typeof onDone}`); + } + return onDone; } /** * We allow four forms of the `onItem` callback (the middle two being equivalent), @@ -119,43 +111,37 @@ function getDoneCallback(args) { * coalesces the former forms into the latter form. */ function getItemCallback(args) { - if (args.length === 0) { - return undefined; - } - const onItem = args[0]; - if (typeof onItem !== 'function') { - throw Error( - `The first argument to autoPagingEach, if present, must be a callback function; received ${typeof onItem}` - ); - } - // 4. `.autoPagingEach((item, next) => { doSomething(item); next(false); });` - if (onItem.length === 2) { - return onItem; - } - if (onItem.length > 2) { - throw Error( - `The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${onItem}` - ); - } - // This magically handles all three of these usecases (the latter two being functionally identical): - // 1. `.autoPagingEach((item) => { doSomething(item); return false; });` - // 2. `.autoPagingEach(async (item) => { await doSomething(item); return false; });` - // 3. `.autoPagingEach((item) => doSomething(item).then(() => false));` - return function _onItem(item, next) { - const shouldContinue = onItem(item); - next(shouldContinue); - }; + if (args.length === 0) { + return undefined; + } + const onItem = args[0]; + if (typeof onItem !== 'function') { + throw Error(`The first argument to autoPagingEach, if present, must be a callback function; received ${typeof onItem}`); + } + // 4. `.autoPagingEach((item, next) => { doSomething(item); next(false); });` + if (onItem.length === 2) { + return onItem; + } + if (onItem.length > 2) { + throw Error(`The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${onItem}`); + } + // This magically handles all three of these usecases (the latter two being functionally identical): + // 1. `.autoPagingEach((item) => { doSomething(item); return false; });` + // 2. `.autoPagingEach(async (item) => { await doSomething(item); return false; });` + // 3. `.autoPagingEach((item) => doSomething(item).then(() => false));` + return function _onItem(item, next) { + const shouldContinue = onItem(item); + next(shouldContinue); + }; } function getLastId(listResult, reverseIteration) { - const lastIdx = reverseIteration ? 0 : listResult.data.length - 1; - const lastItem = listResult.data[lastIdx]; - const lastId = lastItem && lastItem.id; - if (!lastId) { - throw Error( - 'Unexpected: No `id` found on the last item while auto-paging a list.' - ); - } - return lastId; + const lastIdx = reverseIteration ? 0 : listResult.data.length - 1; + const lastItem = listResult.data[lastIdx]; + const lastId = lastItem && lastItem.id; + if (!lastId) { + throw Error('Unexpected: No `id` found on the last item while auto-paging a list.'); + } + return lastId; } /** * If a user calls `.next()` multiple times in parallel, @@ -163,91 +149,86 @@ function getLastId(listResult, reverseIteration) { * to prevent page-turning race conditions. */ function memoizedPromise(promiseCache, cb) { - if (promiseCache.currentPromise) { + if (promiseCache.currentPromise) { + return promiseCache.currentPromise; + } + promiseCache.currentPromise = new Promise(cb).then((ret) => { + promiseCache.currentPromise = undefined; + return ret; + }); return promiseCache.currentPromise; - } - promiseCache.currentPromise = new Promise(cb).then((ret) => { - promiseCache.currentPromise = undefined; - return ret; - }); - return promiseCache.currentPromise; } function makeAutoPagingEach(asyncIteratorNext) { - return function autoPagingEach(/* onItem?, onDone? */) { - const args = [].slice.call(arguments); - const onItem = getItemCallback(args); - const onDone = getDoneCallback(args); - if (args.length > 2) { - throw Error(`autoPagingEach takes up to two arguments; received ${args}`); - } - const autoPagePromise = wrapAsyncIteratorWithCallback( - asyncIteratorNext, - // @ts-ignore we might need a null check - onItem - ); - return utils.callbackifyPromiseWithTimeout(autoPagePromise, onDone); - }; + return function autoPagingEach( /* onItem?, onDone? */) { + const args = [].slice.call(arguments); + const onItem = getItemCallback(args); + const onDone = getDoneCallback(args); + if (args.length > 2) { + throw Error(`autoPagingEach takes up to two arguments; received ${args}`); + } + const autoPagePromise = wrapAsyncIteratorWithCallback(asyncIteratorNext, + // @ts-ignore we might need a null check + onItem); + return utils.callbackifyPromiseWithTimeout(autoPagePromise, onDone); + }; } function makeAutoPagingToArray(autoPagingEach) { - return function autoPagingToArray(opts, onDone) { - const limit = opts && opts.limit; - if (!limit) { - throw Error( - 'You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`.' - ); - } - if (limit > 10000) { - throw Error( - 'You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.' - ); - } - const promise = new Promise((resolve, reject) => { - const items = []; - autoPagingEach((item) => { - items.push(item); - if (items.length >= limit) { - return false; + return function autoPagingToArray(opts, onDone) { + const limit = opts && opts.limit; + if (!limit) { + throw Error('You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`.'); } - }) - .then(() => { - resolve(items); - }) - .catch(reject); - }); - return utils.callbackifyPromiseWithTimeout(promise, onDone); - }; + if (limit > 10000) { + throw Error('You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.'); + } + const promise = new Promise((resolve, reject) => { + const items = []; + autoPagingEach((item) => { + items.push(item); + if (items.length >= limit) { + return false; + } + }) + .then(() => { + resolve(items); + }) + .catch(reject); + }); + return utils.callbackifyPromiseWithTimeout(promise, onDone); + }; } function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { - return new Promise((resolve, reject) => { - function handleIteration(iterResult) { - if (iterResult.done) { - resolve(); - return; - } - const item = iterResult.value; - return new Promise((next) => { - // Bit confusing, perhaps; we pass a `resolve` fn - // to the user, so they can decide when and if to continue. - // They can return false, or a promise which resolves to false, to break. - onItem(item, next); - }).then((shouldContinue) => { - if (shouldContinue === false) { - return handleIteration({done: true}); - } else { - return asyncIteratorNext().then(handleIteration); + return new Promise((resolve, reject) => { + function handleIteration(iterResult) { + if (iterResult.done) { + resolve(); + return; + } + const item = iterResult.value; + return new Promise((next) => { + // Bit confusing, perhaps; we pass a `resolve` fn + // to the user, so they can decide when and if to continue. + // They can return false, or a promise which resolves to false, to break. + onItem(item, next); + }).then((shouldContinue) => { + if (shouldContinue === false) { + return handleIteration({ done: true }); + } + else { + return asyncIteratorNext().then(handleIteration); + } + }); } - }); - } - asyncIteratorNext() - .then(handleIteration) - .catch(reject); - }); + asyncIteratorNext() + .then(handleIteration) + .catch(reject); + }); } function isReverseIteration(requestArgs) { - const args = [].slice.call(requestArgs); - const dataFromArgs = utils.getDataFromArgs(args); - return !!dataFromArgs.ending_before; + const args = [].slice.call(requestArgs); + const dataFromArgs = utils.getDataFromArgs(args); + return !!dataFromArgs.ending_before; } module.exports = { - makeAutoPaginationMethods: makeAutoPaginationMethods, + makeAutoPaginationMethods: makeAutoPaginationMethods, }; diff --git a/lib/crypto/CryptoProvider.js b/lib/crypto/CryptoProvider.js index 015a339447..4491a01725 100644 --- a/lib/crypto/CryptoProvider.js +++ b/lib/crypto/CryptoProvider.js @@ -1,33 +1,33 @@ -'use strict'; +"use strict"; /** * Interface encapsulating the various crypto computations used by the library, * allowing pluggable underlying crypto implementations. */ class CryptoProvider { - /** - * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). - * The output HMAC should be encoded in hexadecimal. - * - * Sample values for implementations: - * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' - * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 - */ - computeHMACSignature(payload, secret) { - throw new Error('computeHMACSignature not implemented.'); - } - /** - * Asynchronous version of `computeHMACSignature`. Some implementations may - * only allow support async signature computation. - * - * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). - * The output HMAC should be encoded in hexadecimal. - * - * Sample values for implementations: - * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' - * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 - */ - computeHMACSignatureAsync(payload, secret) { - throw new Error('computeHMACSignatureAsync not implemented.'); - } + /** + * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). + * The output HMAC should be encoded in hexadecimal. + * + * Sample values for implementations: + * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' + * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 + */ + computeHMACSignature(payload, secret) { + throw new Error('computeHMACSignature not implemented.'); + } + /** + * Asynchronous version of `computeHMACSignature`. Some implementations may + * only allow support async signature computation. + * + * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). + * The output HMAC should be encoded in hexadecimal. + * + * Sample values for implementations: + * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' + * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 + */ + computeHMACSignatureAsync(payload, secret) { + throw new Error('computeHMACSignatureAsync not implemented.'); + } } module.exports = CryptoProvider; diff --git a/lib/crypto/NodeCryptoProvider.js b/lib/crypto/NodeCryptoProvider.js index 4cdeb521fc..95acdd2be9 100644 --- a/lib/crypto/NodeCryptoProvider.js +++ b/lib/crypto/NodeCryptoProvider.js @@ -1,21 +1,21 @@ -'use strict'; -const crypto = require('crypto'); -const CryptoProvider = require('./CryptoProvider'); +"use strict"; +const crypto = require("crypto"); +const CryptoProvider = require("./CryptoProvider"); /** * `CryptoProvider which uses the Node `crypto` package for its computations. */ class NodeCryptoProvider extends CryptoProvider { - /** @override */ - computeHMACSignature(payload, secret) { - return crypto - .createHmac('sha256', secret) - .update(payload, 'utf8') - .digest('hex'); - } - /** @override */ - async computeHMACSignatureAsync(payload, secret) { - const signature = await this.computeHMACSignature(payload, secret); - return signature; - } + /** @override */ + computeHMACSignature(payload, secret) { + return crypto + .createHmac('sha256', secret) + .update(payload, 'utf8') + .digest('hex'); + } + /** @override */ + async computeHMACSignatureAsync(payload, secret) { + const signature = await this.computeHMACSignature(payload, secret); + return signature; + } } module.exports = NodeCryptoProvider; diff --git a/lib/crypto/SubtleCryptoProvider.js b/lib/crypto/SubtleCryptoProvider.js index cbf5d01373..8f23b3bcac 100644 --- a/lib/crypto/SubtleCryptoProvider.js +++ b/lib/crypto/SubtleCryptoProvider.js @@ -1,57 +1,45 @@ -'use strict'; -const CryptoProvider = require('./CryptoProvider'); +"use strict"; +const CryptoProvider = require("./CryptoProvider"); /** * `CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API. * * This only supports asynchronous operations. */ class SubtleCryptoProvider extends CryptoProvider { - constructor(subtleCrypto) { - super(); - // If no subtle crypto is interface, default to the global namespace. This - // is to allow custom interfaces (eg. using the Node webcrypto interface in - // tests). - this.subtleCrypto = subtleCrypto || crypto.subtle; - } - /** @override */ - computeHMACSignature(payload, secret) { - throw new Error( - 'SubtleCryptoProvider cannot be used in a synchronous context.' - ); - } - /** @override */ - async computeHMACSignatureAsync(payload, secret) { - const encoder = new TextEncoder(); - const key = await this.subtleCrypto.importKey( - 'raw', - encoder.encode(secret), - { - name: 'HMAC', - hash: {name: 'SHA-256'}, - }, - false, - ['sign'] - ); - const signatureBuffer = await this.subtleCrypto.sign( - 'hmac', - key, - encoder.encode(payload) - ); - // crypto.subtle returns the signature in base64 format. This must be - // encoded in hex to match the CryptoProvider contract. We map each byte in - // the buffer to its corresponding hex octet and then combine into a string. - const signatureBytes = new Uint8Array(signatureBuffer); - const signatureHexCodes = new Array(signatureBytes.length); - for (let i = 0; i < signatureBytes.length; i++) { - signatureHexCodes[i] = byteHexMapping[signatureBytes[i]]; + constructor(subtleCrypto) { + super(); + // If no subtle crypto is interface, default to the global namespace. This + // is to allow custom interfaces (eg. using the Node webcrypto interface in + // tests). + this.subtleCrypto = subtleCrypto || crypto.subtle; + } + /** @override */ + computeHMACSignature(payload, secret) { + throw new Error('SubtleCryptoProvider cannot be used in a synchronous context.'); + } + /** @override */ + async computeHMACSignatureAsync(payload, secret) { + const encoder = new TextEncoder(); + const key = await this.subtleCrypto.importKey('raw', encoder.encode(secret), { + name: 'HMAC', + hash: { name: 'SHA-256' }, + }, false, ['sign']); + const signatureBuffer = await this.subtleCrypto.sign('hmac', key, encoder.encode(payload)); + // crypto.subtle returns the signature in base64 format. This must be + // encoded in hex to match the CryptoProvider contract. We map each byte in + // the buffer to its corresponding hex octet and then combine into a string. + const signatureBytes = new Uint8Array(signatureBuffer); + const signatureHexCodes = new Array(signatureBytes.length); + for (let i = 0; i < signatureBytes.length; i++) { + signatureHexCodes[i] = byteHexMapping[signatureBytes[i]]; + } + return signatureHexCodes.join(''); } - return signatureHexCodes.join(''); - } } // Cached mapping of byte to hex representation. We do this once to avoid re- // computing every time we need to convert the result of a signature to hex. const byteHexMapping = new Array(256); for (let i = 0; i < byteHexMapping.length; i++) { - byteHexMapping[i] = i.toString(16).padStart(2, '0'); + byteHexMapping[i] = i.toString(16).padStart(2, '0'); } module.exports = SubtleCryptoProvider; diff --git a/lib/makeRequest.js b/lib/makeRequest.js index fc591f3245..0c641a5dce 100644 --- a/lib/makeRequest.js +++ b/lib/makeRequest.js @@ -1,104 +1,90 @@ -'use strict'; +"use strict"; const utils = require('./utils'); function getRequestOpts(self, requestArgs, spec, overrideData) { - // Extract spec values with defaults. - const requestMethod = (spec.method || 'GET').toUpperCase(); - const urlParams = spec.urlParams || []; - const encode = spec.encode || ((data) => data); - const isUsingFullPath = !!spec.fullPath; - const commandPath = utils.makeURLInterpolator( - isUsingFullPath ? spec.fullPath : spec.path || '' - ); - // When using fullPath, we ignore the resource path as it should already be - // fully qualified. - const path = isUsingFullPath - ? spec.fullPath - : self.createResourcePathWithSymbols(spec.path); - // Don't mutate args externally. - const args = [].slice.call(requestArgs); - // Generate and validate url params. - const urlData = urlParams.reduce((urlData, param) => { - const arg = args.shift(); - if (typeof arg !== 'string') { - throw new Error( - `Stripe: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)` - ); + // Extract spec values with defaults. + const requestMethod = (spec.method || 'GET').toUpperCase(); + const urlParams = spec.urlParams || []; + const encode = spec.encode || ((data) => data); + const isUsingFullPath = !!spec.fullPath; + const commandPath = utils.makeURLInterpolator(isUsingFullPath ? spec.fullPath : spec.path || ''); + // When using fullPath, we ignore the resource path as it should already be + // fully qualified. + const path = isUsingFullPath + ? spec.fullPath + : self.createResourcePathWithSymbols(spec.path); + // Don't mutate args externally. + const args = [].slice.call(requestArgs); + // Generate and validate url params. + const urlData = urlParams.reduce((urlData, param) => { + const arg = args.shift(); + if (typeof arg !== 'string') { + throw new Error(`Stripe: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)`); + } + urlData[param] = arg; + return urlData; + }, {}); + // Pull request data and options (headers, auth) from args. + const dataFromArgs = utils.getDataFromArgs(args); + const data = encode(Object.assign({}, dataFromArgs, overrideData)); + const options = utils.getOptionsFromArgs(args); + const host = options.host || spec.host; + const streaming = !!spec.streaming; + // Validate that there are no more args. + if (args.filter((x) => x != null).length) { + throw new Error(`Stripe: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)`); } - urlData[param] = arg; - return urlData; - }, {}); - // Pull request data and options (headers, auth) from args. - const dataFromArgs = utils.getDataFromArgs(args); - const data = encode(Object.assign({}, dataFromArgs, overrideData)); - const options = utils.getOptionsFromArgs(args); - const host = options.host || spec.host; - const streaming = !!spec.streaming; - // Validate that there are no more args. - if (args.filter((x) => x != null).length) { - throw new Error( - `Stripe: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)` - ); - } - // When using full path, we can just invoke the URL interpolator directly - // as we don't need to use the resource to create a full path. - const requestPath = isUsingFullPath - ? commandPath(urlData) - : self.createFullPath(commandPath, urlData); - const headers = Object.assign(options.headers, spec.headers); - if (spec.validator) { - spec.validator(data, {headers}); - } - const dataInQuery = spec.method === 'GET' || spec.method === 'DELETE'; - const bodyData = dataInQuery ? {} : data; - const queryData = dataInQuery ? data : {}; - return { - requestMethod, - requestPath, - bodyData, - queryData, - auth: options.auth, - headers, - host, - streaming, - settings: options.settings, - }; + // When using full path, we can just invoke the URL interpolator directly + // as we don't need to use the resource to create a full path. + const requestPath = isUsingFullPath + ? commandPath(urlData) + : self.createFullPath(commandPath, urlData); + const headers = Object.assign(options.headers, spec.headers); + if (spec.validator) { + spec.validator(data, { headers }); + } + const dataInQuery = spec.method === 'GET' || spec.method === 'DELETE'; + const bodyData = dataInQuery ? {} : data; + const queryData = dataInQuery ? data : {}; + return { + requestMethod, + requestPath, + bodyData, + queryData, + auth: options.auth, + headers, + host, + streaming, + settings: options.settings, + }; } function makeRequest(self, requestArgs, spec, overrideData) { - return new Promise((resolve, reject) => { - let opts; - try { - opts = getRequestOpts(self, requestArgs, spec, overrideData); - } catch (err) { - reject(err); - return; - } - function requestCallback(err, response) { - if (err) { - reject(err); - } else { - resolve( - spec.transformResponseData - ? spec.transformResponseData(response) - : response - ); - } - } - const emptyQuery = Object.keys(opts.queryData).length === 0; - const path = [ - opts.requestPath, - emptyQuery ? '' : '?', - utils.stringifyRequestData(opts.queryData), - ].join(''); - const {headers, settings} = opts; - self._request( - opts.requestMethod, - opts.host, - path, - opts.bodyData, - opts.auth, - {headers, settings, streaming: opts.streaming}, - requestCallback - ); - }); + return new Promise((resolve, reject) => { + let opts; + try { + opts = getRequestOpts(self, requestArgs, spec, overrideData); + } + catch (err) { + reject(err); + return; + } + function requestCallback(err, response) { + if (err) { + reject(err); + } + else { + resolve(spec.transformResponseData + ? spec.transformResponseData(response) + : response); + } + } + const emptyQuery = Object.keys(opts.queryData).length === 0; + const path = [ + opts.requestPath, + emptyQuery ? '' : '?', + utils.stringifyRequestData(opts.queryData), + ].join(''); + const { headers, settings } = opts; + self._request(opts.requestMethod, opts.host, path, opts.bodyData, opts.auth, { headers, settings, streaming: opts.streaming }, requestCallback); + }); } module.exports = makeRequest; diff --git a/lib/multipart.js b/lib/multipart.js index 29e53c8363..566858b429 100644 --- a/lib/multipart.js +++ b/lib/multipart.js @@ -1,87 +1,79 @@ -'use strict'; -const utils = require('./utils'); -const _Error = require('./Error'); -const {StripeError} = _Error; -class StreamProcessingError extends StripeError {} +"use strict"; +const utils = require("./utils"); +const _Error = require("./Error"); +const { StripeError } = _Error; +class StreamProcessingError extends StripeError { +} // Method for formatting HTTP body for the multipart/form-data specification // Mostly taken from Fermata.js // https://github.com/natevw/fermata/blob/5d9732a33d776ce925013a265935facd1626cc88/fermata.js#L315-L343 const multipartDataGenerator = (method, data, headers) => { - const segno = ( - Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16) - ).toString(); - headers['Content-Type'] = `multipart/form-data; boundary=${segno}`; - let buffer = Buffer.alloc(0); - function push(l) { - const prevBuffer = buffer; - const newBuffer = l instanceof Buffer ? l : Buffer.from(l); - buffer = Buffer.alloc(prevBuffer.length + newBuffer.length + 2); - prevBuffer.copy(buffer); - newBuffer.copy(buffer, prevBuffer.length); - buffer.write('\r\n', buffer.length - 2); - } - function q(s) { - return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`; - } - const flattenedData = utils.flattenAndStringify(data); - for (const k in flattenedData) { - const v = flattenedData[k]; - push(`--${segno}`); - if (Object.prototype.hasOwnProperty.call(v, 'data')) { - const typedEntry = v; - push( - `Content-Disposition: form-data; name=${q(k)}; filename=${q( - typedEntry.name || 'blob' - )}` - ); - push(`Content-Type: ${typedEntry.type || 'application/octet-stream'}`); - push(''); - push(typedEntry.data); - } else { - push(`Content-Disposition: form-data; name=${q(k)}`); - push(''); - push(v); + const segno = (Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16)).toString(); + headers['Content-Type'] = `multipart/form-data; boundary=${segno}`; + let buffer = Buffer.alloc(0); + function push(l) { + const prevBuffer = buffer; + const newBuffer = l instanceof Buffer ? l : Buffer.from(l); + buffer = Buffer.alloc(prevBuffer.length + newBuffer.length + 2); + prevBuffer.copy(buffer); + newBuffer.copy(buffer, prevBuffer.length); + buffer.write('\r\n', buffer.length - 2); } - } - push(`--${segno}--`); - return buffer; + function q(s) { + return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`; + } + const flattenedData = utils.flattenAndStringify(data); + for (const k in flattenedData) { + const v = flattenedData[k]; + push(`--${segno}`); + if (Object.prototype.hasOwnProperty.call(v, 'data')) { + const typedEntry = v; + push(`Content-Disposition: form-data; name=${q(k)}; filename=${q(typedEntry.name || 'blob')}`); + push(`Content-Type: ${typedEntry.type || 'application/octet-stream'}`); + push(''); + push(typedEntry.data); + } + else { + push(`Content-Disposition: form-data; name=${q(k)}`); + push(''); + push(v); + } + } + push(`--${segno}--`); + return buffer; }; const streamProcessor = (method, data, headers, callback) => { - const bufferArray = []; - data.file.data - .on('data', (line) => { - bufferArray.push(line); + const bufferArray = []; + data.file.data + .on('data', (line) => { + bufferArray.push(line); }) - .once('end', () => { - // @ts-ignore - const bufferData = Object.assign({}, data); - bufferData.file.data = Buffer.concat(bufferArray); - const buffer = multipartDataGenerator(method, bufferData, headers); - callback(null, buffer); + .once('end', () => { + // @ts-ignore + const bufferData = Object.assign({}, data); + bufferData.file.data = Buffer.concat(bufferArray); + const buffer = multipartDataGenerator(method, bufferData, headers); + callback(null, buffer); }) - .on('error', (err) => { - callback( - new StreamProcessingError({ - message: - 'An error occurred while attempting to process the file for upload.', - detail: err, - }), - null - ); + .on('error', (err) => { + callback(new StreamProcessingError({ + message: 'An error occurred while attempting to process the file for upload.', + detail: err, + }), null); }); }; const multipartRequestDataProcessor = (method, data, headers, callback) => { - data = data || {}; - if (method !== 'POST') { - return callback(null, utils.stringifyRequestData(data)); - } - const isStream = utils.checkForStream(data); - if (isStream) { - return streamProcessor(method, data, headers, callback); - } - const buffer = multipartDataGenerator(method, data, headers); - return callback(null, buffer); + data = data || {}; + if (method !== 'POST') { + return callback(null, utils.stringifyRequestData(data)); + } + const isStream = utils.checkForStream(data); + if (isStream) { + return streamProcessor(method, data, headers, callback); + } + const buffer = multipartDataGenerator(method, data, headers); + return callback(null, buffer); }; module.exports = { - multipartRequestDataProcessor: multipartRequestDataProcessor, + multipartRequestDataProcessor: multipartRequestDataProcessor, }; diff --git a/lib/net/FetchHttpClient.js b/lib/net/FetchHttpClient.js index 355824001a..d47c237616 100644 --- a/lib/net/FetchHttpClient.js +++ b/lib/net/FetchHttpClient.js @@ -1,6 +1,6 @@ -'use strict'; -const _HttpClient = require('./HttpClient'); -const {HttpClient, HttpClientResponse} = _HttpClient; +"use strict"; +const _HttpClient = require("./HttpClient"); +const { HttpClient, HttpClientResponse } = _HttpClient; /** * HTTP client which uses a `fetch` function to issue requests. * @@ -10,113 +10,95 @@ const {HttpClient, HttpClientResponse} = _HttpClient; * node-fetch package (https://github.com/node-fetch/node-fetch). */ class FetchHttpClient extends HttpClient { - constructor(fetchFn) { - super(); - this._fetchFn = fetchFn; - } - /** @override. */ - getClientName() { - return 'fetch'; - } - makeRequest( - host, - port, - path, - method, - headers, - requestData, - protocol, - timeout - ) { - const isInsecureConnection = protocol === 'http'; - const url = new URL( - path, - `${isInsecureConnection ? 'http' : 'https'}://${host}` - ); - url.port = port; - // For methods which expect payloads, we should always pass a body value - // even when it is empty. Without this, some JS runtimes (eg. Deno) will - // inject a second Content-Length header. See https://github.com/stripe/stripe-node/issues/1519 - // for more details. - const methodHasPayload = - method == 'POST' || method == 'PUT' || method == 'PATCH'; - const body = requestData || (methodHasPayload ? '' : undefined); - const fetchFn = this._fetchFn || fetch; - const fetchPromise = fetchFn(url.toString(), { - method, - // @ts-ignore - headers, - // @ts-ignore - body, - }); - // The Fetch API does not support passing in a timeout natively, so a - // timeout promise is constructed to race against the fetch and preempt the - // request, simulating a timeout. - // - // This timeout behavior differs from Node: - // - Fetch uses a single timeout for the entire length of the request. - // - Node is more fine-grained and resets the timeout after each stage of - // the request. - // - // As an example, if the timeout is set to 30s and the connection takes 20s - // to be established followed by 20s for the body, Fetch would timeout but - // Node would not. The more fine-grained timeout cannot be implemented with - // fetch. - let pendingTimeoutId; - const timeoutPromise = new Promise((_, reject) => { - pendingTimeoutId = setTimeout(() => { - pendingTimeoutId = null; - reject(HttpClient.makeTimeoutError()); - }, timeout); - }); - return Promise.race([fetchPromise, timeoutPromise]) - .then((res) => { - return new FetchHttpClientResponse(res); - }) - .finally(() => { - if (pendingTimeoutId) { - clearTimeout(pendingTimeoutId); - } - }); - } + constructor(fetchFn) { + super(); + this._fetchFn = fetchFn; + } + /** @override. */ + getClientName() { + return 'fetch'; + } + makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { + const isInsecureConnection = protocol === 'http'; + const url = new URL(path, `${isInsecureConnection ? 'http' : 'https'}://${host}`); + url.port = port; + // For methods which expect payloads, we should always pass a body value + // even when it is empty. Without this, some JS runtimes (eg. Deno) will + // inject a second Content-Length header. See https://github.com/stripe/stripe-node/issues/1519 + // for more details. + const methodHasPayload = method == 'POST' || method == 'PUT' || method == 'PATCH'; + const body = requestData || (methodHasPayload ? '' : undefined); + const fetchFn = this._fetchFn || fetch; + const fetchPromise = fetchFn(url.toString(), { + method, + // @ts-ignore + headers, + // @ts-ignore + body, + }); + // The Fetch API does not support passing in a timeout natively, so a + // timeout promise is constructed to race against the fetch and preempt the + // request, simulating a timeout. + // + // This timeout behavior differs from Node: + // - Fetch uses a single timeout for the entire length of the request. + // - Node is more fine-grained and resets the timeout after each stage of + // the request. + // + // As an example, if the timeout is set to 30s and the connection takes 20s + // to be established followed by 20s for the body, Fetch would timeout but + // Node would not. The more fine-grained timeout cannot be implemented with + // fetch. + let pendingTimeoutId; + const timeoutPromise = new Promise((_, reject) => { + pendingTimeoutId = setTimeout(() => { + pendingTimeoutId = null; + reject(HttpClient.makeTimeoutError()); + }, timeout); + }); + return Promise.race([fetchPromise, timeoutPromise]) + .then((res) => { + return new FetchHttpClientResponse(res); + }) + .finally(() => { + if (pendingTimeoutId) { + clearTimeout(pendingTimeoutId); + } + }); + } } class FetchHttpClientResponse extends HttpClientResponse { - constructor(res) { - super( - res.status, - FetchHttpClientResponse._transformHeadersToObject(res.headers) - ); - this._res = res; - } - getRawResponse() { - return this._res; - } - toStream(streamCompleteCallback) { - // Unfortunately `fetch` does not have event handlers for when the stream is - // completely read. We therefore invoke the streamCompleteCallback right - // away. This callback emits a response event with metadata and completes - // metrics, so it's ok to do this without waiting for the stream to be - // completely read. - streamCompleteCallback(); - // Fetch's `body` property is expected to be a readable stream of the body. - return this._res.body; - } - toJSON() { - return this._res.json(); - } - static _transformHeadersToObject(headers) { - // Fetch uses a Headers instance so this must be converted to a barebones - // JS object to meet the HttpClient interface. - const headersObj = {}; - for (const entry of headers) { - if (!Array.isArray(entry) || entry.length != 2) { - throw new Error( - 'Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.' - ); - } - headersObj[entry[0]] = entry[1]; + constructor(res) { + super(res.status, FetchHttpClientResponse._transformHeadersToObject(res.headers)); + this._res = res; + } + getRawResponse() { + return this._res; + } + toStream(streamCompleteCallback) { + // Unfortunately `fetch` does not have event handlers for when the stream is + // completely read. We therefore invoke the streamCompleteCallback right + // away. This callback emits a response event with metadata and completes + // metrics, so it's ok to do this without waiting for the stream to be + // completely read. + streamCompleteCallback(); + // Fetch's `body` property is expected to be a readable stream of the body. + return this._res.body; + } + toJSON() { + return this._res.json(); + } + static _transformHeadersToObject(headers) { + // Fetch uses a Headers instance so this must be converted to a barebones + // JS object to meet the HttpClient interface. + const headersObj = {}; + for (const entry of headers) { + if (!Array.isArray(entry) || entry.length != 2) { + throw new Error('Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.'); + } + headersObj[entry[0]] = entry[1]; + } + return headersObj; } - return headersObj; - } } -module.exports = {FetchHttpClient, FetchHttpClientResponse}; +module.exports = { FetchHttpClient, FetchHttpClientResponse }; diff --git a/lib/net/HttpClient.js b/lib/net/HttpClient.js index 88f9f31f1b..d49f8fb584 100644 --- a/lib/net/HttpClient.js +++ b/lib/net/HttpClient.js @@ -1,4 +1,4 @@ -'use strict'; +"use strict"; /** * Encapsulates the logic for issuing a request to the Stripe API. * @@ -9,50 +9,41 @@ * returning their own response class when making requests. */ class HttpClient { - /** The client name used for diagnostics. */ - getClientName() { - throw new Error('getClientName not implemented.'); - } - makeRequest( - host, - port, - path, - method, - headers, - requestData, - protocol, - timeout - ) { - throw new Error('makeRequest not implemented.'); - } - /** Helper to make a consistent timeout error across implementations. */ - static makeTimeoutError() { - const timeoutErr = new TypeError(HttpClient.TIMEOUT_ERROR_CODE); - timeoutErr.code = HttpClient.TIMEOUT_ERROR_CODE; - return timeoutErr; - } + /** The client name used for diagnostics. */ + getClientName() { + throw new Error('getClientName not implemented.'); + } + makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { + throw new Error('makeRequest not implemented.'); + } + /** Helper to make a consistent timeout error across implementations. */ + static makeTimeoutError() { + const timeoutErr = new TypeError(HttpClient.TIMEOUT_ERROR_CODE); + timeoutErr.code = HttpClient.TIMEOUT_ERROR_CODE; + return timeoutErr; + } } HttpClient.CONNECTION_CLOSED_ERROR_CODES = ['ECONNRESET', 'EPIPE']; HttpClient.TIMEOUT_ERROR_CODE = 'ETIMEDOUT'; class HttpClientResponse { - constructor(statusCode, headers) { - this._statusCode = statusCode; - this._headers = headers; - } - getStatusCode() { - return this._statusCode; - } - getHeaders() { - return this._headers; - } - getRawResponse() { - throw new Error('getRawResponse not implemented.'); - } - toStream(streamCompleteCallback) { - throw new Error('toStream not implemented.'); - } - toJSON() { - throw new Error('toJSON not implemented.'); - } + constructor(statusCode, headers) { + this._statusCode = statusCode; + this._headers = headers; + } + getStatusCode() { + return this._statusCode; + } + getHeaders() { + return this._headers; + } + getRawResponse() { + throw new Error('getRawResponse not implemented.'); + } + toStream(streamCompleteCallback) { + throw new Error('toStream not implemented.'); + } + toJSON() { + throw new Error('toJSON not implemented.'); + } } -module.exports = {HttpClient, HttpClientResponse}; +module.exports = { HttpClient, HttpClientResponse }; diff --git a/lib/net/NodeHttpClient.js b/lib/net/NodeHttpClient.js index cf580fd63d..02d02ab761 100644 --- a/lib/net/NodeHttpClient.js +++ b/lib/net/NodeHttpClient.js @@ -1,108 +1,98 @@ -'use strict'; -const http = require('http'); -const https = require('https'); -const _HttpClient = require('./HttpClient'); -const {HttpClient, HttpClientResponse} = _HttpClient; -const defaultHttpAgent = new http.Agent({keepAlive: true}); -const defaultHttpsAgent = new https.Agent({keepAlive: true}); +"use strict"; +const http = require("http"); +const https = require("https"); +const _HttpClient = require("./HttpClient"); +const { HttpClient, HttpClientResponse } = _HttpClient; +const defaultHttpAgent = new http.Agent({ keepAlive: true }); +const defaultHttpsAgent = new https.Agent({ keepAlive: true }); /** * HTTP client which uses the Node `http` and `https` packages to issue * requests.` */ class NodeHttpClient extends HttpClient { - constructor(agent) { - super(); - this._agent = agent; - } - /** @override. */ - getClientName() { - return 'node'; - } - makeRequest( - host, - port, - path, - method, - headers, - requestData, - protocol, - timeout - ) { - const isInsecureConnection = protocol === 'http'; - let agent = this._agent; - if (!agent) { - agent = isInsecureConnection ? defaultHttpAgent : defaultHttpsAgent; + constructor(agent) { + super(); + this._agent = agent; } - const requestPromise = new Promise((resolve, reject) => { - const req = (isInsecureConnection ? http : https).request({ - host: host, - port: port, - path, - method, - agent, - headers, - ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5', - }); - req.setTimeout(timeout, () => { - req.destroy(HttpClient.makeTimeoutError()); - }); - req.on('response', (res) => { - resolve(new NodeHttpClientResponse(res)); - }); - req.on('error', (error) => { - reject(error); - }); - req.once('socket', (socket) => { - if (socket.connecting) { - socket.once( - isInsecureConnection ? 'connect' : 'secureConnect', - () => { - // Send payload; we're safe: - req.write(requestData); - req.end(); - } - ); - } else { - // we're already connected - req.write(requestData); - req.end(); + /** @override. */ + getClientName() { + return 'node'; + } + makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { + const isInsecureConnection = protocol === 'http'; + let agent = this._agent; + if (!agent) { + agent = isInsecureConnection ? defaultHttpAgent : defaultHttpsAgent; } - }); - }); - return requestPromise; - } + const requestPromise = new Promise((resolve, reject) => { + const req = (isInsecureConnection ? http : https).request({ + host: host, + port: port, + path, + method, + agent, + headers, + ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5', + }); + req.setTimeout(timeout, () => { + req.destroy(HttpClient.makeTimeoutError()); + }); + req.on('response', (res) => { + resolve(new NodeHttpClientResponse(res)); + }); + req.on('error', (error) => { + reject(error); + }); + req.once('socket', (socket) => { + if (socket.connecting) { + socket.once(isInsecureConnection ? 'connect' : 'secureConnect', () => { + // Send payload; we're safe: + req.write(requestData); + req.end(); + }); + } + else { + // we're already connected + req.write(requestData); + req.end(); + } + }); + }); + return requestPromise; + } } class NodeHttpClientResponse extends HttpClientResponse { - constructor(res) { - // @ts-ignore - super(res.statusCode, res.headers || {}); - this._res = res; - } - getRawResponse() { - return this._res; - } - toStream(streamCompleteCallback) { - // The raw response is itself the stream, so we just return that. To be - // backwards compatible, we should invoke the streamCompleteCallback only - // once the stream has been fully consumed. - this._res.once('end', () => streamCompleteCallback()); - return this._res; - } - toJSON() { - return new Promise((resolve, reject) => { - let response = ''; - this._res.setEncoding('utf8'); - this._res.on('data', (chunk) => { - response += chunk; - }); - this._res.once('end', () => { - try { - resolve(JSON.parse(response)); - } catch (e) { - reject(e); - } - }); - }); - } + constructor(res) { + // @ts-ignore + super(res.statusCode, res.headers || {}); + this._res = res; + } + getRawResponse() { + return this._res; + } + toStream(streamCompleteCallback) { + // The raw response is itself the stream, so we just return that. To be + // backwards compatible, we should invoke the streamCompleteCallback only + // once the stream has been fully consumed. + this._res.once('end', () => streamCompleteCallback()); + return this._res; + } + toJSON() { + return new Promise((resolve, reject) => { + let response = ''; + this._res.setEncoding('utf8'); + this._res.on('data', (chunk) => { + response += chunk; + }); + this._res.once('end', () => { + try { + resolve(JSON.parse(response)); + } + catch (e) { + reject(e); + } + }); + }); + } } -module.exports = {NodeHttpClient, NodeHttpClientResponse}; +module.exports = { NodeHttpClient, NodeHttpClientResponse }; diff --git a/lib/resources.js b/lib/resources.js index eb497e3587..669f1bff4b 100644 --- a/lib/resources.js +++ b/lib/resources.js @@ -2,124 +2,124 @@ 'use strict'; const resourceNamespace = require('./ResourceNamespace'); module.exports = { - Accounts: require('./resources/Accounts'), - // Support Accounts for consistency, Account for backwards compatibility - Account: require('./resources/Accounts'), - AccountLinks: require('./resources/AccountLinks'), - ApplePayDomains: require('./resources/ApplePayDomains'), - ApplicationFees: require('./resources/ApplicationFees'), - Balance: require('./resources/Balance'), - BalanceTransactions: require('./resources/BalanceTransactions'), - Charges: require('./resources/Charges'), - CountrySpecs: require('./resources/CountrySpecs'), - Coupons: require('./resources/Coupons'), - CreditNotes: require('./resources/CreditNotes'), - Customers: require('./resources/Customers'), - Disputes: require('./resources/Disputes'), - EphemeralKeys: require('./resources/EphemeralKeys'), - Events: require('./resources/Events'), - ExchangeRates: require('./resources/ExchangeRates'), - Files: require('./resources/Files'), - FileLinks: require('./resources/FileLinks'), - Invoices: require('./resources/Invoices'), - InvoiceItems: require('./resources/InvoiceItems'), - Mandates: require('./resources/Mandates'), - OAuth: require('./resources/OAuth'), - PaymentIntents: require('./resources/PaymentIntents'), - PaymentLinks: require('./resources/PaymentLinks'), - PaymentMethods: require('./resources/PaymentMethods'), - Payouts: require('./resources/Payouts'), - Plans: require('./resources/Plans'), - Prices: require('./resources/Prices'), - Products: require('./resources/Products'), - PromotionCodes: require('./resources/PromotionCodes'), - Quotes: require('./resources/Quotes'), - Refunds: require('./resources/Refunds'), - Reviews: require('./resources/Reviews'), - SetupAttempts: require('./resources/SetupAttempts'), - SetupIntents: require('./resources/SetupIntents'), - ShippingRates: require('./resources/ShippingRates'), - Sources: require('./resources/Sources'), - Subscriptions: require('./resources/Subscriptions'), - SubscriptionItems: require('./resources/SubscriptionItems'), - SubscriptionSchedules: require('./resources/SubscriptionSchedules'), - TaxCodes: require('./resources/TaxCodes'), - TaxRates: require('./resources/TaxRates'), - Tokens: require('./resources/Tokens'), - Topups: require('./resources/Topups'), - Transfers: require('./resources/Transfers'), - WebhookEndpoints: require('./resources/WebhookEndpoints'), - Apps: resourceNamespace('apps', { - Secrets: require('./resources/Apps/Secrets'), - }), - BillingPortal: resourceNamespace('billingPortal', { - Configurations: require('./resources/BillingPortal/Configurations'), - Sessions: require('./resources/BillingPortal/Sessions'), - }), - Checkout: resourceNamespace('checkout', { - Sessions: require('./resources/Checkout/Sessions'), - }), - FinancialConnections: resourceNamespace('financialConnections', { - Accounts: require('./resources/FinancialConnections/Accounts'), - Sessions: require('./resources/FinancialConnections/Sessions'), - }), - Identity: resourceNamespace('identity', { - VerificationReports: require('./resources/Identity/VerificationReports'), - VerificationSessions: require('./resources/Identity/VerificationSessions'), - }), - Issuing: resourceNamespace('issuing', { - Authorizations: require('./resources/Issuing/Authorizations'), - Cards: require('./resources/Issuing/Cards'), - Cardholders: require('./resources/Issuing/Cardholders'), - Disputes: require('./resources/Issuing/Disputes'), - Transactions: require('./resources/Issuing/Transactions'), - }), - Radar: resourceNamespace('radar', { - EarlyFraudWarnings: require('./resources/Radar/EarlyFraudWarnings'), - ValueLists: require('./resources/Radar/ValueLists'), - ValueListItems: require('./resources/Radar/ValueListItems'), - }), - Reporting: resourceNamespace('reporting', { - ReportRuns: require('./resources/Reporting/ReportRuns'), - ReportTypes: require('./resources/Reporting/ReportTypes'), - }), - Sigma: resourceNamespace('sigma', { - ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'), - }), - Terminal: resourceNamespace('terminal', { - Configurations: require('./resources/Terminal/Configurations'), - ConnectionTokens: require('./resources/Terminal/ConnectionTokens'), - Locations: require('./resources/Terminal/Locations'), - Readers: require('./resources/Terminal/Readers'), - }), - TestHelpers: resourceNamespace('testHelpers', { - Customers: require('./resources/TestHelpers/Customers'), - Refunds: require('./resources/TestHelpers/Refunds'), - TestClocks: require('./resources/TestHelpers/TestClocks'), + Accounts: require('./resources/Accounts'), + // Support Accounts for consistency, Account for backwards compatibility + Account: require('./resources/Accounts'), + AccountLinks: require('./resources/AccountLinks'), + ApplePayDomains: require('./resources/ApplePayDomains'), + ApplicationFees: require('./resources/ApplicationFees'), + Balance: require('./resources/Balance'), + BalanceTransactions: require('./resources/BalanceTransactions'), + Charges: require('./resources/Charges'), + CountrySpecs: require('./resources/CountrySpecs'), + Coupons: require('./resources/Coupons'), + CreditNotes: require('./resources/CreditNotes'), + Customers: require('./resources/Customers'), + Disputes: require('./resources/Disputes'), + EphemeralKeys: require('./resources/EphemeralKeys'), + Events: require('./resources/Events'), + ExchangeRates: require('./resources/ExchangeRates'), + Files: require('./resources/Files'), + FileLinks: require('./resources/FileLinks'), + Invoices: require('./resources/Invoices'), + InvoiceItems: require('./resources/InvoiceItems'), + Mandates: require('./resources/Mandates'), + OAuth: require('./resources/OAuth'), + PaymentIntents: require('./resources/PaymentIntents'), + PaymentLinks: require('./resources/PaymentLinks'), + PaymentMethods: require('./resources/PaymentMethods'), + Payouts: require('./resources/Payouts'), + Plans: require('./resources/Plans'), + Prices: require('./resources/Prices'), + Products: require('./resources/Products'), + PromotionCodes: require('./resources/PromotionCodes'), + Quotes: require('./resources/Quotes'), + Refunds: require('./resources/Refunds'), + Reviews: require('./resources/Reviews'), + SetupAttempts: require('./resources/SetupAttempts'), + SetupIntents: require('./resources/SetupIntents'), + ShippingRates: require('./resources/ShippingRates'), + Sources: require('./resources/Sources'), + Subscriptions: require('./resources/Subscriptions'), + SubscriptionItems: require('./resources/SubscriptionItems'), + SubscriptionSchedules: require('./resources/SubscriptionSchedules'), + TaxCodes: require('./resources/TaxCodes'), + TaxRates: require('./resources/TaxRates'), + Tokens: require('./resources/Tokens'), + Topups: require('./resources/Topups'), + Transfers: require('./resources/Transfers'), + WebhookEndpoints: require('./resources/WebhookEndpoints'), + Apps: resourceNamespace('apps', { + Secrets: require('./resources/Apps/Secrets'), + }), + BillingPortal: resourceNamespace('billingPortal', { + Configurations: require('./resources/BillingPortal/Configurations'), + Sessions: require('./resources/BillingPortal/Sessions'), + }), + Checkout: resourceNamespace('checkout', { + Sessions: require('./resources/Checkout/Sessions'), + }), + FinancialConnections: resourceNamespace('financialConnections', { + Accounts: require('./resources/FinancialConnections/Accounts'), + Sessions: require('./resources/FinancialConnections/Sessions'), + }), + Identity: resourceNamespace('identity', { + VerificationReports: require('./resources/Identity/VerificationReports'), + VerificationSessions: require('./resources/Identity/VerificationSessions'), + }), Issuing: resourceNamespace('issuing', { - Cards: require('./resources/TestHelpers/Issuing/Cards'), + Authorizations: require('./resources/Issuing/Authorizations'), + Cards: require('./resources/Issuing/Cards'), + Cardholders: require('./resources/Issuing/Cardholders'), + Disputes: require('./resources/Issuing/Disputes'), + Transactions: require('./resources/Issuing/Transactions'), + }), + Radar: resourceNamespace('radar', { + EarlyFraudWarnings: require('./resources/Radar/EarlyFraudWarnings'), + ValueLists: require('./resources/Radar/ValueLists'), + ValueListItems: require('./resources/Radar/ValueListItems'), + }), + Reporting: resourceNamespace('reporting', { + ReportRuns: require('./resources/Reporting/ReportRuns'), + ReportTypes: require('./resources/Reporting/ReportTypes'), + }), + Sigma: resourceNamespace('sigma', { + ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'), }), Terminal: resourceNamespace('terminal', { - Readers: require('./resources/TestHelpers/Terminal/Readers'), + Configurations: require('./resources/Terminal/Configurations'), + ConnectionTokens: require('./resources/Terminal/ConnectionTokens'), + Locations: require('./resources/Terminal/Locations'), + Readers: require('./resources/Terminal/Readers'), + }), + TestHelpers: resourceNamespace('testHelpers', { + Customers: require('./resources/TestHelpers/Customers'), + Refunds: require('./resources/TestHelpers/Refunds'), + TestClocks: require('./resources/TestHelpers/TestClocks'), + Issuing: resourceNamespace('issuing', { + Cards: require('./resources/TestHelpers/Issuing/Cards'), + }), + Terminal: resourceNamespace('terminal', { + Readers: require('./resources/TestHelpers/Terminal/Readers'), + }), + Treasury: resourceNamespace('treasury', { + InboundTransfers: require('./resources/TestHelpers/Treasury/InboundTransfers'), + OutboundPayments: require('./resources/TestHelpers/Treasury/OutboundPayments'), + OutboundTransfers: require('./resources/TestHelpers/Treasury/OutboundTransfers'), + ReceivedCredits: require('./resources/TestHelpers/Treasury/ReceivedCredits'), + ReceivedDebits: require('./resources/TestHelpers/Treasury/ReceivedDebits'), + }), }), Treasury: resourceNamespace('treasury', { - InboundTransfers: require('./resources/TestHelpers/Treasury/InboundTransfers'), - OutboundPayments: require('./resources/TestHelpers/Treasury/OutboundPayments'), - OutboundTransfers: require('./resources/TestHelpers/Treasury/OutboundTransfers'), - ReceivedCredits: require('./resources/TestHelpers/Treasury/ReceivedCredits'), - ReceivedDebits: require('./resources/TestHelpers/Treasury/ReceivedDebits'), + CreditReversals: require('./resources/Treasury/CreditReversals'), + DebitReversals: require('./resources/Treasury/DebitReversals'), + FinancialAccounts: require('./resources/Treasury/FinancialAccounts'), + InboundTransfers: require('./resources/Treasury/InboundTransfers'), + OutboundPayments: require('./resources/Treasury/OutboundPayments'), + OutboundTransfers: require('./resources/Treasury/OutboundTransfers'), + ReceivedCredits: require('./resources/Treasury/ReceivedCredits'), + ReceivedDebits: require('./resources/Treasury/ReceivedDebits'), + Transactions: require('./resources/Treasury/Transactions'), + TransactionEntries: require('./resources/Treasury/TransactionEntries'), }), - }), - Treasury: resourceNamespace('treasury', { - CreditReversals: require('./resources/Treasury/CreditReversals'), - DebitReversals: require('./resources/Treasury/DebitReversals'), - FinancialAccounts: require('./resources/Treasury/FinancialAccounts'), - InboundTransfers: require('./resources/Treasury/InboundTransfers'), - OutboundPayments: require('./resources/Treasury/OutboundPayments'), - OutboundTransfers: require('./resources/Treasury/OutboundTransfers'), - ReceivedCredits: require('./resources/Treasury/ReceivedCredits'), - ReceivedDebits: require('./resources/Treasury/ReceivedDebits'), - Transactions: require('./resources/Treasury/Transactions'), - TransactionEntries: require('./resources/Treasury/TransactionEntries'), - }), }; diff --git a/lib/resources/AccountLinks.js b/lib/resources/AccountLinks.js index 45a2185524..4e454771df 100644 --- a/lib/resources/AccountLinks.js +++ b/lib/resources/AccountLinks.js @@ -3,8 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/account_links', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/account_links', + }), }); diff --git a/lib/resources/Accounts.js b/lib/resources/Accounts.js index 63aa6e6bb5..1be3480640 100644 --- a/lib/resources/Accounts.js +++ b/lib/resources/Accounts.js @@ -4,103 +4,104 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; // Since path can either be `account` or `accounts`, support both through stripeMethod path; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts', - }), - retrieve(id) { - // No longer allow an api key to be passed as the first string to this function due to ambiguity between - // old account ids and api keys. To request the account for an api key, send null as the id - if (typeof id === 'string') { - return stripeMethod({ + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts', + }), + retrieve(id) { + // No longer allow an api key to be passed as the first string to this function due to ambiguity between + // old account ids and api keys. To request the account for an api key, send null as the id + if (typeof id === 'string') { + return stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{id}', + }).apply(this, arguments); + } + else { + if (id === null || id === undefined) { + // Remove id as stripeMethod would complain of unexpected argument + [].shift.apply(arguments); + } + return stripeMethod({ + method: 'GET', + fullPath: '/v1/account', + }).apply(this, arguments); + } + }, + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}', + }), + list: stripeMethod({ method: 'GET', - fullPath: '/v1/accounts/{id}', - }).apply(this, arguments); - } else { - if (id === null || id === undefined) { - // Remove id as stripeMethod would complain of unexpected argument - [].shift.apply(arguments); - } - return stripeMethod({ + fullPath: '/v1/accounts', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/accounts/{account}', + }), + reject: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/reject', + }), + retrieveCapability: stripeMethod({ method: 'GET', - fullPath: '/v1/account', - }).apply(this, arguments); - } - }, - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/accounts/{account}', - }), - reject: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/reject', - }), - retrieveCapability: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/capabilities/{capability}', - }), - updateCapability: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/capabilities/{capability}', - }), - listCapabilities: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/capabilities', - methodType: 'list', - }), - createExternalAccount: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/external_accounts', - }), - retrieveExternalAccount: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/external_accounts/{id}', - }), - updateExternalAccount: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/external_accounts/{id}', - }), - listExternalAccounts: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/external_accounts', - methodType: 'list', - }), - deleteExternalAccount: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/accounts/{account}/external_accounts/{id}', - }), - createLoginLink: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/login_links', - }), - createPerson: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/persons', - }), - retrievePerson: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/persons/{person}', - }), - updatePerson: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/persons/{person}', - }), - listPersons: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/persons', - methodType: 'list', - }), - deletePerson: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/accounts/{account}/persons/{person}', - }), + fullPath: '/v1/accounts/{account}/capabilities/{capability}', + }), + updateCapability: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/capabilities/{capability}', + }), + listCapabilities: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/capabilities', + methodType: 'list', + }), + createExternalAccount: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/external_accounts', + }), + retrieveExternalAccount: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', + }), + updateExternalAccount: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', + }), + listExternalAccounts: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/external_accounts', + methodType: 'list', + }), + deleteExternalAccount: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', + }), + createLoginLink: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/login_links', + }), + createPerson: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/persons', + }), + retrievePerson: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/persons/{person}', + }), + updatePerson: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/persons/{person}', + }), + listPersons: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/persons', + methodType: 'list', + }), + deletePerson: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/accounts/{account}/persons/{person}', + }), }); diff --git a/lib/resources/ApplePayDomains.js b/lib/resources/ApplePayDomains.js index 4ca4546ec3..46fc59ad61 100644 --- a/lib/resources/ApplePayDomains.js +++ b/lib/resources/ApplePayDomains.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/apple_pay/domains', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/apple_pay/domains/{domain}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/apple_pay/domains', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/apple_pay/domains/{domain}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/apple_pay/domains', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/apple_pay/domains/{domain}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/apple_pay/domains', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/apple_pay/domains/{domain}', + }), }); diff --git a/lib/resources/ApplicationFees.js b/lib/resources/ApplicationFees.js index 7f0fa49662..c61a07964e 100644 --- a/lib/resources/ApplicationFees.js +++ b/lib/resources/ApplicationFees.js @@ -3,30 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees', - methodType: 'list', - }), - createRefund: stripeMethod({ - method: 'POST', - fullPath: '/v1/application_fees/{id}/refunds', - }), - retrieveRefund: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees/{fee}/refunds/{id}', - }), - updateRefund: stripeMethod({ - method: 'POST', - fullPath: '/v1/application_fees/{fee}/refunds/{id}', - }), - listRefunds: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees/{id}/refunds', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees', + methodType: 'list', + }), + createRefund: stripeMethod({ + method: 'POST', + fullPath: '/v1/application_fees/{id}/refunds', + }), + retrieveRefund: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', + }), + updateRefund: stripeMethod({ + method: 'POST', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', + }), + listRefunds: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees/{id}/refunds', + methodType: 'list', + }), }); diff --git a/lib/resources/Apps/Secrets.js b/lib/resources/Apps/Secrets.js index 112e3539e5..f94086c14e 100644 --- a/lib/resources/Apps/Secrets.js +++ b/lib/resources/Apps/Secrets.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/apps/secrets', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/apps/secrets', - methodType: 'list', - }), - deleteWhere: stripeMethod({ - method: 'POST', - fullPath: '/v1/apps/secrets/delete', - }), - find: stripeMethod({ - method: 'GET', - fullPath: '/v1/apps/secrets/find', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/apps/secrets', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/apps/secrets', + methodType: 'list', + }), + deleteWhere: stripeMethod({ + method: 'POST', + fullPath: '/v1/apps/secrets/delete', + }), + find: stripeMethod({ + method: 'GET', + fullPath: '/v1/apps/secrets/find', + }), }); diff --git a/lib/resources/Balance.js b/lib/resources/Balance.js index 84378bb100..d1d9b4f30f 100644 --- a/lib/resources/Balance.js +++ b/lib/resources/Balance.js @@ -3,8 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/balance', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/balance', + }), }); diff --git a/lib/resources/BalanceTransactions.js b/lib/resources/BalanceTransactions.js index 3e205b9dc5..eb5317a777 100644 --- a/lib/resources/BalanceTransactions.js +++ b/lib/resources/BalanceTransactions.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/balance_transactions/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/balance_transactions', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/balance_transactions/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/balance_transactions', + methodType: 'list', + }), }); diff --git a/lib/resources/BillingPortal/Configurations.js b/lib/resources/BillingPortal/Configurations.js index df450890e9..a64e367e19 100644 --- a/lib/resources/BillingPortal/Configurations.js +++ b/lib/resources/BillingPortal/Configurations.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/billing_portal/configurations', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/billing_portal/configurations/{configuration}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/billing_portal/configurations/{configuration}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/billing_portal/configurations', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/billing_portal/configurations', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/billing_portal/configurations/{configuration}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/billing_portal/configurations/{configuration}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/billing_portal/configurations', + methodType: 'list', + }), }); diff --git a/lib/resources/BillingPortal/Sessions.js b/lib/resources/BillingPortal/Sessions.js index db2e2e5d2a..04ce6efafc 100644 --- a/lib/resources/BillingPortal/Sessions.js +++ b/lib/resources/BillingPortal/Sessions.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/billing_portal/sessions', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/billing_portal/sessions', + }), }); diff --git a/lib/resources/Charges.js b/lib/resources/Charges.js index 6e3302700c..f329f6b36e 100644 --- a/lib/resources/Charges.js +++ b/lib/resources/Charges.js @@ -3,30 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/charges', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/charges/{charge}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/charges/{charge}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/charges', - methodType: 'list', - }), - capture: stripeMethod({ - method: 'POST', - fullPath: '/v1/charges/{charge}/capture', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/charges/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/charges', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/charges/{charge}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/charges/{charge}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/charges', + methodType: 'list', + }), + capture: stripeMethod({ + method: 'POST', + fullPath: '/v1/charges/{charge}/capture', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/charges/search', + methodType: 'search', + }), }); diff --git a/lib/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js index ecaafb11d2..40adb4662a 100644 --- a/lib/resources/Checkout/Sessions.js +++ b/lib/resources/Checkout/Sessions.js @@ -3,26 +3,26 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/checkout/sessions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/checkout/sessions/{session}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/checkout/sessions', - methodType: 'list', - }), - expire: stripeMethod({ - method: 'POST', - fullPath: '/v1/checkout/sessions/{session}/expire', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/checkout/sessions/{session}/line_items', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/checkout/sessions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/checkout/sessions/{session}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/checkout/sessions', + methodType: 'list', + }), + expire: stripeMethod({ + method: 'POST', + fullPath: '/v1/checkout/sessions/{session}/expire', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/checkout/sessions/{session}/line_items', + methodType: 'list', + }), }); diff --git a/lib/resources/CountrySpecs.js b/lib/resources/CountrySpecs.js index 6a9d410b4d..8aefedb58f 100644 --- a/lib/resources/CountrySpecs.js +++ b/lib/resources/CountrySpecs.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/country_specs/{country}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/country_specs', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/country_specs/{country}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/country_specs', + methodType: 'list', + }), }); diff --git a/lib/resources/Coupons.js b/lib/resources/Coupons.js index 043eeead74..468338f603 100644 --- a/lib/resources/Coupons.js +++ b/lib/resources/Coupons.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/coupons', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/coupons/{coupon}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/coupons/{coupon}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/coupons', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/coupons/{coupon}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/coupons', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/coupons/{coupon}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/coupons/{coupon}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/coupons', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/coupons/{coupon}', + }), }); diff --git a/lib/resources/CreditNotes.js b/lib/resources/CreditNotes.js index 6574070881..2b2f42f4c8 100644 --- a/lib/resources/CreditNotes.js +++ b/lib/resources/CreditNotes.js @@ -3,39 +3,39 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/credit_notes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/{id}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/credit_notes/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes', - methodType: 'list', - }), - listPreviewLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/preview/lines', - methodType: 'list', - }), - preview: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/preview', - }), - voidCreditNote: stripeMethod({ - method: 'POST', - fullPath: '/v1/credit_notes/{id}/void', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/{credit_note}/lines', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/credit_notes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/{id}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/credit_notes/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes', + methodType: 'list', + }), + listPreviewLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/preview/lines', + methodType: 'list', + }), + preview: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/preview', + }), + voidCreditNote: stripeMethod({ + method: 'POST', + fullPath: '/v1/credit_notes/{id}/void', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/{credit_note}/lines', + methodType: 'list', + }), }); diff --git a/lib/resources/Customers.js b/lib/resources/Customers.js index 0c98e91590..5196f84898 100644 --- a/lib/resources/Customers.js +++ b/lib/resources/Customers.js @@ -3,124 +3,123 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}', - }), - createFundingInstructions: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/funding_instructions', - }), - deleteDiscount: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}/discount', - }), - listPaymentMethods: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/payment_methods', - methodType: 'list', - }), - retrievePaymentMethod: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/payment_methods/{payment_method}', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/search', - methodType: 'search', - }), - retrieveCashBalance: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/cash_balance', - }), - updateCashBalance: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/cash_balance', - }), - createBalanceTransaction: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/balance_transactions', - }), - retrieveBalanceTransaction: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', - }), - updateBalanceTransaction: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', - }), - listBalanceTransactions: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/balance_transactions', - methodType: 'list', - }), - retrieveCashBalanceTransaction: stripeMethod({ - method: 'GET', - fullPath: - '/v1/customers/{customer}/cash_balance_transactions/{transaction}', - }), - listCashBalanceTransactions: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/cash_balance_transactions', - methodType: 'list', - }), - createSource: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/sources', - }), - retrieveSource: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/sources/{id}', - }), - updateSource: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/sources/{id}', - }), - listSources: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/sources', - methodType: 'list', - }), - deleteSource: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}/sources/{id}', - }), - verifySource: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/sources/{id}/verify', - }), - createTaxId: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/tax_ids', - }), - retrieveTaxId: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/tax_ids/{id}', - }), - listTaxIds: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/tax_ids', - methodType: 'list', - }), - deleteTaxId: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}/tax_ids/{id}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}', + }), + createFundingInstructions: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/funding_instructions', + }), + deleteDiscount: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}/discount', + }), + listPaymentMethods: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/payment_methods', + methodType: 'list', + }), + retrievePaymentMethod: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/payment_methods/{payment_method}', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/search', + methodType: 'search', + }), + retrieveCashBalance: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/cash_balance', + }), + updateCashBalance: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/cash_balance', + }), + createBalanceTransaction: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/balance_transactions', + }), + retrieveBalanceTransaction: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', + }), + updateBalanceTransaction: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', + }), + listBalanceTransactions: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/balance_transactions', + methodType: 'list', + }), + retrieveCashBalanceTransaction: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/cash_balance_transactions/{transaction}', + }), + listCashBalanceTransactions: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/cash_balance_transactions', + methodType: 'list', + }), + createSource: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/sources', + }), + retrieveSource: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/sources/{id}', + }), + updateSource: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/sources/{id}', + }), + listSources: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/sources', + methodType: 'list', + }), + deleteSource: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}/sources/{id}', + }), + verifySource: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/sources/{id}/verify', + }), + createTaxId: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/tax_ids', + }), + retrieveTaxId: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', + }), + listTaxIds: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/tax_ids', + methodType: 'list', + }), + deleteTaxId: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', + }), }); diff --git a/lib/resources/Disputes.js b/lib/resources/Disputes.js index 3679668634..849bd4ce68 100644 --- a/lib/resources/Disputes.js +++ b/lib/resources/Disputes.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/disputes/{dispute}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/disputes/{dispute}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/disputes', - methodType: 'list', - }), - close: stripeMethod({ - method: 'POST', - fullPath: '/v1/disputes/{dispute}/close', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/disputes/{dispute}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/disputes/{dispute}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/disputes', + methodType: 'list', + }), + close: stripeMethod({ + method: 'POST', + fullPath: '/v1/disputes/{dispute}/close', + }), }); diff --git a/lib/resources/EphemeralKeys.js b/lib/resources/EphemeralKeys.js index 186a3b091e..4672229799 100644 --- a/lib/resources/EphemeralKeys.js +++ b/lib/resources/EphemeralKeys.js @@ -3,19 +3,17 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/ephemeral_keys', - validator: (data, options) => { - if (!options.headers || !options.headers['Stripe-Version']) { - throw new Error( - 'Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node' - ); - } - }, - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/ephemeral_keys/{key}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/ephemeral_keys', + validator: (data, options) => { + if (!options.headers || !options.headers['Stripe-Version']) { + throw new Error('Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node'); + } + }, + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/ephemeral_keys/{key}', + }), }); diff --git a/lib/resources/Events.js b/lib/resources/Events.js index e148e305ae..b33d17b056 100644 --- a/lib/resources/Events.js +++ b/lib/resources/Events.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/events/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/events', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/events/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/events', + methodType: 'list', + }), }); diff --git a/lib/resources/ExchangeRates.js b/lib/resources/ExchangeRates.js index f92da86aab..b1d58339a7 100644 --- a/lib/resources/ExchangeRates.js +++ b/lib/resources/ExchangeRates.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/exchange_rates/{rate_id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/exchange_rates', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/exchange_rates/{rate_id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/exchange_rates', + methodType: 'list', + }), }); diff --git a/lib/resources/FileLinks.js b/lib/resources/FileLinks.js index b474227b31..3d3b0b9281 100644 --- a/lib/resources/FileLinks.js +++ b/lib/resources/FileLinks.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/file_links', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/file_links/{link}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/file_links/{link}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/file_links', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/file_links', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/file_links/{link}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/file_links/{link}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/file_links', + methodType: 'list', + }), }); diff --git a/lib/resources/Files.js b/lib/resources/Files.js index 11856b1323..4b86ed3daa 100644 --- a/lib/resources/Files.js +++ b/lib/resources/Files.js @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec 'use strict'; -const {multipartRequestDataProcessor} = require('../multipart'); +const { multipartRequestDataProcessor } = require('../multipart'); const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/files', - headers: { - 'Content-Type': 'multipart/form-data', - }, - host: 'files.stripe.com', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/files/{file}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/files', - methodType: 'list', - }), - requestDataProcessor: multipartRequestDataProcessor, + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/files', + headers: { + 'Content-Type': 'multipart/form-data', + }, + host: 'files.stripe.com', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/files/{file}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/files', + methodType: 'list', + }), + requestDataProcessor: multipartRequestDataProcessor, }); diff --git a/lib/resources/FinancialConnections/Accounts.js b/lib/resources/FinancialConnections/Accounts.js index 8ce36e37b2..edd9ed420a 100644 --- a/lib/resources/FinancialConnections/Accounts.js +++ b/lib/resources/FinancialConnections/Accounts.js @@ -3,26 +3,26 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/accounts/{account}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/accounts', - methodType: 'list', - }), - disconnect: stripeMethod({ - method: 'POST', - fullPath: '/v1/financial_connections/accounts/{account}/disconnect', - }), - listOwners: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/accounts/{account}/owners', - methodType: 'list', - }), - refresh: stripeMethod({ - method: 'POST', - fullPath: '/v1/financial_connections/accounts/{account}/refresh', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/accounts/{account}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/accounts', + methodType: 'list', + }), + disconnect: stripeMethod({ + method: 'POST', + fullPath: '/v1/financial_connections/accounts/{account}/disconnect', + }), + listOwners: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/accounts/{account}/owners', + methodType: 'list', + }), + refresh: stripeMethod({ + method: 'POST', + fullPath: '/v1/financial_connections/accounts/{account}/refresh', + }), }); diff --git a/lib/resources/FinancialConnections/Sessions.js b/lib/resources/FinancialConnections/Sessions.js index b5bbb4c641..227c39104a 100644 --- a/lib/resources/FinancialConnections/Sessions.js +++ b/lib/resources/FinancialConnections/Sessions.js @@ -3,12 +3,12 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/financial_connections/sessions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/sessions/{session}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/financial_connections/sessions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/sessions/{session}', + }), }); diff --git a/lib/resources/Identity/VerificationReports.js b/lib/resources/Identity/VerificationReports.js index 3bd584a265..1ceb56339c 100644 --- a/lib/resources/Identity/VerificationReports.js +++ b/lib/resources/Identity/VerificationReports.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_reports/{report}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_reports', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_reports/{report}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_reports', + methodType: 'list', + }), }); diff --git a/lib/resources/Identity/VerificationSessions.js b/lib/resources/Identity/VerificationSessions.js index e9d3b72e87..4984233d1b 100644 --- a/lib/resources/Identity/VerificationSessions.js +++ b/lib/resources/Identity/VerificationSessions.js @@ -3,29 +3,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_sessions/{session}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions/{session}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_sessions', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions/{session}/cancel', - }), - redact: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions/{session}/redact', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_sessions/{session}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions/{session}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_sessions', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions/{session}/cancel', + }), + redact: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions/{session}/redact', + }), }); diff --git a/lib/resources/InvoiceItems.js b/lib/resources/InvoiceItems.js index 1a961fddb8..cafc142981 100644 --- a/lib/resources/InvoiceItems.js +++ b/lib/resources/InvoiceItems.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoiceitems', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoiceitems/{invoiceitem}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoiceitems/{invoiceitem}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoiceitems', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/invoiceitems/{invoiceitem}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoiceitems', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoiceitems/{invoiceitem}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoiceitems/{invoiceitem}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoiceitems', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/invoiceitems/{invoiceitem}', + }), }); diff --git a/lib/resources/Invoices.js b/lib/resources/Invoices.js index e1ac39f34f..7516508fac 100644 --- a/lib/resources/Invoices.js +++ b/lib/resources/Invoices.js @@ -3,64 +3,64 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/{invoice}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/invoices/{invoice}', - }), - finalizeInvoice: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/finalize', - }), - listUpcomingLines: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/upcoming/lines', - methodType: 'list', - }), - markUncollectible: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/mark_uncollectible', - }), - pay: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/pay', - }), - retrieveUpcoming: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/upcoming', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/search', - methodType: 'search', - }), - sendInvoice: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/send', - }), - voidInvoice: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/void', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/{invoice}/lines', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/{invoice}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/invoices/{invoice}', + }), + finalizeInvoice: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/finalize', + }), + listUpcomingLines: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/upcoming/lines', + methodType: 'list', + }), + markUncollectible: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/mark_uncollectible', + }), + pay: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/pay', + }), + retrieveUpcoming: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/upcoming', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/search', + methodType: 'search', + }), + sendInvoice: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/send', + }), + voidInvoice: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/void', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/{invoice}/lines', + methodType: 'list', + }), }); diff --git a/lib/resources/Issuing/Authorizations.js b/lib/resources/Issuing/Authorizations.js index 7d9e894b97..6692720c8f 100644 --- a/lib/resources/Issuing/Authorizations.js +++ b/lib/resources/Issuing/Authorizations.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/authorizations/{authorization}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/authorizations/{authorization}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/authorizations', - methodType: 'list', - }), - approve: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/authorizations/{authorization}/approve', - }), - decline: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/authorizations/{authorization}/decline', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/authorizations/{authorization}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/authorizations/{authorization}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/authorizations', + methodType: 'list', + }), + approve: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/authorizations/{authorization}/approve', + }), + decline: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/authorizations/{authorization}/decline', + }), }); diff --git a/lib/resources/Issuing/Cardholders.js b/lib/resources/Issuing/Cardholders.js index a76764eba3..ea37a76d1c 100644 --- a/lib/resources/Issuing/Cardholders.js +++ b/lib/resources/Issuing/Cardholders.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cardholders', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cardholders/{cardholder}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cardholders/{cardholder}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cardholders', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cardholders', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cardholders/{cardholder}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cardholders/{cardholder}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cardholders', + methodType: 'list', + }), }); diff --git a/lib/resources/Issuing/Cards.js b/lib/resources/Issuing/Cards.js index 98cc817f1e..dd63dae5a9 100644 --- a/lib/resources/Issuing/Cards.js +++ b/lib/resources/Issuing/Cards.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cards', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cards/{card}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cards/{card}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cards', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cards', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cards/{card}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cards/{card}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cards', + methodType: 'list', + }), }); diff --git a/lib/resources/Issuing/Disputes.js b/lib/resources/Issuing/Disputes.js index 803d4b6149..012f81575f 100644 --- a/lib/resources/Issuing/Disputes.js +++ b/lib/resources/Issuing/Disputes.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/disputes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/disputes/{dispute}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/disputes/{dispute}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/disputes', - methodType: 'list', - }), - submit: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/disputes/{dispute}/submit', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/disputes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/disputes/{dispute}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/disputes/{dispute}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/disputes', + methodType: 'list', + }), + submit: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/disputes/{dispute}/submit', + }), }); diff --git a/lib/resources/Issuing/Transactions.js b/lib/resources/Issuing/Transactions.js index 789dd7e3df..c6603cbedb 100644 --- a/lib/resources/Issuing/Transactions.js +++ b/lib/resources/Issuing/Transactions.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/transactions/{transaction}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/transactions/{transaction}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/transactions', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/transactions/{transaction}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/transactions/{transaction}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/transactions', + methodType: 'list', + }), }); diff --git a/lib/resources/Mandates.js b/lib/resources/Mandates.js index 06240ae2d2..b8d12d70db 100644 --- a/lib/resources/Mandates.js +++ b/lib/resources/Mandates.js @@ -3,8 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/mandates/{mandate}', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/mandates/{mandate}', + }), }); diff --git a/lib/resources/OAuth.js b/lib/resources/OAuth.js index 2c04c5fb7b..6248fa5929 100644 --- a/lib/resources/OAuth.js +++ b/lib/resources/OAuth.js @@ -4,39 +4,39 @@ const stripeMethod = StripeResource.method; const utils = require('../utils'); const oAuthHost = 'connect.stripe.com'; module.exports = StripeResource.extend({ - basePath: '/', - authorizeUrl(params, options) { - params = params || {}; - options = options || {}; - let path = 'oauth/authorize'; - // For Express accounts, the path changes - if (options.express) { - path = `express/${path}`; - } - if (!params.response_type) { - params.response_type = 'code'; - } - if (!params.client_id) { - params.client_id = this._stripe.getClientId(); - } - if (!params.scope) { - params.scope = 'read_write'; - } - return `https://${oAuthHost}/${path}?${utils.stringifyRequestData(params)}`; - }, - token: stripeMethod({ - method: 'POST', - path: 'oauth/token', - host: oAuthHost, - }), - deauthorize(spec) { - if (!spec.client_id) { - spec.client_id = this._stripe.getClientId(); - } - return stripeMethod({ - method: 'POST', - path: 'oauth/deauthorize', - host: oAuthHost, - }).apply(this, arguments); - }, + basePath: '/', + authorizeUrl(params, options) { + params = params || {}; + options = options || {}; + let path = 'oauth/authorize'; + // For Express accounts, the path changes + if (options.express) { + path = `express/${path}`; + } + if (!params.response_type) { + params.response_type = 'code'; + } + if (!params.client_id) { + params.client_id = this._stripe.getClientId(); + } + if (!params.scope) { + params.scope = 'read_write'; + } + return `https://${oAuthHost}/${path}?${utils.stringifyRequestData(params)}`; + }, + token: stripeMethod({ + method: 'POST', + path: 'oauth/token', + host: oAuthHost, + }), + deauthorize(spec) { + if (!spec.client_id) { + spec.client_id = this._stripe.getClientId(); + } + return stripeMethod({ + method: 'POST', + path: 'oauth/deauthorize', + host: oAuthHost, + }).apply(this, arguments); + }, }); diff --git a/lib/resources/PaymentIntents.js b/lib/resources/PaymentIntents.js index 963f1688e6..4e464c0a31 100644 --- a/lib/resources/PaymentIntents.js +++ b/lib/resources/PaymentIntents.js @@ -3,50 +3,50 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_intents/{intent}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_intents', - methodType: 'list', - }), - applyCustomerBalance: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/apply_customer_balance', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/cancel', - }), - capture: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/capture', - }), - confirm: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/confirm', - }), - incrementAuthorization: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/increment_authorization', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_intents/search', - methodType: 'search', - }), - verifyMicrodeposits: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/verify_microdeposits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_intents/{intent}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_intents', + methodType: 'list', + }), + applyCustomerBalance: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/apply_customer_balance', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/cancel', + }), + capture: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/capture', + }), + confirm: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/confirm', + }), + incrementAuthorization: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/increment_authorization', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_intents/search', + methodType: 'search', + }), + verifyMicrodeposits: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/verify_microdeposits', + }), }); diff --git a/lib/resources/PaymentLinks.js b/lib/resources/PaymentLinks.js index 86acf3cb8c..e693fc9477 100644 --- a/lib/resources/PaymentLinks.js +++ b/lib/resources/PaymentLinks.js @@ -3,26 +3,26 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_links', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_links/{payment_link}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_links/{payment_link}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_links', - methodType: 'list', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_links/{payment_link}/line_items', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_links', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_links/{payment_link}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_links/{payment_link}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_links', + methodType: 'list', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_links/{payment_link}/line_items', + methodType: 'list', + }), }); diff --git a/lib/resources/PaymentMethods.js b/lib/resources/PaymentMethods.js index 85fc630698..3ce80ec613 100644 --- a/lib/resources/PaymentMethods.js +++ b/lib/resources/PaymentMethods.js @@ -3,29 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_methods/{payment_method}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods/{payment_method}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_methods', - methodType: 'list', - }), - attach: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods/{payment_method}/attach', - }), - detach: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods/{payment_method}/detach', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_methods/{payment_method}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods/{payment_method}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_methods', + methodType: 'list', + }), + attach: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods/{payment_method}/attach', + }), + detach: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods/{payment_method}/detach', + }), }); diff --git a/lib/resources/Payouts.js b/lib/resources/Payouts.js index fd8ddde975..aff8a90ed0 100644 --- a/lib/resources/Payouts.js +++ b/lib/resources/Payouts.js @@ -3,29 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payouts/{payout}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts/{payout}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payouts', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts/{payout}/cancel', - }), - reverse: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts/{payout}/reverse', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payouts/{payout}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts/{payout}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payouts', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts/{payout}/cancel', + }), + reverse: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts/{payout}/reverse', + }), }); diff --git a/lib/resources/Plans.js b/lib/resources/Plans.js index a39523bd8c..0f96cb98e9 100644 --- a/lib/resources/Plans.js +++ b/lib/resources/Plans.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/plans', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/plans/{plan}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/plans/{plan}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/plans', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/plans/{plan}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/plans', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/plans/{plan}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/plans/{plan}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/plans', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/plans/{plan}', + }), }); diff --git a/lib/resources/Prices.js b/lib/resources/Prices.js index 7406e1362f..f9b7cb801d 100644 --- a/lib/resources/Prices.js +++ b/lib/resources/Prices.js @@ -3,26 +3,26 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/prices', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/prices/{price}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/prices/{price}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/prices', - methodType: 'list', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/prices/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/prices', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/prices/{price}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/prices/{price}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/prices', + methodType: 'list', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/prices/search', + methodType: 'search', + }), }); diff --git a/lib/resources/Products.js b/lib/resources/Products.js index eba8e78d30..f25ddf8daa 100644 --- a/lib/resources/Products.js +++ b/lib/resources/Products.js @@ -3,30 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/products', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/products/{id}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/products/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/products', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/products/{id}', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/products/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/products', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/products/{id}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/products/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/products', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/products/{id}', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/products/search', + methodType: 'search', + }), }); diff --git a/lib/resources/PromotionCodes.js b/lib/resources/PromotionCodes.js index e112795f02..de58217d82 100644 --- a/lib/resources/PromotionCodes.js +++ b/lib/resources/PromotionCodes.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/promotion_codes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/promotion_codes/{promotion_code}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/promotion_codes/{promotion_code}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/promotion_codes', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/promotion_codes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/promotion_codes/{promotion_code}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/promotion_codes/{promotion_code}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/promotion_codes', + methodType: 'list', + }), }); diff --git a/lib/resources/Quotes.js b/lib/resources/Quotes.js index f5c97a375b..8e9a82007d 100644 --- a/lib/resources/Quotes.js +++ b/lib/resources/Quotes.js @@ -3,49 +3,49 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes/{quote}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes', - methodType: 'list', - }), - accept: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}/accept', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}/cancel', - }), - finalizeQuote: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}/finalize', - }), - listComputedUpfrontLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes/{quote}/computed_upfront_line_items', - methodType: 'list', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes/{quote}/line_items', - methodType: 'list', - }), - pdf: stripeMethod({ - host: 'files.stripe.com', - method: 'GET', - fullPath: '/v1/quotes/{quote}/pdf', - streaming: true, - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes/{quote}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes', + methodType: 'list', + }), + accept: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}/accept', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}/cancel', + }), + finalizeQuote: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}/finalize', + }), + listComputedUpfrontLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes/{quote}/computed_upfront_line_items', + methodType: 'list', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes/{quote}/line_items', + methodType: 'list', + }), + pdf: stripeMethod({ + host: 'files.stripe.com', + method: 'GET', + fullPath: '/v1/quotes/{quote}/pdf', + streaming: true, + }), }); diff --git a/lib/resources/Radar/EarlyFraudWarnings.js b/lib/resources/Radar/EarlyFraudWarnings.js index 5eaf23768a..dd609bed95 100644 --- a/lib/resources/Radar/EarlyFraudWarnings.js +++ b/lib/resources/Radar/EarlyFraudWarnings.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/early_fraud_warnings/{early_fraud_warning}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/early_fraud_warnings', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/early_fraud_warnings/{early_fraud_warning}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/early_fraud_warnings', + methodType: 'list', + }), }); diff --git a/lib/resources/Radar/ValueListItems.js b/lib/resources/Radar/ValueListItems.js index 4fd46fd0ac..864c7897f4 100644 --- a/lib/resources/Radar/ValueListItems.js +++ b/lib/resources/Radar/ValueListItems.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/radar/value_list_items', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_list_items/{item}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_list_items', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/radar/value_list_items/{item}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/radar/value_list_items', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_list_items/{item}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_list_items', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/radar/value_list_items/{item}', + }), }); diff --git a/lib/resources/Radar/ValueLists.js b/lib/resources/Radar/ValueLists.js index e89b5500c8..90b8c66eeb 100644 --- a/lib/resources/Radar/ValueLists.js +++ b/lib/resources/Radar/ValueLists.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/radar/value_lists', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_lists/{value_list}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/radar/value_lists/{value_list}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_lists', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/radar/value_lists/{value_list}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/radar/value_lists', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_lists/{value_list}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/radar/value_lists/{value_list}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_lists', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/radar/value_lists/{value_list}', + }), }); diff --git a/lib/resources/Refunds.js b/lib/resources/Refunds.js index 87d3f6e1dc..095193f9f9 100644 --- a/lib/resources/Refunds.js +++ b/lib/resources/Refunds.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/refunds', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/refunds/{refund}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/refunds/{refund}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/refunds', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/refunds/{refund}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/refunds', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/refunds/{refund}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/refunds/{refund}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/refunds', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/refunds/{refund}/cancel', + }), }); diff --git a/lib/resources/Reporting/ReportRuns.js b/lib/resources/Reporting/ReportRuns.js index d6e853aff0..859e672af2 100644 --- a/lib/resources/Reporting/ReportRuns.js +++ b/lib/resources/Reporting/ReportRuns.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/reporting/report_runs', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_runs/{report_run}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_runs', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/reporting/report_runs', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_runs/{report_run}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_runs', + methodType: 'list', + }), }); diff --git a/lib/resources/Reporting/ReportTypes.js b/lib/resources/Reporting/ReportTypes.js index 58e8075460..87371048df 100644 --- a/lib/resources/Reporting/ReportTypes.js +++ b/lib/resources/Reporting/ReportTypes.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_types/{report_type}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_types', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_types/{report_type}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_types', + methodType: 'list', + }), }); diff --git a/lib/resources/Reviews.js b/lib/resources/Reviews.js index 201fbc1d64..498fbac1b7 100644 --- a/lib/resources/Reviews.js +++ b/lib/resources/Reviews.js @@ -3,17 +3,17 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/reviews/{review}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/reviews', - methodType: 'list', - }), - approve: stripeMethod({ - method: 'POST', - fullPath: '/v1/reviews/{review}/approve', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/reviews/{review}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/reviews', + methodType: 'list', + }), + approve: stripeMethod({ + method: 'POST', + fullPath: '/v1/reviews/{review}/approve', + }), }); diff --git a/lib/resources/SetupAttempts.js b/lib/resources/SetupAttempts.js index 36f232f4b9..a7062e23ea 100644 --- a/lib/resources/SetupAttempts.js +++ b/lib/resources/SetupAttempts.js @@ -3,9 +3,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/setup_attempts', - methodType: 'list', - }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/setup_attempts', + methodType: 'list', + }), }); diff --git a/lib/resources/SetupIntents.js b/lib/resources/SetupIntents.js index 9ce7ca7231..57f76595b6 100644 --- a/lib/resources/SetupIntents.js +++ b/lib/resources/SetupIntents.js @@ -3,33 +3,33 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/setup_intents/{intent}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/setup_intents', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}/cancel', - }), - confirm: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}/confirm', - }), - verifyMicrodeposits: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}/verify_microdeposits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/setup_intents/{intent}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/setup_intents', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}/cancel', + }), + confirm: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}/confirm', + }), + verifyMicrodeposits: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}/verify_microdeposits', + }), }); diff --git a/lib/resources/ShippingRates.js b/lib/resources/ShippingRates.js index abda3a77c0..7a7ebce845 100644 --- a/lib/resources/ShippingRates.js +++ b/lib/resources/ShippingRates.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/shipping_rates', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/shipping_rates/{shipping_rate_token}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/shipping_rates/{shipping_rate_token}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/shipping_rates', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/shipping_rates', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/shipping_rates', + methodType: 'list', + }), }); diff --git a/lib/resources/Sigma/ScheduledQueryRuns.js b/lib/resources/Sigma/ScheduledQueryRuns.js index 4e6c7211a1..a20907900e 100644 --- a/lib/resources/Sigma/ScheduledQueryRuns.js +++ b/lib/resources/Sigma/ScheduledQueryRuns.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/sigma/scheduled_query_runs/{scheduled_query_run}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/sigma/scheduled_query_runs', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/sigma/scheduled_query_runs/{scheduled_query_run}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/sigma/scheduled_query_runs', + methodType: 'list', + }), }); diff --git a/lib/resources/Sources.js b/lib/resources/Sources.js index e26f8ad3b9..cdd7efb728 100644 --- a/lib/resources/Sources.js +++ b/lib/resources/Sources.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/sources', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/sources/{source}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/sources/{source}', - }), - listSourceTransactions: stripeMethod({ - method: 'GET', - fullPath: '/v1/sources/{source}/source_transactions', - methodType: 'list', - }), - verify: stripeMethod({ - method: 'POST', - fullPath: '/v1/sources/{source}/verify', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/sources', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/sources/{source}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/sources/{source}', + }), + listSourceTransactions: stripeMethod({ + method: 'GET', + fullPath: '/v1/sources/{source}/source_transactions', + methodType: 'list', + }), + verify: stripeMethod({ + method: 'POST', + fullPath: '/v1/sources/{source}/verify', + }), }); diff --git a/lib/resources/SubscriptionItems.js b/lib/resources/SubscriptionItems.js index 7681fb88ac..523456507a 100644 --- a/lib/resources/SubscriptionItems.js +++ b/lib/resources/SubscriptionItems.js @@ -3,35 +3,34 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_items', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_items/{item}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_items/{item}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_items', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscription_items/{item}', - }), - createUsageRecord: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_items/{subscription_item}/usage_records', - }), - listUsageRecordSummaries: stripeMethod({ - method: 'GET', - fullPath: - '/v1/subscription_items/{subscription_item}/usage_record_summaries', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_items', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_items/{item}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_items/{item}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_items', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscription_items/{item}', + }), + createUsageRecord: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_items/{subscription_item}/usage_records', + }), + listUsageRecordSummaries: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_items/{subscription_item}/usage_record_summaries', + methodType: 'list', + }), }); diff --git a/lib/resources/SubscriptionSchedules.js b/lib/resources/SubscriptionSchedules.js index c2d3e634f3..5027db2604 100644 --- a/lib/resources/SubscriptionSchedules.js +++ b/lib/resources/SubscriptionSchedules.js @@ -3,29 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_schedules/{schedule}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules/{schedule}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_schedules', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules/{schedule}/cancel', - }), - release: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules/{schedule}/release', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_schedules/{schedule}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules/{schedule}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_schedules', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules/{schedule}/cancel', + }), + release: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules/{schedule}/release', + }), }); diff --git a/lib/resources/Subscriptions.js b/lib/resources/Subscriptions.js index 4790d2d0ca..cbcebdf8a0 100644 --- a/lib/resources/Subscriptions.js +++ b/lib/resources/Subscriptions.js @@ -3,38 +3,38 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscriptions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscriptions', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - deleteDiscount: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscriptions/{subscription_exposed_id}/discount', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscriptions/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscriptions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscriptions', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + deleteDiscount: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscriptions/{subscription_exposed_id}/discount', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscriptions/search', + methodType: 'search', + }), }); diff --git a/lib/resources/TaxCodes.js b/lib/resources/TaxCodes.js index d590878674..84b9e9c403 100644 --- a/lib/resources/TaxCodes.js +++ b/lib/resources/TaxCodes.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_codes/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_codes', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_codes/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_codes', + methodType: 'list', + }), }); diff --git a/lib/resources/TaxRates.js b/lib/resources/TaxRates.js index e4975933ad..6222ec54a3 100644 --- a/lib/resources/TaxRates.js +++ b/lib/resources/TaxRates.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/tax_rates', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_rates/{tax_rate}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/tax_rates/{tax_rate}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_rates', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/tax_rates', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_rates/{tax_rate}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/tax_rates/{tax_rate}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_rates', + methodType: 'list', + }), }); diff --git a/lib/resources/Terminal/Configurations.js b/lib/resources/Terminal/Configurations.js index 02c8297c27..5b2b48bff2 100644 --- a/lib/resources/Terminal/Configurations.js +++ b/lib/resources/Terminal/Configurations.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/configurations', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/configurations/{configuration}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/configurations/{configuration}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/configurations', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/terminal/configurations/{configuration}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/configurations', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/configurations/{configuration}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/configurations/{configuration}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/configurations', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/terminal/configurations/{configuration}', + }), }); diff --git a/lib/resources/Terminal/ConnectionTokens.js b/lib/resources/Terminal/ConnectionTokens.js index 640a6b8712..03b0ddef19 100644 --- a/lib/resources/Terminal/ConnectionTokens.js +++ b/lib/resources/Terminal/ConnectionTokens.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/connection_tokens', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/connection_tokens', + }), }); diff --git a/lib/resources/Terminal/Locations.js b/lib/resources/Terminal/Locations.js index 6b893361a6..9179d077f8 100644 --- a/lib/resources/Terminal/Locations.js +++ b/lib/resources/Terminal/Locations.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/locations', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/locations/{location}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/locations/{location}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/locations', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/terminal/locations/{location}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/locations', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/locations/{location}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/locations/{location}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/locations', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/terminal/locations/{location}', + }), }); diff --git a/lib/resources/Terminal/Readers.js b/lib/resources/Terminal/Readers.js index 879835e91c..dc5ae95d8e 100644 --- a/lib/resources/Terminal/Readers.js +++ b/lib/resources/Terminal/Readers.js @@ -3,41 +3,41 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/readers/{reader}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/readers', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/terminal/readers/{reader}', - }), - cancelAction: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/cancel_action', - }), - processPaymentIntent: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/process_payment_intent', - }), - processSetupIntent: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/process_setup_intent', - }), - setReaderDisplay: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/set_reader_display', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/readers/{reader}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/readers', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/terminal/readers/{reader}', + }), + cancelAction: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/cancel_action', + }), + processPaymentIntent: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/process_payment_intent', + }), + processSetupIntent: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/process_setup_intent', + }), + setReaderDisplay: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/set_reader_display', + }), }); diff --git a/lib/resources/TestHelpers/Customers.js b/lib/resources/TestHelpers/Customers.js index 98bb0b651f..16044f0d62 100644 --- a/lib/resources/TestHelpers/Customers.js +++ b/lib/resources/TestHelpers/Customers.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fundCashBalance: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/customers/{customer}/fund_cash_balance', - }), + fundCashBalance: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/customers/{customer}/fund_cash_balance', + }), }); diff --git a/lib/resources/TestHelpers/Issuing/Cards.js b/lib/resources/TestHelpers/Issuing/Cards.js index 4e13f2245e..6da5bca5bb 100644 --- a/lib/resources/TestHelpers/Issuing/Cards.js +++ b/lib/resources/TestHelpers/Issuing/Cards.js @@ -3,20 +3,20 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - deliverCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/deliver', - }), - failCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/fail', - }), - returnCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/return', - }), - shipCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/ship', - }), + deliverCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/deliver', + }), + failCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/fail', + }), + returnCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/return', + }), + shipCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/ship', + }), }); diff --git a/lib/resources/TestHelpers/Refunds.js b/lib/resources/TestHelpers/Refunds.js index 79f2f221bc..79e16e8ae9 100644 --- a/lib/resources/TestHelpers/Refunds.js +++ b/lib/resources/TestHelpers/Refunds.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - expire: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/refunds/{refund}/expire', - }), + expire: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/refunds/{refund}/expire', + }), }); diff --git a/lib/resources/TestHelpers/Terminal/Readers.js b/lib/resources/TestHelpers/Terminal/Readers.js index a828c20ccf..5db3ce2271 100644 --- a/lib/resources/TestHelpers/Terminal/Readers.js +++ b/lib/resources/TestHelpers/Terminal/Readers.js @@ -3,9 +3,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - presentPaymentMethod: stripeMethod({ - method: 'POST', - fullPath: - '/v1/test_helpers/terminal/readers/{reader}/present_payment_method', - }), + presentPaymentMethod: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/terminal/readers/{reader}/present_payment_method', + }), }); diff --git a/lib/resources/TestHelpers/TestClocks.js b/lib/resources/TestHelpers/TestClocks.js index d3686c123e..0fe10bb858 100644 --- a/lib/resources/TestHelpers/TestClocks.js +++ b/lib/resources/TestHelpers/TestClocks.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/test_clocks', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/test_helpers/test_clocks/{test_clock}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/test_helpers/test_clocks', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/test_helpers/test_clocks/{test_clock}', - }), - advance: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/test_clocks/{test_clock}/advance', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/test_clocks', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/test_helpers/test_clocks', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', + }), + advance: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}/advance', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/InboundTransfers.js b/lib/resources/TestHelpers/Treasury/InboundTransfers.js index 0143e4b71a..8778a49aef 100644 --- a/lib/resources/TestHelpers/Treasury/InboundTransfers.js +++ b/lib/resources/TestHelpers/Treasury/InboundTransfers.js @@ -3,16 +3,16 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fail: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/fail', - }), - returnInboundTransfer: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/return', - }), - succeed: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/succeed', - }), + fail: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/fail', + }), + returnInboundTransfer: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/return', + }), + succeed: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/succeed', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/OutboundPayments.js b/lib/resources/TestHelpers/Treasury/OutboundPayments.js index 7bed50182d..b5f9d52b1c 100644 --- a/lib/resources/TestHelpers/Treasury/OutboundPayments.js +++ b/lib/resources/TestHelpers/Treasury/OutboundPayments.js @@ -3,16 +3,16 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fail: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/fail', - }), - post: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/post', - }), - returnOutboundPayment: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/return', - }), + fail: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/fail', + }), + post: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/post', + }), + returnOutboundPayment: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/return', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/OutboundTransfers.js b/lib/resources/TestHelpers/Treasury/OutboundTransfers.js index f38f2a6743..f10e448dfe 100644 --- a/lib/resources/TestHelpers/Treasury/OutboundTransfers.js +++ b/lib/resources/TestHelpers/Treasury/OutboundTransfers.js @@ -3,19 +3,16 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fail: stripeMethod({ - method: 'POST', - fullPath: - '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail', - }), - post: stripeMethod({ - method: 'POST', - fullPath: - '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post', - }), - returnOutboundTransfer: stripeMethod({ - method: 'POST', - fullPath: - '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return', - }), + fail: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail', + }), + post: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post', + }), + returnOutboundTransfer: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/ReceivedCredits.js b/lib/resources/TestHelpers/Treasury/ReceivedCredits.js index 3461023f91..820e611842 100644 --- a/lib/resources/TestHelpers/Treasury/ReceivedCredits.js +++ b/lib/resources/TestHelpers/Treasury/ReceivedCredits.js @@ -3,8 +3,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/received_credits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/received_credits', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/ReceivedDebits.js b/lib/resources/TestHelpers/Treasury/ReceivedDebits.js index 9d27e31246..f6fbc7d5df 100644 --- a/lib/resources/TestHelpers/Treasury/ReceivedDebits.js +++ b/lib/resources/TestHelpers/Treasury/ReceivedDebits.js @@ -3,8 +3,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/received_debits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/received_debits', + }), }); diff --git a/lib/resources/Tokens.js b/lib/resources/Tokens.js index aba36dc673..a2e355d5ad 100644 --- a/lib/resources/Tokens.js +++ b/lib/resources/Tokens.js @@ -3,12 +3,12 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/tokens', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/tokens/{token}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/tokens', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/tokens/{token}', + }), }); diff --git a/lib/resources/Topups.js b/lib/resources/Topups.js index 98a373ce13..7bcf65713e 100644 --- a/lib/resources/Topups.js +++ b/lib/resources/Topups.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/topups', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/topups/{topup}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/topups/{topup}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/topups', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/topups/{topup}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/topups', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/topups/{topup}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/topups/{topup}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/topups', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/topups/{topup}/cancel', + }), }); diff --git a/lib/resources/Transfers.js b/lib/resources/Transfers.js index f046445237..6fb574d6f2 100644 --- a/lib/resources/Transfers.js +++ b/lib/resources/Transfers.js @@ -3,38 +3,38 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers/{transfer}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers/{transfer}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers', - methodType: 'list', - }), - createReversal: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers/{id}/reversals', - }), - retrieveReversal: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers/{transfer}/reversals/{id}', - }), - updateReversal: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers/{transfer}/reversals/{id}', - }), - listReversals: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers/{id}/reversals', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers/{transfer}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers/{transfer}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers', + methodType: 'list', + }), + createReversal: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers/{id}/reversals', + }), + retrieveReversal: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', + }), + updateReversal: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', + }), + listReversals: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers/{id}/reversals', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/CreditReversals.js b/lib/resources/Treasury/CreditReversals.js index 39f5765ddc..95d6e2118e 100644 --- a/lib/resources/Treasury/CreditReversals.js +++ b/lib/resources/Treasury/CreditReversals.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/credit_reversals', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/credit_reversals/{credit_reversal}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/credit_reversals', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/credit_reversals', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/credit_reversals/{credit_reversal}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/credit_reversals', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/DebitReversals.js b/lib/resources/Treasury/DebitReversals.js index e0c91bc57e..0f53944fcb 100644 --- a/lib/resources/Treasury/DebitReversals.js +++ b/lib/resources/Treasury/DebitReversals.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/debit_reversals', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/debit_reversals/{debit_reversal}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/debit_reversals', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/debit_reversals', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/debit_reversals/{debit_reversal}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/debit_reversals', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/FinancialAccounts.js b/lib/resources/Treasury/FinancialAccounts.js index 370fab541e..5f3d0dd820 100644 --- a/lib/resources/Treasury/FinancialAccounts.js +++ b/lib/resources/Treasury/FinancialAccounts.js @@ -3,29 +3,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/financial_accounts', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/financial_accounts/{financial_account}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/financial_accounts/{financial_account}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/financial_accounts', - methodType: 'list', - }), - retrieveFeatures: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', - }), - updateFeatures: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/financial_accounts', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/financial_accounts', + methodType: 'list', + }), + retrieveFeatures: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', + }), + updateFeatures: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', + }), }); diff --git a/lib/resources/Treasury/InboundTransfers.js b/lib/resources/Treasury/InboundTransfers.js index ef54bf4dca..52caf10fcd 100644 --- a/lib/resources/Treasury/InboundTransfers.js +++ b/lib/resources/Treasury/InboundTransfers.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/inbound_transfers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/inbound_transfers/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/inbound_transfers', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/inbound_transfers/{inbound_transfer}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/inbound_transfers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/inbound_transfers/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/inbound_transfers', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/inbound_transfers/{inbound_transfer}/cancel', + }), }); diff --git a/lib/resources/Treasury/OutboundPayments.js b/lib/resources/Treasury/OutboundPayments.js index 2bab72b957..d6d0225cd3 100644 --- a/lib/resources/Treasury/OutboundPayments.js +++ b/lib/resources/Treasury/OutboundPayments.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_payments', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_payments/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_payments', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_payments/{id}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_payments', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_payments/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_payments', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_payments/{id}/cancel', + }), }); diff --git a/lib/resources/Treasury/OutboundTransfers.js b/lib/resources/Treasury/OutboundTransfers.js index 749b57f884..fc9ca46ac7 100644 --- a/lib/resources/Treasury/OutboundTransfers.js +++ b/lib/resources/Treasury/OutboundTransfers.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_transfers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_transfers', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_transfers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_transfers', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}/cancel', + }), }); diff --git a/lib/resources/Treasury/ReceivedCredits.js b/lib/resources/Treasury/ReceivedCredits.js index 0c32c22d7d..533398cefd 100644 --- a/lib/resources/Treasury/ReceivedCredits.js +++ b/lib/resources/Treasury/ReceivedCredits.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_credits/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_credits', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_credits/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_credits', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/ReceivedDebits.js b/lib/resources/Treasury/ReceivedDebits.js index e4448c1173..f4de1b786d 100644 --- a/lib/resources/Treasury/ReceivedDebits.js +++ b/lib/resources/Treasury/ReceivedDebits.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_debits/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_debits', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_debits/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_debits', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/TransactionEntries.js b/lib/resources/Treasury/TransactionEntries.js index 9500b9f8fc..f899ea919b 100644 --- a/lib/resources/Treasury/TransactionEntries.js +++ b/lib/resources/Treasury/TransactionEntries.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transaction_entries/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transaction_entries', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transaction_entries/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transaction_entries', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/Transactions.js b/lib/resources/Treasury/Transactions.js index 9896e74250..d8c0b0aef9 100644 --- a/lib/resources/Treasury/Transactions.js +++ b/lib/resources/Treasury/Transactions.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transactions/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transactions', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transactions/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transactions', + methodType: 'list', + }), }); diff --git a/lib/resources/WebhookEndpoints.js b/lib/resources/WebhookEndpoints.js index 272a9ac078..72c257d6f2 100644 --- a/lib/resources/WebhookEndpoints.js +++ b/lib/resources/WebhookEndpoints.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/webhook_endpoints', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/webhook_endpoints', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/webhook_endpoints', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/webhook_endpoints', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', + }), }); diff --git a/lib/stripe.js b/lib/stripe.js index f215f86ba6..184eec45f9 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -1,5 +1,6 @@ -'use strict'; -const _Error = require('./Error'); +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const _Error = require("./Error"); const resources = require('./resources'); const DEFAULT_HOST = 'api.stripe.com'; const DEFAULT_PORT = '443'; @@ -8,114 +9,97 @@ const DEFAULT_API_VERSION = null; const DEFAULT_TIMEOUT = 80000; Stripe.PACKAGE_VERSION = require('../package.json').version; const utils = require('./utils'); -const {determineProcessUserAgentProperties, emitWarning} = utils; -Stripe.USER_AGENT = Object.assign( - { - bindings_version: Stripe.PACKAGE_VERSION, - lang: 'node', - publisher: 'stripe', - uname: null, - typescript: false, - }, - determineProcessUserAgentProperties() -); +const { determineProcessUserAgentProperties, emitWarning } = utils; +Stripe.USER_AGENT = Object.assign({ bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', publisher: 'stripe', uname: null, typescript: false }, determineProcessUserAgentProperties()); /** @private */ Stripe._UNAME_CACHE = null; const MAX_NETWORK_RETRY_DELAY_SEC = 2; const INITIAL_NETWORK_RETRY_DELAY_SEC = 0.5; const APP_INFO_PROPERTIES = ['name', 'version', 'url', 'partner_id']; const ALLOWED_CONFIG_PROPERTIES = [ - 'apiVersion', - 'typescript', - 'maxNetworkRetries', - 'httpAgent', - 'httpClient', - 'timeout', - 'host', - 'port', - 'protocol', - 'telemetry', - 'appInfo', - 'stripeAccount', + 'apiVersion', + 'typescript', + 'maxNetworkRetries', + 'httpAgent', + 'httpClient', + 'timeout', + 'host', + 'port', + 'protocol', + 'telemetry', + 'appInfo', + 'stripeAccount', ]; const EventEmitter = require('events').EventEmitter; -const StripeResource = require('./StripeResource'); +const StripeResource = require("./StripeResource"); Stripe.StripeResource = StripeResource; Stripe.resources = resources; -const {HttpClient, HttpClientResponse} = require('./net/HttpClient'); +const { HttpClient, HttpClientResponse } = require('./net/HttpClient'); Stripe.HttpClient = HttpClient; Stripe.HttpClientResponse = HttpClientResponse; const CryptoProvider = require('./crypto/CryptoProvider'); Stripe.CryptoProvider = CryptoProvider; function Stripe(key, config = {}) { - if (!(this instanceof Stripe)) { - return new Stripe(key, config); - } - const props = this._getPropsFromConfig(config); - Object.defineProperty(this, '_emitter', { - value: new EventEmitter(), - enumerable: false, - configurable: false, - writable: false, - }); - this.VERSION = Stripe.PACKAGE_VERSION; - this.on = this._emitter.on.bind(this._emitter); - this.once = this._emitter.once.bind(this._emitter); - this.off = this._emitter.removeListener.bind(this._emitter); - if ( - props.protocol && - props.protocol !== 'https' && - (!props.host || /\.stripe\.com$/.test(props.host)) - ) { - throw new Error( - 'The `https` protocol must be used when sending requests to `*.stripe.com`' - ); - } - const agent = props.httpAgent || null; - this._api = { - auth: null, - host: props.host || DEFAULT_HOST, - port: props.port || DEFAULT_PORT, - protocol: props.protocol || 'https', - basePath: DEFAULT_BASE_PATH, - version: props.apiVersion || DEFAULT_API_VERSION, - timeout: utils.validateInteger('timeout', props.timeout, DEFAULT_TIMEOUT), - maxNetworkRetries: utils.validateInteger( - 'maxNetworkRetries', - props.maxNetworkRetries, - 0 - ), - agent: agent, - httpClient: props.httpClient || Stripe.createNodeHttpClient(agent), - dev: false, - stripeAccount: props.stripeAccount || null, - }; - const typescript = props.typescript || false; - if (typescript !== Stripe.USER_AGENT.typescript) { - // The mutation here is uncomfortable, but likely fastest; - // serializing the user agent involves shelling out to the system, - // and given some users may instantiate the library many times without switching between TS and non-TS, - // we only want to incur the performance hit when that actually happens. - Stripe.USER_AGENT.typescript = typescript; - } - if (props.appInfo) { - this._setAppInfo(props.appInfo); - } - this._prepResources(); - this._setApiKey(key); - this.errors = _Error; - this.webhooks = require('./Webhooks'); - this._prevRequestMetrics = []; - this._enableTelemetry = props.telemetry !== false; - // Expose StripeResource on the instance too - // @ts-ignore - this.StripeResource = Stripe.StripeResource; + if (!(this instanceof Stripe)) { + return new Stripe(key, config); + } + const props = this._getPropsFromConfig(config); + Object.defineProperty(this, '_emitter', { + value: new EventEmitter(), + enumerable: false, + configurable: false, + writable: false, + }); + this.VERSION = Stripe.PACKAGE_VERSION; + this.on = this._emitter.on.bind(this._emitter); + this.once = this._emitter.once.bind(this._emitter); + this.off = this._emitter.removeListener.bind(this._emitter); + if (props.protocol && + props.protocol !== 'https' && + (!props.host || /\.stripe\.com$/.test(props.host))) { + throw new Error('The `https` protocol must be used when sending requests to `*.stripe.com`'); + } + const agent = props.httpAgent || null; + this._api = { + auth: null, + host: props.host || DEFAULT_HOST, + port: props.port || DEFAULT_PORT, + protocol: props.protocol || 'https', + basePath: DEFAULT_BASE_PATH, + version: props.apiVersion || DEFAULT_API_VERSION, + timeout: utils.validateInteger('timeout', props.timeout, DEFAULT_TIMEOUT), + maxNetworkRetries: utils.validateInteger('maxNetworkRetries', props.maxNetworkRetries, 0), + agent: agent, + httpClient: props.httpClient || Stripe.createNodeHttpClient(agent), + dev: false, + stripeAccount: props.stripeAccount || null, + }; + const typescript = props.typescript || false; + if (typescript !== Stripe.USER_AGENT.typescript) { + // The mutation here is uncomfortable, but likely fastest; + // serializing the user agent involves shelling out to the system, + // and given some users may instantiate the library many times without switching between TS and non-TS, + // we only want to incur the performance hit when that actually happens. + Stripe.USER_AGENT.typescript = typescript; + } + if (props.appInfo) { + this._setAppInfo(props.appInfo); + } + this._prepResources(); + this._setApiKey(key); + this.errors = _Error; + this.webhooks = require('./Webhooks'); + this._prevRequestMetrics = []; + this._enableTelemetry = props.telemetry !== false; + // Expose StripeResource on the instance too + // @ts-ignore + this.StripeResource = Stripe.StripeResource; } Stripe.errors = _Error; Stripe.webhooks = require('./Webhooks'); Stripe.createNodeHttpClient = (agent) => { - const {NodeHttpClient} = require('./net/NodeHttpClient'); - return new NodeHttpClient(agent); + const { NodeHttpClient } = require('./net/NodeHttpClient'); + return new NodeHttpClient(agent); }; /** * Creates an HTTP client for issuing Stripe API requests which uses the Web @@ -125,16 +109,16 @@ Stripe.createNodeHttpClient = (agent) => { * passed, will default to the default `fetch` function in the global scope. */ Stripe.createFetchHttpClient = (fetchFn) => { - const {FetchHttpClient} = require('./net/FetchHttpClient'); - return new FetchHttpClient(fetchFn); + const { FetchHttpClient } = require('./net/FetchHttpClient'); + return new FetchHttpClient(fetchFn); }; /** * Create a CryptoProvider which uses the built-in Node crypto libraries for * its crypto operations. */ Stripe.createNodeCryptoProvider = () => { - const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); - return new NodeCryptoProvider(); + const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); + return new NodeCryptoProvider(); }; /** * Creates a CryptoProvider which uses the Subtle Crypto API from the Web @@ -145,242 +129,234 @@ Stripe.createNodeCryptoProvider = () => { * scope. */ Stripe.createSubtleCryptoProvider = (subtleCrypto) => { - const SubtleCryptoProvider = require('./crypto/SubtleCryptoProvider'); - return new SubtleCryptoProvider(subtleCrypto); + const SubtleCryptoProvider = require('./crypto/SubtleCryptoProvider'); + return new SubtleCryptoProvider(subtleCrypto); }; Stripe.prototype = { - // Properties are set in the constructor above - _appInfo: null, - on: null, - off: null, - once: null, - VERSION: null, - StripeResource: null, - webhooks: null, - errors: null, - _api: null, - _prevRequestMetrics: null, - _emitter: null, - _enableTelemetry: null, - /** - * @private - */ - _setApiKey(key) { - if (key) { - this._setApiField('auth', `Bearer ${key}`); - } - }, - /** - * @private - * This may be removed in the future. - */ - _setAppInfo(info) { - if (info && typeof info !== 'object') { - throw new Error('AppInfo must be an object.'); - } - if (info && !info.name) { - throw new Error('AppInfo.name is required'); - } - info = info || {}; - this._appInfo = APP_INFO_PROPERTIES.reduce( - (accum, prop) => { - if (typeof info[prop] == 'string') { - accum = accum || {}; - accum[prop] = info[prop]; + // Properties are set in the constructor above + _appInfo: null, + on: null, + off: null, + once: null, + VERSION: null, + StripeResource: null, + webhooks: null, + errors: null, + _api: null, + _prevRequestMetrics: null, + _emitter: null, + _enableTelemetry: null, + /** + * @private + */ + _setApiKey(key) { + if (key) { + this._setApiField('auth', `Bearer ${key}`); } - return accum; - }, - // @ts-ignore - undefined - ); - }, - /** - * @private - * This may be removed in the future. - */ - _setApiField(key, value) { - this._api[key] = value; - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - */ - getApiField(key) { - return this._api[key]; - }, - setClientId(clientId) { - this._clientId = clientId; - }, - getClientId() { - return this._clientId; - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - */ - getConstant: (c) => { - switch (c) { - case 'DEFAULT_HOST': - return DEFAULT_HOST; - case 'DEFAULT_PORT': - return DEFAULT_PORT; - case 'DEFAULT_BASE_PATH': - return DEFAULT_BASE_PATH; - case 'DEFAULT_API_VERSION': - return DEFAULT_API_VERSION; - case 'DEFAULT_TIMEOUT': - return DEFAULT_TIMEOUT; - case 'MAX_NETWORK_RETRY_DELAY_SEC': + }, + /** + * @private + * This may be removed in the future. + */ + _setAppInfo(info) { + if (info && typeof info !== 'object') { + throw new Error('AppInfo must be an object.'); + } + if (info && !info.name) { + throw new Error('AppInfo.name is required'); + } + info = info || {}; + this._appInfo = APP_INFO_PROPERTIES.reduce((accum, prop) => { + if (typeof info[prop] == 'string') { + accum = accum || {}; + accum[prop] = info[prop]; + } + return accum; + }, + // @ts-ignore + undefined); + }, + /** + * @private + * This may be removed in the future. + */ + _setApiField(key, value) { + this._api[key] = value; + }, + /** + * @private + * Please open or upvote an issue at github.com/stripe/stripe-node + * if you use this, detailing your use-case. + * + * It may be deprecated and removed in the future. + */ + getApiField(key) { + return this._api[key]; + }, + setClientId(clientId) { + this._clientId = clientId; + }, + getClientId() { + return this._clientId; + }, + /** + * @private + * Please open or upvote an issue at github.com/stripe/stripe-node + * if you use this, detailing your use-case. + * + * It may be deprecated and removed in the future. + */ + getConstant: (c) => { + switch (c) { + case 'DEFAULT_HOST': + return DEFAULT_HOST; + case 'DEFAULT_PORT': + return DEFAULT_PORT; + case 'DEFAULT_BASE_PATH': + return DEFAULT_BASE_PATH; + case 'DEFAULT_API_VERSION': + return DEFAULT_API_VERSION; + case 'DEFAULT_TIMEOUT': + return DEFAULT_TIMEOUT; + case 'MAX_NETWORK_RETRY_DELAY_SEC': + return MAX_NETWORK_RETRY_DELAY_SEC; + case 'INITIAL_NETWORK_RETRY_DELAY_SEC': + return INITIAL_NETWORK_RETRY_DELAY_SEC; + } + return Stripe[c]; + }, + getMaxNetworkRetries() { + return this.getApiField('maxNetworkRetries'); + }, + /** + * @private + * This may be removed in the future. + */ + _setApiNumberField(prop, n, defaultVal) { + const val = utils.validateInteger(prop, n, defaultVal); + this._setApiField(prop, val); + }, + getMaxNetworkRetryDelay() { return MAX_NETWORK_RETRY_DELAY_SEC; - case 'INITIAL_NETWORK_RETRY_DELAY_SEC': + }, + getInitialNetworkRetryDelay() { return INITIAL_NETWORK_RETRY_DELAY_SEC; - } - return Stripe[c]; - }, - getMaxNetworkRetries() { - return this.getApiField('maxNetworkRetries'); - }, - /** - * @private - * This may be removed in the future. - */ - _setApiNumberField(prop, n, defaultVal) { - const val = utils.validateInteger(prop, n, defaultVal); - this._setApiField(prop, val); - }, - getMaxNetworkRetryDelay() { - return MAX_NETWORK_RETRY_DELAY_SEC; - }, - getInitialNetworkRetryDelay() { - return INITIAL_NETWORK_RETRY_DELAY_SEC; - }, - /** - * @private - */ - getUname(cb) { - if (!Stripe._UNAME_CACHE) { - Stripe._UNAME_CACHE = new Promise((resolve) => { - utils.safeExec('uname -a', (err, uname) => { - resolve(uname); + }, + /** + * @private + */ + getUname(cb) { + if (!Stripe._UNAME_CACHE) { + Stripe._UNAME_CACHE = new Promise((resolve) => { + utils.safeExec('uname -a', (err, uname) => { + resolve(uname); + }); + }); + } + Stripe._UNAME_CACHE.then((uname) => cb(uname)); + }, + /** + * @private + * Please open or upvote an issue at github.com/stripe/stripe-node + * if you use this, detailing your use-case. + * + * It may be deprecated and removed in the future. + * + * Gets a JSON version of a User-Agent and uses a cached version for a slight + * speed advantage. + */ + getClientUserAgent(cb) { + return this.getClientUserAgentSeeded(Stripe.USER_AGENT, cb); + }, + /** + * @private + * Please open or upvote an issue at github.com/stripe/stripe-node + * if you use this, detailing your use-case. + * + * It may be deprecated and removed in the future. + * + * Gets a JSON version of a User-Agent by encoding a seeded object and + * fetching a uname from the system. + */ + getClientUserAgentSeeded(seed, cb) { + this.getUname((uname) => { + const userAgent = {}; + for (const field in seed) { + userAgent[field] = encodeURIComponent(seed[field]); + } + // URI-encode in case there are unusual characters in the system's uname. + userAgent.uname = encodeURIComponent(uname || 'UNKNOWN'); + const client = this.getApiField('httpClient'); + if (client) { + userAgent.httplib = encodeURIComponent(client.getClientName()); + } + if (this._appInfo) { + userAgent.application = this._appInfo; + } + cb(JSON.stringify(userAgent)); }); - }); - } - Stripe._UNAME_CACHE.then((uname) => cb(uname)); - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - * - * Gets a JSON version of a User-Agent and uses a cached version for a slight - * speed advantage. - */ - getClientUserAgent(cb) { - return this.getClientUserAgentSeeded(Stripe.USER_AGENT, cb); - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - * - * Gets a JSON version of a User-Agent by encoding a seeded object and - * fetching a uname from the system. - */ - getClientUserAgentSeeded(seed, cb) { - this.getUname((uname) => { - const userAgent = {}; - for (const field in seed) { - userAgent[field] = encodeURIComponent(seed[field]); - } - // URI-encode in case there are unusual characters in the system's uname. - userAgent.uname = encodeURIComponent(uname || 'UNKNOWN'); - const client = this.getApiField('httpClient'); - if (client) { - userAgent.httplib = encodeURIComponent(client.getClientName()); - } - if (this._appInfo) { - userAgent.application = this._appInfo; - } - cb(JSON.stringify(userAgent)); - }); - }, - /** - * @private - * Please open or upvote an issue at github.com/stripe/stripe-node - * if you use this, detailing your use-case. - * - * It may be deprecated and removed in the future. - */ - getAppInfoAsString() { - if (!this._appInfo) { - return ''; - } - let formatted = this._appInfo.name; - if (this._appInfo.version) { - formatted += `/${this._appInfo.version}`; - } - if (this._appInfo.url) { - formatted += ` (${this._appInfo.url})`; - } - return formatted; - }, - getTelemetryEnabled() { - return this._enableTelemetry; - }, - /** - * @private - * This may be removed in the future. - */ - _prepResources() { - for (const name in resources) { - // @ts-ignore - this[utils.pascalToCamelCase(name)] = new resources[name](this); - } - }, - /** - * @private - * This may be removed in the future. - */ - _getPropsFromConfig(config) { - // If config is null or undefined, just bail early with no props - if (!config) { - return {}; - } - // config can be an object or a string - const isString = typeof config === 'string'; - const isObject = config === Object(config) && !Array.isArray(config); - if (!isObject && !isString) { - throw new Error('Config must either be an object or a string'); - } - // If config is a string, we assume the old behavior of passing in a string representation of the api version - if (isString) { - return { - apiVersion: config, - }; - } - // If config is an object, we assume the new behavior and make sure it doesn't contain any unexpected values - const values = Object.keys(config).filter( - (value) => !ALLOWED_CONFIG_PROPERTIES.includes(value) - ); - if (values.length > 0) { - throw new Error( - `Config object may only contain the following: ${ALLOWED_CONFIG_PROPERTIES.join( - ', ' - )}` - ); - } - return config; - }, + }, + /** + * @private + * Please open or upvote an issue at github.com/stripe/stripe-node + * if you use this, detailing your use-case. + * + * It may be deprecated and removed in the future. + */ + getAppInfoAsString() { + if (!this._appInfo) { + return ''; + } + let formatted = this._appInfo.name; + if (this._appInfo.version) { + formatted += `/${this._appInfo.version}`; + } + if (this._appInfo.url) { + formatted += ` (${this._appInfo.url})`; + } + return formatted; + }, + getTelemetryEnabled() { + return this._enableTelemetry; + }, + /** + * @private + * This may be removed in the future. + */ + _prepResources() { + for (const name in resources) { + // @ts-ignore + this[utils.pascalToCamelCase(name)] = new resources[name](this); + } + }, + /** + * @private + * This may be removed in the future. + */ + _getPropsFromConfig(config) { + // If config is null or undefined, just bail early with no props + if (!config) { + return {}; + } + // config can be an object or a string + const isString = typeof config === 'string'; + const isObject = config === Object(config) && !Array.isArray(config); + if (!isObject && !isString) { + throw new Error('Config must either be an object or a string'); + } + // If config is a string, we assume the old behavior of passing in a string representation of the api version + if (isString) { + return { + apiVersion: config, + }; + } + // If config is an object, we assume the new behavior and make sure it doesn't contain any unexpected values + const values = Object.keys(config).filter((value) => !ALLOWED_CONFIG_PROPERTIES.includes(value)); + if (values.length > 0) { + throw new Error(`Config object may only contain the following: ${ALLOWED_CONFIG_PROPERTIES.join(', ')}`); + } + return config; + }, }; module.exports = Stripe; // expose constructor as a named property to enable mocking with Sinon.JS diff --git a/lib/utils.js b/lib/utils.js index d803d84932..a4d1b1fd9c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,4 +1,4 @@ -'use strict'; +"use strict"; const EventEmitter = require('events').EventEmitter; const qs = require('qs'); const crypto = require('crypto'); @@ -7,375 +7,356 @@ const crypto = require('crypto'); // to the operation of stripe-node, we handle this unavailability gracefully. let exec = null; try { - exec = require('child_process').exec; -} catch (e) { - // @ts-ignore - if (e.code !== 'MODULE_NOT_FOUND') { - throw e; - } + exec = require('child_process').exec; +} +catch (e) { + // @ts-ignore + if (e.code !== 'MODULE_NOT_FOUND') { + throw e; + } } const OPTIONS_KEYS = [ - 'apiKey', - 'idempotencyKey', - 'stripeAccount', - 'apiVersion', - 'maxNetworkRetries', - 'timeout', - 'host', + 'apiKey', + 'idempotencyKey', + 'stripeAccount', + 'apiVersion', + 'maxNetworkRetries', + 'timeout', + 'host', ]; const utils = { - isOptionsHash(o) { - return ( - o && - typeof o === 'object' && - OPTIONS_KEYS.some((prop) => Object.prototype.hasOwnProperty.call(o, prop)) - ); - }, - /** - * Stringifies an Object, accommodating nested objects - * (forming the conventional key 'parent[child]=value') - */ - stringifyRequestData: (data) => { - return ( - qs - .stringify(data, { - serializeDate: (d) => Math.floor(d.getTime() / 1000), + isOptionsHash(o) { + return (o && + typeof o === 'object' && + OPTIONS_KEYS.some((prop) => Object.prototype.hasOwnProperty.call(o, prop))); + }, + /** + * Stringifies an Object, accommodating nested objects + * (forming the conventional key 'parent[child]=value') + */ + stringifyRequestData: (data) => { + return (qs + .stringify(data, { + serializeDate: (d) => Math.floor(d.getTime() / 1000), }) - // Don't use strict form encoding by changing the square bracket control - // characters back to their literals. This is fine by the server, and - // makes these parameter strings easier to read. - .replace(/%5B/g, '[') - .replace(/%5D/g, ']') - ); - }, - /** - * Outputs a new function with interpolated object property values. - * Use like so: - * const fn = makeURLInterpolator('some/url/{param1}/{param2}'); - * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' - */ - makeURLInterpolator: (() => { - const rc = { - '\n': '\\n', - '"': '\\"', - '\u2028': '\\u2028', - '\u2029': '\\u2029', - }; - return (str) => { - const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]); - return (outputs) => { - return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => - // @ts-ignore - encodeURIComponent(outputs[$1] || '') - ); - }; - }; - })(), - extractUrlParams: (path) => { - const params = path.match(/\{\w+\}/g); - if (!params) { - return []; - } - return params.map((param) => param.replace(/[{}]/g, '')); - }, - /** - * Return the data argument from a list of arguments - * - * @param {object[]} args - * @returns {object} - */ - getDataFromArgs(args) { - if (!Array.isArray(args) || !args[0] || typeof args[0] !== 'object') { - return {}; - } - if (!utils.isOptionsHash(args[0])) { - return args.shift(); - } - const argKeys = Object.keys(args[0]); - const optionKeysInArgs = argKeys.filter((key) => - OPTIONS_KEYS.includes(key) - ); - // In some cases options may be the provided as the first argument. - // Here we're detecting a case where there are two distinct arguments - // (the first being args and the second options) and with known - // option keys in the first so that we can warn the user about it. - if ( - optionKeysInArgs.length > 0 && - optionKeysInArgs.length !== argKeys.length - ) { - emitWarning( - `Options found in arguments (${optionKeysInArgs.join( - ', ' - )}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.` - ); - } - return {}; - }, - /** - * Return the options hash from a list of arguments - */ - getOptionsFromArgs: (args) => { - const opts = { - auth: null, - headers: {}, - settings: {}, - }; - if (args.length > 0) { - const arg = args[args.length - 1]; - if (typeof arg === 'string') { - opts.auth = args.pop(); - } else if (utils.isOptionsHash(arg)) { - const params = Object.assign({}, args.pop()); - const extraKeys = Object.keys(params).filter( - (key) => !OPTIONS_KEYS.includes(key) - ); - if (extraKeys.length) { - emitWarning( - `Invalid options found (${extraKeys.join(', ')}); ignoring.` - ); + // Don't use strict form encoding by changing the square bracket control + // characters back to their literals. This is fine by the server, and + // makes these parameter strings easier to read. + .replace(/%5B/g, '[') + .replace(/%5D/g, ']')); + }, + /** + * Outputs a new function with interpolated object property values. + * Use like so: + * const fn = makeURLInterpolator('some/url/{param1}/{param2}'); + * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' + */ + makeURLInterpolator: (() => { + const rc = { + '\n': '\\n', + '"': '\\"', + '\u2028': '\\u2028', + '\u2029': '\\u2029', + }; + return (str) => { + const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]); + return (outputs) => { + return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => + // @ts-ignore + encodeURIComponent(outputs[$1] || '')); + }; + }; + })(), + extractUrlParams: (path) => { + const params = path.match(/\{\w+\}/g); + if (!params) { + return []; } - if (params.apiKey) { - opts.auth = params.apiKey; + return params.map((param) => param.replace(/[{}]/g, '')); + }, + /** + * Return the data argument from a list of arguments + * + * @param {object[]} args + * @returns {object} + */ + getDataFromArgs(args) { + if (!Array.isArray(args) || !args[0] || typeof args[0] !== 'object') { + return {}; } - if (params.idempotencyKey) { - opts.headers['Idempotency-Key'] = params.idempotencyKey; + if (!utils.isOptionsHash(args[0])) { + return args.shift(); } - if (params.stripeAccount) { - opts.headers['Stripe-Account'] = params.stripeAccount; + const argKeys = Object.keys(args[0]); + const optionKeysInArgs = argKeys.filter((key) => OPTIONS_KEYS.includes(key)); + // In some cases options may be the provided as the first argument. + // Here we're detecting a case where there are two distinct arguments + // (the first being args and the second options) and with known + // option keys in the first so that we can warn the user about it. + if (optionKeysInArgs.length > 0 && + optionKeysInArgs.length !== argKeys.length) { + emitWarning(`Options found in arguments (${optionKeysInArgs.join(', ')}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.`); } - if (params.apiVersion) { - opts.headers['Stripe-Version'] = params.apiVersion; + return {}; + }, + /** + * Return the options hash from a list of arguments + */ + getOptionsFromArgs: (args) => { + const opts = { + auth: null, + headers: {}, + settings: {}, + }; + if (args.length > 0) { + const arg = args[args.length - 1]; + if (typeof arg === 'string') { + opts.auth = args.pop(); + } + else if (utils.isOptionsHash(arg)) { + const params = Object.assign({}, args.pop()); + const extraKeys = Object.keys(params).filter((key) => !OPTIONS_KEYS.includes(key)); + if (extraKeys.length) { + emitWarning(`Invalid options found (${extraKeys.join(', ')}); ignoring.`); + } + if (params.apiKey) { + opts.auth = params.apiKey; + } + if (params.idempotencyKey) { + opts.headers['Idempotency-Key'] = params.idempotencyKey; + } + if (params.stripeAccount) { + opts.headers['Stripe-Account'] = params.stripeAccount; + } + if (params.apiVersion) { + opts.headers['Stripe-Version'] = params.apiVersion; + } + if (Number.isInteger(params.maxNetworkRetries)) { + opts.settings.maxNetworkRetries = params.maxNetworkRetries; + } + if (Number.isInteger(params.timeout)) { + opts.settings.timeout = params.timeout; + } + if (params.host) { + opts.host = params.host; + } + } } - if (Number.isInteger(params.maxNetworkRetries)) { - opts.settings.maxNetworkRetries = params.maxNetworkRetries; + return opts; + }, + /** + * Provide simple "Class" extension mechanism + */ + protoExtend(sub) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const Super = this; + const Constructor = Object.prototype.hasOwnProperty.call(sub, 'constructor') + ? sub.constructor + : function (...args) { + Super.apply(this, args); + }; + // This initialization logic is somewhat sensitive to be compatible with + // divergent JS implementations like the one found in Qt. See here for more + // context: + // + // https://github.com/stripe/stripe-node/pull/334 + Object.assign(Constructor, Super); + Constructor.prototype = Object.create(Super.prototype); + Object.assign(Constructor.prototype, sub); + return Constructor; + }, + /** + * Secure compare, from https://github.com/freewil/scmp + */ + secureCompare: (a, b) => { + a = Buffer.from(a); + b = Buffer.from(b); + // return early here if buffer lengths are not equal since timingSafeEqual + // will throw if buffer lengths are not equal + if (a.length !== b.length) { + return false; } - if (Number.isInteger(params.timeout)) { - opts.settings.timeout = params.timeout; + // use crypto.timingSafeEqual if available (since Node.js v6.6.0), + // otherwise use our own scmp-internal function. + if (crypto.timingSafeEqual) { + return crypto.timingSafeEqual(a, b); } - if (params.host) { - opts.host = params.host; + const len = a.length; + let result = 0; + for (let i = 0; i < len; ++i) { + result |= a[i] ^ b[i]; } - } - } - return opts; - }, - /** - * Provide simple "Class" extension mechanism - */ - protoExtend(sub) { - // eslint-disable-next-line @typescript-eslint/no-this-alias - const Super = this; - const Constructor = Object.prototype.hasOwnProperty.call(sub, 'constructor') - ? sub.constructor - : function(...args) { - Super.apply(this, args); - }; - // This initialization logic is somewhat sensitive to be compatible with - // divergent JS implementations like the one found in Qt. See here for more - // context: - // - // https://github.com/stripe/stripe-node/pull/334 - Object.assign(Constructor, Super); - Constructor.prototype = Object.create(Super.prototype); - Object.assign(Constructor.prototype, sub); - return Constructor; - }, - /** - * Secure compare, from https://github.com/freewil/scmp - */ - secureCompare: (a, b) => { - a = Buffer.from(a); - b = Buffer.from(b); - // return early here if buffer lengths are not equal since timingSafeEqual - // will throw if buffer lengths are not equal - if (a.length !== b.length) { - return false; - } - // use crypto.timingSafeEqual if available (since Node.js v6.6.0), - // otherwise use our own scmp-internal function. - if (crypto.timingSafeEqual) { - return crypto.timingSafeEqual(a, b); - } - const len = a.length; - let result = 0; - for (let i = 0; i < len; ++i) { - result |= a[i] ^ b[i]; - } - return result === 0; - }, - /** - * Remove empty values from an object - */ - removeNullish: (obj) => { - if (typeof obj !== 'object') { - throw new Error('Argument must be an object'); - } - return Object.keys(obj).reduce((result, key) => { - if (obj[key] != null) { - result[key] = obj[key]; - } - return result; - }, {}); - }, - /** - * Normalize standard HTTP Headers: - * {'foo-bar': 'hi'} - * becomes - * {'Foo-Bar': 'hi'} - */ - normalizeHeaders: (obj) => { - if (!(obj && typeof obj === 'object')) { - return obj; - } - return Object.keys(obj).reduce((result, header) => { - result[utils.normalizeHeader(header)] = obj[header]; - return result; - }, {}); - }, - /** - * Stolen from https://github.com/marten-de-vries/header-case-normalizer/blob/master/index.js#L36-L41 - * without the exceptions which are irrelevant to us. - */ - normalizeHeader: (header) => { - return header - .split('-') - .map( - (text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase() - ) - .join('-'); - }, - /** - * Determine if file data is a derivative of EventEmitter class. - * https://nodejs.org/api/events.html#events_events - */ - checkForStream: (obj) => { - if (obj.file && obj.file.data) { - return obj.file.data instanceof EventEmitter; - } - return false; - }, - callbackifyPromiseWithTimeout: (promise, callback) => { - if (callback) { - // Ensure callback is called outside of promise stack. - return promise.then( - (res) => { - setTimeout(() => { - callback(null, res); - }, 0); - }, - (err) => { - setTimeout(() => { - callback(err, null); - }, 0); + return result === 0; + }, + /** + * Remove empty values from an object + */ + removeNullish: (obj) => { + if (typeof obj !== 'object') { + throw new Error('Argument must be an object'); } - ); - } - return promise; - }, - /** - * Allow for special capitalization cases (such as OAuth) - */ - pascalToCamelCase: (name) => { - if (name === 'OAuth') { - return 'oauth'; - } else { - return name[0].toLowerCase() + name.substring(1); - } - }, - emitWarning, - /** - * Node's built in `exec` function sometimes throws outright, - * and sometimes has a callback with an error, - * depending on the type of error. - * - * This unifies that interface. - */ - safeExec: (cmd, cb) => { - // Occurs if we couldn't load the `child_process` module, which might - // happen in certain sandboxed environments like a CloudFlare Worker. - if (utils._exec === null) { - cb(new Error('exec not available'), null); - return; - } - try { - utils._exec(cmd, cb); - } catch (e) { - cb(e, null); - } - }, - // For mocking in tests. - _exec: exec, - isObject: (obj) => { - const type = typeof obj; - return (type === 'function' || type === 'object') && !!obj; - }, - // For use in multipart requests - flattenAndStringify: (data) => { - const result = {}; - const step = (obj, prevKey) => { - Object.keys(obj).forEach((key) => { - const value = obj[key]; - const newKey = prevKey ? `${prevKey}[${key}]` : key; - if (utils.isObject(value)) { - if ( - !Buffer.isBuffer(value) && - !Object.prototype.hasOwnProperty.call(value, 'data') - ) { - // Non-buffer non-file Objects are recursively flattened - return step(value, newKey); - } else { - // Buffers and file objects are stored without modification - result[newKey] = value; - } - } else { - // Primitives are converted to strings - result[newKey] = String(value); + return Object.keys(obj).reduce((result, key) => { + if (obj[key] != null) { + result[key] = obj[key]; + } + return result; + }, {}); + }, + /** + * Normalize standard HTTP Headers: + * {'foo-bar': 'hi'} + * becomes + * {'Foo-Bar': 'hi'} + */ + normalizeHeaders: (obj) => { + if (!(obj && typeof obj === 'object')) { + return obj; } - }); - }; - step(data, null); - return result; - }, - /** - * https://stackoverflow.com/a/2117523 - */ - uuid4: () => { - // available in: v14.17.x+ - if (crypto.randomUUID) { - return crypto.randomUUID(); - } - // legacy behavior if native UUIDs aren't available - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { - const r = (Math.random() * 16) | 0; - const v = c === 'x' ? r : (r & 0x3) | 0x8; - return v.toString(16); - }); - }, - validateInteger: (name, n, defaultVal) => { - if (!Number.isInteger(n)) { - if (defaultVal !== undefined) { - return defaultVal; - } else { - throw new Error(`${name} must be an integer`); - } - } - return n; - }, - determineProcessUserAgentProperties: () => { - return typeof process === 'undefined' - ? {} - : { - lang_version: process.version, - platform: process.platform, + return Object.keys(obj).reduce((result, header) => { + result[utils.normalizeHeader(header)] = obj[header]; + return result; + }, {}); + }, + /** + * Stolen from https://github.com/marten-de-vries/header-case-normalizer/blob/master/index.js#L36-L41 + * without the exceptions which are irrelevant to us. + */ + normalizeHeader: (header) => { + return header + .split('-') + .map((text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase()) + .join('-'); + }, + /** + * Determine if file data is a derivative of EventEmitter class. + * https://nodejs.org/api/events.html#events_events + */ + checkForStream: (obj) => { + if (obj.file && obj.file.data) { + return obj.file.data instanceof EventEmitter; + } + return false; + }, + callbackifyPromiseWithTimeout: (promise, callback) => { + if (callback) { + // Ensure callback is called outside of promise stack. + return promise.then((res) => { + setTimeout(() => { + callback(null, res); + }, 0); + }, (err) => { + setTimeout(() => { + callback(err, null); + }, 0); + }); + } + return promise; + }, + /** + * Allow for special capitalization cases (such as OAuth) + */ + pascalToCamelCase: (name) => { + if (name === 'OAuth') { + return 'oauth'; + } + else { + return name[0].toLowerCase() + name.substring(1); + } + }, + emitWarning, + /** + * Node's built in `exec` function sometimes throws outright, + * and sometimes has a callback with an error, + * depending on the type of error. + * + * This unifies that interface. + */ + safeExec: (cmd, cb) => { + // Occurs if we couldn't load the `child_process` module, which might + // happen in certain sandboxed environments like a CloudFlare Worker. + if (utils._exec === null) { + cb(new Error('exec not available'), null); + return; + } + try { + utils._exec(cmd, cb); + } + catch (e) { + cb(e, null); + } + }, + // For mocking in tests. + _exec: exec, + isObject: (obj) => { + const type = typeof obj; + return (type === 'function' || type === 'object') && !!obj; + }, + // For use in multipart requests + flattenAndStringify: (data) => { + const result = {}; + const step = (obj, prevKey) => { + Object.keys(obj).forEach((key) => { + const value = obj[key]; + const newKey = prevKey ? `${prevKey}[${key}]` : key; + if (utils.isObject(value)) { + if (!Buffer.isBuffer(value) && + !Object.prototype.hasOwnProperty.call(value, 'data')) { + // Non-buffer non-file Objects are recursively flattened + return step(value, newKey); + } + else { + // Buffers and file objects are stored without modification + result[newKey] = value; + } + } + else { + // Primitives are converted to strings + result[newKey] = String(value); + } + }); }; - }, + step(data, null); + return result; + }, + /** + * https://stackoverflow.com/a/2117523 + */ + uuid4: () => { + // available in: v14.17.x+ + if (crypto.randomUUID) { + return crypto.randomUUID(); + } + // legacy behavior if native UUIDs aren't available + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + const r = (Math.random() * 16) | 0; + const v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); + }, + validateInteger: (name, n, defaultVal) => { + if (!Number.isInteger(n)) { + if (defaultVal !== undefined) { + return defaultVal; + } + else { + throw new Error(`${name} must be an integer`); + } + } + return n; + }, + determineProcessUserAgentProperties: () => { + return typeof process === 'undefined' + ? {} + : { + lang_version: process.version, + platform: process.platform, + }; + }, }; function emitWarning(warning) { - if (typeof process.emitWarning !== 'function') { - return console.warn( - `Stripe: ${warning}` - ); /* eslint-disable-line no-console */ - } - return process.emitWarning(warning, 'Stripe'); + if (typeof process.emitWarning !== 'function') { + return console.warn(`Stripe: ${warning}`); /* eslint-disable-line no-console */ + } + return process.emitWarning(warning, 'Stripe'); } module.exports = utils; diff --git a/src/apiVersion.js b/src/apiVersion.js index 8c1d730e34..f164407310 100644 --- a/src/apiVersion.js +++ b/src/apiVersion.js @@ -1,3 +1,3 @@ // File generated from our OpenAPI spec -module.exports = {ApiVersion: '2022-11-09'}; +module.exports = {ApiVersion: '2022-11-15'}; diff --git a/types/2022-11-09/AccountLinks.d.ts b/types/2022-11-15/AccountLinks.d.ts similarity index 100% rename from types/2022-11-09/AccountLinks.d.ts rename to types/2022-11-15/AccountLinks.d.ts diff --git a/types/2022-11-09/Accounts.d.ts b/types/2022-11-15/Accounts.d.ts similarity index 100% rename from types/2022-11-09/Accounts.d.ts rename to types/2022-11-15/Accounts.d.ts diff --git a/types/2022-11-09/ApplePayDomains.d.ts b/types/2022-11-15/ApplePayDomains.d.ts similarity index 100% rename from types/2022-11-09/ApplePayDomains.d.ts rename to types/2022-11-15/ApplePayDomains.d.ts diff --git a/types/2022-11-09/ApplicationFees.d.ts b/types/2022-11-15/ApplicationFees.d.ts similarity index 100% rename from types/2022-11-09/ApplicationFees.d.ts rename to types/2022-11-15/ApplicationFees.d.ts diff --git a/types/2022-11-09/Applications.d.ts b/types/2022-11-15/Applications.d.ts similarity index 100% rename from types/2022-11-09/Applications.d.ts rename to types/2022-11-15/Applications.d.ts diff --git a/types/2022-11-09/Apps/Secrets.d.ts b/types/2022-11-15/Apps/Secrets.d.ts similarity index 100% rename from types/2022-11-09/Apps/Secrets.d.ts rename to types/2022-11-15/Apps/Secrets.d.ts diff --git a/types/2022-11-09/Balance.d.ts b/types/2022-11-15/Balance.d.ts similarity index 100% rename from types/2022-11-09/Balance.d.ts rename to types/2022-11-15/Balance.d.ts diff --git a/types/2022-11-09/BalanceTransactions.d.ts b/types/2022-11-15/BalanceTransactions.d.ts similarity index 100% rename from types/2022-11-09/BalanceTransactions.d.ts rename to types/2022-11-15/BalanceTransactions.d.ts diff --git a/types/2022-11-09/BankAccounts.d.ts b/types/2022-11-15/BankAccounts.d.ts similarity index 100% rename from types/2022-11-09/BankAccounts.d.ts rename to types/2022-11-15/BankAccounts.d.ts diff --git a/types/2022-11-09/BillingPortal/Configurations.d.ts b/types/2022-11-15/BillingPortal/Configurations.d.ts similarity index 100% rename from types/2022-11-09/BillingPortal/Configurations.d.ts rename to types/2022-11-15/BillingPortal/Configurations.d.ts diff --git a/types/2022-11-09/BillingPortal/Sessions.d.ts b/types/2022-11-15/BillingPortal/Sessions.d.ts similarity index 100% rename from types/2022-11-09/BillingPortal/Sessions.d.ts rename to types/2022-11-15/BillingPortal/Sessions.d.ts diff --git a/types/2022-11-09/Capabilities.d.ts b/types/2022-11-15/Capabilities.d.ts similarity index 100% rename from types/2022-11-09/Capabilities.d.ts rename to types/2022-11-15/Capabilities.d.ts diff --git a/types/2022-11-09/Cards.d.ts b/types/2022-11-15/Cards.d.ts similarity index 100% rename from types/2022-11-09/Cards.d.ts rename to types/2022-11-15/Cards.d.ts diff --git a/types/2022-11-09/CashBalances.d.ts b/types/2022-11-15/CashBalances.d.ts similarity index 100% rename from types/2022-11-09/CashBalances.d.ts rename to types/2022-11-15/CashBalances.d.ts diff --git a/types/2022-11-09/Charges.d.ts b/types/2022-11-15/Charges.d.ts similarity index 100% rename from types/2022-11-09/Charges.d.ts rename to types/2022-11-15/Charges.d.ts diff --git a/types/2022-11-09/Checkout/Sessions.d.ts b/types/2022-11-15/Checkout/Sessions.d.ts similarity index 100% rename from types/2022-11-09/Checkout/Sessions.d.ts rename to types/2022-11-15/Checkout/Sessions.d.ts diff --git a/types/2022-11-09/ConnectCollectionTransfers.d.ts b/types/2022-11-15/ConnectCollectionTransfers.d.ts similarity index 100% rename from types/2022-11-09/ConnectCollectionTransfers.d.ts rename to types/2022-11-15/ConnectCollectionTransfers.d.ts diff --git a/types/2022-11-09/CountrySpecs.d.ts b/types/2022-11-15/CountrySpecs.d.ts similarity index 100% rename from types/2022-11-09/CountrySpecs.d.ts rename to types/2022-11-15/CountrySpecs.d.ts diff --git a/types/2022-11-09/Coupons.d.ts b/types/2022-11-15/Coupons.d.ts similarity index 100% rename from types/2022-11-09/Coupons.d.ts rename to types/2022-11-15/Coupons.d.ts diff --git a/types/2022-11-09/CreditNoteLineItems.d.ts b/types/2022-11-15/CreditNoteLineItems.d.ts similarity index 100% rename from types/2022-11-09/CreditNoteLineItems.d.ts rename to types/2022-11-15/CreditNoteLineItems.d.ts diff --git a/types/2022-11-09/CreditNotes.d.ts b/types/2022-11-15/CreditNotes.d.ts similarity index 100% rename from types/2022-11-09/CreditNotes.d.ts rename to types/2022-11-15/CreditNotes.d.ts diff --git a/types/2022-11-09/CustomerBalanceTransactions.d.ts b/types/2022-11-15/CustomerBalanceTransactions.d.ts similarity index 100% rename from types/2022-11-09/CustomerBalanceTransactions.d.ts rename to types/2022-11-15/CustomerBalanceTransactions.d.ts diff --git a/types/2022-11-09/CustomerCashBalanceTransactions.d.ts b/types/2022-11-15/CustomerCashBalanceTransactions.d.ts similarity index 100% rename from types/2022-11-09/CustomerCashBalanceTransactions.d.ts rename to types/2022-11-15/CustomerCashBalanceTransactions.d.ts diff --git a/types/2022-11-09/CustomerSources.d.ts b/types/2022-11-15/CustomerSources.d.ts similarity index 100% rename from types/2022-11-09/CustomerSources.d.ts rename to types/2022-11-15/CustomerSources.d.ts diff --git a/types/2022-11-09/Customers.d.ts b/types/2022-11-15/Customers.d.ts similarity index 100% rename from types/2022-11-09/Customers.d.ts rename to types/2022-11-15/Customers.d.ts diff --git a/types/2022-11-09/Discounts.d.ts b/types/2022-11-15/Discounts.d.ts similarity index 100% rename from types/2022-11-09/Discounts.d.ts rename to types/2022-11-15/Discounts.d.ts diff --git a/types/2022-11-09/Disputes.d.ts b/types/2022-11-15/Disputes.d.ts similarity index 100% rename from types/2022-11-09/Disputes.d.ts rename to types/2022-11-15/Disputes.d.ts diff --git a/types/2022-11-09/EphemeralKeys.d.ts b/types/2022-11-15/EphemeralKeys.d.ts similarity index 100% rename from types/2022-11-09/EphemeralKeys.d.ts rename to types/2022-11-15/EphemeralKeys.d.ts diff --git a/types/2022-11-09/Events.d.ts b/types/2022-11-15/Events.d.ts similarity index 100% rename from types/2022-11-09/Events.d.ts rename to types/2022-11-15/Events.d.ts diff --git a/types/2022-11-09/ExchangeRates.d.ts b/types/2022-11-15/ExchangeRates.d.ts similarity index 100% rename from types/2022-11-09/ExchangeRates.d.ts rename to types/2022-11-15/ExchangeRates.d.ts diff --git a/types/2022-11-09/ExternalAccounts.d.ts b/types/2022-11-15/ExternalAccounts.d.ts similarity index 100% rename from types/2022-11-09/ExternalAccounts.d.ts rename to types/2022-11-15/ExternalAccounts.d.ts diff --git a/types/2022-11-09/FeeRefunds.d.ts b/types/2022-11-15/FeeRefunds.d.ts similarity index 100% rename from types/2022-11-09/FeeRefunds.d.ts rename to types/2022-11-15/FeeRefunds.d.ts diff --git a/types/2022-11-09/FileLinks.d.ts b/types/2022-11-15/FileLinks.d.ts similarity index 100% rename from types/2022-11-09/FileLinks.d.ts rename to types/2022-11-15/FileLinks.d.ts diff --git a/types/2022-11-09/Files.d.ts b/types/2022-11-15/Files.d.ts similarity index 100% rename from types/2022-11-09/Files.d.ts rename to types/2022-11-15/Files.d.ts diff --git a/types/2022-11-09/FinancialConnections/AccountOwners.d.ts b/types/2022-11-15/FinancialConnections/AccountOwners.d.ts similarity index 100% rename from types/2022-11-09/FinancialConnections/AccountOwners.d.ts rename to types/2022-11-15/FinancialConnections/AccountOwners.d.ts diff --git a/types/2022-11-09/FinancialConnections/AccountOwnerships.d.ts b/types/2022-11-15/FinancialConnections/AccountOwnerships.d.ts similarity index 100% rename from types/2022-11-09/FinancialConnections/AccountOwnerships.d.ts rename to types/2022-11-15/FinancialConnections/AccountOwnerships.d.ts diff --git a/types/2022-11-09/FinancialConnections/Accounts.d.ts b/types/2022-11-15/FinancialConnections/Accounts.d.ts similarity index 100% rename from types/2022-11-09/FinancialConnections/Accounts.d.ts rename to types/2022-11-15/FinancialConnections/Accounts.d.ts diff --git a/types/2022-11-09/FinancialConnections/Sessions.d.ts b/types/2022-11-15/FinancialConnections/Sessions.d.ts similarity index 100% rename from types/2022-11-09/FinancialConnections/Sessions.d.ts rename to types/2022-11-15/FinancialConnections/Sessions.d.ts diff --git a/types/2022-11-09/FundingInstructions.d.ts b/types/2022-11-15/FundingInstructions.d.ts similarity index 100% rename from types/2022-11-09/FundingInstructions.d.ts rename to types/2022-11-15/FundingInstructions.d.ts diff --git a/types/2022-11-09/Identity/VerificationReports.d.ts b/types/2022-11-15/Identity/VerificationReports.d.ts similarity index 100% rename from types/2022-11-09/Identity/VerificationReports.d.ts rename to types/2022-11-15/Identity/VerificationReports.d.ts diff --git a/types/2022-11-09/Identity/VerificationSessions.d.ts b/types/2022-11-15/Identity/VerificationSessions.d.ts similarity index 100% rename from types/2022-11-09/Identity/VerificationSessions.d.ts rename to types/2022-11-15/Identity/VerificationSessions.d.ts diff --git a/types/2022-11-09/InvoiceItems.d.ts b/types/2022-11-15/InvoiceItems.d.ts similarity index 100% rename from types/2022-11-09/InvoiceItems.d.ts rename to types/2022-11-15/InvoiceItems.d.ts diff --git a/types/2022-11-09/InvoiceLineItems.d.ts b/types/2022-11-15/InvoiceLineItems.d.ts similarity index 100% rename from types/2022-11-09/InvoiceLineItems.d.ts rename to types/2022-11-15/InvoiceLineItems.d.ts diff --git a/types/2022-11-09/Invoices.d.ts b/types/2022-11-15/Invoices.d.ts similarity index 100% rename from types/2022-11-09/Invoices.d.ts rename to types/2022-11-15/Invoices.d.ts diff --git a/types/2022-11-09/Issuing/Authorizations.d.ts b/types/2022-11-15/Issuing/Authorizations.d.ts similarity index 100% rename from types/2022-11-09/Issuing/Authorizations.d.ts rename to types/2022-11-15/Issuing/Authorizations.d.ts diff --git a/types/2022-11-09/Issuing/Cardholders.d.ts b/types/2022-11-15/Issuing/Cardholders.d.ts similarity index 100% rename from types/2022-11-09/Issuing/Cardholders.d.ts rename to types/2022-11-15/Issuing/Cardholders.d.ts diff --git a/types/2022-11-09/Issuing/Cards.d.ts b/types/2022-11-15/Issuing/Cards.d.ts similarity index 100% rename from types/2022-11-09/Issuing/Cards.d.ts rename to types/2022-11-15/Issuing/Cards.d.ts diff --git a/types/2022-11-09/Issuing/Disputes.d.ts b/types/2022-11-15/Issuing/Disputes.d.ts similarity index 100% rename from types/2022-11-09/Issuing/Disputes.d.ts rename to types/2022-11-15/Issuing/Disputes.d.ts diff --git a/types/2022-11-09/Issuing/Transactions.d.ts b/types/2022-11-15/Issuing/Transactions.d.ts similarity index 100% rename from types/2022-11-09/Issuing/Transactions.d.ts rename to types/2022-11-15/Issuing/Transactions.d.ts diff --git a/types/2022-11-09/LineItems.d.ts b/types/2022-11-15/LineItems.d.ts similarity index 100% rename from types/2022-11-09/LineItems.d.ts rename to types/2022-11-15/LineItems.d.ts diff --git a/types/2022-11-09/LoginLinks.d.ts b/types/2022-11-15/LoginLinks.d.ts similarity index 100% rename from types/2022-11-09/LoginLinks.d.ts rename to types/2022-11-15/LoginLinks.d.ts diff --git a/types/2022-11-09/Mandates.d.ts b/types/2022-11-15/Mandates.d.ts similarity index 100% rename from types/2022-11-09/Mandates.d.ts rename to types/2022-11-15/Mandates.d.ts diff --git a/types/2022-11-09/PaymentIntents.d.ts b/types/2022-11-15/PaymentIntents.d.ts similarity index 100% rename from types/2022-11-09/PaymentIntents.d.ts rename to types/2022-11-15/PaymentIntents.d.ts diff --git a/types/2022-11-09/PaymentLinks.d.ts b/types/2022-11-15/PaymentLinks.d.ts similarity index 100% rename from types/2022-11-09/PaymentLinks.d.ts rename to types/2022-11-15/PaymentLinks.d.ts diff --git a/types/2022-11-09/PaymentMethods.d.ts b/types/2022-11-15/PaymentMethods.d.ts similarity index 100% rename from types/2022-11-09/PaymentMethods.d.ts rename to types/2022-11-15/PaymentMethods.d.ts diff --git a/types/2022-11-09/Payouts.d.ts b/types/2022-11-15/Payouts.d.ts similarity index 100% rename from types/2022-11-09/Payouts.d.ts rename to types/2022-11-15/Payouts.d.ts diff --git a/types/2022-11-09/Persons.d.ts b/types/2022-11-15/Persons.d.ts similarity index 100% rename from types/2022-11-09/Persons.d.ts rename to types/2022-11-15/Persons.d.ts diff --git a/types/2022-11-09/Plans.d.ts b/types/2022-11-15/Plans.d.ts similarity index 100% rename from types/2022-11-09/Plans.d.ts rename to types/2022-11-15/Plans.d.ts diff --git a/types/2022-11-09/PlatformTaxFees.d.ts b/types/2022-11-15/PlatformTaxFees.d.ts similarity index 100% rename from types/2022-11-09/PlatformTaxFees.d.ts rename to types/2022-11-15/PlatformTaxFees.d.ts diff --git a/types/2022-11-09/Prices.d.ts b/types/2022-11-15/Prices.d.ts similarity index 100% rename from types/2022-11-09/Prices.d.ts rename to types/2022-11-15/Prices.d.ts diff --git a/types/2022-11-09/Products.d.ts b/types/2022-11-15/Products.d.ts similarity index 100% rename from types/2022-11-09/Products.d.ts rename to types/2022-11-15/Products.d.ts diff --git a/types/2022-11-09/PromotionCodes.d.ts b/types/2022-11-15/PromotionCodes.d.ts similarity index 100% rename from types/2022-11-09/PromotionCodes.d.ts rename to types/2022-11-15/PromotionCodes.d.ts diff --git a/types/2022-11-09/Quotes.d.ts b/types/2022-11-15/Quotes.d.ts similarity index 100% rename from types/2022-11-09/Quotes.d.ts rename to types/2022-11-15/Quotes.d.ts diff --git a/types/2022-11-09/Radar/EarlyFraudWarnings.d.ts b/types/2022-11-15/Radar/EarlyFraudWarnings.d.ts similarity index 100% rename from types/2022-11-09/Radar/EarlyFraudWarnings.d.ts rename to types/2022-11-15/Radar/EarlyFraudWarnings.d.ts diff --git a/types/2022-11-09/Radar/ValueListItems.d.ts b/types/2022-11-15/Radar/ValueListItems.d.ts similarity index 100% rename from types/2022-11-09/Radar/ValueListItems.d.ts rename to types/2022-11-15/Radar/ValueListItems.d.ts diff --git a/types/2022-11-09/Radar/ValueLists.d.ts b/types/2022-11-15/Radar/ValueLists.d.ts similarity index 100% rename from types/2022-11-09/Radar/ValueLists.d.ts rename to types/2022-11-15/Radar/ValueLists.d.ts diff --git a/types/2022-11-09/Refunds.d.ts b/types/2022-11-15/Refunds.d.ts similarity index 97% rename from types/2022-11-09/Refunds.d.ts rename to types/2022-11-15/Refunds.d.ts index 97e274cd4b..f620ad25da 100644 --- a/types/2022-11-09/Refunds.d.ts +++ b/types/2022-11-15/Refunds.d.ts @@ -7,10 +7,6 @@ declare module 'stripe' { * but not yet refunded. Funds will be refunded to the credit or debit card that * was originally charged. * - * Stripe Tax users with recurring payments and invoices can create [Credit Notes](https://stripe.com/docs/api/credit_notes), - * which reduce overall tax liability because tax is correctly recalculated and - * apportioned to the related invoice. - * * Related guide: [Refunds](https://stripe.com/docs/refunds). */ interface Refund { diff --git a/types/2022-11-09/Reporting/ReportRuns.d.ts b/types/2022-11-15/Reporting/ReportRuns.d.ts similarity index 100% rename from types/2022-11-09/Reporting/ReportRuns.d.ts rename to types/2022-11-15/Reporting/ReportRuns.d.ts diff --git a/types/2022-11-09/Reporting/ReportTypes.d.ts b/types/2022-11-15/Reporting/ReportTypes.d.ts similarity index 100% rename from types/2022-11-09/Reporting/ReportTypes.d.ts rename to types/2022-11-15/Reporting/ReportTypes.d.ts diff --git a/types/2022-11-09/ReserveTransactions.d.ts b/types/2022-11-15/ReserveTransactions.d.ts similarity index 100% rename from types/2022-11-09/ReserveTransactions.d.ts rename to types/2022-11-15/ReserveTransactions.d.ts diff --git a/types/2022-11-09/Reviews.d.ts b/types/2022-11-15/Reviews.d.ts similarity index 100% rename from types/2022-11-09/Reviews.d.ts rename to types/2022-11-15/Reviews.d.ts diff --git a/types/2022-11-09/SetupAttempts.d.ts b/types/2022-11-15/SetupAttempts.d.ts similarity index 100% rename from types/2022-11-09/SetupAttempts.d.ts rename to types/2022-11-15/SetupAttempts.d.ts diff --git a/types/2022-11-09/SetupIntents.d.ts b/types/2022-11-15/SetupIntents.d.ts similarity index 100% rename from types/2022-11-09/SetupIntents.d.ts rename to types/2022-11-15/SetupIntents.d.ts diff --git a/types/2022-11-09/ShippingRates.d.ts b/types/2022-11-15/ShippingRates.d.ts similarity index 100% rename from types/2022-11-09/ShippingRates.d.ts rename to types/2022-11-15/ShippingRates.d.ts diff --git a/types/2022-11-09/Sigma/ScheduledQueryRuns.d.ts b/types/2022-11-15/Sigma/ScheduledQueryRuns.d.ts similarity index 100% rename from types/2022-11-09/Sigma/ScheduledQueryRuns.d.ts rename to types/2022-11-15/Sigma/ScheduledQueryRuns.d.ts diff --git a/types/2022-11-09/SourceMandateNotifications.d.ts b/types/2022-11-15/SourceMandateNotifications.d.ts similarity index 100% rename from types/2022-11-09/SourceMandateNotifications.d.ts rename to types/2022-11-15/SourceMandateNotifications.d.ts diff --git a/types/2022-11-09/SourceTransactions.d.ts b/types/2022-11-15/SourceTransactions.d.ts similarity index 100% rename from types/2022-11-09/SourceTransactions.d.ts rename to types/2022-11-15/SourceTransactions.d.ts diff --git a/types/2022-11-09/Sources.d.ts b/types/2022-11-15/Sources.d.ts similarity index 100% rename from types/2022-11-09/Sources.d.ts rename to types/2022-11-15/Sources.d.ts diff --git a/types/2022-11-09/SubscriptionItems.d.ts b/types/2022-11-15/SubscriptionItems.d.ts similarity index 100% rename from types/2022-11-09/SubscriptionItems.d.ts rename to types/2022-11-15/SubscriptionItems.d.ts diff --git a/types/2022-11-09/SubscriptionSchedules.d.ts b/types/2022-11-15/SubscriptionSchedules.d.ts similarity index 100% rename from types/2022-11-09/SubscriptionSchedules.d.ts rename to types/2022-11-15/SubscriptionSchedules.d.ts diff --git a/types/2022-11-09/Subscriptions.d.ts b/types/2022-11-15/Subscriptions.d.ts similarity index 100% rename from types/2022-11-09/Subscriptions.d.ts rename to types/2022-11-15/Subscriptions.d.ts diff --git a/types/2022-11-09/TaxCodes.d.ts b/types/2022-11-15/TaxCodes.d.ts similarity index 100% rename from types/2022-11-09/TaxCodes.d.ts rename to types/2022-11-15/TaxCodes.d.ts diff --git a/types/2022-11-09/TaxDeductedAtSources.d.ts b/types/2022-11-15/TaxDeductedAtSources.d.ts similarity index 100% rename from types/2022-11-09/TaxDeductedAtSources.d.ts rename to types/2022-11-15/TaxDeductedAtSources.d.ts diff --git a/types/2022-11-09/TaxIds.d.ts b/types/2022-11-15/TaxIds.d.ts similarity index 100% rename from types/2022-11-09/TaxIds.d.ts rename to types/2022-11-15/TaxIds.d.ts diff --git a/types/2022-11-09/TaxRates.d.ts b/types/2022-11-15/TaxRates.d.ts similarity index 100% rename from types/2022-11-09/TaxRates.d.ts rename to types/2022-11-15/TaxRates.d.ts diff --git a/types/2022-11-09/Terminal/Configurations.d.ts b/types/2022-11-15/Terminal/Configurations.d.ts similarity index 100% rename from types/2022-11-09/Terminal/Configurations.d.ts rename to types/2022-11-15/Terminal/Configurations.d.ts diff --git a/types/2022-11-09/Terminal/ConnectionTokens.d.ts b/types/2022-11-15/Terminal/ConnectionTokens.d.ts similarity index 100% rename from types/2022-11-09/Terminal/ConnectionTokens.d.ts rename to types/2022-11-15/Terminal/ConnectionTokens.d.ts diff --git a/types/2022-11-09/Terminal/Locations.d.ts b/types/2022-11-15/Terminal/Locations.d.ts similarity index 100% rename from types/2022-11-09/Terminal/Locations.d.ts rename to types/2022-11-15/Terminal/Locations.d.ts diff --git a/types/2022-11-09/Terminal/Readers.d.ts b/types/2022-11-15/Terminal/Readers.d.ts similarity index 100% rename from types/2022-11-09/Terminal/Readers.d.ts rename to types/2022-11-15/Terminal/Readers.d.ts diff --git a/types/2022-11-09/TestHelpers/Customers.d.ts b/types/2022-11-15/TestHelpers/Customers.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Customers.d.ts rename to types/2022-11-15/TestHelpers/Customers.d.ts diff --git a/types/2022-11-09/TestHelpers/Issuing/Cards.d.ts b/types/2022-11-15/TestHelpers/Issuing/Cards.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Issuing/Cards.d.ts rename to types/2022-11-15/TestHelpers/Issuing/Cards.d.ts diff --git a/types/2022-11-09/TestHelpers/Refunds.d.ts b/types/2022-11-15/TestHelpers/Refunds.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Refunds.d.ts rename to types/2022-11-15/TestHelpers/Refunds.d.ts diff --git a/types/2022-11-09/TestHelpers/Terminal/Readers.d.ts b/types/2022-11-15/TestHelpers/Terminal/Readers.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Terminal/Readers.d.ts rename to types/2022-11-15/TestHelpers/Terminal/Readers.d.ts diff --git a/types/2022-11-09/TestHelpers/TestClocks.d.ts b/types/2022-11-15/TestHelpers/TestClocks.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/TestClocks.d.ts rename to types/2022-11-15/TestHelpers/TestClocks.d.ts diff --git a/types/2022-11-09/TestHelpers/Treasury/InboundTransfers.d.ts b/types/2022-11-15/TestHelpers/Treasury/InboundTransfers.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Treasury/InboundTransfers.d.ts rename to types/2022-11-15/TestHelpers/Treasury/InboundTransfers.d.ts diff --git a/types/2022-11-09/TestHelpers/Treasury/OutboundPayments.d.ts b/types/2022-11-15/TestHelpers/Treasury/OutboundPayments.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Treasury/OutboundPayments.d.ts rename to types/2022-11-15/TestHelpers/Treasury/OutboundPayments.d.ts diff --git a/types/2022-11-09/TestHelpers/Treasury/OutboundTransfers.d.ts b/types/2022-11-15/TestHelpers/Treasury/OutboundTransfers.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Treasury/OutboundTransfers.d.ts rename to types/2022-11-15/TestHelpers/Treasury/OutboundTransfers.d.ts diff --git a/types/2022-11-09/TestHelpers/Treasury/ReceivedCredits.d.ts b/types/2022-11-15/TestHelpers/Treasury/ReceivedCredits.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Treasury/ReceivedCredits.d.ts rename to types/2022-11-15/TestHelpers/Treasury/ReceivedCredits.d.ts diff --git a/types/2022-11-09/TestHelpers/Treasury/ReceivedDebits.d.ts b/types/2022-11-15/TestHelpers/Treasury/ReceivedDebits.d.ts similarity index 100% rename from types/2022-11-09/TestHelpers/Treasury/ReceivedDebits.d.ts rename to types/2022-11-15/TestHelpers/Treasury/ReceivedDebits.d.ts diff --git a/types/2022-11-09/Tokens.d.ts b/types/2022-11-15/Tokens.d.ts similarity index 100% rename from types/2022-11-09/Tokens.d.ts rename to types/2022-11-15/Tokens.d.ts diff --git a/types/2022-11-09/Topups.d.ts b/types/2022-11-15/Topups.d.ts similarity index 100% rename from types/2022-11-09/Topups.d.ts rename to types/2022-11-15/Topups.d.ts diff --git a/types/2022-11-09/TransferReversals.d.ts b/types/2022-11-15/TransferReversals.d.ts similarity index 100% rename from types/2022-11-09/TransferReversals.d.ts rename to types/2022-11-15/TransferReversals.d.ts diff --git a/types/2022-11-09/Transfers.d.ts b/types/2022-11-15/Transfers.d.ts similarity index 100% rename from types/2022-11-09/Transfers.d.ts rename to types/2022-11-15/Transfers.d.ts diff --git a/types/2022-11-09/Treasury/CreditReversals.d.ts b/types/2022-11-15/Treasury/CreditReversals.d.ts similarity index 100% rename from types/2022-11-09/Treasury/CreditReversals.d.ts rename to types/2022-11-15/Treasury/CreditReversals.d.ts diff --git a/types/2022-11-09/Treasury/DebitReversals.d.ts b/types/2022-11-15/Treasury/DebitReversals.d.ts similarity index 100% rename from types/2022-11-09/Treasury/DebitReversals.d.ts rename to types/2022-11-15/Treasury/DebitReversals.d.ts diff --git a/types/2022-11-09/Treasury/FinancialAccountFeatures.d.ts b/types/2022-11-15/Treasury/FinancialAccountFeatures.d.ts similarity index 100% rename from types/2022-11-09/Treasury/FinancialAccountFeatures.d.ts rename to types/2022-11-15/Treasury/FinancialAccountFeatures.d.ts diff --git a/types/2022-11-09/Treasury/FinancialAccounts.d.ts b/types/2022-11-15/Treasury/FinancialAccounts.d.ts similarity index 100% rename from types/2022-11-09/Treasury/FinancialAccounts.d.ts rename to types/2022-11-15/Treasury/FinancialAccounts.d.ts diff --git a/types/2022-11-09/Treasury/InboundTransfers.d.ts b/types/2022-11-15/Treasury/InboundTransfers.d.ts similarity index 100% rename from types/2022-11-09/Treasury/InboundTransfers.d.ts rename to types/2022-11-15/Treasury/InboundTransfers.d.ts diff --git a/types/2022-11-09/Treasury/OutboundPayments.d.ts b/types/2022-11-15/Treasury/OutboundPayments.d.ts similarity index 100% rename from types/2022-11-09/Treasury/OutboundPayments.d.ts rename to types/2022-11-15/Treasury/OutboundPayments.d.ts diff --git a/types/2022-11-09/Treasury/OutboundTransfers.d.ts b/types/2022-11-15/Treasury/OutboundTransfers.d.ts similarity index 100% rename from types/2022-11-09/Treasury/OutboundTransfers.d.ts rename to types/2022-11-15/Treasury/OutboundTransfers.d.ts diff --git a/types/2022-11-09/Treasury/ReceivedCredits.d.ts b/types/2022-11-15/Treasury/ReceivedCredits.d.ts similarity index 100% rename from types/2022-11-09/Treasury/ReceivedCredits.d.ts rename to types/2022-11-15/Treasury/ReceivedCredits.d.ts diff --git a/types/2022-11-09/Treasury/ReceivedDebits.d.ts b/types/2022-11-15/Treasury/ReceivedDebits.d.ts similarity index 100% rename from types/2022-11-09/Treasury/ReceivedDebits.d.ts rename to types/2022-11-15/Treasury/ReceivedDebits.d.ts diff --git a/types/2022-11-09/Treasury/TransactionEntries.d.ts b/types/2022-11-15/Treasury/TransactionEntries.d.ts similarity index 100% rename from types/2022-11-09/Treasury/TransactionEntries.d.ts rename to types/2022-11-15/Treasury/TransactionEntries.d.ts diff --git a/types/2022-11-09/Treasury/Transactions.d.ts b/types/2022-11-15/Treasury/Transactions.d.ts similarity index 100% rename from types/2022-11-09/Treasury/Transactions.d.ts rename to types/2022-11-15/Treasury/Transactions.d.ts diff --git a/types/2022-11-09/UsageRecordSummaries.d.ts b/types/2022-11-15/UsageRecordSummaries.d.ts similarity index 100% rename from types/2022-11-09/UsageRecordSummaries.d.ts rename to types/2022-11-15/UsageRecordSummaries.d.ts diff --git a/types/2022-11-09/UsageRecords.d.ts b/types/2022-11-15/UsageRecords.d.ts similarity index 100% rename from types/2022-11-09/UsageRecords.d.ts rename to types/2022-11-15/UsageRecords.d.ts diff --git a/types/2022-11-09/WebhookEndpoints.d.ts b/types/2022-11-15/WebhookEndpoints.d.ts similarity index 99% rename from types/2022-11-09/WebhookEndpoints.d.ts rename to types/2022-11-15/WebhookEndpoints.d.ts index 1d5cfdc5f7..fcdb1516f5 100644 --- a/types/2022-11-09/WebhookEndpoints.d.ts +++ b/types/2022-11-15/WebhookEndpoints.d.ts @@ -231,7 +231,7 @@ declare module 'stripe' { | '2020-03-02' | '2020-08-27' | '2022-08-01' - | '2022-11-09'; + | '2022-11-15'; type EnabledEvent = | '*' diff --git a/types/2022-11-09/index.d.ts b/types/2022-11-15/index.d.ts similarity index 100% rename from types/2022-11-09/index.d.ts rename to types/2022-11-15/index.d.ts From 92c6218c5ff49fe7fa071826f4d2214c7ccdca05 Mon Sep 17 00:00:00 2001 From: Pavel Krymets Date: Tue, 15 Nov 2022 13:46:56 -0800 Subject: [PATCH 14/16] fix tests --- lib/stripe.js | 2 +- src/stripe.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stripe.js b/lib/stripe.js index f215f86ba6..7288061bad 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -150,7 +150,7 @@ Stripe.createSubtleCryptoProvider = (subtleCrypto) => { }; Stripe.prototype = { // Properties are set in the constructor above - _appInfo: null, + _appInfo: undefined, on: null, off: null, once: null, diff --git a/src/stripe.ts b/src/stripe.ts index 16086b066e..a662ccda54 100644 --- a/src/stripe.ts +++ b/src/stripe.ts @@ -186,7 +186,7 @@ Stripe.createSubtleCryptoProvider = ( Stripe.prototype = { // Properties are set in the constructor above - _appInfo: null!, + _appInfo: undefined!, on: null!, off: null!, once: null!, From 34eb1353c5acdaad4f6902070bf1f794841f7738 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 15 Nov 2022 13:48:38 -0800 Subject: [PATCH 15/16] Update API_VERSION and references --- API_VERSION | 2 +- README.md | 2 +- .../webhook-signing/typescript-node-express/express-ts.ts | 2 +- package.json | 2 +- types/lib.d.ts | 2 +- types/test/typescriptTest.ts | 8 ++++---- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/API_VERSION b/API_VERSION index 439033dac5..63dfe03884 100644 --- a/API_VERSION +++ b/API_VERSION @@ -1 +1 @@ -2022-11-09 +2022-11-15 diff --git a/README.md b/README.md index e335a74a93..13b2974a8d 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ and instantiate it as `new Stripe()` with the latest API version. ```ts import Stripe from 'stripe'; const stripe = new Stripe('sk_test_...', { - apiVersion: '2022-11-09', + apiVersion: '2022-11-15', }); const createCustomer = async () => { diff --git a/examples/webhook-signing/typescript-node-express/express-ts.ts b/examples/webhook-signing/typescript-node-express/express-ts.ts index f3d901e75b..88b6da04b2 100644 --- a/examples/webhook-signing/typescript-node-express/express-ts.ts +++ b/examples/webhook-signing/typescript-node-express/express-ts.ts @@ -5,7 +5,7 @@ import env from 'dotenv'; env.config(); const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { - apiVersion: '2022-11-09', + apiVersion: '2022-11-15', }); const webhookSecret: string = process.env.STRIPE_WEBHOOK_SECRET; diff --git a/package.json b/package.json index e25fd933f5..e7c6cb83c5 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "node": ">=12.*" }, "main": "lib/stripe.js", - "types": "types/2022-11-09/index.d.ts", + "types": "types/2022-11-15/index.d.ts", "devDependencies": { "@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/parser": "^4.33.0", diff --git a/types/lib.d.ts b/types/lib.d.ts index 0cc5e43bfd..f63308e3a4 100644 --- a/types/lib.d.ts +++ b/types/lib.d.ts @@ -52,7 +52,7 @@ declare module 'stripe' { }; static MAX_BUFFERED_REQUEST_METRICS: number; } - export type LatestApiVersion = '2022-11-09'; + export type LatestApiVersion = '2022-11-15'; export type HttpAgent = Agent; export type HttpProtocol = 'http' | 'https'; diff --git a/types/test/typescriptTest.ts b/types/test/typescriptTest.ts index 10d483e74a..08c2418b2b 100644 --- a/types/test/typescriptTest.ts +++ b/types/test/typescriptTest.ts @@ -5,11 +5,11 @@ * and to perform a basic sanity check that types are exported as intended. */ -/// +/// import Stripe from 'stripe'; let stripe = new Stripe('sk_test_123', { - apiVersion: '2022-11-09', + apiVersion: '2022-11-15', }); // @ts-ignore lazily ignore apiVersion requirement. @@ -27,7 +27,7 @@ stripe = new Stripe('sk_test_123', { // Check config object. stripe = new Stripe('sk_test_123', { - apiVersion: '2022-11-09', + apiVersion: '2022-11-15', typescript: true, maxNetworkRetries: 1, timeout: 1000, @@ -45,7 +45,7 @@ stripe = new Stripe('sk_test_123', { description: 'test', }; const opts: Stripe.RequestOptions = { - apiVersion: '2022-11-09', + apiVersion: '2022-11-15', }; const customer: Stripe.Customer = await stripe.customers.create(params, opts); From 6c64bbf429c9dfd0a38c9199bea7d2a5d3b42249 Mon Sep 17 00:00:00 2001 From: Annie Li Date: Tue, 15 Nov 2022 13:57:15 -0800 Subject: [PATCH 16/16] Format --- lib/Error.js | 156 ++-- lib/ResourceNamespace.js | 20 +- lib/StripeMethod.js | 46 +- lib/StripeResource.js | 42 +- lib/Webhooks.js | 334 +++++---- lib/apiVersion.js | 4 +- lib/autoPagination.js | 389 +++++----- lib/crypto/CryptoProvider.js | 52 +- lib/crypto/NodeCryptoProvider.js | 30 +- lib/crypto/SubtleCryptoProvider.js | 74 +- lib/makeRequest.js | 180 ++--- lib/multipart.js | 136 ++-- lib/net/FetchHttpClient.js | 200 ++--- lib/net/HttpClient.js | 77 +- lib/net/NodeHttpClient.js | 186 ++--- lib/resources.js | 228 +++--- lib/resources/AccountLinks.js | 8 +- lib/resources/Accounts.js | 195 +++-- lib/resources/ApplePayDomains.js | 34 +- lib/resources/ApplicationFees.js | 52 +- lib/resources/Apps/Secrets.js | 34 +- lib/resources/Balance.js | 8 +- lib/resources/BalanceTransactions.js | 18 +- lib/resources/BillingPortal/Configurations.js | 34 +- lib/resources/BillingPortal/Sessions.js | 8 +- lib/resources/Charges.js | 52 +- lib/resources/Checkout/Sessions.js | 44 +- lib/resources/CountrySpecs.js | 18 +- lib/resources/Coupons.js | 42 +- lib/resources/CreditNotes.js | 70 +- lib/resources/Customers.js | 239 +++--- lib/resources/Disputes.js | 34 +- lib/resources/EphemeralKeys.js | 28 +- lib/resources/Events.js | 18 +- lib/resources/ExchangeRates.js | 18 +- lib/resources/FileLinks.js | 34 +- lib/resources/Files.js | 38 +- .../FinancialConnections/Accounts.js | 44 +- .../FinancialConnections/Sessions.js | 16 +- lib/resources/Identity/VerificationReports.js | 18 +- .../Identity/VerificationSessions.js | 50 +- lib/resources/InvoiceItems.js | 42 +- lib/resources/Invoices.js | 120 +-- lib/resources/Issuing/Authorizations.js | 42 +- lib/resources/Issuing/Cardholders.js | 34 +- lib/resources/Issuing/Cards.js | 34 +- lib/resources/Issuing/Disputes.js | 42 +- lib/resources/Issuing/Transactions.js | 26 +- lib/resources/Mandates.js | 8 +- lib/resources/OAuth.js | 70 +- lib/resources/PaymentIntents.js | 92 +-- lib/resources/PaymentLinks.js | 44 +- lib/resources/PaymentMethods.js | 50 +- lib/resources/Payouts.js | 50 +- lib/resources/Plans.js | 42 +- lib/resources/Prices.js | 44 +- lib/resources/Products.js | 52 +- lib/resources/PromotionCodes.js | 34 +- lib/resources/Quotes.js | 90 +-- lib/resources/Radar/EarlyFraudWarnings.js | 18 +- lib/resources/Radar/ValueListItems.js | 34 +- lib/resources/Radar/ValueLists.js | 42 +- lib/resources/Refunds.js | 42 +- lib/resources/Reporting/ReportRuns.js | 26 +- lib/resources/Reporting/ReportTypes.js | 18 +- lib/resources/Reviews.js | 26 +- lib/resources/SetupAttempts.js | 10 +- lib/resources/SetupIntents.js | 58 +- lib/resources/ShippingRates.js | 34 +- lib/resources/Sigma/ScheduledQueryRuns.js | 18 +- lib/resources/Sources.js | 42 +- lib/resources/SubscriptionItems.js | 61 +- lib/resources/SubscriptionSchedules.js | 50 +- lib/resources/Subscriptions.js | 68 +- lib/resources/TaxCodes.js | 18 +- lib/resources/TaxRates.js | 34 +- lib/resources/Terminal/Configurations.js | 42 +- lib/resources/Terminal/ConnectionTokens.js | 8 +- lib/resources/Terminal/Locations.js | 42 +- lib/resources/Terminal/Readers.js | 74 +- lib/resources/TestHelpers/Customers.js | 8 +- lib/resources/TestHelpers/Issuing/Cards.js | 32 +- lib/resources/TestHelpers/Refunds.js | 8 +- lib/resources/TestHelpers/Terminal/Readers.js | 9 +- lib/resources/TestHelpers/TestClocks.js | 42 +- .../TestHelpers/Treasury/InboundTransfers.js | 24 +- .../TestHelpers/Treasury/OutboundPayments.js | 24 +- .../TestHelpers/Treasury/OutboundTransfers.js | 27 +- .../TestHelpers/Treasury/ReceivedCredits.js | 8 +- .../TestHelpers/Treasury/ReceivedDebits.js | 8 +- lib/resources/Tokens.js | 16 +- lib/resources/Topups.js | 42 +- lib/resources/Transfers.js | 68 +- lib/resources/Treasury/CreditReversals.js | 26 +- lib/resources/Treasury/DebitReversals.js | 26 +- lib/resources/Treasury/FinancialAccounts.js | 50 +- lib/resources/Treasury/InboundTransfers.js | 34 +- lib/resources/Treasury/OutboundPayments.js | 34 +- lib/resources/Treasury/OutboundTransfers.js | 34 +- lib/resources/Treasury/ReceivedCredits.js | 18 +- lib/resources/Treasury/ReceivedDebits.js | 18 +- lib/resources/Treasury/TransactionEntries.js | 18 +- lib/resources/Treasury/Transactions.js | 18 +- lib/resources/WebhookEndpoints.js | 42 +- lib/stripe.js | 178 ++--- lib/utils.js | 687 +++++++++--------- 106 files changed, 3352 insertions(+), 3136 deletions(-) diff --git a/lib/Error.js b/lib/Error.js index 68d6a0b521..dfdfb447fd 100644 --- a/lib/Error.js +++ b/lib/Error.js @@ -1,145 +1,135 @@ -"use strict"; +'use strict'; /* eslint-disable camelcase */ /** * StripeError is the base error from which all other more specific Stripe errors derive. * Specifically for errors returned from Stripe's REST API. */ class StripeError extends Error { - constructor(raw = {}) { - super(raw.message); - this.type = this.constructor.name; - this.raw = raw; - this.rawType = raw.type; - this.code = raw.code; - this.doc_url = raw.doc_url; - this.param = raw.param; - this.detail = raw.detail; - this.headers = raw.headers; - this.requestId = raw.requestId; - this.statusCode = raw.statusCode; - // @ts-ignore - this.message = raw.message; - this.charge = raw.charge; - this.decline_code = raw.decline_code; - this.payment_intent = raw.payment_intent; - this.payment_method = raw.payment_method; - this.payment_method_type = raw.payment_method_type; - this.setup_intent = raw.setup_intent; - this.source = raw.source; - } - /** - * Helper factory which takes raw stripe errors and outputs wrapping instances - */ - static generate(rawStripeError) { - switch (rawStripeError.type) { - case 'card_error': - return new StripeCardError(rawStripeError); - case 'invalid_request_error': - return new StripeInvalidRequestError(rawStripeError); - case 'api_error': - return new StripeAPIError(rawStripeError); - case 'authentication_error': - return new StripeAuthenticationError(rawStripeError); - case 'rate_limit_error': - return new StripeRateLimitError(rawStripeError); - case 'idempotency_error': - return new StripeIdempotencyError(rawStripeError); - case 'invalid_grant': - return new StripeInvalidGrantError(rawStripeError); - default: - return new StripeUnknownError(rawStripeError); - } + constructor(raw = {}) { + super(raw.message); + this.type = this.constructor.name; + this.raw = raw; + this.rawType = raw.type; + this.code = raw.code; + this.doc_url = raw.doc_url; + this.param = raw.param; + this.detail = raw.detail; + this.headers = raw.headers; + this.requestId = raw.requestId; + this.statusCode = raw.statusCode; + // @ts-ignore + this.message = raw.message; + this.charge = raw.charge; + this.decline_code = raw.decline_code; + this.payment_intent = raw.payment_intent; + this.payment_method = raw.payment_method; + this.payment_method_type = raw.payment_method_type; + this.setup_intent = raw.setup_intent; + this.source = raw.source; + } + /** + * Helper factory which takes raw stripe errors and outputs wrapping instances + */ + static generate(rawStripeError) { + switch (rawStripeError.type) { + case 'card_error': + return new StripeCardError(rawStripeError); + case 'invalid_request_error': + return new StripeInvalidRequestError(rawStripeError); + case 'api_error': + return new StripeAPIError(rawStripeError); + case 'authentication_error': + return new StripeAuthenticationError(rawStripeError); + case 'rate_limit_error': + return new StripeRateLimitError(rawStripeError); + case 'idempotency_error': + return new StripeIdempotencyError(rawStripeError); + case 'invalid_grant': + return new StripeInvalidGrantError(rawStripeError); + default: + return new StripeUnknownError(rawStripeError); } + } } // Specific Stripe Error types: /** * CardError is raised when a user enters a card that can't be charged for * some reason. */ -class StripeCardError extends StripeError { -} +class StripeCardError extends StripeError {} /** * InvalidRequestError is raised when a request is initiated with invalid * parameters. */ -class StripeInvalidRequestError extends StripeError { -} +class StripeInvalidRequestError extends StripeError {} /** * APIError is a generic error that may be raised in cases where none of the * other named errors cover the problem. It could also be raised in the case * that a new error has been introduced in the API, but this version of the * Node.JS SDK doesn't know how to handle it. */ -class StripeAPIError extends StripeError { -} +class StripeAPIError extends StripeError {} /** * AuthenticationError is raised when invalid credentials are used to connect * to Stripe's servers. */ -class StripeAuthenticationError extends StripeError { -} +class StripeAuthenticationError extends StripeError {} /** * PermissionError is raised in cases where access was attempted on a resource * that wasn't allowed. */ -class StripePermissionError extends StripeError { -} +class StripePermissionError extends StripeError {} /** * RateLimitError is raised in cases where an account is putting too much load * on Stripe's API servers (usually by performing too many requests). Please * back off on request rate. */ -class StripeRateLimitError extends StripeError { -} +class StripeRateLimitError extends StripeError {} /** * StripeConnectionError is raised in the event that the SDK can't connect to * Stripe's servers. That can be for a variety of different reasons from a * downed network to a bad TLS certificate. */ -class StripeConnectionError extends StripeError { -} +class StripeConnectionError extends StripeError {} /** * SignatureVerificationError is raised when the signature verification for a * webhook fails */ class StripeSignatureVerificationError extends StripeError { - constructor(header, payload, raw = {}) { - super(raw); - this.header = header; - this.payload = payload; - } + constructor(header, payload, raw = {}) { + super(raw); + this.header = header; + this.payload = payload; + } } /** * IdempotencyError is raised in cases where an idempotency key was used * improperly. */ -class StripeIdempotencyError extends StripeError { -} +class StripeIdempotencyError extends StripeError {} /** * InvalidGrantError is raised when a specified code doesn't exist, is * expired, has been used, or doesn't belong to you; a refresh token doesn't * exist, or doesn't belong to you; or if an API key's mode (live or test) * doesn't match the mode of a code or refresh token. */ -class StripeInvalidGrantError extends StripeError { -} +class StripeInvalidGrantError extends StripeError {} /** * Any other error from Stripe not specifically captured above */ -class StripeUnknownError extends StripeError { -} +class StripeUnknownError extends StripeError {} module.exports = { - generate: StripeError.generate, - StripeError: StripeError, - StripeCardError: StripeCardError, - StripeInvalidRequestError: StripeInvalidRequestError, - StripeAPIError: StripeAPIError, - StripeAuthenticationError: StripeAuthenticationError, - StripePermissionError: StripePermissionError, - StripeRateLimitError: StripeRateLimitError, - StripeConnectionError: StripeConnectionError, - StripeSignatureVerificationError: StripeSignatureVerificationError, - StripeIdempotencyError: StripeIdempotencyError, - StripeInvalidGrantError: StripeInvalidGrantError, - StripeUnknownError: StripeUnknownError, + generate: StripeError.generate, + StripeError: StripeError, + StripeCardError: StripeCardError, + StripeInvalidRequestError: StripeInvalidRequestError, + StripeAPIError: StripeAPIError, + StripeAuthenticationError: StripeAuthenticationError, + StripePermissionError: StripePermissionError, + StripeRateLimitError: StripeRateLimitError, + StripeConnectionError: StripeConnectionError, + StripeSignatureVerificationError: StripeSignatureVerificationError, + StripeIdempotencyError: StripeIdempotencyError, + StripeInvalidGrantError: StripeInvalidGrantError, + StripeUnknownError: StripeUnknownError, }; diff --git a/lib/ResourceNamespace.js b/lib/ResourceNamespace.js index 5d7f0e7e09..8267a0fa8b 100644 --- a/lib/ResourceNamespace.js +++ b/lib/ResourceNamespace.js @@ -1,16 +1,16 @@ -"use strict"; +'use strict'; // ResourceNamespace allows you to create nested resources, i.e. `stripe.issuing.cards`. // It also works recursively, so you could do i.e. `stripe.billing.invoicing.pay`. function ResourceNamespace(stripe, resources) { - for (const name in resources) { - const camelCaseName = name[0].toLowerCase() + name.substring(1); - const resource = new resources[name](stripe); - this[camelCaseName] = resource; - } + for (const name in resources) { + const camelCaseName = name[0].toLowerCase() + name.substring(1); + const resource = new resources[name](stripe); + this[camelCaseName] = resource; + } } -module.exports = function (namespace, resources) { - return function (stripe) { - return new ResourceNamespace(stripe, resources); - }; +module.exports = function(namespace, resources) { + return function(stripe) { + return new ResourceNamespace(stripe, resources); + }; }; module.exports.ResourceNamespace = ResourceNamespace; diff --git a/lib/StripeMethod.js b/lib/StripeMethod.js index f233e26acc..f4e9ada721 100644 --- a/lib/StripeMethod.js +++ b/lib/StripeMethod.js @@ -1,7 +1,7 @@ -"use strict"; +'use strict'; const utils = require('./utils'); -const makeRequest = require("./makeRequest"); -const autoPagination = require("./autoPagination"); +const makeRequest = require('./makeRequest'); +const autoPagination = require('./autoPagination'); const makeAutoPaginationMethods = autoPagination.makeAutoPaginationMethods; /** * Create an API method from the declared spec. @@ -20,20 +20,32 @@ const makeAutoPaginationMethods = autoPagination.makeAutoPaginationMethods; * @param [spec.host] Hostname for the request. */ function stripeMethod(spec) { - if (spec.path !== undefined && spec.fullPath !== undefined) { - throw new Error(`Method spec specified both a 'path' (${spec.path}) and a 'fullPath' (${spec.fullPath}).`); + if (spec.path !== undefined && spec.fullPath !== undefined) { + throw new Error( + `Method spec specified both a 'path' (${spec.path}) and a 'fullPath' (${spec.fullPath}).` + ); + } + return function(...args) { + const callback = typeof args[args.length - 1] == 'function' && args.pop(); + spec.urlParams = utils.extractUrlParams( + spec.fullPath || this.createResourcePathWithSymbols(spec.path || '') + ); + const requestPromise = utils.callbackifyPromiseWithTimeout( + makeRequest(this, args, spec, {}), + callback + ); + // Please note `spec.methodType === 'search'` is beta functionality and this + // interface is subject to change/removal at any time. + if (spec.methodType === 'list' || spec.methodType === 'search') { + const autoPaginationMethods = makeAutoPaginationMethods( + this, + args, + spec, + requestPromise + ); + Object.assign(requestPromise, autoPaginationMethods); } - return function (...args) { - const callback = typeof args[args.length - 1] == 'function' && args.pop(); - spec.urlParams = utils.extractUrlParams(spec.fullPath || this.createResourcePathWithSymbols(spec.path || '')); - const requestPromise = utils.callbackifyPromiseWithTimeout(makeRequest(this, args, spec, {}), callback); - // Please note `spec.methodType === 'search'` is beta functionality and this - // interface is subject to change/removal at any time. - if (spec.methodType === 'list' || spec.methodType === 'search') { - const autoPaginationMethods = makeAutoPaginationMethods(this, args, spec, requestPromise); - Object.assign(requestPromise, autoPaginationMethods); - } - return requestPromise; - }; + return requestPromise; + }; } module.exports = stripeMethod; diff --git a/lib/StripeResource.js b/lib/StripeResource.js index da6047e006..6ca731d883 100644 --- a/lib/StripeResource.js +++ b/lib/StripeResource.js @@ -1,8 +1,15 @@ -"use strict"; -const utils = require("./utils"); -const _Error = require("./Error"); -const { StripeAPIError, StripeAuthenticationError, StripeConnectionError, StripeError, StripePermissionError, StripeRateLimitError, } = _Error; -const { HttpClient } = require('./net/HttpClient'); +'use strict'; +const utils = require('./utils'); +const _Error = require('./Error'); +const { + StripeAPIError, + StripeAuthenticationError, + StripeConnectionError, + StripeError, + StripePermissionError, + StripeRateLimitError, +} = _Error; +const {HttpClient} = require('./net/HttpClient'); // Provide extension mechanism for Stripe Resource Sub-Classes StripeResource.extend = utils.protoExtend; // Expose method-creator @@ -13,18 +20,21 @@ const MAX_RETRY_AFTER_WAIT = 60; * Encapsulates request logic for a Stripe Resource */ function StripeResource(stripe, deprecatedUrlData) { - this._stripe = stripe; - if (deprecatedUrlData) { - throw new Error('Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.'); - } - this.basePath = utils.makeURLInterpolator( + this._stripe = stripe; + if (deprecatedUrlData) { + throw new Error( + 'Support for curried url params was dropped in stripe-node v7.0.0. Instead, pass two ids.' + ); + } + this.basePath = utils.makeURLInterpolator( // @ts-ignore changing type of basePath - this.basePath || stripe.getApiField('basePath')); - // @ts-ignore changing type of path - this.resourcePath = this.path; - // @ts-ignore changing type of path - this.path = utils.makeURLInterpolator(this.path); - this.initialize(...arguments); + this.basePath || stripe.getApiField('basePath') + ); + // @ts-ignore changing type of path + this.resourcePath = this.path; + // @ts-ignore changing type of path + this.path = utils.makeURLInterpolator(this.path); + this.initialize(...arguments); } StripeResource.prototype = { _stripe: null, diff --git a/lib/Webhooks.js b/lib/Webhooks.js index e7ea5fc81f..23690d44a3 100644 --- a/lib/Webhooks.js +++ b/lib/Webhooks.js @@ -1,142 +1,214 @@ -"use strict"; -const utils = require("./utils"); -const _Error = require("./Error"); -const { StripeError, StripeSignatureVerificationError } = _Error; +'use strict'; +const utils = require('./utils'); +const _Error = require('./Error'); +const {StripeError, StripeSignatureVerificationError} = _Error; const Webhook = { - DEFAULT_TOLERANCE: 300, + DEFAULT_TOLERANCE: 300, + // @ts-ignore + signature: null, + constructEvent(payload, header, secret, tolerance, cryptoProvider) { + this.signature.verifyHeader( + payload, + header, + secret, + tolerance || Webhook.DEFAULT_TOLERANCE, + cryptoProvider + ); // @ts-ignore - signature: null, - constructEvent(payload, header, secret, tolerance, cryptoProvider) { - this.signature.verifyHeader(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider); - // @ts-ignore - const jsonPayload = JSON.parse(payload); - return jsonPayload; - }, - async constructEventAsync(payload, header, secret, tolerance, cryptoProvider) { - await this.signature.verifyHeaderAsync(payload, header, secret, tolerance || Webhook.DEFAULT_TOLERANCE, cryptoProvider); - // @ts-ignore - const jsonPayload = JSON.parse(payload); - return jsonPayload; - }, - /** - * Generates a header to be used for webhook mocking - * - * @typedef {object} opts - * @property {number} timestamp - Timestamp of the header. Defaults to Date.now() - * @property {string} payload - JSON stringified payload object, containing the 'id' and 'object' parameters - * @property {string} secret - Stripe webhook secret 'whsec_...' - * @property {string} scheme - Version of API to hit. Defaults to 'v1'. - * @property {string} signature - Computed webhook signature - * @property {CryptoProvider} cryptoProvider - Crypto provider to use for computing the signature if none was provided. Defaults to NodeCryptoProvider. - */ - generateTestHeaderString: function (opts) { - if (!opts) { - throw new StripeError({ - message: 'Options are required', - }); - } - opts.timestamp = - Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000); - opts.scheme = opts.scheme || signature.EXPECTED_SCHEME; - opts.cryptoProvider = opts.cryptoProvider || getNodeCryptoProvider(); - opts.signature = - opts.signature || - opts.cryptoProvider.computeHMACSignature(opts.timestamp + '.' + opts.payload, opts.secret); - const generatedHeader = [ - 't=' + opts.timestamp, - opts.scheme + '=' + opts.signature, - ].join(','); - return generatedHeader; - }, + const jsonPayload = JSON.parse(payload); + return jsonPayload; + }, + async constructEventAsync( + payload, + header, + secret, + tolerance, + cryptoProvider + ) { + await this.signature.verifyHeaderAsync( + payload, + header, + secret, + tolerance || Webhook.DEFAULT_TOLERANCE, + cryptoProvider + ); + // @ts-ignore + const jsonPayload = JSON.parse(payload); + return jsonPayload; + }, + /** + * Generates a header to be used for webhook mocking + * + * @typedef {object} opts + * @property {number} timestamp - Timestamp of the header. Defaults to Date.now() + * @property {string} payload - JSON stringified payload object, containing the 'id' and 'object' parameters + * @property {string} secret - Stripe webhook secret 'whsec_...' + * @property {string} scheme - Version of API to hit. Defaults to 'v1'. + * @property {string} signature - Computed webhook signature + * @property {CryptoProvider} cryptoProvider - Crypto provider to use for computing the signature if none was provided. Defaults to NodeCryptoProvider. + */ + generateTestHeaderString: function(opts) { + if (!opts) { + throw new StripeError({ + message: 'Options are required', + }); + } + opts.timestamp = + Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000); + opts.scheme = opts.scheme || signature.EXPECTED_SCHEME; + opts.cryptoProvider = opts.cryptoProvider || getNodeCryptoProvider(); + opts.signature = + opts.signature || + opts.cryptoProvider.computeHMACSignature( + opts.timestamp + '.' + opts.payload, + opts.secret + ); + const generatedHeader = [ + 't=' + opts.timestamp, + opts.scheme + '=' + opts.signature, + ].join(','); + return generatedHeader; + }, }; const signature = { - EXPECTED_SCHEME: 'v1', - verifyHeader(encodedPayload, encodedHeader, secret, tolerance, cryptoProvider) { - const { decodedHeader: header, decodedPayload: payload, details, } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); - cryptoProvider = cryptoProvider || getNodeCryptoProvider(); - const expectedSignature = cryptoProvider.computeHMACSignature(makeHMACContent(payload, details), secret); - validateComputedSignature(payload, header, details, expectedSignature, tolerance); - return true; - }, - async verifyHeaderAsync(encodedPayload, encodedHeader, secret, tolerance, cryptoProvider) { - const { decodedHeader: header, decodedPayload: payload, details, } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); - cryptoProvider = cryptoProvider || getNodeCryptoProvider(); - const expectedSignature = await cryptoProvider.computeHMACSignatureAsync(makeHMACContent(payload, details), secret); - return validateComputedSignature(payload, header, details, expectedSignature, tolerance); - }, + EXPECTED_SCHEME: 'v1', + verifyHeader( + encodedPayload, + encodedHeader, + secret, + tolerance, + cryptoProvider + ) { + const { + decodedHeader: header, + decodedPayload: payload, + details, + } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); + cryptoProvider = cryptoProvider || getNodeCryptoProvider(); + const expectedSignature = cryptoProvider.computeHMACSignature( + makeHMACContent(payload, details), + secret + ); + validateComputedSignature( + payload, + header, + details, + expectedSignature, + tolerance + ); + return true; + }, + async verifyHeaderAsync( + encodedPayload, + encodedHeader, + secret, + tolerance, + cryptoProvider + ) { + const { + decodedHeader: header, + decodedPayload: payload, + details, + } = parseEventDetails(encodedPayload, encodedHeader, this.EXPECTED_SCHEME); + cryptoProvider = cryptoProvider || getNodeCryptoProvider(); + const expectedSignature = await cryptoProvider.computeHMACSignatureAsync( + makeHMACContent(payload, details), + secret + ); + return validateComputedSignature( + payload, + header, + details, + expectedSignature, + tolerance + ); + }, }; function makeHMACContent(payload, details) { - return `${details.timestamp}.${payload}`; + return `${details.timestamp}.${payload}`; } function parseEventDetails(encodedPayload, encodedHeader, expectedScheme) { - const decodedPayload = Buffer.isBuffer(encodedPayload) - ? encodedPayload.toString('utf8') - : encodedPayload; - // Express's type for `Request#headers` is `string | []string` - // which is because the `set-cookie` header is an array, - // but no other headers are an array (docs: https://nodejs.org/api/http.html#http_message_headers) - // (Express's Request class is an extension of http.IncomingMessage, and doesn't appear to be relevantly modified: https://github.com/expressjs/express/blob/master/lib/request.js#L31) - if (Array.isArray(encodedHeader)) { - throw new Error('Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.'); - } - const decodedHeader = Buffer.isBuffer(encodedHeader) - ? encodedHeader.toString('utf8') - : encodedHeader; - const details = parseHeader(decodedHeader, expectedScheme); - if (!details || details.timestamp === -1) { - throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { - message: 'Unable to extract timestamp and signatures from header', - }); - } - if (!details.signatures.length) { - throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { - message: 'No signatures found with expected scheme', - }); - } - return { - decodedPayload, - decodedHeader, - details, - }; + const decodedPayload = Buffer.isBuffer(encodedPayload) + ? encodedPayload.toString('utf8') + : encodedPayload; + // Express's type for `Request#headers` is `string | []string` + // which is because the `set-cookie` header is an array, + // but no other headers are an array (docs: https://nodejs.org/api/http.html#http_message_headers) + // (Express's Request class is an extension of http.IncomingMessage, and doesn't appear to be relevantly modified: https://github.com/expressjs/express/blob/master/lib/request.js#L31) + if (Array.isArray(encodedHeader)) { + throw new Error( + 'Unexpected: An array was passed as a header, which should not be possible for the stripe-signature header.' + ); + } + const decodedHeader = Buffer.isBuffer(encodedHeader) + ? encodedHeader.toString('utf8') + : encodedHeader; + const details = parseHeader(decodedHeader, expectedScheme); + if (!details || details.timestamp === -1) { + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { + message: 'Unable to extract timestamp and signatures from header', + }); + } + if (!details.signatures.length) { + throw new StripeSignatureVerificationError(decodedHeader, decodedPayload, { + message: 'No signatures found with expected scheme', + }); + } + return { + decodedPayload, + decodedHeader, + details, + }; } -function validateComputedSignature(payload, header, details, expectedSignature, tolerance) { - const signatureFound = !!details.signatures.filter( +function validateComputedSignature( + payload, + header, + details, + expectedSignature, + tolerance +) { + const signatureFound = !!details.signatures.filter( // @ts-ignore - utils.secureCompare.bind(utils, expectedSignature)).length; - if (!signatureFound) { - // @ts-ignore - throw new StripeSignatureVerificationError(header, payload, { - message: 'No signatures found matching the expected signature for payload.' + - ' Are you passing the raw request body you received from Stripe?' + - ' https://github.com/stripe/stripe-node#webhook-signing', - }); - } - const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; - if (tolerance > 0 && timestampAge > tolerance) { - // @ts-ignore - throw new StripeSignatureVerificationError(header, payload, { - message: 'Timestamp outside the tolerance zone', - }); - } - return true; + utils.secureCompare.bind(utils, expectedSignature) + ).length; + if (!signatureFound) { + // @ts-ignore + throw new StripeSignatureVerificationError(header, payload, { + message: + 'No signatures found matching the expected signature for payload.' + + ' Are you passing the raw request body you received from Stripe?' + + ' https://github.com/stripe/stripe-node#webhook-signing', + }); + } + const timestampAge = Math.floor(Date.now() / 1000) - details.timestamp; + if (tolerance > 0 && timestampAge > tolerance) { + // @ts-ignore + throw new StripeSignatureVerificationError(header, payload, { + message: 'Timestamp outside the tolerance zone', + }); + } + return true; } function parseHeader(header, scheme) { - if (typeof header !== 'string') { - return null; + if (typeof header !== 'string') { + return null; + } + return header.split(',').reduce( + (accum, item) => { + const kv = item.split('='); + if (kv[0] === 't') { + accum.timestamp = parseInt(kv[1], 10); + } + if (kv[0] === scheme) { + accum.signatures.push(kv[1]); + } + return accum; + }, + { + timestamp: -1, + signatures: [], } - return header.split(',').reduce((accum, item) => { - const kv = item.split('='); - if (kv[0] === 't') { - accum.timestamp = parseInt(kv[1], 10); - } - if (kv[0] === scheme) { - accum.signatures.push(kv[1]); - } - return accum; - }, { - timestamp: -1, - signatures: [], - }); + ); } let webhooksNodeCryptoProviderInstance = null; /** @@ -144,11 +216,11 @@ let webhooksNodeCryptoProviderInstance = null; * so a singleton can be used here. */ function getNodeCryptoProvider() { - if (!webhooksNodeCryptoProviderInstance) { - const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); - webhooksNodeCryptoProviderInstance = new NodeCryptoProvider(); - } - return webhooksNodeCryptoProviderInstance; + if (!webhooksNodeCryptoProviderInstance) { + const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); + webhooksNodeCryptoProviderInstance = new NodeCryptoProvider(); + } + return webhooksNodeCryptoProviderInstance; } Webhook.signature = signature; module.exports = Webhook; diff --git a/lib/apiVersion.js b/lib/apiVersion.js index 12993d017c..d28b6bac34 100644 --- a/lib/apiVersion.js +++ b/lib/apiVersion.js @@ -1,3 +1,3 @@ -"use strict"; +'use strict'; // File generated from our OpenAPI spec -module.exports = { ApiVersion: '2022-11-15' }; +module.exports = {ApiVersion: '2022-11-15'}; diff --git a/lib/autoPagination.js b/lib/autoPagination.js index ed7352c866..3626ffeae3 100644 --- a/lib/autoPagination.js +++ b/lib/autoPagination.js @@ -1,81 +1,87 @@ -"use strict"; -const makeRequest = require("./makeRequest"); +'use strict'; +const makeRequest = require('./makeRequest'); const utils = require('./utils'); function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { - const promiseCache = { currentPromise: null }; - const reverseIteration = isReverseIteration(requestArgs); - let pagePromise = firstPagePromise; - let i = 0; - // Search and List methods iterate differently. - // Search relies on a `next_page` token and can only iterate in one direction. - // List relies on either an `ending_before` or `starting_after` field with - // an item ID to paginate and is bi-directional. - // - // Please note: spec.methodType === 'search' is beta functionality and is - // subject to change/removal at any time. - let getNextPagePromise; - if (spec.methodType === 'search') { - getNextPagePromise = (pageResult) => { - if (!pageResult.next_page) { - throw Error('Unexpected: Stripe API response does not have a well-formed `next_page` field, but `has_more` was true.'); - } - return makeRequest(self, requestArgs, spec, { - page: pageResult.next_page, - }); - }; - } - else { - getNextPagePromise = (pageResult) => { - const lastId = getLastId(pageResult, reverseIteration); - return makeRequest(self, requestArgs, spec, { - [reverseIteration ? 'ending_before' : 'starting_after']: lastId, - }); - }; - } - function iterate(pageResult) { - if (!(pageResult && - pageResult.data && - typeof pageResult.data.length === 'number')) { - throw Error('Unexpected: Stripe API response does not have a well-formed `data` array.'); - } - if (i < pageResult.data.length) { - const idx = reverseIteration ? pageResult.data.length - 1 - i : i; - const value = pageResult.data[idx]; - i += 1; - return { value, done: false }; - } - else if (pageResult.has_more) { - // Reset counter, request next page, and recurse. - i = 0; - pagePromise = getNextPagePromise(pageResult); - return pagePromise.then(iterate); - } - return { value: undefined, done: true }; + const promiseCache = {currentPromise: null}; + const reverseIteration = isReverseIteration(requestArgs); + let pagePromise = firstPagePromise; + let i = 0; + // Search and List methods iterate differently. + // Search relies on a `next_page` token and can only iterate in one direction. + // List relies on either an `ending_before` or `starting_after` field with + // an item ID to paginate and is bi-directional. + // + // Please note: spec.methodType === 'search' is beta functionality and is + // subject to change/removal at any time. + let getNextPagePromise; + if (spec.methodType === 'search') { + getNextPagePromise = (pageResult) => { + if (!pageResult.next_page) { + throw Error( + 'Unexpected: Stripe API response does not have a well-formed `next_page` field, but `has_more` was true.' + ); + } + return makeRequest(self, requestArgs, spec, { + page: pageResult.next_page, + }); + }; + } else { + getNextPagePromise = (pageResult) => { + const lastId = getLastId(pageResult, reverseIteration); + return makeRequest(self, requestArgs, spec, { + [reverseIteration ? 'ending_before' : 'starting_after']: lastId, + }); + }; + } + function iterate(pageResult) { + if ( + !( + pageResult && + pageResult.data && + typeof pageResult.data.length === 'number' + ) + ) { + throw Error( + 'Unexpected: Stripe API response does not have a well-formed `data` array.' + ); } - function asyncIteratorNext() { - return memoizedPromise(promiseCache, (resolve, reject) => { - return pagePromise - .then(iterate) - .then(resolve) - .catch(reject); - }); + if (i < pageResult.data.length) { + const idx = reverseIteration ? pageResult.data.length - 1 - i : i; + const value = pageResult.data[idx]; + i += 1; + return {value, done: false}; + } else if (pageResult.has_more) { + // Reset counter, request next page, and recurse. + i = 0; + pagePromise = getNextPagePromise(pageResult); + return pagePromise.then(iterate); } - const autoPagingEach = makeAutoPagingEach(asyncIteratorNext); - const autoPagingToArray = makeAutoPagingToArray(autoPagingEach); - const autoPaginationMethods = { - autoPagingEach, - autoPagingToArray, - // Async iterator functions: - next: asyncIteratorNext, - return: () => { - // This is required for `break`. - return {}; - }, - [getAsyncIteratorSymbol()]: () => { - return autoPaginationMethods; - }, - }; - return autoPaginationMethods; + return {value: undefined, done: true}; + } + function asyncIteratorNext() { + return memoizedPromise(promiseCache, (resolve, reject) => { + return pagePromise + .then(iterate) + .then(resolve) + .catch(reject); + }); + } + const autoPagingEach = makeAutoPagingEach(asyncIteratorNext); + const autoPagingToArray = makeAutoPagingToArray(autoPagingEach); + const autoPaginationMethods = { + autoPagingEach, + autoPagingToArray, + // Async iterator functions: + next: asyncIteratorNext, + return: () => { + // This is required for `break`. + return {}; + }, + [getAsyncIteratorSymbol()]: () => { + return autoPaginationMethods; + }, + }; + return autoPaginationMethods; } /** * ---------------- @@ -83,21 +89,23 @@ function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { * ---------------- */ function getAsyncIteratorSymbol() { - if (typeof Symbol !== 'undefined' && Symbol.asyncIterator) { - return Symbol.asyncIterator; - } - // Follow the convention from libraries like iterall: https://github.com/leebyron/iterall#asynciterator-1 - return '@@asyncIterator'; + if (typeof Symbol !== 'undefined' && Symbol.asyncIterator) { + return Symbol.asyncIterator; + } + // Follow the convention from libraries like iterall: https://github.com/leebyron/iterall#asynciterator-1 + return '@@asyncIterator'; } function getDoneCallback(args) { - if (args.length < 2) { - return undefined; - } - const onDone = args[1]; - if (typeof onDone !== 'function') { - throw Error(`The second argument to autoPagingEach, if present, must be a callback function; received ${typeof onDone}`); - } - return onDone; + if (args.length < 2) { + return undefined; + } + const onDone = args[1]; + if (typeof onDone !== 'function') { + throw Error( + `The second argument to autoPagingEach, if present, must be a callback function; received ${typeof onDone}` + ); + } + return onDone; } /** * We allow four forms of the `onItem` callback (the middle two being equivalent), @@ -111,37 +119,43 @@ function getDoneCallback(args) { * coalesces the former forms into the latter form. */ function getItemCallback(args) { - if (args.length === 0) { - return undefined; - } - const onItem = args[0]; - if (typeof onItem !== 'function') { - throw Error(`The first argument to autoPagingEach, if present, must be a callback function; received ${typeof onItem}`); - } - // 4. `.autoPagingEach((item, next) => { doSomething(item); next(false); });` - if (onItem.length === 2) { - return onItem; - } - if (onItem.length > 2) { - throw Error(`The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${onItem}`); - } - // This magically handles all three of these usecases (the latter two being functionally identical): - // 1. `.autoPagingEach((item) => { doSomething(item); return false; });` - // 2. `.autoPagingEach(async (item) => { await doSomething(item); return false; });` - // 3. `.autoPagingEach((item) => doSomething(item).then(() => false));` - return function _onItem(item, next) { - const shouldContinue = onItem(item); - next(shouldContinue); - }; + if (args.length === 0) { + return undefined; + } + const onItem = args[0]; + if (typeof onItem !== 'function') { + throw Error( + `The first argument to autoPagingEach, if present, must be a callback function; received ${typeof onItem}` + ); + } + // 4. `.autoPagingEach((item, next) => { doSomething(item); next(false); });` + if (onItem.length === 2) { + return onItem; + } + if (onItem.length > 2) { + throw Error( + `The \`onItem\` callback function passed to autoPagingEach must accept at most two arguments; got ${onItem}` + ); + } + // This magically handles all three of these usecases (the latter two being functionally identical): + // 1. `.autoPagingEach((item) => { doSomething(item); return false; });` + // 2. `.autoPagingEach(async (item) => { await doSomething(item); return false; });` + // 3. `.autoPagingEach((item) => doSomething(item).then(() => false));` + return function _onItem(item, next) { + const shouldContinue = onItem(item); + next(shouldContinue); + }; } function getLastId(listResult, reverseIteration) { - const lastIdx = reverseIteration ? 0 : listResult.data.length - 1; - const lastItem = listResult.data[lastIdx]; - const lastId = lastItem && lastItem.id; - if (!lastId) { - throw Error('Unexpected: No `id` found on the last item while auto-paging a list.'); - } - return lastId; + const lastIdx = reverseIteration ? 0 : listResult.data.length - 1; + const lastItem = listResult.data[lastIdx]; + const lastId = lastItem && lastItem.id; + if (!lastId) { + throw Error( + 'Unexpected: No `id` found on the last item while auto-paging a list.' + ); + } + return lastId; } /** * If a user calls `.next()` multiple times in parallel, @@ -149,86 +163,91 @@ function getLastId(listResult, reverseIteration) { * to prevent page-turning race conditions. */ function memoizedPromise(promiseCache, cb) { - if (promiseCache.currentPromise) { - return promiseCache.currentPromise; - } - promiseCache.currentPromise = new Promise(cb).then((ret) => { - promiseCache.currentPromise = undefined; - return ret; - }); + if (promiseCache.currentPromise) { return promiseCache.currentPromise; + } + promiseCache.currentPromise = new Promise(cb).then((ret) => { + promiseCache.currentPromise = undefined; + return ret; + }); + return promiseCache.currentPromise; } function makeAutoPagingEach(asyncIteratorNext) { - return function autoPagingEach( /* onItem?, onDone? */) { - const args = [].slice.call(arguments); - const onItem = getItemCallback(args); - const onDone = getDoneCallback(args); - if (args.length > 2) { - throw Error(`autoPagingEach takes up to two arguments; received ${args}`); - } - const autoPagePromise = wrapAsyncIteratorWithCallback(asyncIteratorNext, - // @ts-ignore we might need a null check - onItem); - return utils.callbackifyPromiseWithTimeout(autoPagePromise, onDone); - }; + return function autoPagingEach(/* onItem?, onDone? */) { + const args = [].slice.call(arguments); + const onItem = getItemCallback(args); + const onDone = getDoneCallback(args); + if (args.length > 2) { + throw Error(`autoPagingEach takes up to two arguments; received ${args}`); + } + const autoPagePromise = wrapAsyncIteratorWithCallback( + asyncIteratorNext, + // @ts-ignore we might need a null check + onItem + ); + return utils.callbackifyPromiseWithTimeout(autoPagePromise, onDone); + }; } function makeAutoPagingToArray(autoPagingEach) { - return function autoPagingToArray(opts, onDone) { - const limit = opts && opts.limit; - if (!limit) { - throw Error('You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`.'); - } - if (limit > 10000) { - throw Error('You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.'); + return function autoPagingToArray(opts, onDone) { + const limit = opts && opts.limit; + if (!limit) { + throw Error( + 'You must pass a `limit` option to autoPagingToArray, e.g., `autoPagingToArray({limit: 1000});`.' + ); + } + if (limit > 10000) { + throw Error( + 'You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.' + ); + } + const promise = new Promise((resolve, reject) => { + const items = []; + autoPagingEach((item) => { + items.push(item); + if (items.length >= limit) { + return false; } - const promise = new Promise((resolve, reject) => { - const items = []; - autoPagingEach((item) => { - items.push(item); - if (items.length >= limit) { - return false; - } - }) - .then(() => { - resolve(items); - }) - .catch(reject); - }); - return utils.callbackifyPromiseWithTimeout(promise, onDone); - }; + }) + .then(() => { + resolve(items); + }) + .catch(reject); + }); + return utils.callbackifyPromiseWithTimeout(promise, onDone); + }; } function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { - return new Promise((resolve, reject) => { - function handleIteration(iterResult) { - if (iterResult.done) { - resolve(); - return; - } - const item = iterResult.value; - return new Promise((next) => { - // Bit confusing, perhaps; we pass a `resolve` fn - // to the user, so they can decide when and if to continue. - // They can return false, or a promise which resolves to false, to break. - onItem(item, next); - }).then((shouldContinue) => { - if (shouldContinue === false) { - return handleIteration({ done: true }); - } - else { - return asyncIteratorNext().then(handleIteration); - } - }); + return new Promise((resolve, reject) => { + function handleIteration(iterResult) { + if (iterResult.done) { + resolve(); + return; + } + const item = iterResult.value; + return new Promise((next) => { + // Bit confusing, perhaps; we pass a `resolve` fn + // to the user, so they can decide when and if to continue. + // They can return false, or a promise which resolves to false, to break. + onItem(item, next); + }).then((shouldContinue) => { + if (shouldContinue === false) { + return handleIteration({done: true}); + } else { + return asyncIteratorNext().then(handleIteration); } - asyncIteratorNext() - .then(handleIteration) - .catch(reject); - }); + }); + } + asyncIteratorNext() + .then(handleIteration) + .catch(reject); + }); } function isReverseIteration(requestArgs) { - const args = [].slice.call(requestArgs); - const dataFromArgs = utils.getDataFromArgs(args); - return !!dataFromArgs.ending_before; + const args = [].slice.call(requestArgs); + const dataFromArgs = utils.getDataFromArgs(args); + return !!dataFromArgs.ending_before; } module.exports = { - makeAutoPaginationMethods: makeAutoPaginationMethods, + makeAutoPaginationMethods: makeAutoPaginationMethods, }; diff --git a/lib/crypto/CryptoProvider.js b/lib/crypto/CryptoProvider.js index 4491a01725..015a339447 100644 --- a/lib/crypto/CryptoProvider.js +++ b/lib/crypto/CryptoProvider.js @@ -1,33 +1,33 @@ -"use strict"; +'use strict'; /** * Interface encapsulating the various crypto computations used by the library, * allowing pluggable underlying crypto implementations. */ class CryptoProvider { - /** - * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). - * The output HMAC should be encoded in hexadecimal. - * - * Sample values for implementations: - * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' - * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 - */ - computeHMACSignature(payload, secret) { - throw new Error('computeHMACSignature not implemented.'); - } - /** - * Asynchronous version of `computeHMACSignature`. Some implementations may - * only allow support async signature computation. - * - * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). - * The output HMAC should be encoded in hexadecimal. - * - * Sample values for implementations: - * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' - * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 - */ - computeHMACSignatureAsync(payload, secret) { - throw new Error('computeHMACSignatureAsync not implemented.'); - } + /** + * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). + * The output HMAC should be encoded in hexadecimal. + * + * Sample values for implementations: + * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' + * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 + */ + computeHMACSignature(payload, secret) { + throw new Error('computeHMACSignature not implemented.'); + } + /** + * Asynchronous version of `computeHMACSignature`. Some implementations may + * only allow support async signature computation. + * + * Computes a SHA-256 HMAC given a secret and a payload (encoded in UTF-8). + * The output HMAC should be encoded in hexadecimal. + * + * Sample values for implementations: + * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' + * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 + */ + computeHMACSignatureAsync(payload, secret) { + throw new Error('computeHMACSignatureAsync not implemented.'); + } } module.exports = CryptoProvider; diff --git a/lib/crypto/NodeCryptoProvider.js b/lib/crypto/NodeCryptoProvider.js index 95acdd2be9..4cdeb521fc 100644 --- a/lib/crypto/NodeCryptoProvider.js +++ b/lib/crypto/NodeCryptoProvider.js @@ -1,21 +1,21 @@ -"use strict"; -const crypto = require("crypto"); -const CryptoProvider = require("./CryptoProvider"); +'use strict'; +const crypto = require('crypto'); +const CryptoProvider = require('./CryptoProvider'); /** * `CryptoProvider which uses the Node `crypto` package for its computations. */ class NodeCryptoProvider extends CryptoProvider { - /** @override */ - computeHMACSignature(payload, secret) { - return crypto - .createHmac('sha256', secret) - .update(payload, 'utf8') - .digest('hex'); - } - /** @override */ - async computeHMACSignatureAsync(payload, secret) { - const signature = await this.computeHMACSignature(payload, secret); - return signature; - } + /** @override */ + computeHMACSignature(payload, secret) { + return crypto + .createHmac('sha256', secret) + .update(payload, 'utf8') + .digest('hex'); + } + /** @override */ + async computeHMACSignatureAsync(payload, secret) { + const signature = await this.computeHMACSignature(payload, secret); + return signature; + } } module.exports = NodeCryptoProvider; diff --git a/lib/crypto/SubtleCryptoProvider.js b/lib/crypto/SubtleCryptoProvider.js index 8f23b3bcac..cbf5d01373 100644 --- a/lib/crypto/SubtleCryptoProvider.js +++ b/lib/crypto/SubtleCryptoProvider.js @@ -1,45 +1,57 @@ -"use strict"; -const CryptoProvider = require("./CryptoProvider"); +'use strict'; +const CryptoProvider = require('./CryptoProvider'); /** * `CryptoProvider which uses the SubtleCrypto interface of the Web Crypto API. * * This only supports asynchronous operations. */ class SubtleCryptoProvider extends CryptoProvider { - constructor(subtleCrypto) { - super(); - // If no subtle crypto is interface, default to the global namespace. This - // is to allow custom interfaces (eg. using the Node webcrypto interface in - // tests). - this.subtleCrypto = subtleCrypto || crypto.subtle; - } - /** @override */ - computeHMACSignature(payload, secret) { - throw new Error('SubtleCryptoProvider cannot be used in a synchronous context.'); - } - /** @override */ - async computeHMACSignatureAsync(payload, secret) { - const encoder = new TextEncoder(); - const key = await this.subtleCrypto.importKey('raw', encoder.encode(secret), { - name: 'HMAC', - hash: { name: 'SHA-256' }, - }, false, ['sign']); - const signatureBuffer = await this.subtleCrypto.sign('hmac', key, encoder.encode(payload)); - // crypto.subtle returns the signature in base64 format. This must be - // encoded in hex to match the CryptoProvider contract. We map each byte in - // the buffer to its corresponding hex octet and then combine into a string. - const signatureBytes = new Uint8Array(signatureBuffer); - const signatureHexCodes = new Array(signatureBytes.length); - for (let i = 0; i < signatureBytes.length; i++) { - signatureHexCodes[i] = byteHexMapping[signatureBytes[i]]; - } - return signatureHexCodes.join(''); + constructor(subtleCrypto) { + super(); + // If no subtle crypto is interface, default to the global namespace. This + // is to allow custom interfaces (eg. using the Node webcrypto interface in + // tests). + this.subtleCrypto = subtleCrypto || crypto.subtle; + } + /** @override */ + computeHMACSignature(payload, secret) { + throw new Error( + 'SubtleCryptoProvider cannot be used in a synchronous context.' + ); + } + /** @override */ + async computeHMACSignatureAsync(payload, secret) { + const encoder = new TextEncoder(); + const key = await this.subtleCrypto.importKey( + 'raw', + encoder.encode(secret), + { + name: 'HMAC', + hash: {name: 'SHA-256'}, + }, + false, + ['sign'] + ); + const signatureBuffer = await this.subtleCrypto.sign( + 'hmac', + key, + encoder.encode(payload) + ); + // crypto.subtle returns the signature in base64 format. This must be + // encoded in hex to match the CryptoProvider contract. We map each byte in + // the buffer to its corresponding hex octet and then combine into a string. + const signatureBytes = new Uint8Array(signatureBuffer); + const signatureHexCodes = new Array(signatureBytes.length); + for (let i = 0; i < signatureBytes.length; i++) { + signatureHexCodes[i] = byteHexMapping[signatureBytes[i]]; } + return signatureHexCodes.join(''); + } } // Cached mapping of byte to hex representation. We do this once to avoid re- // computing every time we need to convert the result of a signature to hex. const byteHexMapping = new Array(256); for (let i = 0; i < byteHexMapping.length; i++) { - byteHexMapping[i] = i.toString(16).padStart(2, '0'); + byteHexMapping[i] = i.toString(16).padStart(2, '0'); } module.exports = SubtleCryptoProvider; diff --git a/lib/makeRequest.js b/lib/makeRequest.js index 0c641a5dce..fc591f3245 100644 --- a/lib/makeRequest.js +++ b/lib/makeRequest.js @@ -1,90 +1,104 @@ -"use strict"; +'use strict'; const utils = require('./utils'); function getRequestOpts(self, requestArgs, spec, overrideData) { - // Extract spec values with defaults. - const requestMethod = (spec.method || 'GET').toUpperCase(); - const urlParams = spec.urlParams || []; - const encode = spec.encode || ((data) => data); - const isUsingFullPath = !!spec.fullPath; - const commandPath = utils.makeURLInterpolator(isUsingFullPath ? spec.fullPath : spec.path || ''); - // When using fullPath, we ignore the resource path as it should already be - // fully qualified. - const path = isUsingFullPath - ? spec.fullPath - : self.createResourcePathWithSymbols(spec.path); - // Don't mutate args externally. - const args = [].slice.call(requestArgs); - // Generate and validate url params. - const urlData = urlParams.reduce((urlData, param) => { - const arg = args.shift(); - if (typeof arg !== 'string') { - throw new Error(`Stripe: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)`); - } - urlData[param] = arg; - return urlData; - }, {}); - // Pull request data and options (headers, auth) from args. - const dataFromArgs = utils.getDataFromArgs(args); - const data = encode(Object.assign({}, dataFromArgs, overrideData)); - const options = utils.getOptionsFromArgs(args); - const host = options.host || spec.host; - const streaming = !!spec.streaming; - // Validate that there are no more args. - if (args.filter((x) => x != null).length) { - throw new Error(`Stripe: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)`); + // Extract spec values with defaults. + const requestMethod = (spec.method || 'GET').toUpperCase(); + const urlParams = spec.urlParams || []; + const encode = spec.encode || ((data) => data); + const isUsingFullPath = !!spec.fullPath; + const commandPath = utils.makeURLInterpolator( + isUsingFullPath ? spec.fullPath : spec.path || '' + ); + // When using fullPath, we ignore the resource path as it should already be + // fully qualified. + const path = isUsingFullPath + ? spec.fullPath + : self.createResourcePathWithSymbols(spec.path); + // Don't mutate args externally. + const args = [].slice.call(requestArgs); + // Generate and validate url params. + const urlData = urlParams.reduce((urlData, param) => { + const arg = args.shift(); + if (typeof arg !== 'string') { + throw new Error( + `Stripe: Argument "${param}" must be a string, but got: ${arg} (on API request to \`${requestMethod} ${path}\`)` + ); } - // When using full path, we can just invoke the URL interpolator directly - // as we don't need to use the resource to create a full path. - const requestPath = isUsingFullPath - ? commandPath(urlData) - : self.createFullPath(commandPath, urlData); - const headers = Object.assign(options.headers, spec.headers); - if (spec.validator) { - spec.validator(data, { headers }); - } - const dataInQuery = spec.method === 'GET' || spec.method === 'DELETE'; - const bodyData = dataInQuery ? {} : data; - const queryData = dataInQuery ? data : {}; - return { - requestMethod, - requestPath, - bodyData, - queryData, - auth: options.auth, - headers, - host, - streaming, - settings: options.settings, - }; + urlData[param] = arg; + return urlData; + }, {}); + // Pull request data and options (headers, auth) from args. + const dataFromArgs = utils.getDataFromArgs(args); + const data = encode(Object.assign({}, dataFromArgs, overrideData)); + const options = utils.getOptionsFromArgs(args); + const host = options.host || spec.host; + const streaming = !!spec.streaming; + // Validate that there are no more args. + if (args.filter((x) => x != null).length) { + throw new Error( + `Stripe: Unknown arguments (${args}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options. (on API request to ${requestMethod} \`${path}\`)` + ); + } + // When using full path, we can just invoke the URL interpolator directly + // as we don't need to use the resource to create a full path. + const requestPath = isUsingFullPath + ? commandPath(urlData) + : self.createFullPath(commandPath, urlData); + const headers = Object.assign(options.headers, spec.headers); + if (spec.validator) { + spec.validator(data, {headers}); + } + const dataInQuery = spec.method === 'GET' || spec.method === 'DELETE'; + const bodyData = dataInQuery ? {} : data; + const queryData = dataInQuery ? data : {}; + return { + requestMethod, + requestPath, + bodyData, + queryData, + auth: options.auth, + headers, + host, + streaming, + settings: options.settings, + }; } function makeRequest(self, requestArgs, spec, overrideData) { - return new Promise((resolve, reject) => { - let opts; - try { - opts = getRequestOpts(self, requestArgs, spec, overrideData); - } - catch (err) { - reject(err); - return; - } - function requestCallback(err, response) { - if (err) { - reject(err); - } - else { - resolve(spec.transformResponseData - ? spec.transformResponseData(response) - : response); - } - } - const emptyQuery = Object.keys(opts.queryData).length === 0; - const path = [ - opts.requestPath, - emptyQuery ? '' : '?', - utils.stringifyRequestData(opts.queryData), - ].join(''); - const { headers, settings } = opts; - self._request(opts.requestMethod, opts.host, path, opts.bodyData, opts.auth, { headers, settings, streaming: opts.streaming }, requestCallback); - }); + return new Promise((resolve, reject) => { + let opts; + try { + opts = getRequestOpts(self, requestArgs, spec, overrideData); + } catch (err) { + reject(err); + return; + } + function requestCallback(err, response) { + if (err) { + reject(err); + } else { + resolve( + spec.transformResponseData + ? spec.transformResponseData(response) + : response + ); + } + } + const emptyQuery = Object.keys(opts.queryData).length === 0; + const path = [ + opts.requestPath, + emptyQuery ? '' : '?', + utils.stringifyRequestData(opts.queryData), + ].join(''); + const {headers, settings} = opts; + self._request( + opts.requestMethod, + opts.host, + path, + opts.bodyData, + opts.auth, + {headers, settings, streaming: opts.streaming}, + requestCallback + ); + }); } module.exports = makeRequest; diff --git a/lib/multipart.js b/lib/multipart.js index 566858b429..29e53c8363 100644 --- a/lib/multipart.js +++ b/lib/multipart.js @@ -1,79 +1,87 @@ -"use strict"; -const utils = require("./utils"); -const _Error = require("./Error"); -const { StripeError } = _Error; -class StreamProcessingError extends StripeError { -} +'use strict'; +const utils = require('./utils'); +const _Error = require('./Error'); +const {StripeError} = _Error; +class StreamProcessingError extends StripeError {} // Method for formatting HTTP body for the multipart/form-data specification // Mostly taken from Fermata.js // https://github.com/natevw/fermata/blob/5d9732a33d776ce925013a265935facd1626cc88/fermata.js#L315-L343 const multipartDataGenerator = (method, data, headers) => { - const segno = (Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16)).toString(); - headers['Content-Type'] = `multipart/form-data; boundary=${segno}`; - let buffer = Buffer.alloc(0); - function push(l) { - const prevBuffer = buffer; - const newBuffer = l instanceof Buffer ? l : Buffer.from(l); - buffer = Buffer.alloc(prevBuffer.length + newBuffer.length + 2); - prevBuffer.copy(buffer); - newBuffer.copy(buffer, prevBuffer.length); - buffer.write('\r\n', buffer.length - 2); + const segno = ( + Math.round(Math.random() * 1e16) + Math.round(Math.random() * 1e16) + ).toString(); + headers['Content-Type'] = `multipart/form-data; boundary=${segno}`; + let buffer = Buffer.alloc(0); + function push(l) { + const prevBuffer = buffer; + const newBuffer = l instanceof Buffer ? l : Buffer.from(l); + buffer = Buffer.alloc(prevBuffer.length + newBuffer.length + 2); + prevBuffer.copy(buffer); + newBuffer.copy(buffer, prevBuffer.length); + buffer.write('\r\n', buffer.length - 2); + } + function q(s) { + return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`; + } + const flattenedData = utils.flattenAndStringify(data); + for (const k in flattenedData) { + const v = flattenedData[k]; + push(`--${segno}`); + if (Object.prototype.hasOwnProperty.call(v, 'data')) { + const typedEntry = v; + push( + `Content-Disposition: form-data; name=${q(k)}; filename=${q( + typedEntry.name || 'blob' + )}` + ); + push(`Content-Type: ${typedEntry.type || 'application/octet-stream'}`); + push(''); + push(typedEntry.data); + } else { + push(`Content-Disposition: form-data; name=${q(k)}`); + push(''); + push(v); } - function q(s) { - return `"${s.replace(/"|"/g, '%22').replace(/\r\n|\r|\n/g, ' ')}"`; - } - const flattenedData = utils.flattenAndStringify(data); - for (const k in flattenedData) { - const v = flattenedData[k]; - push(`--${segno}`); - if (Object.prototype.hasOwnProperty.call(v, 'data')) { - const typedEntry = v; - push(`Content-Disposition: form-data; name=${q(k)}; filename=${q(typedEntry.name || 'blob')}`); - push(`Content-Type: ${typedEntry.type || 'application/octet-stream'}`); - push(''); - push(typedEntry.data); - } - else { - push(`Content-Disposition: form-data; name=${q(k)}`); - push(''); - push(v); - } - } - push(`--${segno}--`); - return buffer; + } + push(`--${segno}--`); + return buffer; }; const streamProcessor = (method, data, headers, callback) => { - const bufferArray = []; - data.file.data - .on('data', (line) => { - bufferArray.push(line); + const bufferArray = []; + data.file.data + .on('data', (line) => { + bufferArray.push(line); }) - .once('end', () => { - // @ts-ignore - const bufferData = Object.assign({}, data); - bufferData.file.data = Buffer.concat(bufferArray); - const buffer = multipartDataGenerator(method, bufferData, headers); - callback(null, buffer); + .once('end', () => { + // @ts-ignore + const bufferData = Object.assign({}, data); + bufferData.file.data = Buffer.concat(bufferArray); + const buffer = multipartDataGenerator(method, bufferData, headers); + callback(null, buffer); }) - .on('error', (err) => { - callback(new StreamProcessingError({ - message: 'An error occurred while attempting to process the file for upload.', - detail: err, - }), null); + .on('error', (err) => { + callback( + new StreamProcessingError({ + message: + 'An error occurred while attempting to process the file for upload.', + detail: err, + }), + null + ); }); }; const multipartRequestDataProcessor = (method, data, headers, callback) => { - data = data || {}; - if (method !== 'POST') { - return callback(null, utils.stringifyRequestData(data)); - } - const isStream = utils.checkForStream(data); - if (isStream) { - return streamProcessor(method, data, headers, callback); - } - const buffer = multipartDataGenerator(method, data, headers); - return callback(null, buffer); + data = data || {}; + if (method !== 'POST') { + return callback(null, utils.stringifyRequestData(data)); + } + const isStream = utils.checkForStream(data); + if (isStream) { + return streamProcessor(method, data, headers, callback); + } + const buffer = multipartDataGenerator(method, data, headers); + return callback(null, buffer); }; module.exports = { - multipartRequestDataProcessor: multipartRequestDataProcessor, + multipartRequestDataProcessor: multipartRequestDataProcessor, }; diff --git a/lib/net/FetchHttpClient.js b/lib/net/FetchHttpClient.js index d47c237616..355824001a 100644 --- a/lib/net/FetchHttpClient.js +++ b/lib/net/FetchHttpClient.js @@ -1,6 +1,6 @@ -"use strict"; -const _HttpClient = require("./HttpClient"); -const { HttpClient, HttpClientResponse } = _HttpClient; +'use strict'; +const _HttpClient = require('./HttpClient'); +const {HttpClient, HttpClientResponse} = _HttpClient; /** * HTTP client which uses a `fetch` function to issue requests. * @@ -10,95 +10,113 @@ const { HttpClient, HttpClientResponse } = _HttpClient; * node-fetch package (https://github.com/node-fetch/node-fetch). */ class FetchHttpClient extends HttpClient { - constructor(fetchFn) { - super(); - this._fetchFn = fetchFn; - } - /** @override. */ - getClientName() { - return 'fetch'; - } - makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { - const isInsecureConnection = protocol === 'http'; - const url = new URL(path, `${isInsecureConnection ? 'http' : 'https'}://${host}`); - url.port = port; - // For methods which expect payloads, we should always pass a body value - // even when it is empty. Without this, some JS runtimes (eg. Deno) will - // inject a second Content-Length header. See https://github.com/stripe/stripe-node/issues/1519 - // for more details. - const methodHasPayload = method == 'POST' || method == 'PUT' || method == 'PATCH'; - const body = requestData || (methodHasPayload ? '' : undefined); - const fetchFn = this._fetchFn || fetch; - const fetchPromise = fetchFn(url.toString(), { - method, - // @ts-ignore - headers, - // @ts-ignore - body, - }); - // The Fetch API does not support passing in a timeout natively, so a - // timeout promise is constructed to race against the fetch and preempt the - // request, simulating a timeout. - // - // This timeout behavior differs from Node: - // - Fetch uses a single timeout for the entire length of the request. - // - Node is more fine-grained and resets the timeout after each stage of - // the request. - // - // As an example, if the timeout is set to 30s and the connection takes 20s - // to be established followed by 20s for the body, Fetch would timeout but - // Node would not. The more fine-grained timeout cannot be implemented with - // fetch. - let pendingTimeoutId; - const timeoutPromise = new Promise((_, reject) => { - pendingTimeoutId = setTimeout(() => { - pendingTimeoutId = null; - reject(HttpClient.makeTimeoutError()); - }, timeout); - }); - return Promise.race([fetchPromise, timeoutPromise]) - .then((res) => { - return new FetchHttpClientResponse(res); - }) - .finally(() => { - if (pendingTimeoutId) { - clearTimeout(pendingTimeoutId); - } - }); - } + constructor(fetchFn) { + super(); + this._fetchFn = fetchFn; + } + /** @override. */ + getClientName() { + return 'fetch'; + } + makeRequest( + host, + port, + path, + method, + headers, + requestData, + protocol, + timeout + ) { + const isInsecureConnection = protocol === 'http'; + const url = new URL( + path, + `${isInsecureConnection ? 'http' : 'https'}://${host}` + ); + url.port = port; + // For methods which expect payloads, we should always pass a body value + // even when it is empty. Without this, some JS runtimes (eg. Deno) will + // inject a second Content-Length header. See https://github.com/stripe/stripe-node/issues/1519 + // for more details. + const methodHasPayload = + method == 'POST' || method == 'PUT' || method == 'PATCH'; + const body = requestData || (methodHasPayload ? '' : undefined); + const fetchFn = this._fetchFn || fetch; + const fetchPromise = fetchFn(url.toString(), { + method, + // @ts-ignore + headers, + // @ts-ignore + body, + }); + // The Fetch API does not support passing in a timeout natively, so a + // timeout promise is constructed to race against the fetch and preempt the + // request, simulating a timeout. + // + // This timeout behavior differs from Node: + // - Fetch uses a single timeout for the entire length of the request. + // - Node is more fine-grained and resets the timeout after each stage of + // the request. + // + // As an example, if the timeout is set to 30s and the connection takes 20s + // to be established followed by 20s for the body, Fetch would timeout but + // Node would not. The more fine-grained timeout cannot be implemented with + // fetch. + let pendingTimeoutId; + const timeoutPromise = new Promise((_, reject) => { + pendingTimeoutId = setTimeout(() => { + pendingTimeoutId = null; + reject(HttpClient.makeTimeoutError()); + }, timeout); + }); + return Promise.race([fetchPromise, timeoutPromise]) + .then((res) => { + return new FetchHttpClientResponse(res); + }) + .finally(() => { + if (pendingTimeoutId) { + clearTimeout(pendingTimeoutId); + } + }); + } } class FetchHttpClientResponse extends HttpClientResponse { - constructor(res) { - super(res.status, FetchHttpClientResponse._transformHeadersToObject(res.headers)); - this._res = res; - } - getRawResponse() { - return this._res; - } - toStream(streamCompleteCallback) { - // Unfortunately `fetch` does not have event handlers for when the stream is - // completely read. We therefore invoke the streamCompleteCallback right - // away. This callback emits a response event with metadata and completes - // metrics, so it's ok to do this without waiting for the stream to be - // completely read. - streamCompleteCallback(); - // Fetch's `body` property is expected to be a readable stream of the body. - return this._res.body; - } - toJSON() { - return this._res.json(); - } - static _transformHeadersToObject(headers) { - // Fetch uses a Headers instance so this must be converted to a barebones - // JS object to meet the HttpClient interface. - const headersObj = {}; - for (const entry of headers) { - if (!Array.isArray(entry) || entry.length != 2) { - throw new Error('Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.'); - } - headersObj[entry[0]] = entry[1]; - } - return headersObj; + constructor(res) { + super( + res.status, + FetchHttpClientResponse._transformHeadersToObject(res.headers) + ); + this._res = res; + } + getRawResponse() { + return this._res; + } + toStream(streamCompleteCallback) { + // Unfortunately `fetch` does not have event handlers for when the stream is + // completely read. We therefore invoke the streamCompleteCallback right + // away. This callback emits a response event with metadata and completes + // metrics, so it's ok to do this without waiting for the stream to be + // completely read. + streamCompleteCallback(); + // Fetch's `body` property is expected to be a readable stream of the body. + return this._res.body; + } + toJSON() { + return this._res.json(); + } + static _transformHeadersToObject(headers) { + // Fetch uses a Headers instance so this must be converted to a barebones + // JS object to meet the HttpClient interface. + const headersObj = {}; + for (const entry of headers) { + if (!Array.isArray(entry) || entry.length != 2) { + throw new Error( + 'Response objects produced by the fetch function given to FetchHttpClient do not have an iterable headers map. Response#headers should be an iterable object.' + ); + } + headersObj[entry[0]] = entry[1]; } + return headersObj; + } } -module.exports = { FetchHttpClient, FetchHttpClientResponse }; +module.exports = {FetchHttpClient, FetchHttpClientResponse}; diff --git a/lib/net/HttpClient.js b/lib/net/HttpClient.js index d49f8fb584..88f9f31f1b 100644 --- a/lib/net/HttpClient.js +++ b/lib/net/HttpClient.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; /** * Encapsulates the logic for issuing a request to the Stripe API. * @@ -9,41 +9,50 @@ * returning their own response class when making requests. */ class HttpClient { - /** The client name used for diagnostics. */ - getClientName() { - throw new Error('getClientName not implemented.'); - } - makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { - throw new Error('makeRequest not implemented.'); - } - /** Helper to make a consistent timeout error across implementations. */ - static makeTimeoutError() { - const timeoutErr = new TypeError(HttpClient.TIMEOUT_ERROR_CODE); - timeoutErr.code = HttpClient.TIMEOUT_ERROR_CODE; - return timeoutErr; - } + /** The client name used for diagnostics. */ + getClientName() { + throw new Error('getClientName not implemented.'); + } + makeRequest( + host, + port, + path, + method, + headers, + requestData, + protocol, + timeout + ) { + throw new Error('makeRequest not implemented.'); + } + /** Helper to make a consistent timeout error across implementations. */ + static makeTimeoutError() { + const timeoutErr = new TypeError(HttpClient.TIMEOUT_ERROR_CODE); + timeoutErr.code = HttpClient.TIMEOUT_ERROR_CODE; + return timeoutErr; + } } HttpClient.CONNECTION_CLOSED_ERROR_CODES = ['ECONNRESET', 'EPIPE']; HttpClient.TIMEOUT_ERROR_CODE = 'ETIMEDOUT'; class HttpClientResponse { - constructor(statusCode, headers) { - this._statusCode = statusCode; - this._headers = headers; - } - getStatusCode() { - return this._statusCode; - } - getHeaders() { - return this._headers; - } - getRawResponse() { - throw new Error('getRawResponse not implemented.'); - } - toStream(streamCompleteCallback) { - throw new Error('toStream not implemented.'); - } - toJSON() { - throw new Error('toJSON not implemented.'); - } + constructor(statusCode, headers) { + this._statusCode = statusCode; + this._headers = headers; + } + getStatusCode() { + return this._statusCode; + } + getHeaders() { + return this._headers; + } + getRawResponse() { + throw new Error('getRawResponse not implemented.'); + } + toStream(streamCompleteCallback) { + throw new Error('toStream not implemented.'); + } + toJSON() { + throw new Error('toJSON not implemented.'); + } } -module.exports = { HttpClient, HttpClientResponse }; +module.exports = {HttpClient, HttpClientResponse}; diff --git a/lib/net/NodeHttpClient.js b/lib/net/NodeHttpClient.js index 02d02ab761..cf580fd63d 100644 --- a/lib/net/NodeHttpClient.js +++ b/lib/net/NodeHttpClient.js @@ -1,98 +1,108 @@ -"use strict"; -const http = require("http"); -const https = require("https"); -const _HttpClient = require("./HttpClient"); -const { HttpClient, HttpClientResponse } = _HttpClient; -const defaultHttpAgent = new http.Agent({ keepAlive: true }); -const defaultHttpsAgent = new https.Agent({ keepAlive: true }); +'use strict'; +const http = require('http'); +const https = require('https'); +const _HttpClient = require('./HttpClient'); +const {HttpClient, HttpClientResponse} = _HttpClient; +const defaultHttpAgent = new http.Agent({keepAlive: true}); +const defaultHttpsAgent = new https.Agent({keepAlive: true}); /** * HTTP client which uses the Node `http` and `https` packages to issue * requests.` */ class NodeHttpClient extends HttpClient { - constructor(agent) { - super(); - this._agent = agent; + constructor(agent) { + super(); + this._agent = agent; + } + /** @override. */ + getClientName() { + return 'node'; + } + makeRequest( + host, + port, + path, + method, + headers, + requestData, + protocol, + timeout + ) { + const isInsecureConnection = protocol === 'http'; + let agent = this._agent; + if (!agent) { + agent = isInsecureConnection ? defaultHttpAgent : defaultHttpsAgent; } - /** @override. */ - getClientName() { - return 'node'; - } - makeRequest(host, port, path, method, headers, requestData, protocol, timeout) { - const isInsecureConnection = protocol === 'http'; - let agent = this._agent; - if (!agent) { - agent = isInsecureConnection ? defaultHttpAgent : defaultHttpsAgent; + const requestPromise = new Promise((resolve, reject) => { + const req = (isInsecureConnection ? http : https).request({ + host: host, + port: port, + path, + method, + agent, + headers, + ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5', + }); + req.setTimeout(timeout, () => { + req.destroy(HttpClient.makeTimeoutError()); + }); + req.on('response', (res) => { + resolve(new NodeHttpClientResponse(res)); + }); + req.on('error', (error) => { + reject(error); + }); + req.once('socket', (socket) => { + if (socket.connecting) { + socket.once( + isInsecureConnection ? 'connect' : 'secureConnect', + () => { + // Send payload; we're safe: + req.write(requestData); + req.end(); + } + ); + } else { + // we're already connected + req.write(requestData); + req.end(); } - const requestPromise = new Promise((resolve, reject) => { - const req = (isInsecureConnection ? http : https).request({ - host: host, - port: port, - path, - method, - agent, - headers, - ciphers: 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5', - }); - req.setTimeout(timeout, () => { - req.destroy(HttpClient.makeTimeoutError()); - }); - req.on('response', (res) => { - resolve(new NodeHttpClientResponse(res)); - }); - req.on('error', (error) => { - reject(error); - }); - req.once('socket', (socket) => { - if (socket.connecting) { - socket.once(isInsecureConnection ? 'connect' : 'secureConnect', () => { - // Send payload; we're safe: - req.write(requestData); - req.end(); - }); - } - else { - // we're already connected - req.write(requestData); - req.end(); - } - }); - }); - return requestPromise; - } + }); + }); + return requestPromise; + } } class NodeHttpClientResponse extends HttpClientResponse { - constructor(res) { - // @ts-ignore - super(res.statusCode, res.headers || {}); - this._res = res; - } - getRawResponse() { - return this._res; - } - toStream(streamCompleteCallback) { - // The raw response is itself the stream, so we just return that. To be - // backwards compatible, we should invoke the streamCompleteCallback only - // once the stream has been fully consumed. - this._res.once('end', () => streamCompleteCallback()); - return this._res; - } - toJSON() { - return new Promise((resolve, reject) => { - let response = ''; - this._res.setEncoding('utf8'); - this._res.on('data', (chunk) => { - response += chunk; - }); - this._res.once('end', () => { - try { - resolve(JSON.parse(response)); - } - catch (e) { - reject(e); - } - }); - }); - } + constructor(res) { + // @ts-ignore + super(res.statusCode, res.headers || {}); + this._res = res; + } + getRawResponse() { + return this._res; + } + toStream(streamCompleteCallback) { + // The raw response is itself the stream, so we just return that. To be + // backwards compatible, we should invoke the streamCompleteCallback only + // once the stream has been fully consumed. + this._res.once('end', () => streamCompleteCallback()); + return this._res; + } + toJSON() { + return new Promise((resolve, reject) => { + let response = ''; + this._res.setEncoding('utf8'); + this._res.on('data', (chunk) => { + response += chunk; + }); + this._res.once('end', () => { + try { + resolve(JSON.parse(response)); + } catch (e) { + reject(e); + } + }); + }); + } } -module.exports = { NodeHttpClient, NodeHttpClientResponse }; +module.exports = {NodeHttpClient, NodeHttpClientResponse}; diff --git a/lib/resources.js b/lib/resources.js index 669f1bff4b..eb497e3587 100644 --- a/lib/resources.js +++ b/lib/resources.js @@ -2,124 +2,124 @@ 'use strict'; const resourceNamespace = require('./ResourceNamespace'); module.exports = { - Accounts: require('./resources/Accounts'), - // Support Accounts for consistency, Account for backwards compatibility - Account: require('./resources/Accounts'), - AccountLinks: require('./resources/AccountLinks'), - ApplePayDomains: require('./resources/ApplePayDomains'), - ApplicationFees: require('./resources/ApplicationFees'), - Balance: require('./resources/Balance'), - BalanceTransactions: require('./resources/BalanceTransactions'), - Charges: require('./resources/Charges'), - CountrySpecs: require('./resources/CountrySpecs'), - Coupons: require('./resources/Coupons'), - CreditNotes: require('./resources/CreditNotes'), - Customers: require('./resources/Customers'), - Disputes: require('./resources/Disputes'), - EphemeralKeys: require('./resources/EphemeralKeys'), - Events: require('./resources/Events'), - ExchangeRates: require('./resources/ExchangeRates'), - Files: require('./resources/Files'), - FileLinks: require('./resources/FileLinks'), - Invoices: require('./resources/Invoices'), - InvoiceItems: require('./resources/InvoiceItems'), - Mandates: require('./resources/Mandates'), - OAuth: require('./resources/OAuth'), - PaymentIntents: require('./resources/PaymentIntents'), - PaymentLinks: require('./resources/PaymentLinks'), - PaymentMethods: require('./resources/PaymentMethods'), - Payouts: require('./resources/Payouts'), - Plans: require('./resources/Plans'), - Prices: require('./resources/Prices'), - Products: require('./resources/Products'), - PromotionCodes: require('./resources/PromotionCodes'), - Quotes: require('./resources/Quotes'), - Refunds: require('./resources/Refunds'), - Reviews: require('./resources/Reviews'), - SetupAttempts: require('./resources/SetupAttempts'), - SetupIntents: require('./resources/SetupIntents'), - ShippingRates: require('./resources/ShippingRates'), - Sources: require('./resources/Sources'), - Subscriptions: require('./resources/Subscriptions'), - SubscriptionItems: require('./resources/SubscriptionItems'), - SubscriptionSchedules: require('./resources/SubscriptionSchedules'), - TaxCodes: require('./resources/TaxCodes'), - TaxRates: require('./resources/TaxRates'), - Tokens: require('./resources/Tokens'), - Topups: require('./resources/Topups'), - Transfers: require('./resources/Transfers'), - WebhookEndpoints: require('./resources/WebhookEndpoints'), - Apps: resourceNamespace('apps', { - Secrets: require('./resources/Apps/Secrets'), - }), - BillingPortal: resourceNamespace('billingPortal', { - Configurations: require('./resources/BillingPortal/Configurations'), - Sessions: require('./resources/BillingPortal/Sessions'), - }), - Checkout: resourceNamespace('checkout', { - Sessions: require('./resources/Checkout/Sessions'), - }), - FinancialConnections: resourceNamespace('financialConnections', { - Accounts: require('./resources/FinancialConnections/Accounts'), - Sessions: require('./resources/FinancialConnections/Sessions'), - }), - Identity: resourceNamespace('identity', { - VerificationReports: require('./resources/Identity/VerificationReports'), - VerificationSessions: require('./resources/Identity/VerificationSessions'), - }), + Accounts: require('./resources/Accounts'), + // Support Accounts for consistency, Account for backwards compatibility + Account: require('./resources/Accounts'), + AccountLinks: require('./resources/AccountLinks'), + ApplePayDomains: require('./resources/ApplePayDomains'), + ApplicationFees: require('./resources/ApplicationFees'), + Balance: require('./resources/Balance'), + BalanceTransactions: require('./resources/BalanceTransactions'), + Charges: require('./resources/Charges'), + CountrySpecs: require('./resources/CountrySpecs'), + Coupons: require('./resources/Coupons'), + CreditNotes: require('./resources/CreditNotes'), + Customers: require('./resources/Customers'), + Disputes: require('./resources/Disputes'), + EphemeralKeys: require('./resources/EphemeralKeys'), + Events: require('./resources/Events'), + ExchangeRates: require('./resources/ExchangeRates'), + Files: require('./resources/Files'), + FileLinks: require('./resources/FileLinks'), + Invoices: require('./resources/Invoices'), + InvoiceItems: require('./resources/InvoiceItems'), + Mandates: require('./resources/Mandates'), + OAuth: require('./resources/OAuth'), + PaymentIntents: require('./resources/PaymentIntents'), + PaymentLinks: require('./resources/PaymentLinks'), + PaymentMethods: require('./resources/PaymentMethods'), + Payouts: require('./resources/Payouts'), + Plans: require('./resources/Plans'), + Prices: require('./resources/Prices'), + Products: require('./resources/Products'), + PromotionCodes: require('./resources/PromotionCodes'), + Quotes: require('./resources/Quotes'), + Refunds: require('./resources/Refunds'), + Reviews: require('./resources/Reviews'), + SetupAttempts: require('./resources/SetupAttempts'), + SetupIntents: require('./resources/SetupIntents'), + ShippingRates: require('./resources/ShippingRates'), + Sources: require('./resources/Sources'), + Subscriptions: require('./resources/Subscriptions'), + SubscriptionItems: require('./resources/SubscriptionItems'), + SubscriptionSchedules: require('./resources/SubscriptionSchedules'), + TaxCodes: require('./resources/TaxCodes'), + TaxRates: require('./resources/TaxRates'), + Tokens: require('./resources/Tokens'), + Topups: require('./resources/Topups'), + Transfers: require('./resources/Transfers'), + WebhookEndpoints: require('./resources/WebhookEndpoints'), + Apps: resourceNamespace('apps', { + Secrets: require('./resources/Apps/Secrets'), + }), + BillingPortal: resourceNamespace('billingPortal', { + Configurations: require('./resources/BillingPortal/Configurations'), + Sessions: require('./resources/BillingPortal/Sessions'), + }), + Checkout: resourceNamespace('checkout', { + Sessions: require('./resources/Checkout/Sessions'), + }), + FinancialConnections: resourceNamespace('financialConnections', { + Accounts: require('./resources/FinancialConnections/Accounts'), + Sessions: require('./resources/FinancialConnections/Sessions'), + }), + Identity: resourceNamespace('identity', { + VerificationReports: require('./resources/Identity/VerificationReports'), + VerificationSessions: require('./resources/Identity/VerificationSessions'), + }), + Issuing: resourceNamespace('issuing', { + Authorizations: require('./resources/Issuing/Authorizations'), + Cards: require('./resources/Issuing/Cards'), + Cardholders: require('./resources/Issuing/Cardholders'), + Disputes: require('./resources/Issuing/Disputes'), + Transactions: require('./resources/Issuing/Transactions'), + }), + Radar: resourceNamespace('radar', { + EarlyFraudWarnings: require('./resources/Radar/EarlyFraudWarnings'), + ValueLists: require('./resources/Radar/ValueLists'), + ValueListItems: require('./resources/Radar/ValueListItems'), + }), + Reporting: resourceNamespace('reporting', { + ReportRuns: require('./resources/Reporting/ReportRuns'), + ReportTypes: require('./resources/Reporting/ReportTypes'), + }), + Sigma: resourceNamespace('sigma', { + ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'), + }), + Terminal: resourceNamespace('terminal', { + Configurations: require('./resources/Terminal/Configurations'), + ConnectionTokens: require('./resources/Terminal/ConnectionTokens'), + Locations: require('./resources/Terminal/Locations'), + Readers: require('./resources/Terminal/Readers'), + }), + TestHelpers: resourceNamespace('testHelpers', { + Customers: require('./resources/TestHelpers/Customers'), + Refunds: require('./resources/TestHelpers/Refunds'), + TestClocks: require('./resources/TestHelpers/TestClocks'), Issuing: resourceNamespace('issuing', { - Authorizations: require('./resources/Issuing/Authorizations'), - Cards: require('./resources/Issuing/Cards'), - Cardholders: require('./resources/Issuing/Cardholders'), - Disputes: require('./resources/Issuing/Disputes'), - Transactions: require('./resources/Issuing/Transactions'), - }), - Radar: resourceNamespace('radar', { - EarlyFraudWarnings: require('./resources/Radar/EarlyFraudWarnings'), - ValueLists: require('./resources/Radar/ValueLists'), - ValueListItems: require('./resources/Radar/ValueListItems'), - }), - Reporting: resourceNamespace('reporting', { - ReportRuns: require('./resources/Reporting/ReportRuns'), - ReportTypes: require('./resources/Reporting/ReportTypes'), - }), - Sigma: resourceNamespace('sigma', { - ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'), + Cards: require('./resources/TestHelpers/Issuing/Cards'), }), Terminal: resourceNamespace('terminal', { - Configurations: require('./resources/Terminal/Configurations'), - ConnectionTokens: require('./resources/Terminal/ConnectionTokens'), - Locations: require('./resources/Terminal/Locations'), - Readers: require('./resources/Terminal/Readers'), - }), - TestHelpers: resourceNamespace('testHelpers', { - Customers: require('./resources/TestHelpers/Customers'), - Refunds: require('./resources/TestHelpers/Refunds'), - TestClocks: require('./resources/TestHelpers/TestClocks'), - Issuing: resourceNamespace('issuing', { - Cards: require('./resources/TestHelpers/Issuing/Cards'), - }), - Terminal: resourceNamespace('terminal', { - Readers: require('./resources/TestHelpers/Terminal/Readers'), - }), - Treasury: resourceNamespace('treasury', { - InboundTransfers: require('./resources/TestHelpers/Treasury/InboundTransfers'), - OutboundPayments: require('./resources/TestHelpers/Treasury/OutboundPayments'), - OutboundTransfers: require('./resources/TestHelpers/Treasury/OutboundTransfers'), - ReceivedCredits: require('./resources/TestHelpers/Treasury/ReceivedCredits'), - ReceivedDebits: require('./resources/TestHelpers/Treasury/ReceivedDebits'), - }), + Readers: require('./resources/TestHelpers/Terminal/Readers'), }), Treasury: resourceNamespace('treasury', { - CreditReversals: require('./resources/Treasury/CreditReversals'), - DebitReversals: require('./resources/Treasury/DebitReversals'), - FinancialAccounts: require('./resources/Treasury/FinancialAccounts'), - InboundTransfers: require('./resources/Treasury/InboundTransfers'), - OutboundPayments: require('./resources/Treasury/OutboundPayments'), - OutboundTransfers: require('./resources/Treasury/OutboundTransfers'), - ReceivedCredits: require('./resources/Treasury/ReceivedCredits'), - ReceivedDebits: require('./resources/Treasury/ReceivedDebits'), - Transactions: require('./resources/Treasury/Transactions'), - TransactionEntries: require('./resources/Treasury/TransactionEntries'), + InboundTransfers: require('./resources/TestHelpers/Treasury/InboundTransfers'), + OutboundPayments: require('./resources/TestHelpers/Treasury/OutboundPayments'), + OutboundTransfers: require('./resources/TestHelpers/Treasury/OutboundTransfers'), + ReceivedCredits: require('./resources/TestHelpers/Treasury/ReceivedCredits'), + ReceivedDebits: require('./resources/TestHelpers/Treasury/ReceivedDebits'), }), + }), + Treasury: resourceNamespace('treasury', { + CreditReversals: require('./resources/Treasury/CreditReversals'), + DebitReversals: require('./resources/Treasury/DebitReversals'), + FinancialAccounts: require('./resources/Treasury/FinancialAccounts'), + InboundTransfers: require('./resources/Treasury/InboundTransfers'), + OutboundPayments: require('./resources/Treasury/OutboundPayments'), + OutboundTransfers: require('./resources/Treasury/OutboundTransfers'), + ReceivedCredits: require('./resources/Treasury/ReceivedCredits'), + ReceivedDebits: require('./resources/Treasury/ReceivedDebits'), + Transactions: require('./resources/Treasury/Transactions'), + TransactionEntries: require('./resources/Treasury/TransactionEntries'), + }), }; diff --git a/lib/resources/AccountLinks.js b/lib/resources/AccountLinks.js index 4e454771df..45a2185524 100644 --- a/lib/resources/AccountLinks.js +++ b/lib/resources/AccountLinks.js @@ -3,8 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/account_links', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/account_links', + }), }); diff --git a/lib/resources/Accounts.js b/lib/resources/Accounts.js index 1be3480640..63aa6e6bb5 100644 --- a/lib/resources/Accounts.js +++ b/lib/resources/Accounts.js @@ -4,104 +4,103 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; // Since path can either be `account` or `accounts`, support both through stripeMethod path; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts', - }), - retrieve(id) { - // No longer allow an api key to be passed as the first string to this function due to ambiguity between - // old account ids and api keys. To request the account for an api key, send null as the id - if (typeof id === 'string') { - return stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{id}', - }).apply(this, arguments); - } - else { - if (id === null || id === undefined) { - // Remove id as stripeMethod would complain of unexpected argument - [].shift.apply(arguments); - } - return stripeMethod({ - method: 'GET', - fullPath: '/v1/account', - }).apply(this, arguments); - } - }, - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}', - }), - list: stripeMethod({ + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts', + }), + retrieve(id) { + // No longer allow an api key to be passed as the first string to this function due to ambiguity between + // old account ids and api keys. To request the account for an api key, send null as the id + if (typeof id === 'string') { + return stripeMethod({ method: 'GET', - fullPath: '/v1/accounts', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/accounts/{account}', - }), - reject: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/reject', - }), - retrieveCapability: stripeMethod({ + fullPath: '/v1/accounts/{id}', + }).apply(this, arguments); + } else { + if (id === null || id === undefined) { + // Remove id as stripeMethod would complain of unexpected argument + [].shift.apply(arguments); + } + return stripeMethod({ method: 'GET', - fullPath: '/v1/accounts/{account}/capabilities/{capability}', - }), - updateCapability: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/capabilities/{capability}', - }), - listCapabilities: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/capabilities', - methodType: 'list', - }), - createExternalAccount: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/external_accounts', - }), - retrieveExternalAccount: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/external_accounts/{id}', - }), - updateExternalAccount: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/external_accounts/{id}', - }), - listExternalAccounts: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/external_accounts', - methodType: 'list', - }), - deleteExternalAccount: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/accounts/{account}/external_accounts/{id}', - }), - createLoginLink: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/login_links', - }), - createPerson: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/persons', - }), - retrievePerson: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/persons/{person}', - }), - updatePerson: stripeMethod({ - method: 'POST', - fullPath: '/v1/accounts/{account}/persons/{person}', - }), - listPersons: stripeMethod({ - method: 'GET', - fullPath: '/v1/accounts/{account}/persons', - methodType: 'list', - }), - deletePerson: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/accounts/{account}/persons/{person}', - }), + fullPath: '/v1/account', + }).apply(this, arguments); + } + }, + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/accounts/{account}', + }), + reject: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/reject', + }), + retrieveCapability: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/capabilities/{capability}', + }), + updateCapability: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/capabilities/{capability}', + }), + listCapabilities: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/capabilities', + methodType: 'list', + }), + createExternalAccount: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/external_accounts', + }), + retrieveExternalAccount: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', + }), + updateExternalAccount: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', + }), + listExternalAccounts: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/external_accounts', + methodType: 'list', + }), + deleteExternalAccount: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/accounts/{account}/external_accounts/{id}', + }), + createLoginLink: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/login_links', + }), + createPerson: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/persons', + }), + retrievePerson: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/persons/{person}', + }), + updatePerson: stripeMethod({ + method: 'POST', + fullPath: '/v1/accounts/{account}/persons/{person}', + }), + listPersons: stripeMethod({ + method: 'GET', + fullPath: '/v1/accounts/{account}/persons', + methodType: 'list', + }), + deletePerson: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/accounts/{account}/persons/{person}', + }), }); diff --git a/lib/resources/ApplePayDomains.js b/lib/resources/ApplePayDomains.js index 46fc59ad61..4ca4546ec3 100644 --- a/lib/resources/ApplePayDomains.js +++ b/lib/resources/ApplePayDomains.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/apple_pay/domains', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/apple_pay/domains/{domain}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/apple_pay/domains', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/apple_pay/domains/{domain}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/apple_pay/domains', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/apple_pay/domains/{domain}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/apple_pay/domains', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/apple_pay/domains/{domain}', + }), }); diff --git a/lib/resources/ApplicationFees.js b/lib/resources/ApplicationFees.js index c61a07964e..7f0fa49662 100644 --- a/lib/resources/ApplicationFees.js +++ b/lib/resources/ApplicationFees.js @@ -3,30 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees', - methodType: 'list', - }), - createRefund: stripeMethod({ - method: 'POST', - fullPath: '/v1/application_fees/{id}/refunds', - }), - retrieveRefund: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees/{fee}/refunds/{id}', - }), - updateRefund: stripeMethod({ - method: 'POST', - fullPath: '/v1/application_fees/{fee}/refunds/{id}', - }), - listRefunds: stripeMethod({ - method: 'GET', - fullPath: '/v1/application_fees/{id}/refunds', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees', + methodType: 'list', + }), + createRefund: stripeMethod({ + method: 'POST', + fullPath: '/v1/application_fees/{id}/refunds', + }), + retrieveRefund: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', + }), + updateRefund: stripeMethod({ + method: 'POST', + fullPath: '/v1/application_fees/{fee}/refunds/{id}', + }), + listRefunds: stripeMethod({ + method: 'GET', + fullPath: '/v1/application_fees/{id}/refunds', + methodType: 'list', + }), }); diff --git a/lib/resources/Apps/Secrets.js b/lib/resources/Apps/Secrets.js index f94086c14e..112e3539e5 100644 --- a/lib/resources/Apps/Secrets.js +++ b/lib/resources/Apps/Secrets.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/apps/secrets', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/apps/secrets', - methodType: 'list', - }), - deleteWhere: stripeMethod({ - method: 'POST', - fullPath: '/v1/apps/secrets/delete', - }), - find: stripeMethod({ - method: 'GET', - fullPath: '/v1/apps/secrets/find', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/apps/secrets', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/apps/secrets', + methodType: 'list', + }), + deleteWhere: stripeMethod({ + method: 'POST', + fullPath: '/v1/apps/secrets/delete', + }), + find: stripeMethod({ + method: 'GET', + fullPath: '/v1/apps/secrets/find', + }), }); diff --git a/lib/resources/Balance.js b/lib/resources/Balance.js index d1d9b4f30f..84378bb100 100644 --- a/lib/resources/Balance.js +++ b/lib/resources/Balance.js @@ -3,8 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/balance', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/balance', + }), }); diff --git a/lib/resources/BalanceTransactions.js b/lib/resources/BalanceTransactions.js index eb5317a777..3e205b9dc5 100644 --- a/lib/resources/BalanceTransactions.js +++ b/lib/resources/BalanceTransactions.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/balance_transactions/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/balance_transactions', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/balance_transactions/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/balance_transactions', + methodType: 'list', + }), }); diff --git a/lib/resources/BillingPortal/Configurations.js b/lib/resources/BillingPortal/Configurations.js index a64e367e19..df450890e9 100644 --- a/lib/resources/BillingPortal/Configurations.js +++ b/lib/resources/BillingPortal/Configurations.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/billing_portal/configurations', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/billing_portal/configurations/{configuration}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/billing_portal/configurations/{configuration}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/billing_portal/configurations', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/billing_portal/configurations', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/billing_portal/configurations/{configuration}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/billing_portal/configurations/{configuration}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/billing_portal/configurations', + methodType: 'list', + }), }); diff --git a/lib/resources/BillingPortal/Sessions.js b/lib/resources/BillingPortal/Sessions.js index 04ce6efafc..db2e2e5d2a 100644 --- a/lib/resources/BillingPortal/Sessions.js +++ b/lib/resources/BillingPortal/Sessions.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/billing_portal/sessions', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/billing_portal/sessions', + }), }); diff --git a/lib/resources/Charges.js b/lib/resources/Charges.js index f329f6b36e..6e3302700c 100644 --- a/lib/resources/Charges.js +++ b/lib/resources/Charges.js @@ -3,30 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/charges', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/charges/{charge}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/charges/{charge}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/charges', - methodType: 'list', - }), - capture: stripeMethod({ - method: 'POST', - fullPath: '/v1/charges/{charge}/capture', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/charges/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/charges', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/charges/{charge}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/charges/{charge}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/charges', + methodType: 'list', + }), + capture: stripeMethod({ + method: 'POST', + fullPath: '/v1/charges/{charge}/capture', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/charges/search', + methodType: 'search', + }), }); diff --git a/lib/resources/Checkout/Sessions.js b/lib/resources/Checkout/Sessions.js index 40adb4662a..ecaafb11d2 100644 --- a/lib/resources/Checkout/Sessions.js +++ b/lib/resources/Checkout/Sessions.js @@ -3,26 +3,26 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/checkout/sessions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/checkout/sessions/{session}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/checkout/sessions', - methodType: 'list', - }), - expire: stripeMethod({ - method: 'POST', - fullPath: '/v1/checkout/sessions/{session}/expire', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/checkout/sessions/{session}/line_items', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/checkout/sessions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/checkout/sessions/{session}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/checkout/sessions', + methodType: 'list', + }), + expire: stripeMethod({ + method: 'POST', + fullPath: '/v1/checkout/sessions/{session}/expire', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/checkout/sessions/{session}/line_items', + methodType: 'list', + }), }); diff --git a/lib/resources/CountrySpecs.js b/lib/resources/CountrySpecs.js index 8aefedb58f..6a9d410b4d 100644 --- a/lib/resources/CountrySpecs.js +++ b/lib/resources/CountrySpecs.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/country_specs/{country}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/country_specs', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/country_specs/{country}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/country_specs', + methodType: 'list', + }), }); diff --git a/lib/resources/Coupons.js b/lib/resources/Coupons.js index 468338f603..043eeead74 100644 --- a/lib/resources/Coupons.js +++ b/lib/resources/Coupons.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/coupons', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/coupons/{coupon}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/coupons/{coupon}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/coupons', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/coupons/{coupon}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/coupons', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/coupons/{coupon}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/coupons/{coupon}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/coupons', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/coupons/{coupon}', + }), }); diff --git a/lib/resources/CreditNotes.js b/lib/resources/CreditNotes.js index 2b2f42f4c8..6574070881 100644 --- a/lib/resources/CreditNotes.js +++ b/lib/resources/CreditNotes.js @@ -3,39 +3,39 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/credit_notes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/{id}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/credit_notes/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes', - methodType: 'list', - }), - listPreviewLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/preview/lines', - methodType: 'list', - }), - preview: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/preview', - }), - voidCreditNote: stripeMethod({ - method: 'POST', - fullPath: '/v1/credit_notes/{id}/void', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/credit_notes/{credit_note}/lines', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/credit_notes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/{id}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/credit_notes/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes', + methodType: 'list', + }), + listPreviewLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/preview/lines', + methodType: 'list', + }), + preview: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/preview', + }), + voidCreditNote: stripeMethod({ + method: 'POST', + fullPath: '/v1/credit_notes/{id}/void', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/credit_notes/{credit_note}/lines', + methodType: 'list', + }), }); diff --git a/lib/resources/Customers.js b/lib/resources/Customers.js index 5196f84898..0c98e91590 100644 --- a/lib/resources/Customers.js +++ b/lib/resources/Customers.js @@ -3,123 +3,124 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}', - }), - createFundingInstructions: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/funding_instructions', - }), - deleteDiscount: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}/discount', - }), - listPaymentMethods: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/payment_methods', - methodType: 'list', - }), - retrievePaymentMethod: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/payment_methods/{payment_method}', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/search', - methodType: 'search', - }), - retrieveCashBalance: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/cash_balance', - }), - updateCashBalance: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/cash_balance', - }), - createBalanceTransaction: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/balance_transactions', - }), - retrieveBalanceTransaction: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', - }), - updateBalanceTransaction: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', - }), - listBalanceTransactions: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/balance_transactions', - methodType: 'list', - }), - retrieveCashBalanceTransaction: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/cash_balance_transactions/{transaction}', - }), - listCashBalanceTransactions: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/cash_balance_transactions', - methodType: 'list', - }), - createSource: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/sources', - }), - retrieveSource: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/sources/{id}', - }), - updateSource: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/sources/{id}', - }), - listSources: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/sources', - methodType: 'list', - }), - deleteSource: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}/sources/{id}', - }), - verifySource: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/sources/{id}/verify', - }), - createTaxId: stripeMethod({ - method: 'POST', - fullPath: '/v1/customers/{customer}/tax_ids', - }), - retrieveTaxId: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/tax_ids/{id}', - }), - listTaxIds: stripeMethod({ - method: 'GET', - fullPath: '/v1/customers/{customer}/tax_ids', - methodType: 'list', - }), - deleteTaxId: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/customers/{customer}/tax_ids/{id}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}', + }), + createFundingInstructions: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/funding_instructions', + }), + deleteDiscount: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}/discount', + }), + listPaymentMethods: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/payment_methods', + methodType: 'list', + }), + retrievePaymentMethod: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/payment_methods/{payment_method}', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/search', + methodType: 'search', + }), + retrieveCashBalance: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/cash_balance', + }), + updateCashBalance: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/cash_balance', + }), + createBalanceTransaction: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/balance_transactions', + }), + retrieveBalanceTransaction: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', + }), + updateBalanceTransaction: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/balance_transactions/{transaction}', + }), + listBalanceTransactions: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/balance_transactions', + methodType: 'list', + }), + retrieveCashBalanceTransaction: stripeMethod({ + method: 'GET', + fullPath: + '/v1/customers/{customer}/cash_balance_transactions/{transaction}', + }), + listCashBalanceTransactions: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/cash_balance_transactions', + methodType: 'list', + }), + createSource: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/sources', + }), + retrieveSource: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/sources/{id}', + }), + updateSource: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/sources/{id}', + }), + listSources: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/sources', + methodType: 'list', + }), + deleteSource: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}/sources/{id}', + }), + verifySource: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/sources/{id}/verify', + }), + createTaxId: stripeMethod({ + method: 'POST', + fullPath: '/v1/customers/{customer}/tax_ids', + }), + retrieveTaxId: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', + }), + listTaxIds: stripeMethod({ + method: 'GET', + fullPath: '/v1/customers/{customer}/tax_ids', + methodType: 'list', + }), + deleteTaxId: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/customers/{customer}/tax_ids/{id}', + }), }); diff --git a/lib/resources/Disputes.js b/lib/resources/Disputes.js index 849bd4ce68..3679668634 100644 --- a/lib/resources/Disputes.js +++ b/lib/resources/Disputes.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/disputes/{dispute}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/disputes/{dispute}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/disputes', - methodType: 'list', - }), - close: stripeMethod({ - method: 'POST', - fullPath: '/v1/disputes/{dispute}/close', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/disputes/{dispute}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/disputes/{dispute}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/disputes', + methodType: 'list', + }), + close: stripeMethod({ + method: 'POST', + fullPath: '/v1/disputes/{dispute}/close', + }), }); diff --git a/lib/resources/EphemeralKeys.js b/lib/resources/EphemeralKeys.js index 4672229799..186a3b091e 100644 --- a/lib/resources/EphemeralKeys.js +++ b/lib/resources/EphemeralKeys.js @@ -3,17 +3,19 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/ephemeral_keys', - validator: (data, options) => { - if (!options.headers || !options.headers['Stripe-Version']) { - throw new Error('Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node'); - } - }, - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/ephemeral_keys/{key}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/ephemeral_keys', + validator: (data, options) => { + if (!options.headers || !options.headers['Stripe-Version']) { + throw new Error( + 'Passing apiVersion in a separate options hash is required to create an ephemeral key. See https://stripe.com/docs/api/versioning?lang=node' + ); + } + }, + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/ephemeral_keys/{key}', + }), }); diff --git a/lib/resources/Events.js b/lib/resources/Events.js index b33d17b056..e148e305ae 100644 --- a/lib/resources/Events.js +++ b/lib/resources/Events.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/events/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/events', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/events/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/events', + methodType: 'list', + }), }); diff --git a/lib/resources/ExchangeRates.js b/lib/resources/ExchangeRates.js index b1d58339a7..f92da86aab 100644 --- a/lib/resources/ExchangeRates.js +++ b/lib/resources/ExchangeRates.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/exchange_rates/{rate_id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/exchange_rates', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/exchange_rates/{rate_id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/exchange_rates', + methodType: 'list', + }), }); diff --git a/lib/resources/FileLinks.js b/lib/resources/FileLinks.js index 3d3b0b9281..b474227b31 100644 --- a/lib/resources/FileLinks.js +++ b/lib/resources/FileLinks.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/file_links', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/file_links/{link}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/file_links/{link}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/file_links', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/file_links', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/file_links/{link}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/file_links/{link}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/file_links', + methodType: 'list', + }), }); diff --git a/lib/resources/Files.js b/lib/resources/Files.js index 4b86ed3daa..11856b1323 100644 --- a/lib/resources/Files.js +++ b/lib/resources/Files.js @@ -1,25 +1,25 @@ // File generated from our OpenAPI spec 'use strict'; -const { multipartRequestDataProcessor } = require('../multipart'); +const {multipartRequestDataProcessor} = require('../multipart'); const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/files', - headers: { - 'Content-Type': 'multipart/form-data', - }, - host: 'files.stripe.com', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/files/{file}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/files', - methodType: 'list', - }), - requestDataProcessor: multipartRequestDataProcessor, + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/files', + headers: { + 'Content-Type': 'multipart/form-data', + }, + host: 'files.stripe.com', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/files/{file}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/files', + methodType: 'list', + }), + requestDataProcessor: multipartRequestDataProcessor, }); diff --git a/lib/resources/FinancialConnections/Accounts.js b/lib/resources/FinancialConnections/Accounts.js index edd9ed420a..8ce36e37b2 100644 --- a/lib/resources/FinancialConnections/Accounts.js +++ b/lib/resources/FinancialConnections/Accounts.js @@ -3,26 +3,26 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/accounts/{account}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/accounts', - methodType: 'list', - }), - disconnect: stripeMethod({ - method: 'POST', - fullPath: '/v1/financial_connections/accounts/{account}/disconnect', - }), - listOwners: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/accounts/{account}/owners', - methodType: 'list', - }), - refresh: stripeMethod({ - method: 'POST', - fullPath: '/v1/financial_connections/accounts/{account}/refresh', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/accounts/{account}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/accounts', + methodType: 'list', + }), + disconnect: stripeMethod({ + method: 'POST', + fullPath: '/v1/financial_connections/accounts/{account}/disconnect', + }), + listOwners: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/accounts/{account}/owners', + methodType: 'list', + }), + refresh: stripeMethod({ + method: 'POST', + fullPath: '/v1/financial_connections/accounts/{account}/refresh', + }), }); diff --git a/lib/resources/FinancialConnections/Sessions.js b/lib/resources/FinancialConnections/Sessions.js index 227c39104a..b5bbb4c641 100644 --- a/lib/resources/FinancialConnections/Sessions.js +++ b/lib/resources/FinancialConnections/Sessions.js @@ -3,12 +3,12 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/financial_connections/sessions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/financial_connections/sessions/{session}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/financial_connections/sessions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/financial_connections/sessions/{session}', + }), }); diff --git a/lib/resources/Identity/VerificationReports.js b/lib/resources/Identity/VerificationReports.js index 1ceb56339c..3bd584a265 100644 --- a/lib/resources/Identity/VerificationReports.js +++ b/lib/resources/Identity/VerificationReports.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_reports/{report}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_reports', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_reports/{report}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_reports', + methodType: 'list', + }), }); diff --git a/lib/resources/Identity/VerificationSessions.js b/lib/resources/Identity/VerificationSessions.js index 4984233d1b..e9d3b72e87 100644 --- a/lib/resources/Identity/VerificationSessions.js +++ b/lib/resources/Identity/VerificationSessions.js @@ -3,29 +3,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_sessions/{session}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions/{session}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/identity/verification_sessions', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions/{session}/cancel', - }), - redact: stripeMethod({ - method: 'POST', - fullPath: '/v1/identity/verification_sessions/{session}/redact', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_sessions/{session}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions/{session}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/identity/verification_sessions', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions/{session}/cancel', + }), + redact: stripeMethod({ + method: 'POST', + fullPath: '/v1/identity/verification_sessions/{session}/redact', + }), }); diff --git a/lib/resources/InvoiceItems.js b/lib/resources/InvoiceItems.js index cafc142981..1a961fddb8 100644 --- a/lib/resources/InvoiceItems.js +++ b/lib/resources/InvoiceItems.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoiceitems', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoiceitems/{invoiceitem}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoiceitems/{invoiceitem}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoiceitems', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/invoiceitems/{invoiceitem}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoiceitems', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoiceitems/{invoiceitem}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoiceitems/{invoiceitem}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoiceitems', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/invoiceitems/{invoiceitem}', + }), }); diff --git a/lib/resources/Invoices.js b/lib/resources/Invoices.js index 7516508fac..e1ac39f34f 100644 --- a/lib/resources/Invoices.js +++ b/lib/resources/Invoices.js @@ -3,64 +3,64 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/{invoice}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/invoices/{invoice}', - }), - finalizeInvoice: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/finalize', - }), - listUpcomingLines: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/upcoming/lines', - methodType: 'list', - }), - markUncollectible: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/mark_uncollectible', - }), - pay: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/pay', - }), - retrieveUpcoming: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/upcoming', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/search', - methodType: 'search', - }), - sendInvoice: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/send', - }), - voidInvoice: stripeMethod({ - method: 'POST', - fullPath: '/v1/invoices/{invoice}/void', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/invoices/{invoice}/lines', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/{invoice}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/invoices/{invoice}', + }), + finalizeInvoice: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/finalize', + }), + listUpcomingLines: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/upcoming/lines', + methodType: 'list', + }), + markUncollectible: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/mark_uncollectible', + }), + pay: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/pay', + }), + retrieveUpcoming: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/upcoming', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/search', + methodType: 'search', + }), + sendInvoice: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/send', + }), + voidInvoice: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/void', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/invoices/{invoice}/lines', + methodType: 'list', + }), }); diff --git a/lib/resources/Issuing/Authorizations.js b/lib/resources/Issuing/Authorizations.js index 6692720c8f..7d9e894b97 100644 --- a/lib/resources/Issuing/Authorizations.js +++ b/lib/resources/Issuing/Authorizations.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/authorizations/{authorization}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/authorizations/{authorization}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/authorizations', - methodType: 'list', - }), - approve: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/authorizations/{authorization}/approve', - }), - decline: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/authorizations/{authorization}/decline', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/authorizations/{authorization}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/authorizations/{authorization}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/authorizations', + methodType: 'list', + }), + approve: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/authorizations/{authorization}/approve', + }), + decline: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/authorizations/{authorization}/decline', + }), }); diff --git a/lib/resources/Issuing/Cardholders.js b/lib/resources/Issuing/Cardholders.js index ea37a76d1c..a76764eba3 100644 --- a/lib/resources/Issuing/Cardholders.js +++ b/lib/resources/Issuing/Cardholders.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cardholders', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cardholders/{cardholder}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cardholders/{cardholder}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cardholders', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cardholders', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cardholders/{cardholder}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cardholders/{cardholder}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cardholders', + methodType: 'list', + }), }); diff --git a/lib/resources/Issuing/Cards.js b/lib/resources/Issuing/Cards.js index dd63dae5a9..98cc817f1e 100644 --- a/lib/resources/Issuing/Cards.js +++ b/lib/resources/Issuing/Cards.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cards', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cards/{card}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/cards/{card}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/cards', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cards', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cards/{card}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/cards/{card}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/cards', + methodType: 'list', + }), }); diff --git a/lib/resources/Issuing/Disputes.js b/lib/resources/Issuing/Disputes.js index 012f81575f..803d4b6149 100644 --- a/lib/resources/Issuing/Disputes.js +++ b/lib/resources/Issuing/Disputes.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/disputes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/disputes/{dispute}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/disputes/{dispute}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/disputes', - methodType: 'list', - }), - submit: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/disputes/{dispute}/submit', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/disputes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/disputes/{dispute}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/disputes/{dispute}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/disputes', + methodType: 'list', + }), + submit: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/disputes/{dispute}/submit', + }), }); diff --git a/lib/resources/Issuing/Transactions.js b/lib/resources/Issuing/Transactions.js index c6603cbedb..789dd7e3df 100644 --- a/lib/resources/Issuing/Transactions.js +++ b/lib/resources/Issuing/Transactions.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/transactions/{transaction}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/issuing/transactions/{transaction}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/issuing/transactions', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/transactions/{transaction}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/issuing/transactions/{transaction}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/issuing/transactions', + methodType: 'list', + }), }); diff --git a/lib/resources/Mandates.js b/lib/resources/Mandates.js index b8d12d70db..06240ae2d2 100644 --- a/lib/resources/Mandates.js +++ b/lib/resources/Mandates.js @@ -3,8 +3,8 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/mandates/{mandate}', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/mandates/{mandate}', + }), }); diff --git a/lib/resources/OAuth.js b/lib/resources/OAuth.js index 6248fa5929..2c04c5fb7b 100644 --- a/lib/resources/OAuth.js +++ b/lib/resources/OAuth.js @@ -4,39 +4,39 @@ const stripeMethod = StripeResource.method; const utils = require('../utils'); const oAuthHost = 'connect.stripe.com'; module.exports = StripeResource.extend({ - basePath: '/', - authorizeUrl(params, options) { - params = params || {}; - options = options || {}; - let path = 'oauth/authorize'; - // For Express accounts, the path changes - if (options.express) { - path = `express/${path}`; - } - if (!params.response_type) { - params.response_type = 'code'; - } - if (!params.client_id) { - params.client_id = this._stripe.getClientId(); - } - if (!params.scope) { - params.scope = 'read_write'; - } - return `https://${oAuthHost}/${path}?${utils.stringifyRequestData(params)}`; - }, - token: stripeMethod({ - method: 'POST', - path: 'oauth/token', - host: oAuthHost, - }), - deauthorize(spec) { - if (!spec.client_id) { - spec.client_id = this._stripe.getClientId(); - } - return stripeMethod({ - method: 'POST', - path: 'oauth/deauthorize', - host: oAuthHost, - }).apply(this, arguments); - }, + basePath: '/', + authorizeUrl(params, options) { + params = params || {}; + options = options || {}; + let path = 'oauth/authorize'; + // For Express accounts, the path changes + if (options.express) { + path = `express/${path}`; + } + if (!params.response_type) { + params.response_type = 'code'; + } + if (!params.client_id) { + params.client_id = this._stripe.getClientId(); + } + if (!params.scope) { + params.scope = 'read_write'; + } + return `https://${oAuthHost}/${path}?${utils.stringifyRequestData(params)}`; + }, + token: stripeMethod({ + method: 'POST', + path: 'oauth/token', + host: oAuthHost, + }), + deauthorize(spec) { + if (!spec.client_id) { + spec.client_id = this._stripe.getClientId(); + } + return stripeMethod({ + method: 'POST', + path: 'oauth/deauthorize', + host: oAuthHost, + }).apply(this, arguments); + }, }); diff --git a/lib/resources/PaymentIntents.js b/lib/resources/PaymentIntents.js index 4e464c0a31..963f1688e6 100644 --- a/lib/resources/PaymentIntents.js +++ b/lib/resources/PaymentIntents.js @@ -3,50 +3,50 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_intents/{intent}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_intents', - methodType: 'list', - }), - applyCustomerBalance: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/apply_customer_balance', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/cancel', - }), - capture: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/capture', - }), - confirm: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/confirm', - }), - incrementAuthorization: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/increment_authorization', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_intents/search', - methodType: 'search', - }), - verifyMicrodeposits: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_intents/{intent}/verify_microdeposits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_intents/{intent}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_intents', + methodType: 'list', + }), + applyCustomerBalance: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/apply_customer_balance', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/cancel', + }), + capture: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/capture', + }), + confirm: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/confirm', + }), + incrementAuthorization: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/increment_authorization', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_intents/search', + methodType: 'search', + }), + verifyMicrodeposits: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_intents/{intent}/verify_microdeposits', + }), }); diff --git a/lib/resources/PaymentLinks.js b/lib/resources/PaymentLinks.js index e693fc9477..86acf3cb8c 100644 --- a/lib/resources/PaymentLinks.js +++ b/lib/resources/PaymentLinks.js @@ -3,26 +3,26 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_links', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_links/{payment_link}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_links/{payment_link}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_links', - methodType: 'list', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_links/{payment_link}/line_items', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_links', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_links/{payment_link}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_links/{payment_link}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_links', + methodType: 'list', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_links/{payment_link}/line_items', + methodType: 'list', + }), }); diff --git a/lib/resources/PaymentMethods.js b/lib/resources/PaymentMethods.js index 3ce80ec613..85fc630698 100644 --- a/lib/resources/PaymentMethods.js +++ b/lib/resources/PaymentMethods.js @@ -3,29 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_methods/{payment_method}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods/{payment_method}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payment_methods', - methodType: 'list', - }), - attach: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods/{payment_method}/attach', - }), - detach: stripeMethod({ - method: 'POST', - fullPath: '/v1/payment_methods/{payment_method}/detach', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_methods/{payment_method}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods/{payment_method}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payment_methods', + methodType: 'list', + }), + attach: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods/{payment_method}/attach', + }), + detach: stripeMethod({ + method: 'POST', + fullPath: '/v1/payment_methods/{payment_method}/detach', + }), }); diff --git a/lib/resources/Payouts.js b/lib/resources/Payouts.js index aff8a90ed0..fd8ddde975 100644 --- a/lib/resources/Payouts.js +++ b/lib/resources/Payouts.js @@ -3,29 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/payouts/{payout}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts/{payout}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/payouts', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts/{payout}/cancel', - }), - reverse: stripeMethod({ - method: 'POST', - fullPath: '/v1/payouts/{payout}/reverse', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/payouts/{payout}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts/{payout}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/payouts', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts/{payout}/cancel', + }), + reverse: stripeMethod({ + method: 'POST', + fullPath: '/v1/payouts/{payout}/reverse', + }), }); diff --git a/lib/resources/Plans.js b/lib/resources/Plans.js index 0f96cb98e9..a39523bd8c 100644 --- a/lib/resources/Plans.js +++ b/lib/resources/Plans.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/plans', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/plans/{plan}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/plans/{plan}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/plans', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/plans/{plan}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/plans', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/plans/{plan}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/plans/{plan}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/plans', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/plans/{plan}', + }), }); diff --git a/lib/resources/Prices.js b/lib/resources/Prices.js index f9b7cb801d..7406e1362f 100644 --- a/lib/resources/Prices.js +++ b/lib/resources/Prices.js @@ -3,26 +3,26 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/prices', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/prices/{price}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/prices/{price}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/prices', - methodType: 'list', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/prices/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/prices', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/prices/{price}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/prices/{price}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/prices', + methodType: 'list', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/prices/search', + methodType: 'search', + }), }); diff --git a/lib/resources/Products.js b/lib/resources/Products.js index f25ddf8daa..eba8e78d30 100644 --- a/lib/resources/Products.js +++ b/lib/resources/Products.js @@ -3,30 +3,30 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/products', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/products/{id}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/products/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/products', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/products/{id}', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/products/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/products', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/products/{id}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/products/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/products', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/products/{id}', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/products/search', + methodType: 'search', + }), }); diff --git a/lib/resources/PromotionCodes.js b/lib/resources/PromotionCodes.js index de58217d82..e112795f02 100644 --- a/lib/resources/PromotionCodes.js +++ b/lib/resources/PromotionCodes.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/promotion_codes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/promotion_codes/{promotion_code}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/promotion_codes/{promotion_code}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/promotion_codes', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/promotion_codes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/promotion_codes/{promotion_code}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/promotion_codes/{promotion_code}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/promotion_codes', + methodType: 'list', + }), }); diff --git a/lib/resources/Quotes.js b/lib/resources/Quotes.js index 8e9a82007d..f5c97a375b 100644 --- a/lib/resources/Quotes.js +++ b/lib/resources/Quotes.js @@ -3,49 +3,49 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes/{quote}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes', - methodType: 'list', - }), - accept: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}/accept', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}/cancel', - }), - finalizeQuote: stripeMethod({ - method: 'POST', - fullPath: '/v1/quotes/{quote}/finalize', - }), - listComputedUpfrontLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes/{quote}/computed_upfront_line_items', - methodType: 'list', - }), - listLineItems: stripeMethod({ - method: 'GET', - fullPath: '/v1/quotes/{quote}/line_items', - methodType: 'list', - }), - pdf: stripeMethod({ - host: 'files.stripe.com', - method: 'GET', - fullPath: '/v1/quotes/{quote}/pdf', - streaming: true, - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes/{quote}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes', + methodType: 'list', + }), + accept: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}/accept', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}/cancel', + }), + finalizeQuote: stripeMethod({ + method: 'POST', + fullPath: '/v1/quotes/{quote}/finalize', + }), + listComputedUpfrontLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes/{quote}/computed_upfront_line_items', + methodType: 'list', + }), + listLineItems: stripeMethod({ + method: 'GET', + fullPath: '/v1/quotes/{quote}/line_items', + methodType: 'list', + }), + pdf: stripeMethod({ + host: 'files.stripe.com', + method: 'GET', + fullPath: '/v1/quotes/{quote}/pdf', + streaming: true, + }), }); diff --git a/lib/resources/Radar/EarlyFraudWarnings.js b/lib/resources/Radar/EarlyFraudWarnings.js index dd609bed95..5eaf23768a 100644 --- a/lib/resources/Radar/EarlyFraudWarnings.js +++ b/lib/resources/Radar/EarlyFraudWarnings.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/early_fraud_warnings/{early_fraud_warning}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/early_fraud_warnings', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/early_fraud_warnings/{early_fraud_warning}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/early_fraud_warnings', + methodType: 'list', + }), }); diff --git a/lib/resources/Radar/ValueListItems.js b/lib/resources/Radar/ValueListItems.js index 864c7897f4..4fd46fd0ac 100644 --- a/lib/resources/Radar/ValueListItems.js +++ b/lib/resources/Radar/ValueListItems.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/radar/value_list_items', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_list_items/{item}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_list_items', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/radar/value_list_items/{item}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/radar/value_list_items', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_list_items/{item}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_list_items', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/radar/value_list_items/{item}', + }), }); diff --git a/lib/resources/Radar/ValueLists.js b/lib/resources/Radar/ValueLists.js index 90b8c66eeb..e89b5500c8 100644 --- a/lib/resources/Radar/ValueLists.js +++ b/lib/resources/Radar/ValueLists.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/radar/value_lists', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_lists/{value_list}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/radar/value_lists/{value_list}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/radar/value_lists', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/radar/value_lists/{value_list}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/radar/value_lists', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_lists/{value_list}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/radar/value_lists/{value_list}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/radar/value_lists', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/radar/value_lists/{value_list}', + }), }); diff --git a/lib/resources/Refunds.js b/lib/resources/Refunds.js index 095193f9f9..87d3f6e1dc 100644 --- a/lib/resources/Refunds.js +++ b/lib/resources/Refunds.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/refunds', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/refunds/{refund}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/refunds/{refund}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/refunds', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/refunds/{refund}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/refunds', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/refunds/{refund}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/refunds/{refund}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/refunds', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/refunds/{refund}/cancel', + }), }); diff --git a/lib/resources/Reporting/ReportRuns.js b/lib/resources/Reporting/ReportRuns.js index 859e672af2..d6e853aff0 100644 --- a/lib/resources/Reporting/ReportRuns.js +++ b/lib/resources/Reporting/ReportRuns.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/reporting/report_runs', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_runs/{report_run}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_runs', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/reporting/report_runs', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_runs/{report_run}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_runs', + methodType: 'list', + }), }); diff --git a/lib/resources/Reporting/ReportTypes.js b/lib/resources/Reporting/ReportTypes.js index 87371048df..58e8075460 100644 --- a/lib/resources/Reporting/ReportTypes.js +++ b/lib/resources/Reporting/ReportTypes.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_types/{report_type}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/reporting/report_types', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_types/{report_type}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/reporting/report_types', + methodType: 'list', + }), }); diff --git a/lib/resources/Reviews.js b/lib/resources/Reviews.js index 498fbac1b7..201fbc1d64 100644 --- a/lib/resources/Reviews.js +++ b/lib/resources/Reviews.js @@ -3,17 +3,17 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/reviews/{review}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/reviews', - methodType: 'list', - }), - approve: stripeMethod({ - method: 'POST', - fullPath: '/v1/reviews/{review}/approve', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/reviews/{review}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/reviews', + methodType: 'list', + }), + approve: stripeMethod({ + method: 'POST', + fullPath: '/v1/reviews/{review}/approve', + }), }); diff --git a/lib/resources/SetupAttempts.js b/lib/resources/SetupAttempts.js index a7062e23ea..36f232f4b9 100644 --- a/lib/resources/SetupAttempts.js +++ b/lib/resources/SetupAttempts.js @@ -3,9 +3,9 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/setup_attempts', - methodType: 'list', - }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/setup_attempts', + methodType: 'list', + }), }); diff --git a/lib/resources/SetupIntents.js b/lib/resources/SetupIntents.js index 57f76595b6..9ce7ca7231 100644 --- a/lib/resources/SetupIntents.js +++ b/lib/resources/SetupIntents.js @@ -3,33 +3,33 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/setup_intents/{intent}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/setup_intents', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}/cancel', - }), - confirm: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}/confirm', - }), - verifyMicrodeposits: stripeMethod({ - method: 'POST', - fullPath: '/v1/setup_intents/{intent}/verify_microdeposits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/setup_intents/{intent}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/setup_intents', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}/cancel', + }), + confirm: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}/confirm', + }), + verifyMicrodeposits: stripeMethod({ + method: 'POST', + fullPath: '/v1/setup_intents/{intent}/verify_microdeposits', + }), }); diff --git a/lib/resources/ShippingRates.js b/lib/resources/ShippingRates.js index 7a7ebce845..abda3a77c0 100644 --- a/lib/resources/ShippingRates.js +++ b/lib/resources/ShippingRates.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/shipping_rates', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/shipping_rates/{shipping_rate_token}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/shipping_rates/{shipping_rate_token}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/shipping_rates', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/shipping_rates', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/shipping_rates/{shipping_rate_token}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/shipping_rates', + methodType: 'list', + }), }); diff --git a/lib/resources/Sigma/ScheduledQueryRuns.js b/lib/resources/Sigma/ScheduledQueryRuns.js index a20907900e..4e6c7211a1 100644 --- a/lib/resources/Sigma/ScheduledQueryRuns.js +++ b/lib/resources/Sigma/ScheduledQueryRuns.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/sigma/scheduled_query_runs/{scheduled_query_run}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/sigma/scheduled_query_runs', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/sigma/scheduled_query_runs/{scheduled_query_run}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/sigma/scheduled_query_runs', + methodType: 'list', + }), }); diff --git a/lib/resources/Sources.js b/lib/resources/Sources.js index cdd7efb728..e26f8ad3b9 100644 --- a/lib/resources/Sources.js +++ b/lib/resources/Sources.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/sources', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/sources/{source}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/sources/{source}', - }), - listSourceTransactions: stripeMethod({ - method: 'GET', - fullPath: '/v1/sources/{source}/source_transactions', - methodType: 'list', - }), - verify: stripeMethod({ - method: 'POST', - fullPath: '/v1/sources/{source}/verify', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/sources', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/sources/{source}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/sources/{source}', + }), + listSourceTransactions: stripeMethod({ + method: 'GET', + fullPath: '/v1/sources/{source}/source_transactions', + methodType: 'list', + }), + verify: stripeMethod({ + method: 'POST', + fullPath: '/v1/sources/{source}/verify', + }), }); diff --git a/lib/resources/SubscriptionItems.js b/lib/resources/SubscriptionItems.js index 523456507a..7681fb88ac 100644 --- a/lib/resources/SubscriptionItems.js +++ b/lib/resources/SubscriptionItems.js @@ -3,34 +3,35 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_items', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_items/{item}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_items/{item}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_items', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscription_items/{item}', - }), - createUsageRecord: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_items/{subscription_item}/usage_records', - }), - listUsageRecordSummaries: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_items/{subscription_item}/usage_record_summaries', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_items', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_items/{item}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_items/{item}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_items', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscription_items/{item}', + }), + createUsageRecord: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_items/{subscription_item}/usage_records', + }), + listUsageRecordSummaries: stripeMethod({ + method: 'GET', + fullPath: + '/v1/subscription_items/{subscription_item}/usage_record_summaries', + methodType: 'list', + }), }); diff --git a/lib/resources/SubscriptionSchedules.js b/lib/resources/SubscriptionSchedules.js index 5027db2604..c2d3e634f3 100644 --- a/lib/resources/SubscriptionSchedules.js +++ b/lib/resources/SubscriptionSchedules.js @@ -3,29 +3,29 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_schedules/{schedule}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules/{schedule}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscription_schedules', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules/{schedule}/cancel', - }), - release: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscription_schedules/{schedule}/release', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_schedules/{schedule}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules/{schedule}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscription_schedules', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules/{schedule}/cancel', + }), + release: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscription_schedules/{schedule}/release', + }), }); diff --git a/lib/resources/Subscriptions.js b/lib/resources/Subscriptions.js index cbcebdf8a0..4790d2d0ca 100644 --- a/lib/resources/Subscriptions.js +++ b/lib/resources/Subscriptions.js @@ -3,38 +3,38 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscriptions', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscriptions', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscriptions/{subscription_exposed_id}', - }), - deleteDiscount: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/subscriptions/{subscription_exposed_id}/discount', - }), - search: stripeMethod({ - method: 'GET', - fullPath: '/v1/subscriptions/search', - methodType: 'search', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscriptions', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscriptions', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscriptions/{subscription_exposed_id}', + }), + deleteDiscount: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/subscriptions/{subscription_exposed_id}/discount', + }), + search: stripeMethod({ + method: 'GET', + fullPath: '/v1/subscriptions/search', + methodType: 'search', + }), }); diff --git a/lib/resources/TaxCodes.js b/lib/resources/TaxCodes.js index 84b9e9c403..d590878674 100644 --- a/lib/resources/TaxCodes.js +++ b/lib/resources/TaxCodes.js @@ -3,13 +3,13 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_codes/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_codes', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_codes/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_codes', + methodType: 'list', + }), }); diff --git a/lib/resources/TaxRates.js b/lib/resources/TaxRates.js index 6222ec54a3..e4975933ad 100644 --- a/lib/resources/TaxRates.js +++ b/lib/resources/TaxRates.js @@ -3,21 +3,21 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/tax_rates', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_rates/{tax_rate}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/tax_rates/{tax_rate}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/tax_rates', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/tax_rates', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_rates/{tax_rate}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/tax_rates/{tax_rate}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/tax_rates', + methodType: 'list', + }), }); diff --git a/lib/resources/Terminal/Configurations.js b/lib/resources/Terminal/Configurations.js index 5b2b48bff2..02c8297c27 100644 --- a/lib/resources/Terminal/Configurations.js +++ b/lib/resources/Terminal/Configurations.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/configurations', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/configurations/{configuration}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/configurations/{configuration}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/configurations', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/terminal/configurations/{configuration}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/configurations', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/configurations/{configuration}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/configurations/{configuration}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/configurations', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/terminal/configurations/{configuration}', + }), }); diff --git a/lib/resources/Terminal/ConnectionTokens.js b/lib/resources/Terminal/ConnectionTokens.js index 03b0ddef19..640a6b8712 100644 --- a/lib/resources/Terminal/ConnectionTokens.js +++ b/lib/resources/Terminal/ConnectionTokens.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/connection_tokens', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/connection_tokens', + }), }); diff --git a/lib/resources/Terminal/Locations.js b/lib/resources/Terminal/Locations.js index 9179d077f8..6b893361a6 100644 --- a/lib/resources/Terminal/Locations.js +++ b/lib/resources/Terminal/Locations.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/locations', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/locations/{location}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/locations/{location}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/locations', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/terminal/locations/{location}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/locations', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/locations/{location}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/locations/{location}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/locations', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/terminal/locations/{location}', + }), }); diff --git a/lib/resources/Terminal/Readers.js b/lib/resources/Terminal/Readers.js index dc5ae95d8e..879835e91c 100644 --- a/lib/resources/Terminal/Readers.js +++ b/lib/resources/Terminal/Readers.js @@ -3,41 +3,41 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/readers/{reader}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/terminal/readers', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/terminal/readers/{reader}', - }), - cancelAction: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/cancel_action', - }), - processPaymentIntent: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/process_payment_intent', - }), - processSetupIntent: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/process_setup_intent', - }), - setReaderDisplay: stripeMethod({ - method: 'POST', - fullPath: '/v1/terminal/readers/{reader}/set_reader_display', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/readers/{reader}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/terminal/readers', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/terminal/readers/{reader}', + }), + cancelAction: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/cancel_action', + }), + processPaymentIntent: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/process_payment_intent', + }), + processSetupIntent: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/process_setup_intent', + }), + setReaderDisplay: stripeMethod({ + method: 'POST', + fullPath: '/v1/terminal/readers/{reader}/set_reader_display', + }), }); diff --git a/lib/resources/TestHelpers/Customers.js b/lib/resources/TestHelpers/Customers.js index 16044f0d62..98bb0b651f 100644 --- a/lib/resources/TestHelpers/Customers.js +++ b/lib/resources/TestHelpers/Customers.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fundCashBalance: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/customers/{customer}/fund_cash_balance', - }), + fundCashBalance: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/customers/{customer}/fund_cash_balance', + }), }); diff --git a/lib/resources/TestHelpers/Issuing/Cards.js b/lib/resources/TestHelpers/Issuing/Cards.js index 6da5bca5bb..4e13f2245e 100644 --- a/lib/resources/TestHelpers/Issuing/Cards.js +++ b/lib/resources/TestHelpers/Issuing/Cards.js @@ -3,20 +3,20 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - deliverCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/deliver', - }), - failCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/fail', - }), - returnCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/return', - }), - shipCard: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/ship', - }), + deliverCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/deliver', + }), + failCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/fail', + }), + returnCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/return', + }), + shipCard: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/issuing/cards/{card}/shipping/ship', + }), }); diff --git a/lib/resources/TestHelpers/Refunds.js b/lib/resources/TestHelpers/Refunds.js index 79e16e8ae9..79f2f221bc 100644 --- a/lib/resources/TestHelpers/Refunds.js +++ b/lib/resources/TestHelpers/Refunds.js @@ -3,8 +3,8 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - expire: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/refunds/{refund}/expire', - }), + expire: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/refunds/{refund}/expire', + }), }); diff --git a/lib/resources/TestHelpers/Terminal/Readers.js b/lib/resources/TestHelpers/Terminal/Readers.js index 5db3ce2271..a828c20ccf 100644 --- a/lib/resources/TestHelpers/Terminal/Readers.js +++ b/lib/resources/TestHelpers/Terminal/Readers.js @@ -3,8 +3,9 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - presentPaymentMethod: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/terminal/readers/{reader}/present_payment_method', - }), + presentPaymentMethod: stripeMethod({ + method: 'POST', + fullPath: + '/v1/test_helpers/terminal/readers/{reader}/present_payment_method', + }), }); diff --git a/lib/resources/TestHelpers/TestClocks.js b/lib/resources/TestHelpers/TestClocks.js index 0fe10bb858..d3686c123e 100644 --- a/lib/resources/TestHelpers/TestClocks.js +++ b/lib/resources/TestHelpers/TestClocks.js @@ -3,25 +3,25 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/test_clocks', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/test_helpers/test_clocks/{test_clock}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/test_helpers/test_clocks', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/test_helpers/test_clocks/{test_clock}', - }), - advance: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/test_clocks/{test_clock}/advance', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/test_clocks', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/test_helpers/test_clocks', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}', + }), + advance: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/test_clocks/{test_clock}/advance', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/InboundTransfers.js b/lib/resources/TestHelpers/Treasury/InboundTransfers.js index 8778a49aef..0143e4b71a 100644 --- a/lib/resources/TestHelpers/Treasury/InboundTransfers.js +++ b/lib/resources/TestHelpers/Treasury/InboundTransfers.js @@ -3,16 +3,16 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fail: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/fail', - }), - returnInboundTransfer: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/return', - }), - succeed: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/succeed', - }), + fail: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/fail', + }), + returnInboundTransfer: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/return', + }), + succeed: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/inbound_transfers/{id}/succeed', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/OutboundPayments.js b/lib/resources/TestHelpers/Treasury/OutboundPayments.js index b5f9d52b1c..7bed50182d 100644 --- a/lib/resources/TestHelpers/Treasury/OutboundPayments.js +++ b/lib/resources/TestHelpers/Treasury/OutboundPayments.js @@ -3,16 +3,16 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fail: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/fail', - }), - post: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/post', - }), - returnOutboundPayment: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/return', - }), + fail: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/fail', + }), + post: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/post', + }), + returnOutboundPayment: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/outbound_payments/{id}/return', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/OutboundTransfers.js b/lib/resources/TestHelpers/Treasury/OutboundTransfers.js index f10e448dfe..f38f2a6743 100644 --- a/lib/resources/TestHelpers/Treasury/OutboundTransfers.js +++ b/lib/resources/TestHelpers/Treasury/OutboundTransfers.js @@ -3,16 +3,19 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - fail: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail', - }), - post: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post', - }), - returnOutboundTransfer: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return', - }), + fail: stripeMethod({ + method: 'POST', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/fail', + }), + post: stripeMethod({ + method: 'POST', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/post', + }), + returnOutboundTransfer: stripeMethod({ + method: 'POST', + fullPath: + '/v1/test_helpers/treasury/outbound_transfers/{outbound_transfer}/return', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/ReceivedCredits.js b/lib/resources/TestHelpers/Treasury/ReceivedCredits.js index 820e611842..3461023f91 100644 --- a/lib/resources/TestHelpers/Treasury/ReceivedCredits.js +++ b/lib/resources/TestHelpers/Treasury/ReceivedCredits.js @@ -3,8 +3,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/received_credits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/received_credits', + }), }); diff --git a/lib/resources/TestHelpers/Treasury/ReceivedDebits.js b/lib/resources/TestHelpers/Treasury/ReceivedDebits.js index f6fbc7d5df..9d27e31246 100644 --- a/lib/resources/TestHelpers/Treasury/ReceivedDebits.js +++ b/lib/resources/TestHelpers/Treasury/ReceivedDebits.js @@ -3,8 +3,8 @@ const StripeResource = require('../../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/test_helpers/treasury/received_debits', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/test_helpers/treasury/received_debits', + }), }); diff --git a/lib/resources/Tokens.js b/lib/resources/Tokens.js index a2e355d5ad..aba36dc673 100644 --- a/lib/resources/Tokens.js +++ b/lib/resources/Tokens.js @@ -3,12 +3,12 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/tokens', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/tokens/{token}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/tokens', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/tokens/{token}', + }), }); diff --git a/lib/resources/Topups.js b/lib/resources/Topups.js index 7bcf65713e..98a373ce13 100644 --- a/lib/resources/Topups.js +++ b/lib/resources/Topups.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/topups', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/topups/{topup}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/topups/{topup}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/topups', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/topups/{topup}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/topups', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/topups/{topup}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/topups/{topup}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/topups', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/topups/{topup}/cancel', + }), }); diff --git a/lib/resources/Transfers.js b/lib/resources/Transfers.js index 6fb574d6f2..f046445237 100644 --- a/lib/resources/Transfers.js +++ b/lib/resources/Transfers.js @@ -3,38 +3,38 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers/{transfer}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers/{transfer}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers', - methodType: 'list', - }), - createReversal: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers/{id}/reversals', - }), - retrieveReversal: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers/{transfer}/reversals/{id}', - }), - updateReversal: stripeMethod({ - method: 'POST', - fullPath: '/v1/transfers/{transfer}/reversals/{id}', - }), - listReversals: stripeMethod({ - method: 'GET', - fullPath: '/v1/transfers/{id}/reversals', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers/{transfer}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers/{transfer}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers', + methodType: 'list', + }), + createReversal: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers/{id}/reversals', + }), + retrieveReversal: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', + }), + updateReversal: stripeMethod({ + method: 'POST', + fullPath: '/v1/transfers/{transfer}/reversals/{id}', + }), + listReversals: stripeMethod({ + method: 'GET', + fullPath: '/v1/transfers/{id}/reversals', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/CreditReversals.js b/lib/resources/Treasury/CreditReversals.js index 95d6e2118e..39f5765ddc 100644 --- a/lib/resources/Treasury/CreditReversals.js +++ b/lib/resources/Treasury/CreditReversals.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/credit_reversals', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/credit_reversals/{credit_reversal}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/credit_reversals', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/credit_reversals', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/credit_reversals/{credit_reversal}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/credit_reversals', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/DebitReversals.js b/lib/resources/Treasury/DebitReversals.js index 0f53944fcb..e0c91bc57e 100644 --- a/lib/resources/Treasury/DebitReversals.js +++ b/lib/resources/Treasury/DebitReversals.js @@ -3,17 +3,17 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/debit_reversals', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/debit_reversals/{debit_reversal}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/debit_reversals', - methodType: 'list', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/debit_reversals', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/debit_reversals/{debit_reversal}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/debit_reversals', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/FinancialAccounts.js b/lib/resources/Treasury/FinancialAccounts.js index 5f3d0dd820..370fab541e 100644 --- a/lib/resources/Treasury/FinancialAccounts.js +++ b/lib/resources/Treasury/FinancialAccounts.js @@ -3,29 +3,29 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/financial_accounts', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/financial_accounts/{financial_account}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/financial_accounts/{financial_account}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/financial_accounts', - methodType: 'list', - }), - retrieveFeatures: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', - }), - updateFeatures: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/financial_accounts', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/financial_accounts/{financial_account}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/financial_accounts', + methodType: 'list', + }), + retrieveFeatures: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', + }), + updateFeatures: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/financial_accounts/{financial_account}/features', + }), }); diff --git a/lib/resources/Treasury/InboundTransfers.js b/lib/resources/Treasury/InboundTransfers.js index 52caf10fcd..ef54bf4dca 100644 --- a/lib/resources/Treasury/InboundTransfers.js +++ b/lib/resources/Treasury/InboundTransfers.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/inbound_transfers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/inbound_transfers/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/inbound_transfers', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/inbound_transfers/{inbound_transfer}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/inbound_transfers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/inbound_transfers/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/inbound_transfers', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/inbound_transfers/{inbound_transfer}/cancel', + }), }); diff --git a/lib/resources/Treasury/OutboundPayments.js b/lib/resources/Treasury/OutboundPayments.js index d6d0225cd3..2bab72b957 100644 --- a/lib/resources/Treasury/OutboundPayments.js +++ b/lib/resources/Treasury/OutboundPayments.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_payments', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_payments/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_payments', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_payments/{id}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_payments', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_payments/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_payments', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_payments/{id}/cancel', + }), }); diff --git a/lib/resources/Treasury/OutboundTransfers.js b/lib/resources/Treasury/OutboundTransfers.js index fc9ca46ac7..749b57f884 100644 --- a/lib/resources/Treasury/OutboundTransfers.js +++ b/lib/resources/Treasury/OutboundTransfers.js @@ -3,21 +3,21 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_transfers', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/outbound_transfers', - methodType: 'list', - }), - cancel: stripeMethod({ - method: 'POST', - fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}/cancel', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_transfers', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/outbound_transfers', + methodType: 'list', + }), + cancel: stripeMethod({ + method: 'POST', + fullPath: '/v1/treasury/outbound_transfers/{outbound_transfer}/cancel', + }), }); diff --git a/lib/resources/Treasury/ReceivedCredits.js b/lib/resources/Treasury/ReceivedCredits.js index 533398cefd..0c32c22d7d 100644 --- a/lib/resources/Treasury/ReceivedCredits.js +++ b/lib/resources/Treasury/ReceivedCredits.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_credits/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_credits', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_credits/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_credits', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/ReceivedDebits.js b/lib/resources/Treasury/ReceivedDebits.js index f4de1b786d..e4448c1173 100644 --- a/lib/resources/Treasury/ReceivedDebits.js +++ b/lib/resources/Treasury/ReceivedDebits.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_debits/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/received_debits', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_debits/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/received_debits', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/TransactionEntries.js b/lib/resources/Treasury/TransactionEntries.js index f899ea919b..9500b9f8fc 100644 --- a/lib/resources/Treasury/TransactionEntries.js +++ b/lib/resources/Treasury/TransactionEntries.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transaction_entries/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transaction_entries', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transaction_entries/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transaction_entries', + methodType: 'list', + }), }); diff --git a/lib/resources/Treasury/Transactions.js b/lib/resources/Treasury/Transactions.js index d8c0b0aef9..9896e74250 100644 --- a/lib/resources/Treasury/Transactions.js +++ b/lib/resources/Treasury/Transactions.js @@ -3,13 +3,13 @@ const StripeResource = require('../../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transactions/{id}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/treasury/transactions', - methodType: 'list', - }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transactions/{id}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/treasury/transactions', + methodType: 'list', + }), }); diff --git a/lib/resources/WebhookEndpoints.js b/lib/resources/WebhookEndpoints.js index 72c257d6f2..272a9ac078 100644 --- a/lib/resources/WebhookEndpoints.js +++ b/lib/resources/WebhookEndpoints.js @@ -3,25 +3,25 @@ const StripeResource = require('../StripeResource'); const stripeMethod = StripeResource.method; module.exports = StripeResource.extend({ - create: stripeMethod({ - method: 'POST', - fullPath: '/v1/webhook_endpoints', - }), - retrieve: stripeMethod({ - method: 'GET', - fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', - }), - update: stripeMethod({ - method: 'POST', - fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', - }), - list: stripeMethod({ - method: 'GET', - fullPath: '/v1/webhook_endpoints', - methodType: 'list', - }), - del: stripeMethod({ - method: 'DELETE', - fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', - }), + create: stripeMethod({ + method: 'POST', + fullPath: '/v1/webhook_endpoints', + }), + retrieve: stripeMethod({ + method: 'GET', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', + }), + update: stripeMethod({ + method: 'POST', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', + }), + list: stripeMethod({ + method: 'GET', + fullPath: '/v1/webhook_endpoints', + methodType: 'list', + }), + del: stripeMethod({ + method: 'DELETE', + fullPath: '/v1/webhook_endpoints/{webhook_endpoint}', + }), }); diff --git a/lib/stripe.js b/lib/stripe.js index f5bcaecb61..7288061bad 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -1,6 +1,5 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const _Error = require("./Error"); +'use strict'; +const _Error = require('./Error'); const resources = require('./resources'); const DEFAULT_HOST = 'api.stripe.com'; const DEFAULT_PORT = '443'; @@ -9,97 +8,114 @@ const DEFAULT_API_VERSION = null; const DEFAULT_TIMEOUT = 80000; Stripe.PACKAGE_VERSION = require('../package.json').version; const utils = require('./utils'); -const { determineProcessUserAgentProperties, emitWarning } = utils; -Stripe.USER_AGENT = Object.assign({ bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', publisher: 'stripe', uname: null, typescript: false }, determineProcessUserAgentProperties()); +const {determineProcessUserAgentProperties, emitWarning} = utils; +Stripe.USER_AGENT = Object.assign( + { + bindings_version: Stripe.PACKAGE_VERSION, + lang: 'node', + publisher: 'stripe', + uname: null, + typescript: false, + }, + determineProcessUserAgentProperties() +); /** @private */ Stripe._UNAME_CACHE = null; const MAX_NETWORK_RETRY_DELAY_SEC = 2; const INITIAL_NETWORK_RETRY_DELAY_SEC = 0.5; const APP_INFO_PROPERTIES = ['name', 'version', 'url', 'partner_id']; const ALLOWED_CONFIG_PROPERTIES = [ - 'apiVersion', - 'typescript', - 'maxNetworkRetries', - 'httpAgent', - 'httpClient', - 'timeout', - 'host', - 'port', - 'protocol', - 'telemetry', - 'appInfo', - 'stripeAccount', + 'apiVersion', + 'typescript', + 'maxNetworkRetries', + 'httpAgent', + 'httpClient', + 'timeout', + 'host', + 'port', + 'protocol', + 'telemetry', + 'appInfo', + 'stripeAccount', ]; const EventEmitter = require('events').EventEmitter; -const StripeResource = require("./StripeResource"); +const StripeResource = require('./StripeResource'); Stripe.StripeResource = StripeResource; Stripe.resources = resources; -const { HttpClient, HttpClientResponse } = require('./net/HttpClient'); +const {HttpClient, HttpClientResponse} = require('./net/HttpClient'); Stripe.HttpClient = HttpClient; Stripe.HttpClientResponse = HttpClientResponse; const CryptoProvider = require('./crypto/CryptoProvider'); Stripe.CryptoProvider = CryptoProvider; function Stripe(key, config = {}) { - if (!(this instanceof Stripe)) { - return new Stripe(key, config); - } - const props = this._getPropsFromConfig(config); - Object.defineProperty(this, '_emitter', { - value: new EventEmitter(), - enumerable: false, - configurable: false, - writable: false, - }); - this.VERSION = Stripe.PACKAGE_VERSION; - this.on = this._emitter.on.bind(this._emitter); - this.once = this._emitter.once.bind(this._emitter); - this.off = this._emitter.removeListener.bind(this._emitter); - if (props.protocol && - props.protocol !== 'https' && - (!props.host || /\.stripe\.com$/.test(props.host))) { - throw new Error('The `https` protocol must be used when sending requests to `*.stripe.com`'); - } - const agent = props.httpAgent || null; - this._api = { - auth: null, - host: props.host || DEFAULT_HOST, - port: props.port || DEFAULT_PORT, - protocol: props.protocol || 'https', - basePath: DEFAULT_BASE_PATH, - version: props.apiVersion || DEFAULT_API_VERSION, - timeout: utils.validateInteger('timeout', props.timeout, DEFAULT_TIMEOUT), - maxNetworkRetries: utils.validateInteger('maxNetworkRetries', props.maxNetworkRetries, 0), - agent: agent, - httpClient: props.httpClient || Stripe.createNodeHttpClient(agent), - dev: false, - stripeAccount: props.stripeAccount || null, - }; - const typescript = props.typescript || false; - if (typescript !== Stripe.USER_AGENT.typescript) { - // The mutation here is uncomfortable, but likely fastest; - // serializing the user agent involves shelling out to the system, - // and given some users may instantiate the library many times without switching between TS and non-TS, - // we only want to incur the performance hit when that actually happens. - Stripe.USER_AGENT.typescript = typescript; - } - if (props.appInfo) { - this._setAppInfo(props.appInfo); - } - this._prepResources(); - this._setApiKey(key); - this.errors = _Error; - this.webhooks = require('./Webhooks'); - this._prevRequestMetrics = []; - this._enableTelemetry = props.telemetry !== false; - // Expose StripeResource on the instance too - // @ts-ignore - this.StripeResource = Stripe.StripeResource; + if (!(this instanceof Stripe)) { + return new Stripe(key, config); + } + const props = this._getPropsFromConfig(config); + Object.defineProperty(this, '_emitter', { + value: new EventEmitter(), + enumerable: false, + configurable: false, + writable: false, + }); + this.VERSION = Stripe.PACKAGE_VERSION; + this.on = this._emitter.on.bind(this._emitter); + this.once = this._emitter.once.bind(this._emitter); + this.off = this._emitter.removeListener.bind(this._emitter); + if ( + props.protocol && + props.protocol !== 'https' && + (!props.host || /\.stripe\.com$/.test(props.host)) + ) { + throw new Error( + 'The `https` protocol must be used when sending requests to `*.stripe.com`' + ); + } + const agent = props.httpAgent || null; + this._api = { + auth: null, + host: props.host || DEFAULT_HOST, + port: props.port || DEFAULT_PORT, + protocol: props.protocol || 'https', + basePath: DEFAULT_BASE_PATH, + version: props.apiVersion || DEFAULT_API_VERSION, + timeout: utils.validateInteger('timeout', props.timeout, DEFAULT_TIMEOUT), + maxNetworkRetries: utils.validateInteger( + 'maxNetworkRetries', + props.maxNetworkRetries, + 0 + ), + agent: agent, + httpClient: props.httpClient || Stripe.createNodeHttpClient(agent), + dev: false, + stripeAccount: props.stripeAccount || null, + }; + const typescript = props.typescript || false; + if (typescript !== Stripe.USER_AGENT.typescript) { + // The mutation here is uncomfortable, but likely fastest; + // serializing the user agent involves shelling out to the system, + // and given some users may instantiate the library many times without switching between TS and non-TS, + // we only want to incur the performance hit when that actually happens. + Stripe.USER_AGENT.typescript = typescript; + } + if (props.appInfo) { + this._setAppInfo(props.appInfo); + } + this._prepResources(); + this._setApiKey(key); + this.errors = _Error; + this.webhooks = require('./Webhooks'); + this._prevRequestMetrics = []; + this._enableTelemetry = props.telemetry !== false; + // Expose StripeResource on the instance too + // @ts-ignore + this.StripeResource = Stripe.StripeResource; } Stripe.errors = _Error; Stripe.webhooks = require('./Webhooks'); Stripe.createNodeHttpClient = (agent) => { - const { NodeHttpClient } = require('./net/NodeHttpClient'); - return new NodeHttpClient(agent); + const {NodeHttpClient} = require('./net/NodeHttpClient'); + return new NodeHttpClient(agent); }; /** * Creates an HTTP client for issuing Stripe API requests which uses the Web @@ -109,16 +125,16 @@ Stripe.createNodeHttpClient = (agent) => { * passed, will default to the default `fetch` function in the global scope. */ Stripe.createFetchHttpClient = (fetchFn) => { - const { FetchHttpClient } = require('./net/FetchHttpClient'); - return new FetchHttpClient(fetchFn); + const {FetchHttpClient} = require('./net/FetchHttpClient'); + return new FetchHttpClient(fetchFn); }; /** * Create a CryptoProvider which uses the built-in Node crypto libraries for * its crypto operations. */ Stripe.createNodeCryptoProvider = () => { - const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); - return new NodeCryptoProvider(); + const NodeCryptoProvider = require('./crypto/NodeCryptoProvider'); + return new NodeCryptoProvider(); }; /** * Creates a CryptoProvider which uses the Subtle Crypto API from the Web @@ -129,8 +145,8 @@ Stripe.createNodeCryptoProvider = () => { * scope. */ Stripe.createSubtleCryptoProvider = (subtleCrypto) => { - const SubtleCryptoProvider = require('./crypto/SubtleCryptoProvider'); - return new SubtleCryptoProvider(subtleCrypto); + const SubtleCryptoProvider = require('./crypto/SubtleCryptoProvider'); + return new SubtleCryptoProvider(subtleCrypto); }; Stripe.prototype = { // Properties are set in the constructor above diff --git a/lib/utils.js b/lib/utils.js index a4d1b1fd9c..d803d84932 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,4 +1,4 @@ -"use strict"; +'use strict'; const EventEmitter = require('events').EventEmitter; const qs = require('qs'); const crypto = require('crypto'); @@ -7,356 +7,375 @@ const crypto = require('crypto'); // to the operation of stripe-node, we handle this unavailability gracefully. let exec = null; try { - exec = require('child_process').exec; -} -catch (e) { - // @ts-ignore - if (e.code !== 'MODULE_NOT_FOUND') { - throw e; - } + exec = require('child_process').exec; +} catch (e) { + // @ts-ignore + if (e.code !== 'MODULE_NOT_FOUND') { + throw e; + } } const OPTIONS_KEYS = [ - 'apiKey', - 'idempotencyKey', - 'stripeAccount', - 'apiVersion', - 'maxNetworkRetries', - 'timeout', - 'host', + 'apiKey', + 'idempotencyKey', + 'stripeAccount', + 'apiVersion', + 'maxNetworkRetries', + 'timeout', + 'host', ]; const utils = { - isOptionsHash(o) { - return (o && - typeof o === 'object' && - OPTIONS_KEYS.some((prop) => Object.prototype.hasOwnProperty.call(o, prop))); - }, - /** - * Stringifies an Object, accommodating nested objects - * (forming the conventional key 'parent[child]=value') - */ - stringifyRequestData: (data) => { - return (qs - .stringify(data, { - serializeDate: (d) => Math.floor(d.getTime() / 1000), + isOptionsHash(o) { + return ( + o && + typeof o === 'object' && + OPTIONS_KEYS.some((prop) => Object.prototype.hasOwnProperty.call(o, prop)) + ); + }, + /** + * Stringifies an Object, accommodating nested objects + * (forming the conventional key 'parent[child]=value') + */ + stringifyRequestData: (data) => { + return ( + qs + .stringify(data, { + serializeDate: (d) => Math.floor(d.getTime() / 1000), }) - // Don't use strict form encoding by changing the square bracket control - // characters back to their literals. This is fine by the server, and - // makes these parameter strings easier to read. - .replace(/%5B/g, '[') - .replace(/%5D/g, ']')); - }, - /** - * Outputs a new function with interpolated object property values. - * Use like so: - * const fn = makeURLInterpolator('some/url/{param1}/{param2}'); - * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' - */ - makeURLInterpolator: (() => { - const rc = { - '\n': '\\n', - '"': '\\"', - '\u2028': '\\u2028', - '\u2029': '\\u2029', - }; - return (str) => { - const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]); - return (outputs) => { - return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => - // @ts-ignore - encodeURIComponent(outputs[$1] || '')); - }; - }; - })(), - extractUrlParams: (path) => { - const params = path.match(/\{\w+\}/g); - if (!params) { - return []; - } - return params.map((param) => param.replace(/[{}]/g, '')); - }, - /** - * Return the data argument from a list of arguments - * - * @param {object[]} args - * @returns {object} - */ - getDataFromArgs(args) { - if (!Array.isArray(args) || !args[0] || typeof args[0] !== 'object') { - return {}; - } - if (!utils.isOptionsHash(args[0])) { - return args.shift(); - } - const argKeys = Object.keys(args[0]); - const optionKeysInArgs = argKeys.filter((key) => OPTIONS_KEYS.includes(key)); - // In some cases options may be the provided as the first argument. - // Here we're detecting a case where there are two distinct arguments - // (the first being args and the second options) and with known - // option keys in the first so that we can warn the user about it. - if (optionKeysInArgs.length > 0 && - optionKeysInArgs.length !== argKeys.length) { - emitWarning(`Options found in arguments (${optionKeysInArgs.join(', ')}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.`); - } - return {}; - }, - /** - * Return the options hash from a list of arguments - */ - getOptionsFromArgs: (args) => { - const opts = { - auth: null, - headers: {}, - settings: {}, - }; - if (args.length > 0) { - const arg = args[args.length - 1]; - if (typeof arg === 'string') { - opts.auth = args.pop(); - } - else if (utils.isOptionsHash(arg)) { - const params = Object.assign({}, args.pop()); - const extraKeys = Object.keys(params).filter((key) => !OPTIONS_KEYS.includes(key)); - if (extraKeys.length) { - emitWarning(`Invalid options found (${extraKeys.join(', ')}); ignoring.`); - } - if (params.apiKey) { - opts.auth = params.apiKey; - } - if (params.idempotencyKey) { - opts.headers['Idempotency-Key'] = params.idempotencyKey; - } - if (params.stripeAccount) { - opts.headers['Stripe-Account'] = params.stripeAccount; - } - if (params.apiVersion) { - opts.headers['Stripe-Version'] = params.apiVersion; - } - if (Number.isInteger(params.maxNetworkRetries)) { - opts.settings.maxNetworkRetries = params.maxNetworkRetries; - } - if (Number.isInteger(params.timeout)) { - opts.settings.timeout = params.timeout; - } - if (params.host) { - opts.host = params.host; - } - } - } - return opts; - }, - /** - * Provide simple "Class" extension mechanism - */ - protoExtend(sub) { - // eslint-disable-next-line @typescript-eslint/no-this-alias - const Super = this; - const Constructor = Object.prototype.hasOwnProperty.call(sub, 'constructor') - ? sub.constructor - : function (...args) { - Super.apply(this, args); - }; - // This initialization logic is somewhat sensitive to be compatible with - // divergent JS implementations like the one found in Qt. See here for more - // context: - // - // https://github.com/stripe/stripe-node/pull/334 - Object.assign(Constructor, Super); - Constructor.prototype = Object.create(Super.prototype); - Object.assign(Constructor.prototype, sub); - return Constructor; - }, - /** - * Secure compare, from https://github.com/freewil/scmp - */ - secureCompare: (a, b) => { - a = Buffer.from(a); - b = Buffer.from(b); - // return early here if buffer lengths are not equal since timingSafeEqual - // will throw if buffer lengths are not equal - if (a.length !== b.length) { - return false; - } - // use crypto.timingSafeEqual if available (since Node.js v6.6.0), - // otherwise use our own scmp-internal function. - if (crypto.timingSafeEqual) { - return crypto.timingSafeEqual(a, b); - } - const len = a.length; - let result = 0; - for (let i = 0; i < len; ++i) { - result |= a[i] ^ b[i]; - } - return result === 0; - }, - /** - * Remove empty values from an object - */ - removeNullish: (obj) => { - if (typeof obj !== 'object') { - throw new Error('Argument must be an object'); - } - return Object.keys(obj).reduce((result, key) => { - if (obj[key] != null) { - result[key] = obj[key]; - } - return result; - }, {}); - }, - /** - * Normalize standard HTTP Headers: - * {'foo-bar': 'hi'} - * becomes - * {'Foo-Bar': 'hi'} - */ - normalizeHeaders: (obj) => { - if (!(obj && typeof obj === 'object')) { - return obj; + // Don't use strict form encoding by changing the square bracket control + // characters back to their literals. This is fine by the server, and + // makes these parameter strings easier to read. + .replace(/%5B/g, '[') + .replace(/%5D/g, ']') + ); + }, + /** + * Outputs a new function with interpolated object property values. + * Use like so: + * const fn = makeURLInterpolator('some/url/{param1}/{param2}'); + * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' + */ + makeURLInterpolator: (() => { + const rc = { + '\n': '\\n', + '"': '\\"', + '\u2028': '\\u2028', + '\u2029': '\\u2029', + }; + return (str) => { + const cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]); + return (outputs) => { + return cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => + // @ts-ignore + encodeURIComponent(outputs[$1] || '') + ); + }; + }; + })(), + extractUrlParams: (path) => { + const params = path.match(/\{\w+\}/g); + if (!params) { + return []; + } + return params.map((param) => param.replace(/[{}]/g, '')); + }, + /** + * Return the data argument from a list of arguments + * + * @param {object[]} args + * @returns {object} + */ + getDataFromArgs(args) { + if (!Array.isArray(args) || !args[0] || typeof args[0] !== 'object') { + return {}; + } + if (!utils.isOptionsHash(args[0])) { + return args.shift(); + } + const argKeys = Object.keys(args[0]); + const optionKeysInArgs = argKeys.filter((key) => + OPTIONS_KEYS.includes(key) + ); + // In some cases options may be the provided as the first argument. + // Here we're detecting a case where there are two distinct arguments + // (the first being args and the second options) and with known + // option keys in the first so that we can warn the user about it. + if ( + optionKeysInArgs.length > 0 && + optionKeysInArgs.length !== argKeys.length + ) { + emitWarning( + `Options found in arguments (${optionKeysInArgs.join( + ', ' + )}). Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.` + ); + } + return {}; + }, + /** + * Return the options hash from a list of arguments + */ + getOptionsFromArgs: (args) => { + const opts = { + auth: null, + headers: {}, + settings: {}, + }; + if (args.length > 0) { + const arg = args[args.length - 1]; + if (typeof arg === 'string') { + opts.auth = args.pop(); + } else if (utils.isOptionsHash(arg)) { + const params = Object.assign({}, args.pop()); + const extraKeys = Object.keys(params).filter( + (key) => !OPTIONS_KEYS.includes(key) + ); + if (extraKeys.length) { + emitWarning( + `Invalid options found (${extraKeys.join(', ')}); ignoring.` + ); } - return Object.keys(obj).reduce((result, header) => { - result[utils.normalizeHeader(header)] = obj[header]; - return result; - }, {}); - }, - /** - * Stolen from https://github.com/marten-de-vries/header-case-normalizer/blob/master/index.js#L36-L41 - * without the exceptions which are irrelevant to us. - */ - normalizeHeader: (header) => { - return header - .split('-') - .map((text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase()) - .join('-'); - }, - /** - * Determine if file data is a derivative of EventEmitter class. - * https://nodejs.org/api/events.html#events_events - */ - checkForStream: (obj) => { - if (obj.file && obj.file.data) { - return obj.file.data instanceof EventEmitter; + if (params.apiKey) { + opts.auth = params.apiKey; } - return false; - }, - callbackifyPromiseWithTimeout: (promise, callback) => { - if (callback) { - // Ensure callback is called outside of promise stack. - return promise.then((res) => { - setTimeout(() => { - callback(null, res); - }, 0); - }, (err) => { - setTimeout(() => { - callback(err, null); - }, 0); - }); + if (params.idempotencyKey) { + opts.headers['Idempotency-Key'] = params.idempotencyKey; } - return promise; - }, - /** - * Allow for special capitalization cases (such as OAuth) - */ - pascalToCamelCase: (name) => { - if (name === 'OAuth') { - return 'oauth'; + if (params.stripeAccount) { + opts.headers['Stripe-Account'] = params.stripeAccount; } - else { - return name[0].toLowerCase() + name.substring(1); + if (params.apiVersion) { + opts.headers['Stripe-Version'] = params.apiVersion; } - }, - emitWarning, - /** - * Node's built in `exec` function sometimes throws outright, - * and sometimes has a callback with an error, - * depending on the type of error. - * - * This unifies that interface. - */ - safeExec: (cmd, cb) => { - // Occurs if we couldn't load the `child_process` module, which might - // happen in certain sandboxed environments like a CloudFlare Worker. - if (utils._exec === null) { - cb(new Error('exec not available'), null); - return; + if (Number.isInteger(params.maxNetworkRetries)) { + opts.settings.maxNetworkRetries = params.maxNetworkRetries; } - try { - utils._exec(cmd, cb); + if (Number.isInteger(params.timeout)) { + opts.settings.timeout = params.timeout; } - catch (e) { - cb(e, null); + if (params.host) { + opts.host = params.host; } - }, - // For mocking in tests. - _exec: exec, - isObject: (obj) => { - const type = typeof obj; - return (type === 'function' || type === 'object') && !!obj; - }, - // For use in multipart requests - flattenAndStringify: (data) => { - const result = {}; - const step = (obj, prevKey) => { - Object.keys(obj).forEach((key) => { - const value = obj[key]; - const newKey = prevKey ? `${prevKey}[${key}]` : key; - if (utils.isObject(value)) { - if (!Buffer.isBuffer(value) && - !Object.prototype.hasOwnProperty.call(value, 'data')) { - // Non-buffer non-file Objects are recursively flattened - return step(value, newKey); - } - else { - // Buffers and file objects are stored without modification - result[newKey] = value; - } - } - else { - // Primitives are converted to strings - result[newKey] = String(value); - } - }); + } + } + return opts; + }, + /** + * Provide simple "Class" extension mechanism + */ + protoExtend(sub) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const Super = this; + const Constructor = Object.prototype.hasOwnProperty.call(sub, 'constructor') + ? sub.constructor + : function(...args) { + Super.apply(this, args); }; - step(data, null); - return result; - }, - /** - * https://stackoverflow.com/a/2117523 - */ - uuid4: () => { - // available in: v14.17.x+ - if (crypto.randomUUID) { - return crypto.randomUUID(); + // This initialization logic is somewhat sensitive to be compatible with + // divergent JS implementations like the one found in Qt. See here for more + // context: + // + // https://github.com/stripe/stripe-node/pull/334 + Object.assign(Constructor, Super); + Constructor.prototype = Object.create(Super.prototype); + Object.assign(Constructor.prototype, sub); + return Constructor; + }, + /** + * Secure compare, from https://github.com/freewil/scmp + */ + secureCompare: (a, b) => { + a = Buffer.from(a); + b = Buffer.from(b); + // return early here if buffer lengths are not equal since timingSafeEqual + // will throw if buffer lengths are not equal + if (a.length !== b.length) { + return false; + } + // use crypto.timingSafeEqual if available (since Node.js v6.6.0), + // otherwise use our own scmp-internal function. + if (crypto.timingSafeEqual) { + return crypto.timingSafeEqual(a, b); + } + const len = a.length; + let result = 0; + for (let i = 0; i < len; ++i) { + result |= a[i] ^ b[i]; + } + return result === 0; + }, + /** + * Remove empty values from an object + */ + removeNullish: (obj) => { + if (typeof obj !== 'object') { + throw new Error('Argument must be an object'); + } + return Object.keys(obj).reduce((result, key) => { + if (obj[key] != null) { + result[key] = obj[key]; + } + return result; + }, {}); + }, + /** + * Normalize standard HTTP Headers: + * {'foo-bar': 'hi'} + * becomes + * {'Foo-Bar': 'hi'} + */ + normalizeHeaders: (obj) => { + if (!(obj && typeof obj === 'object')) { + return obj; + } + return Object.keys(obj).reduce((result, header) => { + result[utils.normalizeHeader(header)] = obj[header]; + return result; + }, {}); + }, + /** + * Stolen from https://github.com/marten-de-vries/header-case-normalizer/blob/master/index.js#L36-L41 + * without the exceptions which are irrelevant to us. + */ + normalizeHeader: (header) => { + return header + .split('-') + .map( + (text) => text.charAt(0).toUpperCase() + text.substr(1).toLowerCase() + ) + .join('-'); + }, + /** + * Determine if file data is a derivative of EventEmitter class. + * https://nodejs.org/api/events.html#events_events + */ + checkForStream: (obj) => { + if (obj.file && obj.file.data) { + return obj.file.data instanceof EventEmitter; + } + return false; + }, + callbackifyPromiseWithTimeout: (promise, callback) => { + if (callback) { + // Ensure callback is called outside of promise stack. + return promise.then( + (res) => { + setTimeout(() => { + callback(null, res); + }, 0); + }, + (err) => { + setTimeout(() => { + callback(err, null); + }, 0); } - // legacy behavior if native UUIDs aren't available - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { - const r = (Math.random() * 16) | 0; - const v = c === 'x' ? r : (r & 0x3) | 0x8; - return v.toString(16); - }); - }, - validateInteger: (name, n, defaultVal) => { - if (!Number.isInteger(n)) { - if (defaultVal !== undefined) { - return defaultVal; - } - else { - throw new Error(`${name} must be an integer`); - } + ); + } + return promise; + }, + /** + * Allow for special capitalization cases (such as OAuth) + */ + pascalToCamelCase: (name) => { + if (name === 'OAuth') { + return 'oauth'; + } else { + return name[0].toLowerCase() + name.substring(1); + } + }, + emitWarning, + /** + * Node's built in `exec` function sometimes throws outright, + * and sometimes has a callback with an error, + * depending on the type of error. + * + * This unifies that interface. + */ + safeExec: (cmd, cb) => { + // Occurs if we couldn't load the `child_process` module, which might + // happen in certain sandboxed environments like a CloudFlare Worker. + if (utils._exec === null) { + cb(new Error('exec not available'), null); + return; + } + try { + utils._exec(cmd, cb); + } catch (e) { + cb(e, null); + } + }, + // For mocking in tests. + _exec: exec, + isObject: (obj) => { + const type = typeof obj; + return (type === 'function' || type === 'object') && !!obj; + }, + // For use in multipart requests + flattenAndStringify: (data) => { + const result = {}; + const step = (obj, prevKey) => { + Object.keys(obj).forEach((key) => { + const value = obj[key]; + const newKey = prevKey ? `${prevKey}[${key}]` : key; + if (utils.isObject(value)) { + if ( + !Buffer.isBuffer(value) && + !Object.prototype.hasOwnProperty.call(value, 'data') + ) { + // Non-buffer non-file Objects are recursively flattened + return step(value, newKey); + } else { + // Buffers and file objects are stored without modification + result[newKey] = value; + } + } else { + // Primitives are converted to strings + result[newKey] = String(value); } - return n; - }, - determineProcessUserAgentProperties: () => { - return typeof process === 'undefined' - ? {} - : { - lang_version: process.version, - platform: process.platform, - }; - }, + }); + }; + step(data, null); + return result; + }, + /** + * https://stackoverflow.com/a/2117523 + */ + uuid4: () => { + // available in: v14.17.x+ + if (crypto.randomUUID) { + return crypto.randomUUID(); + } + // legacy behavior if native UUIDs aren't available + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + const r = (Math.random() * 16) | 0; + const v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); + }, + validateInteger: (name, n, defaultVal) => { + if (!Number.isInteger(n)) { + if (defaultVal !== undefined) { + return defaultVal; + } else { + throw new Error(`${name} must be an integer`); + } + } + return n; + }, + determineProcessUserAgentProperties: () => { + return typeof process === 'undefined' + ? {} + : { + lang_version: process.version, + platform: process.platform, + }; + }, }; function emitWarning(warning) { - if (typeof process.emitWarning !== 'function') { - return console.warn(`Stripe: ${warning}`); /* eslint-disable-line no-console */ - } - return process.emitWarning(warning, 'Stripe'); + if (typeof process.emitWarning !== 'function') { + return console.warn( + `Stripe: ${warning}` + ); /* eslint-disable-line no-console */ + } + return process.emitWarning(warning, 'Stripe'); } module.exports = utils;