mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 17:20:09 +00:00
[@types/stripe] createSource accepts bank account arguments (#37843)
* [@types/stripe] createSource accepts bank account arguments * amend tests and add additional method signature * create helper type for external account union type
This commit is contained in:
committed by
Sheetal Nandi
parent
47f0eec500
commit
4b7d4b107d
29
types/stripe/index.d.ts
vendored
29
types/stripe/index.d.ts
vendored
@@ -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<cards.ICard | bankAccounts.IBankAccount>;
|
||||
external_accounts?: IList<IExternalAccount>;
|
||||
}
|
||||
|
||||
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<IList<cards.ICard>>): IListPromise<cards.ICard>;
|
||||
listCards(customerId: string, response?: IResponseFn<IList<cards.ICard>>): IListPromise<cards.ICard>;
|
||||
|
||||
/**
|
||||
* 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<bankAccounts.IBankAccount>): Promise<bankAccounts.IBankAccount>;
|
||||
createSource(customerId: string, data: customers.ICustomerBankAccountSourceCreationOptions, response?: IResponseFn<bankAccounts.IBankAccount>): Promise<bankAccounts.IBankAccount>;
|
||||
/**
|
||||
* 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<cards.ICard>): Promise<cards.ICard>;
|
||||
createSource(customerId: string, data: customers.ICustomerCardSourceCreationOptions, response?: IResponseFn<cards.ICard>): Promise<cards.ICard>;
|
||||
/**
|
||||
* 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<IStripeSource>): Promise<IStripeSource>;
|
||||
createSource(customerId: string, data: customers.ICustomerSourceCreationOptions, response?: IResponseFn<IStripeSource>): Promise<IStripeSource>;
|
||||
|
||||
@@ -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<ICard | IBankAccount>
|
||||
account.external_accounts; // $ExpectType IList<IExternalAccount>
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user