From f0e71657132b022c9106b86c5aa07a5a8c83a661 Mon Sep 17 00:00:00 2001 From: "stripe-openapi[bot]" <105521251+stripe-openapi[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:27:08 -0400 Subject: [PATCH 1/5] Update generated code (#2125) * Update generated code for v1105 * Update generated code for v1106 * Update generated code for v1111 * Update generated code for v1112 * Update generated code for v1113 * Update generated code for v1115 * Update generated code for v1116 --------- Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com> --- OPENAPI_VERSION | 2 +- src/resources/Invoices.ts | 12 + types/Billing/MeterEventSummaries.d.ts | 4 +- types/Billing/MetersResource.d.ts | 4 +- types/CustomerSessions.d.ts | 12 +- types/CustomerSessionsResource.d.ts | 4 +- types/Customers.d.ts | 2 +- types/EventTypes.d.ts | 2 +- types/Invoices.d.ts | 1 + types/InvoicesResource.d.ts | 578 ++++++++++++++++++++++++- types/PaymentIntents.d.ts | 1 + types/SetupAttempts.d.ts | 1 + types/SetupIntents.d.ts | 1 + types/Tax/Transactions.d.ts | 5 + types/Tax/TransactionsResource.d.ts | 5 + 15 files changed, 618 insertions(+), 16 deletions(-) diff --git a/OPENAPI_VERSION b/OPENAPI_VERSION index 1129f2eb6f..dbdf3c1cba 100644 --- a/OPENAPI_VERSION +++ b/OPENAPI_VERSION @@ -1 +1 @@ -v1103 \ No newline at end of file +v1116 \ No newline at end of file diff --git a/src/resources/Invoices.ts b/src/resources/Invoices.ts index fc01dc9035..33445358f4 100644 --- a/src/resources/Invoices.ts +++ b/src/resources/Invoices.ts @@ -12,6 +12,10 @@ export const Invoices = StripeResource.extend({ methodType: 'list', }), del: stripeMethod({method: 'DELETE', fullPath: '/v1/invoices/{invoice}'}), + addLines: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/add_lines', + }), createPreview: stripeMethod({ method: 'POST', fullPath: '/v1/invoices/create_preview', @@ -35,6 +39,10 @@ export const Invoices = StripeResource.extend({ fullPath: '/v1/invoices/{invoice}/mark_uncollectible', }), pay: stripeMethod({method: 'POST', fullPath: '/v1/invoices/{invoice}/pay'}), + removeLines: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/remove_lines', + }), retrieveUpcoming: stripeMethod({ method: 'GET', fullPath: '/v1/invoices/upcoming', @@ -48,6 +56,10 @@ export const Invoices = StripeResource.extend({ method: 'POST', fullPath: '/v1/invoices/{invoice}/send', }), + updateLines: stripeMethod({ + method: 'POST', + fullPath: '/v1/invoices/{invoice}/update_lines', + }), updateLineItem: stripeMethod({ method: 'POST', fullPath: '/v1/invoices/{invoice}/lines/{line_item_id}', diff --git a/types/Billing/MeterEventSummaries.d.ts b/types/Billing/MeterEventSummaries.d.ts index 8c74518af3..a94bfa7446 100644 --- a/types/Billing/MeterEventSummaries.d.ts +++ b/types/Billing/MeterEventSummaries.d.ts @@ -24,7 +24,7 @@ declare module 'stripe' { aggregated_value: number; /** - * End timestamp for this event summary (inclusive). + * End timestamp for this event summary (exclusive). Must be aligned with minute boundaries. */ end_time: number; @@ -39,7 +39,7 @@ declare module 'stripe' { meter: string; /** - * Start timestamp for this event summary (inclusive). + * Start timestamp for this event summary (inclusive). Must be aligned with minute boundaries. */ start_time: number; } diff --git a/types/Billing/MetersResource.d.ts b/types/Billing/MetersResource.d.ts index 961d19b62d..26bee2b879 100644 --- a/types/Billing/MetersResource.d.ts +++ b/types/Billing/MetersResource.d.ts @@ -123,12 +123,12 @@ declare module 'stripe' { customer: string; /** - * The timestamp from when to stop aggregating meter events (exclusive). + * The timestamp from when to stop aggregating meter events (exclusive). Must be aligned with minute boundaries. */ end_time: number; /** - * The timestamp from when to start aggregating meter events (inclusive). + * The timestamp from when to start aggregating meter events (inclusive). Must be aligned with minute boundaries. */ start_time: number; diff --git a/types/CustomerSessions.d.ts b/types/CustomerSessions.d.ts index 6f8b56694f..e2898cd12c 100644 --- a/types/CustomerSessions.d.ts +++ b/types/CustomerSessions.d.ts @@ -3,8 +3,8 @@ declare module 'stripe' { namespace Stripe { /** - * A customer session allows you to grant client access to Stripe's frontend SDKs (like StripeJs) - * control over a customer. + * A Customer Session allows you to grant Stripe's frontend SDKs (like Stripe.js) client-side access + * control over a Customer. */ interface CustomerSession { /** @@ -13,14 +13,14 @@ declare module 'stripe' { object: 'customer_session'; /** - * The client secret of this customer session. Used on the client to set up secure access to the given `customer`. + * The client secret of this Customer Session. Used on the client to set up secure access to the given `customer`. * * The client secret can be used to provide access to `customer` from your frontend. It should not be stored, logged, or exposed to anyone other than the relevant customer. Make sure that you have TLS enabled on any page that includes the client secret. */ client_secret: string; /** - * Configuration for the components supported by this customer session. + * Configuration for the components supported by this Customer Session. */ components?: CustomerSession.Components; @@ -30,12 +30,12 @@ declare module 'stripe' { created: number; /** - * The customer the customer session was created for. + * The Customer the Customer Session was created for. */ customer: string | Stripe.Customer; /** - * The timestamp at which this customer session will expire. + * The timestamp at which this Customer Session will expire. */ expires_at: number; diff --git a/types/CustomerSessionsResource.d.ts b/types/CustomerSessionsResource.d.ts index 028145478f..c2b0317620 100644 --- a/types/CustomerSessionsResource.d.ts +++ b/types/CustomerSessionsResource.d.ts @@ -9,7 +9,7 @@ declare module 'stripe' { components: CustomerSessionCreateParams.Components; /** - * The ID of an existing customer for which to create the customer session. + * The ID of an existing customer for which to create the Customer Session. */ customer: string; @@ -51,7 +51,7 @@ declare module 'stripe' { class CustomerSessionsResource { /** - * Creates a customer session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources. + * Creates a Customer Session object that includes a single-use client secret that you can use on your front-end to grant client-side API access for certain customer resources. */ create( params: CustomerSessionCreateParams, diff --git a/types/Customers.d.ts b/types/Customers.d.ts index 19b6d7b25d..27642721f8 100644 --- a/types/Customers.d.ts +++ b/types/Customers.d.ts @@ -109,7 +109,7 @@ declare module 'stripe' { name?: string | null; /** - * The suffix of the customer's next invoice number (for example, 0001). + * The suffix of the customer's next invoice number (for example, 0001). When the account uses account level sequencing, this parameter is ignored in API requests and the field omitted in API responses. */ next_invoice_sequence?: number; diff --git a/types/EventTypes.d.ts b/types/EventTypes.d.ts index 3ee2cba29c..7835097052 100644 --- a/types/EventTypes.d.ts +++ b/types/EventTypes.d.ts @@ -1070,7 +1070,7 @@ declare module 'stripe' { } /** - * Occurs whenever a card or source will expire at the end of the month. + * Occurs whenever a card or source will expire at the end of the month. This event only works with legacy integrations using Card or Source objects. If you use the PaymentMethod API, this event won't occur. */ interface CustomerSourceExpiringEvent extends EventBase { type: 'customer.source.expiring'; diff --git a/types/Invoices.d.ts b/types/Invoices.d.ts index 0d7511aa33..88d3270cb2 100644 --- a/types/Invoices.d.ts +++ b/types/Invoices.d.ts @@ -879,6 +879,7 @@ declare module 'stripe' { | 'parameters_exclusive' | 'payment_intent_action_required' | 'payment_intent_authentication_failure' + | 'payment_intent_fx_quote_invalid' | 'payment_intent_incompatible_payment_method' | 'payment_intent_invalid_parameter' | 'payment_intent_konbini_rejected_confirmation_number' diff --git a/types/InvoicesResource.d.ts b/types/InvoicesResource.d.ts index a3fc934cb6..72f02941ef 100644 --- a/types/InvoicesResource.d.ts +++ b/types/InvoicesResource.d.ts @@ -1458,6 +1458,262 @@ declare module 'stripe' { interface InvoiceDeleteParams {} + interface InvoiceAddLinesParams { + /** + * The line items to add. + */ + lines: Array; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: 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`. + */ + invoice_metadata?: Stripe.Emptyable<{ + [key: string]: string; + }>; + } + + namespace InvoiceAddLinesParams { + interface Line { + /** + * The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer's account, pass a negative amount. + */ + amount?: number; + + /** + * An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking. + */ + description?: string; + + /** + * Controls whether discounts apply to this line item. Defaults to false for prorations or negative line items, and true for all other line items. Cannot be set to true for prorations. + */ + discountable?: boolean; + + /** + * The coupons, promotion codes & existing discounts which apply to the line item. Item discounts are applied before invoice discounts. Pass an empty string to remove previously-defined discounts. + */ + discounts?: Stripe.Emptyable>; + + /** + * ID of an unassigned invoice item to assign to this invoice. If not provided, a new item will be created. + */ + invoice_item?: 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.Emptyable; + + /** + * The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. + */ + period?: Line.Period; + + /** + * The ID of the price object. One of `price` or `price_data` is required. + */ + price?: string; + + /** + * Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required. + */ + price_data?: Line.PriceData; + + /** + * Non-negative integer. The quantity of units for the line item. + */ + quantity?: number; + + /** + * A list of up to 10 tax amounts for this line item. This can be useful if you calculate taxes on your own or use a third-party to calculate them. You cannot set tax amounts if any line item has [tax_rates](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-tax_rates) or if the invoice has [default_tax_rates](https://stripe.com/docs/api/invoices/object#invoice_object-default_tax_rates) or uses [automatic tax](https://stripe.com/docs/tax/invoicing). Pass an empty string to remove previously defined tax amounts. + */ + tax_amounts?: Stripe.Emptyable>; + + /** + * The tax rates which apply to the line item. When set, the `default_tax_rates` on the invoice do not apply to this line item. Pass an empty string to remove previously-defined tax rates. + */ + tax_rates?: Stripe.Emptyable>; + } + + namespace Line { + 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 Period { + /** + * The end of the period, which must be greater than or equal to the start. This value is inclusive. + */ + end: number; + + /** + * The start of the period. This value is inclusive. + */ + start: number; + } + + 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; + + /** + * The ID of the product that this price will belong to. One of `product` or `product_data` is required. + */ + product?: string; + + /** + * Data used to generate a new product object inline. One of `product` or `product_data` is required. + */ + product_data?: PriceData.ProductData; + + /** + * Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. 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 non-negative integer in cents (or local equivalent) representing how much to charge. One of `unit_amount` or `unit_amount_decimal` is required. + */ + 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 { + 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 list of up to 8 URLs of images for this product, meant to be displayable to the customer. + */ + images?: 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.MetadataParam; + + /** + * The product's name, meant to be displayable to the customer. + */ + name: string; + + /** + * A [tax code](https://stripe.com/docs/tax/tax-categories) ID. + */ + tax_code?: string; + } + + type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; + } + + interface TaxAmount { + /** + * The amount, in cents (or local equivalent), of the tax. + */ + amount: number; + + /** + * Data to find or create a TaxRate object. + * + * Stripe automatically creates or reuses a TaxRate object for each tax amount. If the `tax_rate_data` exactly matches a previous value, Stripe will reuse the TaxRate object. TaxRate objects created automatically by Stripe are immediately archived, do not appear in the line item's `tax_rates`, and cannot be directly added to invoices, payments, or line items. + */ + tax_rate_data: TaxAmount.TaxRateData; + + /** + * The amount on which tax is calculated, in cents (or local equivalent). + */ + taxable_amount: number; + } + + namespace TaxAmount { + interface TaxRateData { + /** + * Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + */ + country?: string; + + /** + * An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers. + */ + description?: string; + + /** + * The display name of the tax rate, which will be shown to users. + */ + display_name: string; + + /** + * This specifies if the tax rate is inclusive or exclusive. + */ + inclusive: boolean; + + /** + * The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer's invoice. + */ + jurisdiction?: string; + + /** + * The statutory tax rate percent. This field accepts decimal values between 0 and 100 inclusive with at most 4 decimal places. To accommodate fixed-amount taxes, set the percentage to zero. Stripe will not display zero percentages on the invoice unless the `amount` of the tax is also zero. + */ + percentage: number; + + /** + * [ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2:US), without country prefix. For example, "NY" for New York, United States. + */ + state?: string; + + /** + * The high-level tax type, such as `vat` or `sales_tax`. + */ + tax_type?: TaxRateData.TaxType; + } + + namespace TaxRateData { + type TaxType = + | 'amusement_tax' + | 'communications_tax' + | 'gst' + | 'hst' + | 'igst' + | 'jct' + | 'lease_tax' + | 'pst' + | 'qst' + | 'rst' + | 'sales_tax' + | 'vat'; + } + } + } + } + interface InvoiceCreatePreviewParams { /** * Settings for automatic tax lookup for this invoice preview. @@ -3917,6 +4173,43 @@ declare module 'stripe' { source?: string; } + interface InvoiceRemoveLinesParams { + /** + * The line items to remove. + */ + lines: Array; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: 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`. + */ + invoice_metadata?: Stripe.Emptyable<{ + [key: string]: string; + }>; + } + + namespace InvoiceRemoveLinesParams { + interface Line { + /** + * Either `delete` or `unassign`. Deleted line items are permanently deleted. Unassigned line items can be reassigned to an invoice. + */ + behavior: Line.Behavior; + + /** + * ID of an existing line item to remove from this invoice. + */ + id: string; + } + + namespace Line { + type Behavior = 'delete' | 'unassign'; + } + } + interface InvoiceRetrieveUpcomingParams { /** * Settings for automatic tax lookup for this invoice preview. @@ -5248,6 +5541,262 @@ declare module 'stripe' { expand?: Array; } + interface InvoiceUpdateLinesParams { + /** + * The line items to update. + */ + lines: Array; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: 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`. For [type=subscription](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-type) line items, the incoming metadata specified on the request is directly used to set this value, in contrast to [type=invoiceitem](api/invoices/line_item#invoice_line_item_object-type) line items, where any existing metadata on the invoice line is merged with the incoming data. + */ + invoice_metadata?: Stripe.Emptyable<{ + [key: string]: string; + }>; + } + + namespace InvoiceUpdateLinesParams { + interface Line { + /** + * The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer's account, pass a negative amount. + */ + amount?: number; + + /** + * An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking. + */ + description?: string; + + /** + * Controls whether discounts apply to this line item. Defaults to false for prorations or negative line items, and true for all other line items. Cannot be set to true for prorations. + */ + discountable?: boolean; + + /** + * The coupons, promotion codes & existing discounts which apply to the line item. Item discounts are applied before invoice discounts. Pass an empty string to remove previously-defined discounts. + */ + discounts?: Stripe.Emptyable>; + + /** + * ID of an existing line item on the invoice. + */ + id: 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`. For [type=subscription](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-type) line items, the incoming metadata specified on the request is directly used to set this value, in contrast to [type=invoiceitem](api/invoices/line_item#invoice_line_item_object-type) line items, where any existing metadata on the invoice line is merged with the incoming data. + */ + metadata?: Stripe.Emptyable; + + /** + * The period associated with this invoice item. When set to different values, the period will be rendered on the invoice. If you have [Stripe Revenue Recognition](https://stripe.com/docs/revenue-recognition) enabled, the period will be used to recognize and defer revenue. See the [Revenue Recognition documentation](https://stripe.com/docs/revenue-recognition/methodology/subscriptions-and-invoicing) for details. + */ + period?: Line.Period; + + /** + * The ID of the price object. One of `price` or `price_data` is required. + */ + price?: string; + + /** + * Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. One of `price` or `price_data` is required. + */ + price_data?: Line.PriceData; + + /** + * Non-negative integer. The quantity of units for the line item. + */ + quantity?: number; + + /** + * A list of up to 10 tax amounts for this line item. This can be useful if you calculate taxes on your own or use a third-party to calculate them. You cannot set tax amounts if any line item has [tax_rates](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-tax_rates) or if the invoice has [default_tax_rates](https://stripe.com/docs/api/invoices/object#invoice_object-default_tax_rates) or uses [automatic tax](https://stripe.com/docs/tax/invoicing). Pass an empty string to remove previously defined tax amounts. + */ + tax_amounts?: Stripe.Emptyable>; + + /** + * The tax rates which apply to the line item. When set, the `default_tax_rates` on the invoice do not apply to this line item. Pass an empty string to remove previously-defined tax rates. + */ + tax_rates?: Stripe.Emptyable>; + } + + namespace Line { + 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 Period { + /** + * The end of the period, which must be greater than or equal to the start. This value is inclusive. + */ + end: number; + + /** + * The start of the period. This value is inclusive. + */ + start: number; + } + + 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; + + /** + * The ID of the product that this price will belong to. One of `product` or `product_data` is required. + */ + product?: string; + + /** + * Data used to generate a new product object inline. One of `product` or `product_data` is required. + */ + product_data?: PriceData.ProductData; + + /** + * Only required if a [default tax behavior](https://stripe.com/docs/tax/products-prices-tax-categories-tax-behavior#setting-a-default-tax-behavior-(recommended)) was not provided in the Stripe Tax settings. 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 non-negative integer in cents (or local equivalent) representing how much to charge. One of `unit_amount` or `unit_amount_decimal` is required. + */ + 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 { + 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 list of up to 8 URLs of images for this product, meant to be displayable to the customer. + */ + images?: 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.MetadataParam; + + /** + * The product's name, meant to be displayable to the customer. + */ + name: string; + + /** + * A [tax code](https://stripe.com/docs/tax/tax-categories) ID. + */ + tax_code?: string; + } + + type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; + } + + interface TaxAmount { + /** + * The amount, in cents (or local equivalent), of the tax. + */ + amount: number; + + /** + * Data to find or create a TaxRate object. + * + * Stripe automatically creates or reuses a TaxRate object for each tax amount. If the `tax_rate_data` exactly matches a previous value, Stripe will reuse the TaxRate object. TaxRate objects created automatically by Stripe are immediately archived, do not appear in the line item's `tax_rates`, and cannot be directly added to invoices, payments, or line items. + */ + tax_rate_data: TaxAmount.TaxRateData; + + /** + * The amount on which tax is calculated, in cents (or local equivalent). + */ + taxable_amount: number; + } + + namespace TaxAmount { + interface TaxRateData { + /** + * Two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + */ + country?: string; + + /** + * An arbitrary string attached to the tax rate for your internal use only. It will not be visible to your customers. + */ + description?: string; + + /** + * The display name of the tax rate, which will be shown to users. + */ + display_name: string; + + /** + * This specifies if the tax rate is inclusive or exclusive. + */ + inclusive: boolean; + + /** + * The jurisdiction for the tax rate. You can use this label field for tax reporting purposes. It also appears on your customer's invoice. + */ + jurisdiction?: string; + + /** + * The statutory tax rate percent. This field accepts decimal values between 0 and 100 inclusive with at most 4 decimal places. To accommodate fixed-amount taxes, set the percentage to zero. Stripe will not display zero percentages on the invoice unless the `amount` of the tax is also zero. + */ + percentage: number; + + /** + * [ISO 3166-2 subdivision code](https://en.wikipedia.org/wiki/ISO_3166-2:US), without country prefix. For example, "NY" for New York, United States. + */ + state?: string; + + /** + * The high-level tax type, such as `vat` or `sales_tax`. + */ + tax_type?: TaxRateData.TaxType; + } + + namespace TaxRateData { + type TaxType = + | 'amusement_tax' + | 'communications_tax' + | 'gst' + | 'hst' + | 'igst' + | 'jct' + | 'lease_tax' + | 'pst' + | 'qst' + | 'rst' + | 'sales_tax' + | 'vat'; + } + } + } + } + interface InvoiceUpdateLineItemParams { /** * The integer amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. If you want to apply a credit to the customer's account, pass a negative amount. @@ -5275,7 +5824,7 @@ declare module 'stripe' { expand?: 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`. For `type=recurring` line items, the incoming metadata specified on the request is directly used to set this value, in contrast to `type=invoiceitem` line items, where any existing metadata on the invoice line is merged with the incoming data. + * 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`. For [type=subscription](https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-type) line items, the incoming metadata specified on the request is directly used to set this value, in contrast to [type=invoiceitem](api/invoices/line_item#invoice_line_item_object-type) line items, where any existing metadata on the invoice line is merged with the incoming data. */ metadata?: Stripe.Emptyable; @@ -5553,6 +6102,15 @@ declare module 'stripe' { options?: RequestOptions ): Promise>; + /** + * Adds multiple line items to an invoice. This is only possible when an invoice is still a draft. + */ + addLines( + id: string, + params: InvoiceAddLinesParams, + options?: RequestOptions + ): Promise>; + /** * At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice. * @@ -5633,6 +6191,15 @@ declare module 'stripe' { options?: RequestOptions ): Promise>; + /** + * Removes multiple line items from an invoice. This is only possible when an invoice is still a draft. + */ + removeLines( + id: string, + params: InvoiceRemoveLinesParams, + options?: RequestOptions + ): Promise>; + /** * At any time, you can preview the upcoming invoice for a customer. This will show you all the charges that are pending, including subscription renewal charges, invoice item charges, etc. It will also show you any discounts that are applicable to the invoice. * @@ -5676,6 +6243,15 @@ declare module 'stripe' { options?: RequestOptions ): Promise>; + /** + * Updates multiple line items on an invoice. This is only possible when an invoice is still a draft. + */ + updateLines( + id: string, + params: InvoiceUpdateLinesParams, + options?: RequestOptions + ): Promise>; + /** * Updates an invoice's line item. Some fields, such as tax_amounts, only live on the invoice line item, * so they can only be updated through this endpoint. Other fields, such as amount, live on both the invoice diff --git a/types/PaymentIntents.d.ts b/types/PaymentIntents.d.ts index 8d0f742c8e..5aa424883b 100644 --- a/types/PaymentIntents.d.ts +++ b/types/PaymentIntents.d.ts @@ -475,6 +475,7 @@ declare module 'stripe' { | 'parameters_exclusive' | 'payment_intent_action_required' | 'payment_intent_authentication_failure' + | 'payment_intent_fx_quote_invalid' | 'payment_intent_incompatible_payment_method' | 'payment_intent_invalid_parameter' | 'payment_intent_konbini_rejected_confirmation_number' diff --git a/types/SetupAttempts.d.ts b/types/SetupAttempts.d.ts index 513abcbf00..ef3e5b9a93 100644 --- a/types/SetupAttempts.d.ts +++ b/types/SetupAttempts.d.ts @@ -718,6 +718,7 @@ declare module 'stripe' { | 'parameters_exclusive' | 'payment_intent_action_required' | 'payment_intent_authentication_failure' + | 'payment_intent_fx_quote_invalid' | 'payment_intent_incompatible_payment_method' | 'payment_intent_invalid_parameter' | 'payment_intent_konbini_rejected_confirmation_number' diff --git a/types/SetupIntents.d.ts b/types/SetupIntents.d.ts index 9a92a99bfa..94f7f935b8 100644 --- a/types/SetupIntents.d.ts +++ b/types/SetupIntents.d.ts @@ -388,6 +388,7 @@ declare module 'stripe' { | 'parameters_exclusive' | 'payment_intent_action_required' | 'payment_intent_authentication_failure' + | 'payment_intent_fx_quote_invalid' | 'payment_intent_incompatible_payment_method' | 'payment_intent_invalid_parameter' | 'payment_intent_konbini_rejected_confirmation_number' diff --git a/types/Tax/Transactions.d.ts b/types/Tax/Transactions.d.ts index d7760fd3a5..ea68ee1215 100644 --- a/types/Tax/Transactions.d.ts +++ b/types/Tax/Transactions.d.ts @@ -51,6 +51,11 @@ declare module 'stripe' { */ metadata: Stripe.Metadata | null; + /** + * The Unix timestamp representing when the tax liability is assumed or reduced. + */ + posted_at: number; + /** * A custom unique identifier, such as 'myOrder_123'. */ diff --git a/types/Tax/TransactionsResource.d.ts b/types/Tax/TransactionsResource.d.ts index a18aa269e1..38d1fe770d 100644 --- a/types/Tax/TransactionsResource.d.ts +++ b/types/Tax/TransactionsResource.d.ts @@ -30,6 +30,11 @@ declare module 'stripe' { * 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 Unix timestamp representing when the tax liability is assumed or reduced, which determines the liability posting period and handling in tax liability reports. The timestamp must fall within the `tax_date` and the current time, unless the `tax_date` is scheduled in advance. Defaults to the current time. + */ + posted_at?: number; } interface TransactionCreateReversalParams { From 28eb73e79907958e08da2ebf644ebc8a1ad146d8 Mon Sep 17 00:00:00 2001 From: Prathmesh Ranaut Date: Fri, 5 Jul 2024 14:51:11 -0400 Subject: [PATCH 2/5] Bump version to 16.2.0 --- CHANGELOG.md | 6 ++++++ VERSION | 2 +- package.json | 2 +- src/stripe.core.ts | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b22a6f61bb..d9e8a5dce2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 16.2.0 - 2024-07-05 +* [#2125](https://github.com/stripe/stripe-node/pull/2125) Update generated code + * Add support for `add_lines`, `remove_lines`, and `update_lines` methods on resource `Invoice` + * Add support for new value `payment_intent_fx_quote_invalid` on enums `Invoice.last_finalization_error.code`, `PaymentIntent.last_payment_error.code`, `SetupAttempt.setup_error.code`, `SetupIntent.last_setup_error.code`, and `StripeError.code` + * Add support for `posted_at` on `Tax.TransactionCreateFromCalculationParams` and `Tax.Transaction` + ## 16.1.0 - 2024-06-27 * [#2120](https://github.com/stripe/stripe-node/pull/2120) Update generated code * Add support for `filters` on `Checkout.Session.payment_method_options.us_bank_account.financial_connections`, `Invoice.payment_settings.payment_method_options.us_bank_account.financial_connections`, `InvoiceCreateParams.payment_settings.payment_method_options.us_bank_account.financial_connections`, `InvoiceUpdateParams.payment_settings.payment_method_options.us_bank_account.financial_connections`, `PaymentIntent.payment_method_options.us_bank_account.financial_connections`, `PaymentIntentConfirmParams.payment_method_options.us_bank_account.financial_connections`, `PaymentIntentCreateParams.payment_method_options.us_bank_account.financial_connections`, `PaymentIntentUpdateParams.payment_method_options.us_bank_account.financial_connections`, `SetupIntent.payment_method_options.us_bank_account.financial_connections`, `SetupIntentConfirmParams.payment_method_options.us_bank_account.financial_connections`, `SetupIntentCreateParams.payment_method_options.us_bank_account.financial_connections`, `SetupIntentUpdateParams.payment_method_options.us_bank_account.financial_connections`, `Subscription.payment_settings.payment_method_options.us_bank_account.financial_connections`, `SubscriptionCreateParams.payment_settings.payment_method_options.us_bank_account.financial_connections`, and `SubscriptionUpdateParams.payment_settings.payment_method_options.us_bank_account.financial_connections` diff --git a/VERSION b/VERSION index e0228cf182..fd1bd70b7e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -16.1.0 +16.2.0 diff --git a/package.json b/package.json index 304e937a1f..35e72679c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stripe", - "version": "16.1.0", + "version": "16.2.0", "description": "Stripe API wrapper", "keywords": [ "stripe", diff --git a/src/stripe.core.ts b/src/stripe.core.ts index 6608d1a46b..712fbacaa3 100644 --- a/src/stripe.core.ts +++ b/src/stripe.core.ts @@ -49,7 +49,7 @@ export function createStripe( platformFunctions: PlatformFunctions, requestSender: RequestSenderFactory = defaultRequestSenderFactory ): typeof Stripe { - Stripe.PACKAGE_VERSION = '16.1.0'; + Stripe.PACKAGE_VERSION = '16.2.0'; Stripe.USER_AGENT = { bindings_version: Stripe.PACKAGE_VERSION, lang: 'node', From 3908aca783a60d039e82677a7b7cab65a3982ef5 Mon Sep 17 00:00:00 2001 From: Ziya El Arief Date: Tue, 9 Jul 2024 00:49:44 +0700 Subject: [PATCH 3/5] Add generateTestHeaderStringAsync function to Webhooks.ts (#2048) * Add generateTestHeaderStringAsync function to Webhooks.ts * refactor duplicated codes --- src/Webhooks.ts | 78 +++++++++++++++++++++++++++++++------------- test/Webhook.spec.ts | 24 ++++++++++++++ 2 files changed, 80 insertions(+), 22 deletions(-) diff --git a/src/Webhooks.ts b/src/Webhooks.ts index 038c205d29..fc3dec8907 100644 --- a/src/Webhooks.ts +++ b/src/Webhooks.ts @@ -65,6 +65,9 @@ export type WebhookObject = { receivedAt: number ) => Promise; generateTestHeaderString: (opts: WebhookTestHeaderOptions) => string; + generateTestHeaderStringAsync: ( + opts: WebhookTestHeaderOptions + ) => Promise; }; export function createWebhooks( @@ -142,31 +145,30 @@ export function createWebhooks( * @property {CryptoProvider} cryptoProvider - Crypto provider to use for computing the signature if none was provided. Defaults to NodeCryptoProvider. */ generateTestHeaderString: function(opts: WebhookTestHeaderOptions): string { - 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 || getCryptoProvider(); + const preparedOpts = prepareOptions(opts); - opts.signature = - opts.signature || - opts.cryptoProvider.computeHMACSignature( - opts.timestamp + '.' + opts.payload, - opts.secret + const signature = + preparedOpts.signature || + preparedOpts.cryptoProvider.computeHMACSignature( + preparedOpts.payloadString, + preparedOpts.secret ); - const generatedHeader = [ - 't=' + opts.timestamp, - opts.scheme + '=' + opts.signature, - ].join(','); - - return generatedHeader; + return preparedOpts.generateHeaderString(signature); + }, + generateTestHeaderStringAsync: async function( + opts: WebhookTestHeaderOptions + ) { + const preparedOpts = prepareOptions(opts); + + const signature = + preparedOpts.signature || + (await preparedOpts.cryptoProvider.computeHMACSignatureAsync( + preparedOpts.payloadString, + preparedOpts.secret + )); + + return preparedOpts.generateHeaderString(signature); }, }; @@ -443,6 +445,38 @@ export function createWebhooks( return webhooksCryptoProviderInstance!; } + function prepareOptions( + opts: WebhookTestHeaderOptions + ): WebhookTestHeaderOptions & { + payloadString: string; + generateHeaderString: (signature: string) => string; + } { + if (!opts) { + throw new StripeError({ + message: 'Options are required', + }); + } + + const timestamp = + Math.floor(opts.timestamp) || Math.floor(Date.now() / 1000); + const scheme = opts.scheme || signature.EXPECTED_SCHEME; + const cryptoProvider = opts.cryptoProvider || getCryptoProvider(); + const payloadString = `${timestamp}.${opts.payload}`; + + const generateHeaderString = (signature: string): string => { + return `t=${timestamp},${scheme}=${signature}`; + }; + + return { + ...opts, + timestamp, + scheme, + cryptoProvider, + payloadString, + generateHeaderString, + }; + } + Webhook.signature = signature; return Webhook; diff --git a/test/Webhook.spec.ts b/test/Webhook.spec.ts index 705d89aed6..deae6648de 100644 --- a/test/Webhook.spec.ts +++ b/test/Webhook.spec.ts @@ -41,6 +41,30 @@ function createWebhooksTestSuite(stripe) { }); }); + describe('.generateTestHeaderStringAsync', () => { + it('should throw when no opts are passed', async () => { + await expect( + stripe.webhooks.generateTestHeaderStringAsync() + ).to.be.rejectedWith('Options are required'); + }); + + it('should correctly construct a webhook header', async () => { + const header = await stripe.webhooks.generateTestHeaderStringAsync({ + payload: EVENT_PAYLOAD_STRING, + secret: SECRET, + }); + + expect(header).to.not.be.undefined; + expect(header.split(',')).to.have.lengthOf(2); + expect(header).to.equal( + stripe.webhooks.generateTestHeaderString({ + payload: EVENT_PAYLOAD_STRING, + secret: SECRET, + }) + ); + }); + }); + const makeConstructEventTests = ( constructEventFn: typeof stripe.webhooks.construct ) => { From f5e86aab05832d1087512ea9e2ad56d3b620cd58 Mon Sep 17 00:00:00 2001 From: David Brownman <109395161+xavdid-stripe@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:49:08 -0700 Subject: [PATCH 4/5] check `hasOwnProperty` when using `for..in` (#2132) check hasOwnProperty when using for..in --- .eslintrc.js | 2 +- src/ResourceNamespace.ts | 3 +++ src/multipart.ts | 6 +++++- src/stripe.core.ts | 21 ++++++++++++++------- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2c9460d71c..cb35b11e7b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -39,7 +39,7 @@ module.exports = { 'func-style': ['error', 'declaration', {allowArrowFunctions: true}], 'generator-star-spacing': 'error', 'global-require': 'off', - 'guard-for-in': 'off', + 'guard-for-in': 'error', 'handle-callback-err': 'off', 'id-blacklist': 'error', 'id-length': 'off', diff --git a/src/ResourceNamespace.ts b/src/ResourceNamespace.ts index 0ffdcc67fe..ea7fb9d261 100644 --- a/src/ResourceNamespace.ts +++ b/src/ResourceNamespace.ts @@ -16,6 +16,9 @@ function ResourceNamespace( > ): void { for (const name in resources) { + if (!Object.prototype.hasOwnProperty.call(resources, name)) { + continue; + } const camelCaseName = name[0].toLowerCase() + name.substring(1); const resource = new resources[name](stripe); diff --git a/src/multipart.ts b/src/multipart.ts index 7472864f8f..1e28eb44f9 100644 --- a/src/multipart.ts +++ b/src/multipart.ts @@ -1,8 +1,8 @@ import { MultipartRequestData, + RequestData, RequestHeaders, StripeResourceObject, - RequestData, } from './Types.js'; import {flattenAndStringify, stringifyRequestData} from './utils.js'; @@ -46,6 +46,10 @@ const multipartDataGenerator = ( const flattenedData = flattenAndStringify(data); for (const k in flattenedData) { + if (!Object.prototype.hasOwnProperty.call(flattenedData, k)) { + continue; + } + const v = flattenedData[k]; push(`--${segno}`); if (Object.prototype.hasOwnProperty.call(v, 'data')) { diff --git a/src/stripe.core.ts b/src/stripe.core.ts index 712fbacaa3..a2b74cb4f9 100644 --- a/src/stripe.core.ts +++ b/src/stripe.core.ts @@ -1,18 +1,18 @@ import * as _Error from './Error.js'; +import {RequestSender} from './RequestSender.js'; +import {StripeResource} from './StripeResource.js'; +import {AppInfo, StripeObject, UserProvidedConfig} from './Types.js'; +import {WebhookObject, createWebhooks} from './Webhooks.js'; import * as apiVersion from './apiVersion.js'; -import * as resources from './resources.js'; +import {CryptoProvider} from './crypto/CryptoProvider.js'; import {HttpClient, HttpClientResponse} from './net/HttpClient.js'; +import {PlatformFunctions} from './platform/PlatformFunctions.js'; +import * as resources from './resources.js'; import { determineProcessUserAgentProperties, pascalToCamelCase, validateInteger, } from './utils.js'; -import {CryptoProvider} from './crypto/CryptoProvider.js'; -import {PlatformFunctions} from './platform/PlatformFunctions.js'; -import {RequestSender} from './RequestSender.js'; -import {StripeResource} from './StripeResource.js'; -import {WebhookObject, createWebhooks} from './Webhooks.js'; -import {StripeObject, AppInfo, UserProvidedConfig} from './Types.js'; const DEFAULT_HOST = 'api.stripe.com'; const DEFAULT_PORT = '443'; @@ -363,6 +363,9 @@ export function createStripe( this._platformFunctions.getUname().then((uname: string | null) => { const userAgent: Record = {}; for (const field in seed) { + if (!Object.prototype.hasOwnProperty.call(seed, field)) { + continue; + } userAgent[field] = encodeURIComponent(seed[field] ?? 'null'); } @@ -417,6 +420,10 @@ export function createStripe( */ _prepResources(): void { for (const name in resources) { + if (!Object.prototype.hasOwnProperty.call(resources, name)) { + continue; + } + // @ts-ignore this[pascalToCamelCase(name)] = new resources[name](this); } From 278d489abc37424921c20d0f8d3be41dd8816064 Mon Sep 17 00:00:00 2001 From: David Brownman <109395161+xavdid-stripe@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:36:46 -0700 Subject: [PATCH 5/5] update node versions in CI (#2133) --- .github/workflows/main.yml | 5 ++++- .mise.toml | 3 +++ examples/webhook-signing/.gitignore | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .mise.toml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22124cab7c..ad8d7d728b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,7 +55,10 @@ jobs: os: - "ubuntu-latest" node: - - "19" + # should include even numbers >= 12 + # see: https://nodejs.org/en/about/previous-releases + - "22" + - "20" - "18" - "16" - "14" diff --git a/.mise.toml b/.mise.toml new file mode 100644 index 0000000000..94de2731e4 --- /dev/null +++ b/.mise.toml @@ -0,0 +1,3 @@ +[tools] +# used in unit tests +deno = "1" diff --git a/examples/webhook-signing/.gitignore b/examples/webhook-signing/.gitignore index a85efbf88c..f72e4117b2 100644 --- a/examples/webhook-signing/.gitignore +++ b/examples/webhook-signing/.gitignore @@ -3,3 +3,4 @@ **/package-lock.json .env express-ts.js +deno.lock