From 6be187477440f5b655bee0cbbdd676bbb1a3ce54 Mon Sep 17 00:00:00 2001 From: Ben Stevens Date: Mon, 12 Feb 2018 21:39:34 +0000 Subject: [PATCH] revert enums and change Arra to T[] --- types/stripe-v3/index.d.ts | 14 ++++---------- types/stripe-v3/stripe-v3-tests.ts | 14 +++++++------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/types/stripe-v3/index.d.ts b/types/stripe-v3/index.d.ts index ea4fa9e05e..55cc5962df 100644 --- a/types/stripe-v3/index.d.ts +++ b/types/stripe-v3/index.d.ts @@ -173,9 +173,6 @@ declare namespace stripe { type checkType = 'pass' | 'fail' | 'unavailable' | 'unchecked'; type fundingType = 'credit' | 'debit' | 'prepaid' | 'unknown'; type tokenizationType = 'apple_pay' | 'android_pay'; - enum ThreeDSecureSupport { - Required = 'required', Recommended = 'recommended', Optional = 'optional', NotSupported = 'not_supported' - } interface Card { id: string; object: string; @@ -200,7 +197,7 @@ declare namespace stripe { metadata: any; name?: string; tokenization_method?: tokenizationType; - three_d_secure?: ThreeDSecureSupport; + three_d_secure?: 'required' | 'recommended' | 'optional' | 'not_supported'; } interface RetrieveSourceOptions { @@ -219,7 +216,7 @@ declare namespace stripe { interface StripePaymentRequestUpdateOptions { currency: string; total: DisplayItem; - displayItems?: Array; + displayItems?: DisplayItem[]; shippingOptions?: ShippingOption[]; } @@ -231,13 +228,10 @@ declare namespace stripe { requestShipping?: boolean; } - enum UpdateDetailsStatus { - Success = 'success', Fail = 'fail', InvalidShippingAddress = 'invalid_shipping_address' - } interface UpdateDetails { - status: UpdateDetailsStatus; + status: 'success' | 'fail' | 'invalid_shipping_address'; total?: DisplayItem; - displayItems?: Array; + displayItems?: DisplayItem[]; shippingOptions?: ShippingOption[]; } diff --git a/types/stripe-v3/stripe-v3-tests.ts b/types/stripe-v3/stripe-v3-tests.ts index c3d696fceb..201bad8678 100644 --- a/types/stripe-v3/stripe-v3-tests.ts +++ b/types/stripe-v3/stripe-v3-tests.ts @@ -5,8 +5,8 @@ declare function it(desc: string, fn: () => void): void; describe("Stripe", () => { it("should excercise all Stripe API", () => { - const stripeInstance = Stripe('public-key'); - const elements = stripeInstance.elements(); + const stripe = Stripe('public-key'); + const elements = stripe.elements(); const style = { base: { color: '#32325d', @@ -31,7 +31,7 @@ describe("Stripe", () => { card.on('change', (resp: stripe.elements.ElementChangeResponse) => { console.log(resp.brand); }); - stripeInstance.createToken(card, { + stripe.createToken(card, { name: 'Jimmy', address_city: 'Toronto', address_country: 'Canada' @@ -51,7 +51,7 @@ describe("Stripe", () => { postal_code: 'XYZ' } }; - stripeInstance.createSource(card, { owner: ownerInfo }).then(result => { + stripe.createSource(card, { owner: ownerInfo }).then(result => { if (result.error) { // handle error return Promise.resolve(null); @@ -60,11 +60,11 @@ describe("Stripe", () => { // handle error return Promise.resolve(null); } - if (!result.source.card || result.source.card.three_d_secure === stripe.ThreeDSecureSupport.NotSupported) { + if (!result.source.card || result.source.card.three_d_secure === 'not_supported') { // make regular payment... return Promise.resolve(null); } - return stripeInstance.createSource({ + return stripe.createSource({ type: 'three_d_secure', amount: 100, currency: 'usd', @@ -101,7 +101,7 @@ describe("Stripe", () => { }); card.destroy(); // test payment request - const paymentRequest = stripeInstance.paymentRequest({ + const paymentRequest = stripe.paymentRequest({ country: 'US', currency: 'usd', total: {