From 499d248746c7a3875d7322f78000ad00c8e51af4 Mon Sep 17 00:00:00 2001 From: Garth Kidd Date: Wed, 7 Feb 2018 14:50:26 +1100 Subject: [PATCH 1/2] Stripe card numbers are strings: The Stripe API for Node documentation of [Create a card token][cct] gives the example code: ``` var stripe = require("stripe")( "sk_test_BQokikJOvBiI2HlWgH4olfQ2" ); stripe.tokens.create({ card: { "number": '4242424242424242', "exp_month": 12, "exp_year": 2019, "cvc": '123' } }, function(err, token) { // asynchronously called }); ``` [cct]: https://stripe.com/docs/api/node#create_card_token Relevant typings history: * @borisyankov first added `StripeTokenData.number: number` in 2013-09 * @codeanimal substantially reworked the typings in 2016-04 with `ISourceCreationOptions.number: string` but giving it the comment: > The card number, as a string without any separators. --- types/stripe/index.d.ts | 6 +++--- types/stripe/stripe-tests.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index c3fd4853b7..92f07f2eed 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe 5.0 +// Type definitions for stripe 6.0 // Project: https://github.com/stripe/stripe-node/ // Definitions by: William Johnston // Peter Harris @@ -4051,7 +4051,7 @@ declare namespace Stripe { /** * The card number */ - number: number; + number: string; /** * Card brand. Can be Visa, American Express, MasterCard, Discover, JCB, Diners Club, or Unknown. @@ -4167,7 +4167,7 @@ declare namespace Stripe { /** * The card number, as a string without any separators. */ - number: number; + number: string; /** * Card security code. Required unless your account is registered in diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 99cf3795db..b887ae6228 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -243,7 +243,7 @@ stripe.customers.create({ }).then( function (customer) { // asynchronously called customer.cards.create({ card: "tok_17wV94BoqMA9o2xkhlAd3ALf"}).then(function (customer) {}); - customer.cards.retrieve("card_17xMvXBoqMA9o2xkq6W5gamx").then(function (card) { + customer.cards.retrieve("card_17xMvXBoqMA9o2xkq6W5gamx").then(function (card) { let strCustomer: string = card.customer; let objCustomer: customers.ICustomer = card.customer; }); @@ -394,7 +394,7 @@ stripe.customers.createSource( object: "card", exp_month: 1, exp_year: 16, - number: 4242424242424242 + number: '4242424242424242' } }, function (err, card) { @@ -409,7 +409,7 @@ stripe.customers.createSource( object: "card", exp_month: 1, exp_year: 16, - number: 4242424242424242 + number: '4242424242424242' } }).then( function (card) { From 06e989ba780de0334824fa0c4b28adc3d3fe20e2 Mon Sep 17 00:00:00 2001 From: Garth Kidd Date: Thu, 8 Feb 2018 11:37:13 +1100 Subject: [PATCH 2/2] Revert version, per feedback from @linusu and @codeanimal TODO: squash. --- types/stripe/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 92f07f2eed..12f2b4abea 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe 6.0 +// Type definitions for stripe 5.0 // Project: https://github.com/stripe/stripe-node/ // Definitions by: William Johnston // Peter Harris