From 63543d82a7db336ce9ad8549736bf423bf06cf5b Mon Sep 17 00:00:00 2001 From: Oleg Vaskevich Date: Wed, 3 Jul 2019 09:58:10 -0700 Subject: [PATCH] Add invoices.finalizeInvoice to Stripe (#36513) --- types/stripe/index.d.ts | 25 +++++++++++++++++++++++++ types/stripe/stripe-tests.ts | 8 ++++++++ 2 files changed, 33 insertions(+) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 8e218a7e44..8b62531e34 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -3110,6 +3110,16 @@ declare namespace Stripe { tax_percent?: number; } + interface IInvoiceFinalizeOptions extends IDataOptions { + /** + * Controls whether Stripe will perform + * [automatic collection](https://stripe.com/docs/billing/invoices/workflow/#auto_advance) + * of the invoice. When `false`, the invoice’s state will not automatically advance + * without an explicit action. + */ + auto_advance: boolean; + } + interface IInvoicePayOptions extends IDataOptionsWithMetadata { /** * A payment source to be charged. The source must be the ID of a source @@ -8385,6 +8395,21 @@ declare namespace Stripe { update(id: string, data: invoices.IInvoiceUpdateOptions, options: HeaderOptions, response?: IResponseFn): Promise; update(id: string, data: invoices.IInvoiceUpdateOptions, response?: IResponseFn): 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. + * + * @returns Returns the invoice object. + * + * @param id The ID of the invoice to pay. + * @param data Additional arguments. + */ + finalizeInvoice(id: string, data: invoices.IInvoiceFinalizeOptions, options: HeaderOptions, response?: IResponseFn): Promise; + finalizeInvoice(id: string, data: invoices.IInvoiceFinalizeOptions, response: IResponseFn): Promise; + finalizeInvoice(id: string, data: invoices.IInvoiceFinalizeOptions): Promise; + finalizeInvoice(id: string, options: HeaderOptions, response?: IResponseFn): Promise; + finalizeInvoice(id: string, response?: IResponseFn): Promise; + /** * Stripe automatically creates and then attempts to pay invoices for customers on subscriptions. We'll also retry unpaid * invoices according to your retry settings. However, if you'd like to attempt to collect payment on an invoice out of the diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 67d7f78d1a..34f871ae3c 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -1246,6 +1246,14 @@ stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb", { forgive: true }).then((invo // asynchronously called }); +stripe.invoices.finalizeInvoice("in_15fvyXEe31JkLCeQH7QbgZZb").then(invoice => { + invoice; // $ExpectType IInvoice +}); + +stripe.invoices.finalizeInvoice("in_15fvyXEe31JkLCeQH7QbgZZb", { auto_advance: true }).then(invoice => { + invoice; // $ExpectType IInvoice +}); + stripe.invoices.list( { customer: "cus_5rfJKDJkuxzh5Q", limit: 3 }, (err, invoices) => {