From 2aaa8974b6eaebb2c8bce685d4c76ed61f9d163b Mon Sep 17 00:00:00 2001 From: Kamil Pajdzik <99290280+kamil-stripe@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:13:38 -0700 Subject: [PATCH] Generate stripe-node with breaking changes (#1491) * Generate stripe-node with breaking changes * Update CustomerSource enum * Generate files * Fix type in test * Fix tests --- lib/resources/CreditNotes.js | 12 +- lib/resources/Invoices.js | 12 +- lib/resources/Issuing/Cards.js | 5 - test/resources/Invoices.spec.js | 6 +- test/resources/Issuing/Cards.spec.js | 16 - .../resources/generated_examples_test.spec.js | 14 +- types/2020-08-27/Accounts.d.ts | 10 +- types/2020-08-27/AlipayAccounts.d.ts | 92 -- types/2020-08-27/BitcoinReceivers.d.ts | 142 --- types/2020-08-27/BitcoinTransactions.d.ts | 57 -- types/2020-08-27/Cards.d.ts | 5 - types/2020-08-27/Checkout/Sessions.d.ts | 13 +- types/2020-08-27/CreditNoteLineItems.d.ts | 111 --- types/2020-08-27/CreditNotes.d.ts | 127 ++- types/2020-08-27/CustomerSources.d.ts | 2 + types/2020-08-27/Customers.d.ts | 35 +- types/2020-08-27/InvoiceLineItems.d.ts | 512 ---------- types/2020-08-27/Invoices.d.ts | 924 ++++++++++++++---- types/2020-08-27/Issuing/CardDetails.d.ts | 42 - types/2020-08-27/Issuing/Cards.d.ts | 20 - types/2020-08-27/LineItems.d.ts | 7 - types/2020-08-27/LoginLinks.d.ts | 5 - types/2020-08-27/PaymentIntents.d.ts | 2 - types/2020-08-27/Recipients.d.ts | 98 -- types/2020-08-27/WebhookEndpoints.d.ts | 8 - types/2020-08-27/index.d.ts | 5 - types/shared.d.ts | 8 +- types/test/typescriptTest.ts | 2 +- 28 files changed, 896 insertions(+), 1396 deletions(-) delete mode 100644 types/2020-08-27/AlipayAccounts.d.ts delete mode 100644 types/2020-08-27/BitcoinReceivers.d.ts delete mode 100644 types/2020-08-27/BitcoinTransactions.d.ts delete mode 100644 types/2020-08-27/Issuing/CardDetails.d.ts delete mode 100644 types/2020-08-27/Recipients.d.ts diff --git a/lib/resources/CreditNotes.js b/lib/resources/CreditNotes.js index 512e5a7cde..e435282d00 100644 --- a/lib/resources/CreditNotes.js +++ b/lib/resources/CreditNotes.js @@ -29,6 +29,12 @@ module.exports = StripeResource.extend({ methodType: 'list', }), + listPreviewLineItems: stripeMethod({ + method: 'GET', + path: '/preview/lines', + methodType: 'list', + }), + preview: stripeMethod({ method: 'GET', path: '/preview', @@ -44,10 +50,4 @@ module.exports = StripeResource.extend({ path: '/{creditNote}/lines', methodType: 'list', }), - - listPreviewLineItems: stripeMethod({ - method: 'GET', - path: '/preview/lines', - methodType: 'list', - }), }); diff --git a/lib/resources/Invoices.js b/lib/resources/Invoices.js index 7103c96813..21543c1f3a 100644 --- a/lib/resources/Invoices.js +++ b/lib/resources/Invoices.js @@ -39,6 +39,12 @@ module.exports = StripeResource.extend({ path: '/{invoice}/finalize', }), + listUpcomingLines: stripeMethod({ + method: 'GET', + path: '/upcoming/lines', + methodType: 'list', + }), + markUncollectible: stripeMethod({ method: 'POST', path: '/{invoice}/mark_uncollectible', @@ -75,10 +81,4 @@ module.exports = StripeResource.extend({ path: '/{invoice}/lines', methodType: 'list', }), - - listUpcomingLineItems: stripeMethod({ - method: 'GET', - path: '/upcoming/lines', - methodType: 'list', - }), }); diff --git a/lib/resources/Issuing/Cards.js b/lib/resources/Issuing/Cards.js index b94aeaea28..efc2cbc10f 100644 --- a/lib/resources/Issuing/Cards.js +++ b/lib/resources/Issuing/Cards.js @@ -28,9 +28,4 @@ module.exports = StripeResource.extend({ path: '', methodType: 'list', }), - - retrieveDetails: stripeMethod({ - method: 'GET', - path: '/{card}/details', - }), }); diff --git a/test/resources/Invoices.spec.js b/test/resources/Invoices.spec.js index ea8bb87c84..529bad20c9 100644 --- a/test/resources/Invoices.spec.js +++ b/test/resources/Invoices.spec.js @@ -82,9 +82,9 @@ describe('Invoices Resource', () => { }); }); - describe('listUpcomingLineItems', () => { + describe('listUpcomingLines', () => { it('Sends the correct request', () => { - stripe.invoices.listUpcomingLineItems(); + stripe.invoices.listUpcomingLines(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/invoices/upcoming/lines', @@ -115,7 +115,7 @@ describe('Invoices Resource', () => { describe('listUpcomingLineItems', () => { it('Sends the correct request', () => { - stripe.invoices.listUpcomingLineItems({ + stripe.invoices.listUpcomingLines({ customer: 'cus_abc', subscription_items: [{plan: 'potato'}, {plan: 'rutabaga'}], limit: 5, diff --git a/test/resources/Issuing/Cards.spec.js b/test/resources/Issuing/Cards.spec.js index fcc1c11800..7a7a230a08 100644 --- a/test/resources/Issuing/Cards.spec.js +++ b/test/resources/Issuing/Cards.spec.js @@ -75,20 +75,4 @@ describe('Issuing', () => { }); }); }); - - describe('Virtual Cards Resource', () => { - describe('retrieve', () => { - it('Sends the correct request', () => { - stripe.issuing.cards.retrieveDetails('ic_123'); - - expect(stripe.LAST_REQUEST).to.deep.equal({ - method: 'GET', - url: '/v1/issuing/cards/ic_123/details', - headers: {}, - data: {}, - settings: {}, - }); - }); - }); - }); }); diff --git a/test/resources/generated_examples_test.spec.js b/test/resources/generated_examples_test.spec.js index 64b6f63fab..0c0b414ae9 100644 --- a/test/resources/generated_examples_test.spec.js +++ b/test/resources/generated_examples_test.spec.js @@ -76,6 +76,11 @@ describe('Checkout.Session', function() { expect(session).not.to.be.null; }); + it('listLineItems method', async function() { + const lineItems = await stripe.checkout.sessions.listLineItems('sess_xyz'); + expect(lineItems).not.to.be.null; + }); + it('list method', async function() { const sessions = await stripe.checkout.sessions.list({limit: 3}); expect(sessions).not.to.be.null; @@ -311,13 +316,16 @@ describe('Order', function() { expect(order).not.to.be.null; }); - it('update method', async function() { - const order = await stripe.orders.update('order_xyz'); + it('retrieve method', async function() { + const order = await stripe.orders.retrieve('order_xyz'); expect(order).not.to.be.null; }); it('update method', async function() { - const order = await stripe.orders.update('order_xyz'); + const order = await stripe.orders.update('order_xyz', { + metadata: {reference_number: '123'}, + ip_address: '0.0.0.0', + }); expect(order).not.to.be.null; }); diff --git a/types/2020-08-27/Accounts.d.ts b/types/2020-08-27/Accounts.d.ts index fc902d151c..9eae1b9e9a 100644 --- a/types/2020-08-27/Accounts.d.ts +++ b/types/2020-08-27/Accounts.d.ts @@ -19,12 +19,12 @@ declare module 'stripe' { /** * Business information about the account. */ - business_profile: Account.BusinessProfile | null; + business_profile?: Account.BusinessProfile | null; /** * The business type. */ - business_type: Account.BusinessType | null; + business_type?: Account.BusinessType | null; capabilities?: Account.Capabilities; @@ -40,7 +40,7 @@ declare module 'stripe' { /** * The account's country. */ - country: string; + country?: string; /** * Time at which the account was connected. Measured in seconds since the Unix epoch. @@ -50,7 +50,7 @@ declare module 'stripe' { /** * Three-letter ISO currency code representing the default currency for the account. This must be a currency that [Stripe supports in the account's country](https://stripe.com/docs/payouts). */ - default_currency: string; + default_currency?: string; deleted?: void; @@ -96,7 +96,7 @@ declare module 'stripe' { /** * Options for customizing how the account functions within Stripe. */ - settings: Account.Settings | null; + settings?: Account.Settings | null; tos_acceptance?: Account.TosAcceptance; diff --git a/types/2020-08-27/AlipayAccounts.d.ts b/types/2020-08-27/AlipayAccounts.d.ts deleted file mode 100644 index 46d3af6278..0000000000 --- a/types/2020-08-27/AlipayAccounts.d.ts +++ /dev/null @@ -1,92 +0,0 @@ -// File generated from our OpenAPI spec - -declare module 'stripe' { - namespace Stripe { - /** - * The AlipayAccount object. - */ - interface AlipayAccount { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'alipay_account'; - - /** - * Time at which the object was created. Measured in seconds since the Unix epoch. - */ - created: number; - - /** - * The ID of the customer associated with this Alipay Account. - */ - customer?: string | Stripe.Customer | Stripe.DeletedCustomer | null; - - deleted?: void; - - /** - * Uniquely identifies the account and will be the same across all Alipay account objects that are linked to the same Alipay account. - */ - fingerprint: string; - - /** - * 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; - - /** - * If the Alipay account object is not reusable, the exact amount that you can create a charge for. - */ - payment_amount: number | null; - - /** - * If the Alipay account object is not reusable, the exact currency that you can create a charge for. - */ - payment_currency: string | null; - - /** - * True if you can create multiple payments using this account. If the account is reusable, then you can freely choose the amount of each payment. - */ - reusable: boolean; - - /** - * Whether this Alipay account object has ever been used for a payment. - */ - used: boolean; - - /** - * The username for the Alipay account. - */ - username: string; - } - - /** - * The DeletedAlipayAccount object. - */ - interface DeletedAlipayAccount { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'alipay_account'; - - /** - * Always true for a deleted object - */ - deleted: true; - } - } -} diff --git a/types/2020-08-27/BitcoinReceivers.d.ts b/types/2020-08-27/BitcoinReceivers.d.ts deleted file mode 100644 index a348c2c6b7..0000000000 --- a/types/2020-08-27/BitcoinReceivers.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -// File generated from our OpenAPI spec - -declare module 'stripe' { - namespace Stripe { - /** - * The BitcoinReceiver object. - */ - interface BitcoinReceiver { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'bitcoin_receiver'; - - /** - * True when this bitcoin receiver has received a non-zero amount of bitcoin. - */ - active: boolean; - - /** - * The amount of `currency` that you are collecting as payment. - */ - amount: number; - - /** - * The amount of `currency` to which `bitcoin_amount_received` has been converted. - */ - amount_received: number; - - /** - * The amount of bitcoin that the customer should send to fill the receiver. The `bitcoin_amount` is denominated in Satoshi: there are 10^8 Satoshi in one bitcoin. - */ - bitcoin_amount: number; - - /** - * The amount of bitcoin that has been sent by the customer to this receiver. - */ - bitcoin_amount_received: number; - - /** - * This URI can be displayed to the customer as a clickable link (to activate their bitcoin client) or as a QR code (for mobile wallets). - */ - bitcoin_uri: string; - - /** - * Time at which the object was created. Measured in seconds since the Unix epoch. - */ - created: number; - - /** - * Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) to which the bitcoin will be converted. - */ - currency: string; - - /** - * The customer ID of the bitcoin receiver. - */ - customer?: string | null; - - deleted?: void; - - /** - * An arbitrary string attached to the object. Often useful for displaying to users. - */ - description: string | null; - - /** - * The customer's email address, set by the API call that creates the receiver. - */ - email: string | null; - - /** - * This flag is initially false and updates to true when the customer sends the `bitcoin_amount` to this receiver. - */ - filled: boolean; - - /** - * A bitcoin address that is specific to this receiver. The customer can send bitcoin to this address to fill the receiver. - */ - inbound_address: string; - - /** - * 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; - - /** - * The ID of the payment created from the receiver, if any. Hidden when viewing the receiver with a publishable key. - */ - payment?: string | null; - - /** - * The refund address of this bitcoin receiver. - */ - refund_address: string | null; - - /** - * A list with one entry for each time that the customer sent bitcoin to the receiver. Hidden when viewing the receiver with a publishable key. - */ - transactions?: ApiList; - - /** - * This receiver contains uncaptured funds that can be used for a payment or refunded. - */ - uncaptured_funds: boolean; - - /** - * Indicate if this source is used for payment. - */ - used_for_payment: boolean | null; - } - - /** - * The DeletedBitcoinReceiver object. - */ - interface DeletedBitcoinReceiver { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'bitcoin_receiver'; - - /** - * Always true for a deleted object - */ - deleted: true; - } - } -} diff --git a/types/2020-08-27/BitcoinTransactions.d.ts b/types/2020-08-27/BitcoinTransactions.d.ts deleted file mode 100644 index 1e3baeb633..0000000000 --- a/types/2020-08-27/BitcoinTransactions.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -// File generated from our OpenAPI spec - -declare module 'stripe' { - namespace Stripe { - /** - * The BitcoinTransaction object. - */ - interface BitcoinTransaction { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'bitcoin_transaction'; - - /** - * The amount of `currency` that the transaction was converted to in real-time. - */ - amount: number; - - /** - * The amount of bitcoin contained in the transaction. - */ - bitcoin_amount: number; - - /** - * Time at which the object was created. Measured in seconds since the Unix epoch. - */ - created: number; - - /** - * Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) to which this transaction was converted. - */ - currency: string; - - /** - * The receiver to which this transaction was sent. - */ - receiver: string; - } - - interface BitcoinTransactionListParams extends PaginationParams { - /** - * Only return transactions for the customer specified by this customer ID. - */ - customer?: string; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - } -} diff --git a/types/2020-08-27/Cards.d.ts b/types/2020-08-27/Cards.d.ts index 239f699a78..e16d65819a 100644 --- a/types/2020-08-27/Cards.d.ts +++ b/types/2020-08-27/Cards.d.ts @@ -155,11 +155,6 @@ declare module 'stripe' { */ name: string | null; - /** - * The recipient that this card belongs to. This attribute will not be in the card object if the card belongs to a customer or account instead. - */ - recipient?: string | Stripe.Recipient | null; - /** * For external accounts, possible values are `new` and `errored`. If a transfer fails, the status is set to `errored` and transfers are stopped until account details are updated. */ diff --git a/types/2020-08-27/Checkout/Sessions.d.ts b/types/2020-08-27/Checkout/Sessions.d.ts index 74386467b1..47f5080537 100644 --- a/types/2020-08-27/Checkout/Sessions.d.ts +++ b/types/2020-08-27/Checkout/Sessions.d.ts @@ -503,7 +503,7 @@ declare module 'stripe' { /** * Currency supported by the bank account. Returned when the Session is in `setup` mode. */ - currency?: string; + currency?: AcssDebit.Currency; mandate_options?: AcssDebit.MandateOptions; @@ -523,6 +523,8 @@ declare module 'stripe' { } namespace AcssDebit { + type Currency = 'cad' | 'usd'; + interface MandateOptions { /** * A URL for custom mandate text @@ -3172,6 +3174,13 @@ declare module 'stripe' { expand?: Array; } + interface SessionListLineItemsParams extends PaginationParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + class SessionsResource { /** * Creates a Session object. @@ -3223,7 +3232,7 @@ declare module 'stripe' { */ listLineItems( id: string, - params?: LineItemListParams, + params?: SessionListLineItemsParams, options?: RequestOptions ): ApiListPromise; listLineItems( diff --git a/types/2020-08-27/CreditNoteLineItems.d.ts b/types/2020-08-27/CreditNoteLineItems.d.ts index e8da9c3b77..83c385bbe6 100644 --- a/types/2020-08-27/CreditNoteLineItems.d.ts +++ b/types/2020-08-27/CreditNoteLineItems.d.ts @@ -126,116 +126,5 @@ declare module 'stripe' { */ expand?: Array; } - - interface CreditNoteLineItemListPreviewParams extends PaginationParams { - /** - * ID of the invoice. - */ - invoice: string; - - /** - * The integer amount in cents (or local equivalent) representing the total amount of the credit note. - */ - amount?: number; - - /** - * The integer amount in cents (or local equivalent) representing the amount to credit the customer's balance, which will be automatically applied to their next invoice. - */ - credit_amount?: number; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * Line items that make up the credit note. - */ - lines?: Array; - - /** - * The credit note's memo appears on the credit note PDF. - */ - memo?: 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 integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe. - */ - out_of_band_amount?: number; - - /** - * Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory` - */ - reason?: CreditNoteLineItemListPreviewParams.Reason; - - /** - * ID of an existing refund to link this credit note to. - */ - refund?: string; - - /** - * The integer amount in cents (or local equivalent) representing the amount to refund. If set, a refund will be created for the charge associated with the invoice. - */ - refund_amount?: number; - } - - namespace CreditNoteLineItemListPreviewParams { - interface Line { - /** - * The line item amount to credit. Only valid when `type` is `invoice_line_item`. - */ - amount?: number; - - /** - * The description of the credit note line item. Only valid when the `type` is `custom_line_item`. - */ - description?: string; - - /** - * The invoice line item to credit. Only valid when the `type` is `invoice_line_item`. - */ - invoice_line_item?: string; - - /** - * The line item quantity to credit. - */ - quantity?: number; - - /** - * The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item`. - */ - tax_rates?: Stripe.Emptyable>; - - /** - * Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` - */ - type: Line.Type; - - /** - * The integer unit amount in cents (or local equivalent) of the credit note line item. This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. Only valid when `type` is `custom_line_item`. - */ - 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 Line { - type Type = 'custom_line_item' | 'invoice_line_item'; - } - - type Reason = - | 'duplicate' - | 'fraudulent' - | 'order_change' - | 'product_unsatisfactory'; - } } } diff --git a/types/2020-08-27/CreditNotes.d.ts b/types/2020-08-27/CreditNotes.d.ts index 7ce6b3f654..97d6707c2b 100644 --- a/types/2020-08-27/CreditNotes.d.ts +++ b/types/2020-08-27/CreditNotes.d.ts @@ -338,6 +338,117 @@ declare module 'stripe' { invoice?: string; } + interface CreditNoteListPreviewLineItemsParams extends PaginationParams { + /** + * ID of the invoice. + */ + invoice: string; + + /** + * The integer amount in cents (or local equivalent) representing the total amount of the credit note. + */ + amount?: number; + + /** + * The integer amount in cents (or local equivalent) representing the amount to credit the customer's balance, which will be automatically applied to their next invoice. + */ + credit_amount?: number; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + + /** + * Line items that make up the credit note. + */ + lines?: Array; + + /** + * The credit note's memo appears on the credit note PDF. + */ + memo?: 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 integer amount in cents (or local equivalent) representing the amount that is credited outside of Stripe. + */ + out_of_band_amount?: number; + + /** + * Reason for issuing this credit note, one of `duplicate`, `fraudulent`, `order_change`, or `product_unsatisfactory` + */ + reason?: CreditNoteListPreviewLineItemsParams.Reason; + + /** + * ID of an existing refund to link this credit note to. + */ + refund?: string; + + /** + * The integer amount in cents (or local equivalent) representing the amount to refund. If set, a refund will be created for the charge associated with the invoice. + */ + refund_amount?: number; + } + + namespace CreditNoteListPreviewLineItemsParams { + interface Line { + /** + * The line item amount to credit. Only valid when `type` is `invoice_line_item`. + */ + amount?: number; + + /** + * The description of the credit note line item. Only valid when the `type` is `custom_line_item`. + */ + description?: string; + + /** + * The invoice line item to credit. Only valid when the `type` is `invoice_line_item`. + */ + invoice_line_item?: string; + + /** + * The line item quantity to credit. + */ + quantity?: number; + + /** + * The tax rates which apply to the credit note line item. Only valid when the `type` is `custom_line_item`. + */ + tax_rates?: Stripe.Emptyable>; + + /** + * Type of the credit note line item, one of `invoice_line_item` or `custom_line_item` + */ + type: Line.Type; + + /** + * The integer unit amount in cents (or local equivalent) of the credit note line item. This `unit_amount` will be multiplied by the quantity to get the full amount to credit for this line item. Only valid when `type` is `custom_line_item`. + */ + 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 Line { + type Type = 'custom_line_item' | 'invoice_line_item'; + } + + type Reason = + | 'duplicate' + | 'fraudulent' + | 'order_change' + | 'product_unsatisfactory'; + } + interface CreditNotePreviewParams { /** * ID of the invoice. @@ -509,6 +620,14 @@ declare module 'stripe' { ): ApiListPromise; list(options?: RequestOptions): ApiListPromise; + /** + * When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items. + */ + listPreviewLineItems( + params: CreditNoteListPreviewLineItemsParams, + options?: RequestOptions + ): ApiListPromise; + /** * Get a preview of a credit note without creating it. */ @@ -542,14 +661,6 @@ declare module 'stripe' { id: string, options?: RequestOptions ): ApiListPromise; - - /** - * When retrieving a credit note preview, you'll get a lines property containing the first handful of those items. This URL you can retrieve the full (paginated) list of line items. - */ - listPreviewLineItems( - params: CreditNoteLineItemListPreviewParams, - options?: RequestOptions - ): ApiListPromise; } } } diff --git a/types/2020-08-27/CustomerSources.d.ts b/types/2020-08-27/CustomerSources.d.ts index 69052d8c46..385e460abf 100644 --- a/types/2020-08-27/CustomerSources.d.ts +++ b/types/2020-08-27/CustomerSources.d.ts @@ -17,6 +17,8 @@ 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; + + validate?: boolean; } interface CustomerSourceRetrieveParams { diff --git a/types/2020-08-27/Customers.d.ts b/types/2020-08-27/Customers.d.ts index 72a6054d04..1d8fd0e4a1 100644 --- a/types/2020-08-27/Customers.d.ts +++ b/types/2020-08-27/Customers.d.ts @@ -19,7 +19,7 @@ declare module 'stripe' { /** * The customer's address. */ - address: Stripe.Address | null; + address?: Stripe.Address | null; /** * Current balance, if any, being stored on the customer. If negative, the customer has credit to apply to their next invoice. If positive, the customer has an amount owed that will be added to their next invoice. The balance does not refer to any unpaid invoices; it solely takes into account amounts that have yet to be successfully applied to any invoice. This balance is only taken into account as invoices are finalized. @@ -39,7 +39,7 @@ declare module 'stripe' { /** * Three-letter [ISO code for the currency](https://stripe.com/docs/currencies) the customer can be charged in for recurring billing purposes. */ - currency: string | null; + currency?: string | null; /** * The default three-letter [ISO code for the currency](https://stripe.com/docs/currencies) that the customer will be charged in for billing purposes. @@ -60,7 +60,7 @@ declare module 'stripe' { * * If an invoice is marked uncollectible by [dunning](https://stripe.com/docs/billing/automatic-collection), `delinquent` doesn't get reset to `false`. */ - delinquent: boolean | null; + delinquent?: boolean | null; /** * An arbitrary string attached to the object. Often useful for displaying to users. @@ -70,7 +70,7 @@ declare module 'stripe' { /** * Describes the current discount active on the customer, if there is one. */ - discount: Stripe.Discount | null; + discount?: Stripe.Discount | null; /** * The customer's email address. @@ -87,7 +87,7 @@ declare module 'stripe' { /** * The prefix for the customer used to generate unique invoice numbers. */ - invoice_prefix: string | null; + invoice_prefix?: string | null; invoice_settings: Customer.InvoiceSettings; @@ -104,7 +104,7 @@ declare module 'stripe' { /** * The customer's full name or business name. */ - name: string | null; + name?: string | null; /** * The suffix of the customer's next invoice number, e.g., 0001. @@ -114,12 +114,12 @@ declare module 'stripe' { /** * The customer's phone number. */ - phone: string | null; + phone?: string | null; /** * The customer's preferred locales (languages), ordered by preference. */ - preferred_locales: Array | null; + preferred_locales?: Array | null; /** * Mailing and shipping address for the customer. Appears on invoices emailed to this customer. @@ -396,6 +396,8 @@ declare module 'stripe' { * ID of the test clock to attach to the customer. */ test_clock?: string; + + validate?: boolean; } namespace CustomerCreateParams { @@ -670,10 +672,7 @@ declare module 'stripe' { */ tax_exempt?: Stripe.Emptyable; - /** - * Unix timestamp representing the end of the trial period the customer will get before being charged for the first time. This will always overwrite any trials that might apply via a subscribed plan. If set, trial_end will override the default trial period of the plan the customer is being subscribed to. The special value `now` can be provided to end the customer's trial immediately. Can be at most two years from `billing_cycle_anchor`. - */ - trial_end?: 'now' | number; + validate?: boolean; } namespace CustomerUpdateParams { @@ -1185,11 +1184,7 @@ declare module 'stripe' { options?: RequestOptions ): Promise< Stripe.Response< - | Stripe.CustomerSource - | Stripe.DeletedAlipayAccount - | Stripe.DeletedBankAccount - | Stripe.DeletedBitcoinReceiver - | Stripe.DeletedCard + Stripe.CustomerSource | Stripe.DeletedBankAccount | Stripe.DeletedCard > >; deleteSource( @@ -1198,11 +1193,7 @@ declare module 'stripe' { options?: RequestOptions ): Promise< Stripe.Response< - | Stripe.CustomerSource - | Stripe.DeletedAlipayAccount - | Stripe.DeletedBankAccount - | Stripe.DeletedBitcoinReceiver - | Stripe.DeletedCard + Stripe.CustomerSource | Stripe.DeletedBankAccount | Stripe.DeletedCard > >; diff --git a/types/2020-08-27/InvoiceLineItems.d.ts b/types/2020-08-27/InvoiceLineItems.d.ts index a4678a8df6..9572736ffc 100644 --- a/types/2020-08-27/InvoiceLineItems.d.ts +++ b/types/2020-08-27/InvoiceLineItems.d.ts @@ -196,517 +196,5 @@ declare module 'stripe' { */ expand?: Array; } - - interface InvoiceLineItemListUpcomingParams extends PaginationParams { - /** - * Settings for automatic tax lookup for this invoice preview. - */ - automatic_tax?: InvoiceLineItemListUpcomingParams.AutomaticTax; - - /** - * The code of the coupon to apply. If `subscription` or `subscription_items` is provided, the invoice returned will preview updating or creating a subscription with that coupon. Otherwise, it will preview applying that coupon to the customer for the next upcoming invoice from among the customer's subscriptions. The invoice can be previewed without a coupon by passing this value as an empty string. - */ - coupon?: string; - - /** - * The currency to preview this invoice in. Defaults to that of `customer` if not specified. - */ - currency?: string; - - /** - * The identifier of the customer whose upcoming invoice you'd like to retrieve. - */ - customer?: string; - - /** - * Details about the customer you want to invoice or overrides for an existing customer. - */ - customer_details?: InvoiceLineItemListUpcomingParams.CustomerDetails; - - /** - * The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the customer or subscription. This only works for coupons directly applied to the invoice. To apply a coupon to a subscription, you must use the `coupon` parameter instead. Pass an empty string to avoid inheriting any discounts. To preview the upcoming invoice for a subscription that hasn't been created, use `coupon` instead. - */ - discounts?: Stripe.Emptyable< - Array - >; - - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * List of invoice items to add or update in the upcoming invoice preview. - */ - invoice_items?: Array; - - /** - * The identifier of the unstarted schedule whose upcoming invoice you'd like to retrieve. Cannot be used with subscription or subscription fields. - */ - schedule?: string; - - /** - * The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If not provided, but a `subscription_items` is provided, you will preview creating a subscription with those items. If neither `subscription` nor `subscription_items` is provided, you will retrieve the next upcoming invoice from among the customer's subscriptions. - */ - subscription?: string; - - /** - * For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`. - */ - subscription_billing_cycle_anchor?: - | InvoiceLineItemListUpcomingParams.SubscriptionBillingCycleAnchor - | number; - - /** - * Timestamp indicating when the subscription should be scheduled to cancel. Will prorate if within the current period and prorations have been enabled using `proration_behavior`. - */ - subscription_cancel_at?: Stripe.Emptyable; - - /** - * Boolean indicating whether this subscription should cancel at the end of the current period. - */ - subscription_cancel_at_period_end?: boolean; - - /** - * This simulates the subscription being canceled or expired immediately. - */ - subscription_cancel_now?: boolean; - - /** - * If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set. - */ - subscription_default_tax_rates?: Stripe.Emptyable>; - - /** - * A list of up to 20 subscription items, each with an attached price. - */ - subscription_items?: Array< - InvoiceLineItemListUpcomingParams.SubscriptionItem - >; - - /** - * Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. - */ - subscription_proration_behavior?: InvoiceLineItemListUpcomingParams.SubscriptionProrationBehavior; - - /** - * If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period, and cannot be before the subscription was on its current plan. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration_behavior` cannot be set to 'none'. - */ - subscription_proration_date?: number; - - /** - * Date a subscription is intended to start (can be future or past) - */ - subscription_start_date?: number; - - /** - * If provided, the invoice returned will preview updating or creating a subscription with that trial end. If set, one of `subscription_items` or `subscription` is required. - */ - subscription_trial_end?: 'now' | number; - - /** - * Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more. - */ - subscription_trial_from_plan?: boolean; - } - - namespace InvoiceLineItemListUpcomingParams { - interface AutomaticTax { - /** - * Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. - */ - enabled: boolean; - } - - interface CustomerDetails { - /** - * The customer's address. - */ - address?: Stripe.Emptyable; - - /** - * The customer's shipping information. Appears on invoices emailed to this customer. - */ - shipping?: Stripe.Emptyable; - - /** - * Tax details about the customer. - */ - tax?: CustomerDetails.Tax; - - /** - * The customer's tax exemption. One of `none`, `exempt`, or `reverse`. - */ - tax_exempt?: Stripe.Emptyable; - - /** - * The customer's tax IDs. - */ - tax_ids?: Array; - } - - namespace CustomerDetails { - interface Address extends Omit { - line1?: string; - } - - interface Shipping { - /** - * Customer shipping address. - */ - address: Shipping.Address; - - /** - * Customer name. - */ - name: string; - - /** - * Customer phone (including extension). - */ - phone?: string; - } - - namespace Shipping { - interface Address extends Omit { - line1?: string; - } - } - - interface Tax { - /** - * A recent IP address of the customer used for tax reporting and tax location inference. Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes. - */ - ip_address?: Stripe.Emptyable; - } - - 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 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 InvoiceItem { - /** - * The integer amount in cents (or local equivalent) of previewed invoice item. - */ - 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). Only applicable to new invoice items. - */ - currency?: string; - - /** - * An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking. - */ - description?: string; - - /** - * Explicitly controls whether discounts apply to this invoice item. Defaults to true, except for negative invoice items. - */ - discountable?: boolean; - - /** - * The coupons to redeem into discounts for the invoice item in the preview. - */ - discounts?: Stripe.Emptyable>; - - /** - * The ID of the invoice item to update in preview. If not specified, a new invoice item will be added to the preview of the upcoming invoice. - */ - invoiceitem?: 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. - */ - period?: InvoiceItem.Period; - - /** - * The ID of the price object. - */ - price?: string; - - /** - * Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. - */ - price_data?: InvoiceItem.PriceData; - - /** - * Non-negative integer. The quantity of units for the invoice item. - */ - quantity?: number; - - /** - * The tax rates that apply to the item. When set, any `default_tax_rates` do not apply to this item. - */ - tax_rates?: Stripe.Emptyable>; - - /** - * The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount. - */ - 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 InvoiceItem { - 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 Period { - /** - * The end of the period, which must be greater than or equal to the start. - */ - end: number; - - /** - * The start of the period. - */ - 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. - */ - 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'; - } - } - - type SubscriptionBillingCycleAnchor = 'now' | 'unchanged'; - - interface SubscriptionItem { - /** - * Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds. - */ - billing_thresholds?: Stripe.Emptyable< - SubscriptionItem.BillingThresholds - >; - - /** - * Delete all usage for a given subscription item. Allowed only when `deleted` is set to `true` and the current plan's `usage_type` is `metered`. - */ - clear_usage?: boolean; - - /** - * A flag that, if set to `true`, will delete the specified item. - */ - deleted?: boolean; - - /** - * Subscription item to update. - */ - 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`. - */ - metadata?: Stripe.Emptyable; - - /** - * Plan ID for this item, as a string. - */ - plan?: string; - - /** - * The ID of the price object. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided. - */ - price?: string; - - /** - * Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. - */ - price_data?: SubscriptionItem.PriceData; - - /** - * Quantity for this item. - */ - quantity?: number; - - /** - * A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates. - */ - tax_rates?: Stripe.Emptyable>; - } - - namespace SubscriptionItem { - interface BillingThresholds { - /** - * Usage threshold that triggers the subscription to advance to a new billing period - */ - usage_gte: 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. - */ - product: string; - - /** - * The recurring components of a price such as `interval` and `interval_count`. - */ - recurring: PriceData.Recurring; - - /** - * 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 { - interface Recurring { - /** - * Specifies billing frequency. Either `day`, `week`, `month` or `year`. - */ - interval: Recurring.Interval; - - /** - * The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). - */ - interval_count?: number; - } - - namespace Recurring { - type Interval = 'day' | 'month' | 'week' | 'year'; - } - - type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; - } - } - - type SubscriptionProrationBehavior = - | 'always_invoice' - | 'create_prorations' - | 'none'; - } } } diff --git a/types/2020-08-27/Invoices.d.ts b/types/2020-08-27/Invoices.d.ts index d51385afa8..9f7ac5866a 100644 --- a/types/2020-08-27/Invoices.d.ts +++ b/types/2020-08-27/Invoices.d.ts @@ -9,7 +9,7 @@ declare module 'stripe' { /** * Unique identifier for the object. */ - id: string; + id?: string; /** * String representing the object's type. Objects of the same type share the same value. @@ -1825,57 +1825,11 @@ declare module 'stripe' { expand?: Array; } - interface InvoiceMarkUncollectibleParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - - interface InvoicePayParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - - /** - * In cases where the source used to pay the invoice has insufficient funds, passing `forgive=true` controls whether a charge should be attempted for the full amount available on the source, up to the amount to fully pay the invoice. This effectively forgives the difference between the amount available on the source and the amount due. - * - * Passing `forgive=false` will fail the charge if the source hasn't been pre-funded with the right amount. An example for this case is with ACH Credit Transfers and wires: if the amount wired is less than the amount due by a small amount, you might want to forgive the difference. Defaults to `false`. - */ - forgive?: boolean; - - /** - * ID of the mandate to be used for this invoice. It must correspond to the payment method used to pay the invoice, including the payment_method param or the invoice's default_payment_method or default_source, if set. - */ - mandate?: string; - - /** - * Indicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `true` (off-session). - */ - off_session?: boolean; - - /** - * Boolean representing whether an invoice is paid outside of Stripe. This will result in no charge being made. Defaults to `false`. - */ - paid_out_of_band?: boolean; - - /** - * A PaymentMethod to be charged. The PaymentMethod must be the ID of a PaymentMethod belonging to the customer associated with the invoice being paid. - */ - payment_method?: string; - - /** - * A payment source to be charged. The source must be the ID of a source belonging to the customer associated with the invoice being paid. - */ - source?: string; - } - - interface InvoiceRetrieveUpcomingParams { + interface InvoiceListUpcomingLinesParams extends PaginationParams { /** * Settings for automatic tax lookup for this invoice preview. */ - automatic_tax?: InvoiceRetrieveUpcomingParams.AutomaticTax; + automatic_tax?: InvoiceListUpcomingLinesParams.AutomaticTax; /** * The code of the coupon to apply. If `subscription` or `subscription_items` is provided, the invoice returned will preview updating or creating a subscription with that coupon. Otherwise, it will preview applying that coupon to the customer for the next upcoming invoice from among the customer's subscriptions. The invoice can be previewed without a coupon by passing this value as an empty string. @@ -1895,13 +1849,13 @@ declare module 'stripe' { /** * Details about the customer you want to invoice or overrides for an existing customer. */ - customer_details?: InvoiceRetrieveUpcomingParams.CustomerDetails; + customer_details?: InvoiceListUpcomingLinesParams.CustomerDetails; /** * The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the customer or subscription. This only works for coupons directly applied to the invoice. To apply a coupon to a subscription, you must use the `coupon` parameter instead. Pass an empty string to avoid inheriting any discounts. To preview the upcoming invoice for a subscription that hasn't been created, use `coupon` instead. */ discounts?: Stripe.Emptyable< - Array + Array >; /** @@ -1912,7 +1866,7 @@ declare module 'stripe' { /** * List of invoice items to add or update in the upcoming invoice preview. */ - invoice_items?: Array; + invoice_items?: Array; /** * The identifier of the unstarted schedule whose upcoming invoice you'd like to retrieve. Cannot be used with subscription or subscription fields. @@ -1928,7 +1882,7 @@ declare module 'stripe' { * For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`. */ subscription_billing_cycle_anchor?: - | InvoiceRetrieveUpcomingParams.SubscriptionBillingCycleAnchor + | InvoiceListUpcomingLinesParams.SubscriptionBillingCycleAnchor | number; /** @@ -1955,13 +1909,13 @@ declare module 'stripe' { * A list of up to 20 subscription items, each with an attached price. */ subscription_items?: Array< - InvoiceRetrieveUpcomingParams.SubscriptionItem + InvoiceListUpcomingLinesParams.SubscriptionItem >; /** * Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. */ - subscription_proration_behavior?: InvoiceRetrieveUpcomingParams.SubscriptionProrationBehavior; + subscription_proration_behavior?: InvoiceListUpcomingLinesParams.SubscriptionProrationBehavior; /** * If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period, and cannot be before the subscription was on its current plan. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration_behavior` cannot be set to 'none'. @@ -1984,7 +1938,7 @@ declare module 'stripe' { subscription_trial_from_plan?: boolean; } - namespace InvoiceRetrieveUpcomingParams { + namespace InvoiceListUpcomingLinesParams { interface AutomaticTax { /** * Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. @@ -2383,217 +2337,775 @@ declare module 'stripe' { | 'none'; } - interface InvoiceSearchParams { + interface InvoiceMarkUncollectibleParams { /** - * The search query string. See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for invoices](https://stripe.com/docs/search#query-fields-for-invoices). + * Specifies which fields in the response should be expanded. */ - query: string; + expand?: Array; + } + interface InvoicePayParams { /** * Specifies which fields in the response should be expanded. */ expand?: Array; /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + * In cases where the source used to pay the invoice has insufficient funds, passing `forgive=true` controls whether a charge should be attempted for the full amount available on the source, up to the amount to fully pay the invoice. This effectively forgives the difference between the amount available on the source and the amount due. + * + * Passing `forgive=false` will fail the charge if the source hasn't been pre-funded with the right amount. An example for this case is with ACH Credit Transfers and wires: if the amount wired is less than the amount due by a small amount, you might want to forgive the difference. Defaults to `false`. */ - limit?: number; + forgive?: boolean; /** - * A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + * ID of the mandate to be used for this invoice. It must correspond to the payment method used to pay the invoice, including the payment_method param or the invoice's default_payment_method or default_source, if set. */ - page?: string; - } + mandate?: string; - interface InvoiceSendInvoiceParams { /** - * Specifies which fields in the response should be expanded. + * Indicates if a customer is on or off-session while an invoice payment is attempted. Defaults to `true` (off-session). */ - expand?: Array; - } + off_session?: boolean; - interface InvoiceVoidInvoiceParams { /** - * Specifies which fields in the response should be expanded. + * Boolean representing whether an invoice is paid outside of Stripe. This will result in no charge being made. Defaults to `false`. */ - expand?: Array; - } + paid_out_of_band?: boolean; - class InvoicesResource { /** - * This endpoint creates a draft invoice for a given customer. The draft invoice created pulls in all pending invoice items on that customer, including prorations. The invoice remains a draft until you [finalize the invoice, which allows you to [pay](#pay_invoice) or send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers. + * A PaymentMethod to be charged. The PaymentMethod must be the ID of a PaymentMethod belonging to the customer associated with the invoice being paid. */ - create( - params?: InvoiceCreateParams, - options?: RequestOptions - ): Promise>; - create( - options?: RequestOptions - ): Promise>; + payment_method?: string; /** - * Retrieves the invoice with the given ID. + * A payment source to be charged. The source must be the ID of a source belonging to the customer associated with the invoice being paid. */ - retrieve( - id: string, - params?: InvoiceRetrieveParams, - options?: RequestOptions - ): Promise>; - retrieve( - id: string, - options?: RequestOptions - ): Promise>; + source?: string; + } + interface InvoiceRetrieveUpcomingParams { /** - * Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized), - * monetary values, as well as collection_method, become uneditable. - * - * If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, - * sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass - * auto_advance=false. + * Settings for automatic tax lookup for this invoice preview. */ - update( - id: string, - params?: InvoiceUpdateParams, - options?: RequestOptions - ): Promise>; + automatic_tax?: InvoiceRetrieveUpcomingParams.AutomaticTax; /** - * You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first. + * The code of the coupon to apply. If `subscription` or `subscription_items` is provided, the invoice returned will preview updating or creating a subscription with that coupon. Otherwise, it will preview applying that coupon to the customer for the next upcoming invoice from among the customer's subscriptions. The invoice can be previewed without a coupon by passing this value as an empty string. */ - list( - params?: InvoiceListParams, - options?: RequestOptions - ): ApiListPromise; - list(options?: RequestOptions): ApiListPromise; + coupon?: string; /** - * Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + * The currency to preview this invoice in. Defaults to that of `customer` if not specified. */ - del( - id: string, - params?: InvoiceDeleteParams, - options?: RequestOptions - ): Promise>; - del( - id: string, - options?: RequestOptions - ): Promise>; + currency?: string; /** - * Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + * The identifier of the customer whose upcoming invoice you'd like to retrieve. */ - finalizeInvoice( - id: string, - params?: InvoiceFinalizeInvoiceParams, - options?: RequestOptions - ): Promise>; - finalizeInvoice( - id: string, - options?: RequestOptions - ): Promise>; + customer?: string; /** - * Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + * Details about the customer you want to invoice or overrides for an existing customer. */ - markUncollectible( - id: string, - params?: InvoiceMarkUncollectibleParams, - options?: RequestOptions - ): Promise>; - markUncollectible( - id: string, - options?: RequestOptions - ): Promise>; + customer_details?: InvoiceRetrieveUpcomingParams.CustomerDetails; /** - * Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. + * The coupons to redeem into discounts for the invoice preview. If not specified, inherits the discount from the customer or subscription. This only works for coupons directly applied to the invoice. To apply a coupon to a subscription, you must use the `coupon` parameter instead. Pass an empty string to avoid inheriting any discounts. To preview the upcoming invoice for a subscription that hasn't been created, use `coupon` instead. */ - pay( - id: string, - params?: InvoicePayParams, - options?: RequestOptions - ): Promise>; - pay( - id: string, - options?: RequestOptions - ): Promise>; + discounts?: Stripe.Emptyable< + Array + >; /** - * 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. - * - * Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount. - * - * You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource. + * Specifies which fields in the response should be expanded. */ - retrieveUpcoming( - params?: InvoiceRetrieveUpcomingParams, - options?: RequestOptions - ): Promise>; - retrieveUpcoming( - options?: RequestOptions - ): Promise>; + expand?: Array; /** - * Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). - * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating - * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up - * to an hour behind during outages. Search functionality is not available to merchants in India. + * List of invoice items to add or update in the upcoming invoice preview. */ - search( - params: InvoiceSearchParams, - options?: RequestOptions - ): ApiSearchResultPromise; + invoice_items?: Array; /** - * Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. - * - * Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. + * The identifier of the unstarted schedule whose upcoming invoice you'd like to retrieve. Cannot be used with subscription or subscription fields. */ - sendInvoice( - id: string, - params?: InvoiceSendInvoiceParams, - options?: RequestOptions - ): Promise>; - sendInvoice( - id: string, - options?: RequestOptions - ): Promise>; + schedule?: string; /** - * Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + * The identifier of the subscription for which you'd like to retrieve the upcoming invoice. If not provided, but a `subscription_items` is provided, you will preview creating a subscription with those items. If neither `subscription` nor `subscription_items` is provided, you will retrieve the next upcoming invoice from among the customer's subscriptions. */ - voidInvoice( - id: string, - params?: InvoiceVoidInvoiceParams, - options?: RequestOptions - ): Promise>; - voidInvoice( - id: string, - options?: RequestOptions - ): Promise>; + subscription?: string; /** - * When retrieving an invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + * For new subscriptions, a future timestamp to anchor the subscription's [billing cycle](https://stripe.com/docs/subscriptions/billing-cycle). This is used to determine the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices. For existing subscriptions, the value can only be set to `now` or `unchanged`. */ - listLineItems( - id: string, - params?: InvoiceLineItemListParams, - options?: RequestOptions - ): ApiListPromise; - listLineItems( - id: string, - options?: RequestOptions - ): ApiListPromise; + subscription_billing_cycle_anchor?: + | InvoiceRetrieveUpcomingParams.SubscriptionBillingCycleAnchor + | number; /** - * When retrieving an upcoming invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + * Timestamp indicating when the subscription should be scheduled to cancel. Will prorate if within the current period and prorations have been enabled using `proration_behavior`. */ - listUpcomingLineItems( - params?: InvoiceLineItemListUpcomingParams, - options?: RequestOptions - ): ApiListPromise; - listUpcomingLineItems( + subscription_cancel_at?: Stripe.Emptyable; + + /** + * Boolean indicating whether this subscription should cancel at the end of the current period. + */ + subscription_cancel_at_period_end?: boolean; + + /** + * This simulates the subscription being canceled or expired immediately. + */ + subscription_cancel_now?: boolean; + + /** + * If provided, the invoice returned will preview updating or creating a subscription with these default tax rates. The default tax rates will apply to any line item that does not have `tax_rates` set. + */ + subscription_default_tax_rates?: Stripe.Emptyable>; + + /** + * A list of up to 20 subscription items, each with an attached price. + */ + subscription_items?: Array< + InvoiceRetrieveUpcomingParams.SubscriptionItem + >; + + /** + * Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. + */ + subscription_proration_behavior?: InvoiceRetrieveUpcomingParams.SubscriptionProrationBehavior; + + /** + * If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period, and cannot be before the subscription was on its current plan. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration_behavior` cannot be set to 'none'. + */ + subscription_proration_date?: number; + + /** + * Date a subscription is intended to start (can be future or past) + */ + subscription_start_date?: number; + + /** + * If provided, the invoice returned will preview updating or creating a subscription with that trial end. If set, one of `subscription_items` or `subscription` is required. + */ + subscription_trial_end?: 'now' | number; + + /** + * Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `subscription_trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `subscription_trial_end` is not allowed. See [Using trial periods on subscriptions](https://stripe.com/docs/billing/subscriptions/trials) to learn more. + */ + subscription_trial_from_plan?: boolean; + } + + namespace InvoiceRetrieveUpcomingParams { + interface AutomaticTax { + /** + * Whether Stripe automatically computes tax on this invoice. Note that incompatible invoice items (invoice items with manually specified [tax rates](https://stripe.com/docs/api/tax_rates), negative amounts, or `tax_behavior=unspecified`) cannot be added to automatic tax invoices. + */ + enabled: boolean; + } + + interface CustomerDetails { + /** + * The customer's address. + */ + address?: Stripe.Emptyable; + + /** + * The customer's shipping information. Appears on invoices emailed to this customer. + */ + shipping?: Stripe.Emptyable; + + /** + * Tax details about the customer. + */ + tax?: CustomerDetails.Tax; + + /** + * The customer's tax exemption. One of `none`, `exempt`, or `reverse`. + */ + tax_exempt?: Stripe.Emptyable; + + /** + * The customer's tax IDs. + */ + tax_ids?: Array; + } + + namespace CustomerDetails { + interface Address extends Omit { + line1?: string; + } + + interface Shipping { + /** + * Customer shipping address. + */ + address: Shipping.Address; + + /** + * Customer name. + */ + name: string; + + /** + * Customer phone (including extension). + */ + phone?: string; + } + + namespace Shipping { + interface Address extends Omit { + line1?: string; + } + } + + interface Tax { + /** + * A recent IP address of the customer used for tax reporting and tax location inference. Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated. We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes. + */ + ip_address?: Stripe.Emptyable; + } + + 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 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 InvoiceItem { + /** + * The integer amount in cents (or local equivalent) of previewed invoice item. + */ + 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). Only applicable to new invoice items. + */ + currency?: string; + + /** + * An arbitrary string which you can attach to the invoice item. The description is displayed in the invoice for easy tracking. + */ + description?: string; + + /** + * Explicitly controls whether discounts apply to this invoice item. Defaults to true, except for negative invoice items. + */ + discountable?: boolean; + + /** + * The coupons to redeem into discounts for the invoice item in the preview. + */ + discounts?: Stripe.Emptyable>; + + /** + * The ID of the invoice item to update in preview. If not specified, a new invoice item will be added to the preview of the upcoming invoice. + */ + invoiceitem?: 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. + */ + period?: InvoiceItem.Period; + + /** + * The ID of the price object. + */ + price?: string; + + /** + * Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. + */ + price_data?: InvoiceItem.PriceData; + + /** + * Non-negative integer. The quantity of units for the invoice item. + */ + quantity?: number; + + /** + * The tax rates that apply to the item. When set, any `default_tax_rates` do not apply to this item. + */ + tax_rates?: Stripe.Emptyable>; + + /** + * The integer unit amount in cents (or local equivalent) of the charge to be applied to the upcoming invoice. This unit_amount will be multiplied by the quantity to get the full amount. If you want to apply a credit to the customer's account, pass a negative unit_amount. + */ + 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 InvoiceItem { + 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 Period { + /** + * The end of the period, which must be greater than or equal to the start. + */ + end: number; + + /** + * The start of the period. + */ + 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. + */ + 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'; + } + } + + type SubscriptionBillingCycleAnchor = 'now' | 'unchanged'; + + interface SubscriptionItem { + /** + * Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period. When updating, pass an empty string to remove previously-defined thresholds. + */ + billing_thresholds?: Stripe.Emptyable< + SubscriptionItem.BillingThresholds + >; + + /** + * Delete all usage for a given subscription item. Allowed only when `deleted` is set to `true` and the current plan's `usage_type` is `metered`. + */ + clear_usage?: boolean; + + /** + * A flag that, if set to `true`, will delete the specified item. + */ + deleted?: boolean; + + /** + * Subscription item to update. + */ + 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`. + */ + metadata?: Stripe.Emptyable; + + /** + * Plan ID for this item, as a string. + */ + plan?: string; + + /** + * The ID of the price object. When changing a subscription item's price, `quantity` is set to 1 unless a `quantity` parameter is provided. + */ + price?: string; + + /** + * Data used to generate a new [Price](https://stripe.com/docs/api/prices) object inline. + */ + price_data?: SubscriptionItem.PriceData; + + /** + * Quantity for this item. + */ + quantity?: number; + + /** + * A list of [Tax Rate](https://stripe.com/docs/api/tax_rates) ids. These Tax Rates will override the [`default_tax_rates`](https://stripe.com/docs/api/subscriptions/create#create_subscription-default_tax_rates) on the Subscription. When updating, pass an empty string to remove previously-defined tax rates. + */ + tax_rates?: Stripe.Emptyable>; + } + + namespace SubscriptionItem { + interface BillingThresholds { + /** + * Usage threshold that triggers the subscription to advance to a new billing period + */ + usage_gte: 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. + */ + product: string; + + /** + * The recurring components of a price such as `interval` and `interval_count`. + */ + recurring: PriceData.Recurring; + + /** + * 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 { + interface Recurring { + /** + * Specifies billing frequency. Either `day`, `week`, `month` or `year`. + */ + interval: Recurring.Interval; + + /** + * The number of intervals between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. Maximum of one year interval allowed (1 year, 12 months, or 52 weeks). + */ + interval_count?: number; + } + + namespace Recurring { + type Interval = 'day' | 'month' | 'week' | 'year'; + } + + type TaxBehavior = 'exclusive' | 'inclusive' | 'unspecified'; + } + } + + type SubscriptionProrationBehavior = + | 'always_invoice' + | 'create_prorations' + | 'none'; + } + + interface InvoiceSearchParams { + /** + * The search query string. See [search query language](https://stripe.com/docs/search#search-query-language) and the list of supported [query fields for invoices](https://stripe.com/docs/search#query-fields-for-invoices). + */ + query: string; + + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + + /** + * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + + /** + * A cursor for pagination across multiple pages of results. Don't include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. + */ + page?: string; + } + + interface InvoiceSendInvoiceParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + interface InvoiceVoidInvoiceParams { + /** + * Specifies which fields in the response should be expanded. + */ + expand?: Array; + } + + class InvoicesResource { + /** + * This endpoint creates a draft invoice for a given customer. The draft invoice created pulls in all pending invoice items on that customer, including prorations. The invoice remains a draft until you [finalize the invoice, which allows you to [pay](#pay_invoice) or send](https://stripe.com/docs/api#finalize_invoice) the invoice to your customers. + */ + create( + params?: InvoiceCreateParams, + options?: RequestOptions + ): Promise>; + create( + options?: RequestOptions + ): Promise>; + + /** + * Retrieves the invoice with the given ID. + */ + retrieve( + id: string, + params?: InvoiceRetrieveParams, + options?: RequestOptions + ): Promise>; + retrieve( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * Draft invoices are fully editable. Once an invoice is [finalized](https://stripe.com/docs/billing/invoices/workflow#finalized), + * monetary values, as well as collection_method, become uneditable. + * + * If you would like to stop the Stripe Billing engine from automatically finalizing, reattempting payments on, + * sending reminders for, or [automatically reconciling](https://stripe.com/docs/billing/invoices/reconciliation) invoices, pass + * auto_advance=false. + */ + update( + id: string, + params?: InvoiceUpdateParams, + options?: RequestOptions + ): Promise>; + + /** + * You can list all invoices, or list the invoices for a specific customer. The invoices are returned sorted by creation date, with the most recently created invoices appearing first. + */ + list( + params?: InvoiceListParams, + options?: RequestOptions + ): ApiListPromise; + list(options?: RequestOptions): ApiListPromise; + + /** + * Permanently deletes a one-off invoice draft. This cannot be undone. Attempts to delete invoices that are no longer in a draft state will fail; once an invoice has been finalized or if an invoice is for a subscription, it must be [voided](https://stripe.com/docs/api#void_invoice). + */ + del( + id: string, + params?: InvoiceDeleteParams, + options?: RequestOptions + ): Promise>; + del( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * Stripe automatically finalizes drafts before sending and attempting payment on invoices. However, if you'd like to finalize a draft invoice manually, you can do so using this method. + */ + finalizeInvoice( + id: string, + params?: InvoiceFinalizeInvoiceParams, + options?: RequestOptions + ): Promise>; + finalizeInvoice( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * When retrieving an upcoming invoice, you'll get a lines property containing the total count of line items and the first handful of those items. There is also a URL where you can retrieve the full (paginated) list of line items. + */ + listUpcomingLines( + params?: InvoiceListUpcomingLinesParams, + options?: RequestOptions + ): ApiListPromise; + listUpcomingLines( + options?: RequestOptions + ): ApiListPromise; + + /** + * Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes. + */ + markUncollectible( + id: string, + params?: InvoiceMarkUncollectibleParams, + options?: RequestOptions + ): Promise>; + markUncollectible( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * Stripe automatically creates and then attempts to collect payment on invoices for customers on subscriptions according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to attempt payment on an invoice out of the normal collection schedule or for some other reason, you can do so. + */ + pay( + id: string, + params?: InvoicePayParams, + options?: RequestOptions + ): Promise>; + pay( + id: string, + 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. + * + * Note that when you are viewing an upcoming invoice, you are simply viewing a preview – the invoice has not yet been created. As such, the upcoming invoice will not show up in invoice listing calls, and you cannot use the API to pay or edit the invoice. If you want to change the amount that your customer will be billed, you can add, remove, or update pending invoice items, or update the customer's discount. + * + * You can preview the effects of updating a subscription, including a preview of what proration will take place. To ensure that the actual proration is calculated exactly the same as the previewed proration, you should pass a proration_date parameter when doing the actual subscription update. The value passed in should be the same as the subscription_proration_date returned on the upcoming invoice resource. The recommended way to get only the prorations being previewed is to consider only proration line items where period[start] is equal to the subscription_proration_date on the upcoming invoice resource. + */ + retrieveUpcoming( + params?: InvoiceRetrieveUpcomingParams, + options?: RequestOptions + ): Promise>; + retrieveUpcoming( + options?: RequestOptions + ): Promise>; + + /** + * Search for invoices you've previously created using Stripe's [Search Query Language](https://stripe.com/docs/search#search-query-language). + * Don't use search in read-after-write flows where strict consistency is necessary. Under normal operating + * conditions, data is searchable in less than a minute. Occasionally, propagation of new or updated data can be up + * to an hour behind during outages. Search functionality is not available to merchants in India. + */ + search( + params: InvoiceSearchParams, + options?: RequestOptions + ): ApiSearchResultPromise; + + /** + * Stripe will automatically send invoices to customers according to your [subscriptions settings](https://dashboard.stripe.com/account/billing/automatic). However, if you'd like to manually send an invoice to your customer out of the normal schedule, you can do so. When sending invoices that have already been paid, there will be no reference to the payment in the email. + * + * Requests made in test-mode result in no emails being sent, despite sending an invoice.sent event. + */ + sendInvoice( + id: string, + params?: InvoiceSendInvoiceParams, + options?: RequestOptions + ): Promise>; + sendInvoice( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * Mark a finalized invoice as void. This cannot be undone. Voiding an invoice is similar to [deletion](https://stripe.com/docs/api#delete_invoice), however it only applies to finalized invoices and maintains a papertrail where the invoice can still be found. + */ + voidInvoice( + id: string, + params?: InvoiceVoidInvoiceParams, + options?: RequestOptions + ): Promise>; + voidInvoice( + id: string, + options?: RequestOptions + ): Promise>; + + /** + * When retrieving an invoice, you'll get a lines property containing the total count of line items and 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?: InvoiceLineItemListParams, + options?: RequestOptions + ): ApiListPromise; + listLineItems( + id: string, options?: RequestOptions ): ApiListPromise; } diff --git a/types/2020-08-27/Issuing/CardDetails.d.ts b/types/2020-08-27/Issuing/CardDetails.d.ts deleted file mode 100644 index 8ff13f3b93..0000000000 --- a/types/2020-08-27/Issuing/CardDetails.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec - -declare module 'stripe' { - namespace Stripe { - namespace Issuing { - /** - * The CardDetails object. - */ - interface CardDetails { - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'issuing.card_details'; - - /** - * You can [create physical or virtual cards](https://stripe.com/docs/issuing/cards) that are issued to cardholders. - */ - card: Stripe.Issuing.Card; - - /** - * The CVC number for the card. - */ - cvc: string; - - /** - * The expiration month of the card. - */ - exp_month: number; - - /** - * The expiration year of the card. - */ - exp_year: number; - - /** - * The card number. - */ - number: string; - } - } - } -} diff --git a/types/2020-08-27/Issuing/Cards.d.ts b/types/2020-08-27/Issuing/Cards.d.ts index 3255b004c0..0e36ad035e 100644 --- a/types/2020-08-27/Issuing/Cards.d.ts +++ b/types/2020-08-27/Issuing/Cards.d.ts @@ -3218,13 +3218,6 @@ declare module 'stripe' { type Type = 'physical' | 'virtual'; } - interface CardRetrieveDetailsParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } - class CardsResource { /** * Creates an Issuing Card object. @@ -3264,19 +3257,6 @@ declare module 'stripe' { options?: RequestOptions ): ApiListPromise; list(options?: RequestOptions): ApiListPromise; - - /** - * For virtual cards only. Retrieves an Issuing card_details object that contains [the sensitive details](https://stripe.com/docs/issuing/cards/virtual#virtual-card-info) of a virtual card. - */ - retrieveDetails( - id: string, - params?: CardRetrieveDetailsParams, - options?: RequestOptions - ): Promise>; - retrieveDetails( - id: string, - options?: RequestOptions - ): Promise>; } } } diff --git a/types/2020-08-27/LineItems.d.ts b/types/2020-08-27/LineItems.d.ts index 68a3897b28..36897272d4 100644 --- a/types/2020-08-27/LineItems.d.ts +++ b/types/2020-08-27/LineItems.d.ts @@ -104,12 +104,5 @@ declare module 'stripe' { rate: Stripe.TaxRate; } } - - interface LineItemListParams extends PaginationParams { - /** - * Specifies which fields in the response should be expanded. - */ - expand?: Array; - } } } diff --git a/types/2020-08-27/LoginLinks.d.ts b/types/2020-08-27/LoginLinks.d.ts index 4f8be6a762..18dc53e370 100644 --- a/types/2020-08-27/LoginLinks.d.ts +++ b/types/2020-08-27/LoginLinks.d.ts @@ -27,11 +27,6 @@ declare module 'stripe' { * Specifies which fields in the response should be expanded. */ expand?: Array; - - /** - * Where to redirect the user after they log out of their dashboard. - */ - redirect_url?: string; } } } diff --git a/types/2020-08-27/PaymentIntents.d.ts b/types/2020-08-27/PaymentIntents.d.ts index 10a23335e0..3e87fc985f 100644 --- a/types/2020-08-27/PaymentIntents.d.ts +++ b/types/2020-08-27/PaymentIntents.d.ts @@ -183,9 +183,7 @@ declare module 'stripe' { source: | string | Stripe.CustomerSource - | Stripe.DeletedAlipayAccount | Stripe.DeletedBankAccount - | Stripe.DeletedBitcoinReceiver | Stripe.DeletedCard | null; diff --git a/types/2020-08-27/Recipients.d.ts b/types/2020-08-27/Recipients.d.ts deleted file mode 100644 index 7c684a05d7..0000000000 --- a/types/2020-08-27/Recipients.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -// File generated from our OpenAPI spec - -declare module 'stripe' { - namespace Stripe { - /** - * The Recipient object. - */ - interface Recipient { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'recipient'; - - /** - * Hash describing the current account on the recipient, if there is one. - */ - active_account: Stripe.BankAccount | null; - - cards: ApiList | null; - - /** - * Time at which the object was created. Measured in seconds since the Unix epoch. - */ - created: number; - - /** - * The default card to use for creating transfers to this recipient. - */ - default_card: string | Stripe.Card | null; - - deleted?: void; - - /** - * An arbitrary string attached to the object. Often useful for displaying to users. - */ - description: string | null; - - email: string | null; - - /** - * 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 ID of the [Custom account](https://stripe.com/docs/connect/custom-accounts) this recipient was migrated to. If set, the recipient can no longer be updated, nor can transfers be made to it: use the Custom account instead. - */ - migrated_to: string | Stripe.Account | null; - - /** - * Full, legal name of the recipient. - */ - name: string | null; - - rolled_back_from?: string | Stripe.Account; - - /** - * Type of the recipient, one of `individual` or `corporation`. - */ - type: string; - - /** - * Whether the recipient has been verified. This field is non-standard, and maybe removed in the future - */ - verified: boolean; - } - - /** - * The DeletedRecipient object. - */ - interface DeletedRecipient { - /** - * Unique identifier for the object. - */ - id: string; - - /** - * String representing the object's type. Objects of the same type share the same value. - */ - object: 'recipient'; - - /** - * Always true for a deleted object - */ - deleted: true; - } - } -} diff --git a/types/2020-08-27/WebhookEndpoints.d.ts b/types/2020-08-27/WebhookEndpoints.d.ts index 5ab9755061..f41f82cd0d 100644 --- a/types/2020-08-27/WebhookEndpoints.d.ts +++ b/types/2020-08-27/WebhookEndpoints.d.ts @@ -328,7 +328,6 @@ declare module 'stripe' { | 'issuing_transaction.updated' | 'mandate.updated' | 'order.created' - | 'order.payment_failed' | 'payment_intent.amount_capturable_updated' | 'payment_intent.canceled' | 'payment_intent.created' @@ -414,8 +413,6 @@ declare module 'stripe' { | 'topup.reversed' | 'topup.succeeded' | 'transfer.created' - | 'transfer.failed' - | 'transfer.paid' | 'transfer.reversed' | 'transfer.updated' | 'treasury.credit_reversal.created' @@ -444,7 +441,6 @@ declare module 'stripe' { | 'treasury.outbound_transfer.returned' | 'treasury.received_credit.created' | 'treasury.received_credit.failed' - | 'treasury.received_credit.reversed' | 'treasury.received_credit.succeeded' | 'treasury.received_debit.created'; } @@ -592,7 +588,6 @@ declare module 'stripe' { | 'issuing_transaction.updated' | 'mandate.updated' | 'order.created' - | 'order.payment_failed' | 'payment_intent.amount_capturable_updated' | 'payment_intent.canceled' | 'payment_intent.created' @@ -678,8 +673,6 @@ declare module 'stripe' { | 'topup.reversed' | 'topup.succeeded' | 'transfer.created' - | 'transfer.failed' - | 'transfer.paid' | 'transfer.reversed' | 'transfer.updated' | 'treasury.credit_reversal.created' @@ -708,7 +701,6 @@ declare module 'stripe' { | 'treasury.outbound_transfer.returned' | 'treasury.received_credit.created' | 'treasury.received_credit.failed' - | 'treasury.received_credit.reversed' | 'treasury.received_credit.succeeded' | 'treasury.received_debit.created'; } diff --git a/types/2020-08-27/index.d.ts b/types/2020-08-27/index.d.ts index 42bccc80df..01aef04189 100644 --- a/types/2020-08-27/index.d.ts +++ b/types/2020-08-27/index.d.ts @@ -9,7 +9,6 @@ /// /// /// -/// /// /// /// @@ -19,8 +18,6 @@ /// /// /// -/// -/// /// /// /// @@ -54,7 +51,6 @@ /// /// /// -/// /// /// /// @@ -77,7 +73,6 @@ /// /// /// -/// /// /// /// diff --git a/types/shared.d.ts b/types/shared.d.ts index d343ebdde4..1a9e47de82 100644 --- a/types/shared.d.ts +++ b/types/shared.d.ts @@ -171,13 +171,7 @@ declare module 'stripe' { object: 'account'; }; - type CustomerSource = - | AccountDebitSource - | AlipayAccount - | BankAccount - | BitcoinReceiver - | Card - | Source; + type CustomerSource = AccountDebitSource | BankAccount | Card | Source; interface RangeQueryParam { /** diff --git a/types/test/typescriptTest.ts b/types/test/typescriptTest.ts index c9d9af0ad4..9ed5d59239 100644 --- a/types/test/typescriptTest.ts +++ b/types/test/typescriptTest.ts @@ -53,7 +53,7 @@ stripe.setHost('host', 'port', 'protocol'); }; const customer: Stripe.Customer = await stripe.customers.create(params, opts); - const address: Stripe.Address | null = customer.address; + const address: Stripe.Address | null | undefined = customer.address; if (!address) return; const city: string | null = address.city;