From 250f02b8dc47211b45a24679739f0513fb4f36ac Mon Sep 17 00:00:00 2001 From: Lilians AUVIGNE Date: Sat, 4 Nov 2017 03:44:27 +0100 Subject: [PATCH 1/2] Add amount body in capture --- types/stripe/index.d.ts | 14 ++++++++++++-- types/stripe/stripe-tests.ts | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index d67ee5d115..8c26e39a01 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -975,6 +975,16 @@ declare namespace Stripe { statement_descriptor?: string; } + interface IChargeCaptureOptions extends IDataOptions { + /** + * A positive integer in the smallest currency unit (e.g 100 cents to charge + * $1.00, or 1 to charge ¥1, a 0-decimal currency) representing how much to + * charge the card. The minimum amount is £0.50 (or equivalent in charge + * currency). + */ + amount: number; + } + interface IChargeUpdateOptions extends IDataOptionsWithMetadata { /** * An arbitrary string which you can attach to a charge object. It is displayed when in the web interface alongside the charge. @@ -4785,8 +4795,8 @@ declare namespace Stripe { * you created a charge with the capture option set to false. Uncaptured payments expire exactly seven days after they are * created. If they are not captured by that point in time, they will be marked as refunded and will no longer be capturable. */ - capture(id: string, options: HeaderOptions, response?: IResponseFn): Promise; - capture(id: string, response?: IResponseFn): Promise; + capture(id: string, data: charges.IChargeCaptureOptions, options: HeaderOptions, response?: IResponseFn): Promise; + capture(id: string, data: charges.IChargeCaptureOptions, response?: IResponseFn): Promise; /** * Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index c4b291a7ed..523ffdd45d 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -105,10 +105,10 @@ stripe.charges.update( // asynchronously called }); -stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", function (err, charge) { +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}, function (err, charge) { // asynchronously called }); -stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9").then( function (charge) { +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}).then( function (charge) { // asynchronously called }); From 5bf123f8213911d198b3991f7fab61abc37aeb7b Mon Sep 17 00:00:00 2001 From: Lilians AUVIGNE Date: Wed, 8 Nov 2017 23:17:45 +0100 Subject: [PATCH 2/2] Fix optional with curent documentation --- types/stripe/index.d.ts | 5 ++--- types/stripe/stripe-tests.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 8c26e39a01..c09a4fe202 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -982,7 +982,7 @@ declare namespace Stripe { * charge the card. The minimum amount is £0.50 (or equivalent in charge * currency). */ - amount: number; + amount?: number; } interface IChargeUpdateOptions extends IDataOptionsWithMetadata { @@ -4795,8 +4795,7 @@ declare namespace Stripe { * you created a charge with the capture option set to false. Uncaptured payments expire exactly seven days after they are * created. If they are not captured by that point in time, they will be marked as refunded and will no longer be capturable. */ - capture(id: string, data: charges.IChargeCaptureOptions, options: HeaderOptions, response?: IResponseFn): Promise; - capture(id: string, data: charges.IChargeCaptureOptions, response?: IResponseFn): Promise; + capture(id: string, data?: charges.IChargeCaptureOptions, options?: HeaderOptions, response?: IResponseFn): Promise; /** * Returns a list of charges you've previously created. The charges are returned in sorted order, with the most recent charges diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 523ffdd45d..8e6f48a350 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -111,6 +111,15 @@ stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}, function stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}).then( function (charge) { // asynchronously called }); +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {}, {},function (err, charge) { + // asynchronously called +}); +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {}).then( function (charge) { + // asynchronously called +}); +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9").then( function (charge) { + // asynchronously called +}); stripe.charges.list({ limit: 3 }, function (err, charges) { // asynchronously called