diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index f8d20071ad..7c42965281 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -129,6 +129,9 @@ declare namespace Stripe { type IStripeSource = cards.ICard | bitcoinReceivers.IBitcoinReceiver | bankAccounts.IBankAccount | sources.ISource; namespace accounts { + // Helper + type IExternalAccount = bankAccounts.IBankAccount | cards.ICard; + interface IAccount extends IResourceObject, IAccountShared { /** * Value is "account" @@ -210,7 +213,7 @@ declare namespace Stripe { * External accounts (bank accounts and debit cards) currently * attached to this account */ - external_accounts?: IList; + external_accounts?: IList; } interface IAccountCreationOptions extends IAccountUpdateOptions { @@ -2526,7 +2529,7 @@ declare namespace Stripe { * dictionary containing a user’s credit card details (with the options shown * below). Stripe will automatically validate the card. */ - source: string | cards.ICardSourceCreationOptions; + source: string | cards.ICardSourceCreationOptions | bankAccounts.ISourceCreationOptions; } interface ICustomerInvoiceSettings { @@ -2557,6 +2560,10 @@ declare namespace Stripe { footer?: string; } + interface ICustomerBankAccountSourceCreationOptions extends ICustomerSourceCreationOptions { + source: bankAccounts.ISourceCreationOptions; + } + interface ICustomerCardSourceCreationOptions extends ICustomerSourceCreationOptions { source: cards.ICardSourceCreationOptions; } @@ -9095,6 +9102,18 @@ declare namespace Stripe { listCards(customerId: string, options: HeaderOptions, response?: IResponseFn>): IListPromise; listCards(customerId: string, response?: IResponseFn>): IListPromise; + /** + * When adding a bank account to a customer, the parameter name is source. When + * adding to an account, the parameter name is external_account. The + * value can either be a token, like the ones returned by our Stripe.js, or a + * dictionary containing a user’s bank account details. + * + * @returns Returns the bank account object. + * + * @param customerId The customer ID to which to add the bank account. + */ + createSource(customerId: string, data: customers.ICustomerBankAccountSourceCreationOptions, options: HeaderOptions, response?: IResponseFn): Promise; + createSource(customerId: string, data: customers.ICustomerBankAccountSourceCreationOptions, response?: IResponseFn): Promise; /** * When adding a card to a customer, the parameter name is source. When * adding to an account, the parameter name is external_account. The @@ -9109,15 +9128,15 @@ declare namespace Stripe { createSource(customerId: string, data: customers.ICustomerCardSourceCreationOptions, options: HeaderOptions, response?: IResponseFn): Promise; createSource(customerId: string, data: customers.ICustomerCardSourceCreationOptions, response?: IResponseFn): Promise; /** - * When adding a card to a customer, the parameter name is source. When + * When adding a card or bank account to a customer, the parameter name is source. When * adding to an account, the parameter name is external_account. The * value can either be a token, like the ones returned by our Stripe.js, or a - * dictionary containing a user’s credit card details. + * dictionary containing a user’s credit card or bank account details. * Stripe will automatically validate the card. * * @returns Returns the card or bank account object. * - * @param customerId The customer ID to which to add the card. + * @param customerId The customer ID to which to add the card or bank account. */ createSource(customerId: string, data: customers.ICustomerSourceCreationOptions, options: HeaderOptions, response?: IResponseFn): Promise; createSource(customerId: string, data: customers.ICustomerSourceCreationOptions, response?: IResponseFn): Promise; diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 0f67db9974..5e2ccb2010 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -635,6 +635,41 @@ stripe.customers.createSource( } ); +stripe.customers.createSource( + "cus_5rfJKDJkuxzh5Q", + { + source: { + country: 'US', + currency: 'USD', + account_holder_name: 'Account Holder', + account_holder_type: 'individual', + account_number: '000123456789', + routing_number: '110000000' + } + }, + (err, bankAcc) => { + // asynchronously called + bankAcc; // $ExpectType IBankAccount + } +); +stripe.customers.createSource( + "cus_5rfJKDJkuxzh5Q", + { + source: { + country: 'US', + currency: 'USD', + account_holder_name: 'Account Holder', + account_holder_type: 'individual', + account_number: '000123456789', + routing_number: '110000000' + } + }).then( + (bankAcc) => { + // asynchronously called + bankAcc; // $ExpectType IBankAccount + } +); + stripe.customers.createSubscription( "cus_5rfJKDJkuxzh5Q", { @@ -884,7 +919,7 @@ stripe.accounts.retrieve( // asynchronously called // account should have external_accounts property - account.external_accounts; // $ExpectType IList + account.external_accounts; // $ExpectType IList } );