From aa2969e5121d6d216cf0996bbdb41bc978c04fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20So=C5=82tysiak?= Date: Tue, 25 Feb 2020 23:01:14 +0100 Subject: [PATCH] [stripe-v3] add missing mandate argument to createSource (#41924) * [stripe-v3] add missing mandate argument to createSource * [stripe-v3] Typo + test organization --- types/stripe-v3/index.d.ts | 30 ++++++++++++++++++++++++++++++ types/stripe-v3/stripe-v3-tests.ts | 18 ++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/types/stripe-v3/index.d.ts b/types/stripe-v3/index.d.ts index 6b9096ca4a..67bf9cf728 100644 --- a/types/stripe-v3/index.d.ts +++ b/types/stripe-v3/index.d.ts @@ -13,6 +13,7 @@ // Krishna Pravin // Hiroshi Ioka // Austin Turner +// Kevin Soltysiak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var Stripe: stripe.StripeStatic; @@ -180,6 +181,34 @@ declare namespace stripe { phone?: string; } + interface OfflineAcceptanceMandate { + contact_email: string; + } + + interface OnlineAcceptanceMandate { + date: number; + ip: string; + user_agent: string; + } + + interface SourceMandateAcceptance { + date: number; + status: 'accepted' | 'refused'; + ip?: string; + offline?: OfflineAcceptanceMandate; + online?: OnlineAcceptanceMandate; + type?: 'online'| 'offline'; + user_agent?: string; + } + + interface SourceMandate { + acceptance?: SourceMandateAcceptance; + amount?: number; + currency?: string; + interval?: 'one_time' | 'scheduled' | 'variable'; + notification_method?: 'email' | 'manual' | 'none'; + } + interface SourceOptions { type: string; flow?: 'redirect' | 'receiver' | 'code_verification' | 'none'; @@ -189,6 +218,7 @@ declare namespace stripe { currency?: string; amount?: number; owner?: OwnerInfo; + mandate?: SourceMandate; metadata?: {}; statement_descriptor?: string; redirect?: { diff --git a/types/stripe-v3/stripe-v3-tests.ts b/types/stripe-v3/stripe-v3-tests.ts index 51566556bb..60c78d7cf1 100644 --- a/types/stripe-v3/stripe-v3-tests.ts +++ b/types/stripe-v3/stripe-v3-tests.ts @@ -129,6 +129,24 @@ describe("Stripe elements", () => { card.destroy(); }); + it("should create an iban source with a mandate", () => { + const options: stripe.SourceOptions = { + type: 'sepa_debit', + sepa_debit: { + iban: 'some iban', + }, + owner: { + name: 'some holder', + }, + mandate: { + notification_method: 'email', + }, + currency: 'eur', + }; + + stripe.createSource(options); + }); + it("should create an iban element", () => { const ibanElement = elements.create('iban', { supportedCountries: ['SEPA'],