Stripe connect account & charge definition updates (#35040)

* Business & individual account type objects.

* Adding account settings definitions.

* Adding account business profile and account token definitions.

* Removing top level account object properties in line with API updates.
https://stripe.com/docs/upgrades#2019-02-19

* Updating tests.
Adding missing statement_descriptor definition to account payout settings.

* Fixing linting fail.

* Updating IChargeCreationOptions interface to include transfer_data object definition.

* Removing account legal_entity definition in accordance with API updates.

* Charge destination amount marked as optional.

* Adding some stripe tests.

* Post-merge fixes.

* Implementing IAddress in place of duplicate address objects.

* Bumping stripe package version since it includes potentially breaking changes.

* Creating IAddressKana and IAddressKanji interfaces.

* Moving account_token property to IAccountUpdateOptions interface.

* Correcting properties based on account fetch response.

* `id_provided` fields should be optional as they're only returned from a fetch operation, and should not be supplied during a create or update.

* Splitting out account company and individual objects into interfaces.

* Fixing lint errors.

* Removing SimonSchick from Stripe maintainer list per his request.
This commit is contained in:
Alex Powell 2019-05-27 10:12:38 +01:00 committed by Wesley Wigham
parent 86303f134e
commit aed4ee517f
2 changed files with 440 additions and 143 deletions

View File

@ -13,7 +13,6 @@
// Tyler Jones <https://github.com/squirly>
// Troy Zarger <https://github.com/tzarger>
// Ifiok Jr. <https://github.com/ifiokjr>
// Simon Schick <https://github.com/SimonSchick>
// Slava Yultyyev <https://github.com/yultyyev>
// Corey Psoinos <https://github.com/cpsoinos>
// Adam Duren <https://github.com/adamduren>
@ -174,6 +173,18 @@ declare namespace Stripe {
*/
fields_needed: string[];
};
/**
* Information about the company or business.
* This field is null unless business_type is set to company.
*/
company?: ICompany;
/**
* Information about the person represented by the account.
* This field is null unless business_type is set to individual.
*/
individual?: IIndividual;
}
interface IAccountCreationOptions extends IAccountUpdateOptions {
@ -206,22 +217,21 @@ declare namespace Stripe {
* management directly with them. Possible values are custom and standard.
*/
type: "custom" | "standard";
/**
* Information about the company or business.
* This field is null unless business_type is set to company.
*/
company?: ICompanyCreateUpdateOptions;
/**
* Information about the person represented by the account.
* This field is null unless business_type is set to individual.
*/
individual?: IIndividualCreateUpdateOptions;
}
interface IAccountShared {
business_logo?: string;
/**
* The publicly sharable name for this account
*/
business_name?: string;
/**
* A CSS hex color value representing the primary branding color for this
* account
*/
business_primary_color?: string;
/**
* Optional information related to the business.
*/
@ -300,36 +310,9 @@ declare namespace Stripe {
};
/**
* The URL that best shows the service or product provided for this account
* The business type. Can be individual or company.
*/
business_url?: string;
/**
* A boolean for whether or not Stripe should try to reclaim negative
* balances from the account holders bank account. See our managed
* account bank transfer guide for more information
*/
debit_negative_balances?: boolean;
/**
* Account-level settings to automatically decline certain types of charges
* regardless of the banks decision.
*/
decline_charge_on?: {
/**
* Whether or not Stripe should automatically decline charges with an
* incorrect zip/postal code. This setting only applies if a card includes a
* zip code and the bank specifically marks it as failed.
*/
avs_failure?: boolean;
/**
* Whether or not Stripe should automatically decline charges with an
* incorrect CVC. This setting only applies if a card includes a CVC and the
* bank specifically marks it as failed.
*/
cvc_failure?: boolean;
};
business_type?: "individual" | "company";
/**
* Three-letter ISO currency code representing the default currency for the
@ -346,12 +329,6 @@ declare namespace Stripe {
*/
email?: string;
/**
* Information about the holder of this account, i.e. the user receiving funds
* from this account
*/
legal_entity?: {}; // TODO: Implement this type definition.
/**
* A set of key/value pairs that you can attach to an account object. It can be
* useful for storing additional information about the account in a structured
@ -509,29 +486,6 @@ declare namespace Stripe {
};
};
/**
* The text that will appear on credit card statements by default if a charge is
* being made directly on the account.
*/
statement_descriptor?: string;
/**
* A publicly shareable email address that can be reached for support for this
* account
*/
support_email?: string;
/**
* A publicly shareable phone number that can be reached for support for
* this account
*/
support_phone?: string;
/**
* A publicly shareable URL that can be reached for support for this account
*/
support_url?: string;
/**
* Details on who accepted the Stripe terms of service, and when they
* accepted it. See our updating managed accounts guide for more
@ -555,45 +509,6 @@ declare namespace Stripe {
*/
user_agent?: string;
};
/**
* Details on when funds from charges are available,
* and when they are paid out to an external account.
* See our Setting Bank and Debit Card Payouts documentation for details.
*/
payout_schedule?: {
/**
* The number of days charges for the account will be held before being
* paid out. May also be the string minimum for the lowest available
* value (based on country). Default is minimum. Does not apply when
* interval is manual.
*/
delay_days?: number | string;
/**
* How frequently funds will be paid out. One of "manual" (for only
* triggered via API call), "daily", "weekly", or "monthly". Default is "daily".
*/
interval?: "manual" | "daily" | "weekly" | "monthly";
/**
* The day of the month funds will be paid out. Required and available
* only if interval is "monthly".
*/
monthly_anchor?: number;
/**
* The day of the week funds will be paid out, of the style monday,
* tuesday, etc. Required and available only if interval is weekly.
*/
weekly_anchor?: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday";
};
/**
* The text that appears on the bank account statement for payouts.
* If not set, this defaults to the platforms bank descriptor as set in the Dashboard.
*/
payout_statement_descriptor?: string;
}
interface IAccountUpdateOptions extends IDataOptions, IAccountShared {
@ -653,6 +568,23 @@ declare namespace Stripe {
*/
routing_number?: string;
};
/**
* An account token, used to securely provide details to the account.
*/
account_token?: string;
/**
* Information about the company or business.
* This field is null unless business_type is set to company.
*/
company?: ICompanyCreateUpdateOptions;
/**
* Information about the person represented by the account.
* This field is null unless business_type is set to individual.
*/
individual?: IIndividualCreateUpdateOptions;
}
interface IExternalAccountCreationOptions extends IDataOptionsWithMetadata {
@ -704,6 +636,249 @@ declare namespace Stripe {
*/
url: string;
}
interface ICompanyShared {
/**
* The companys primary address.
*/
address?: IAddress;
/**
* The Kana variation of the companys primary address (Japan only).
*/
address_kana?: IAddressKana;
/**
* The Kanji variation of the companys primary address (Japan only).
*/
address_kanji?: IAddressKanji;
/**
* Whether the companys directors have been provided. Set this Boolean
* to true after creating all the companys directors with the Persons API
* for accounts with a relationship.director requirement. This value is
* not automatically set to true after creating directors, so it needs to
* be updated to indicate all directors have been provided.
*/
directors_provided?: boolean;
/**
* The companys legal name.
* This can be unset by updating the value to null and then saving.
*/
name?: string;
/**
* The Kana variation of the companys legal name (Japan only).
* This can be unset by updating the value to null and then saving.
*/
name_kana?: string;
/**
* The Kanji variation of the companys legal name (Japan only).
* This can be unset by updating the value to null and then saving.
*/
name_kanji?: string;
/**
* Whether the companys owners have been provided. Set this Boolean
* to true after creating all the companys owners with the Persons API
* for accounts with a relationship.owner requirement.
*/
owners_provided?: boolean;
/**
* The companys phone number (used for verification).
* This can be unset by updating the value to null and then saving.
*/
phone?: string;
/**
* The jurisdiction in which the tax_id is registered (Germany-based companies only).
* This can be unset by updating the value to null and then saving.
*/
tax_id_registrar?: string;
}
interface ICompanyCreateUpdateOptions extends ICompanyShared {
/**
* The business ID number of the company, as appropriate for the companys country.
* (Examples are an Employer ID Number in the U.S., a Business Number in Canada, or a
* Company Number in the UK.) This can be unset by updating the value to null and then saving.
*/
tax_id?: string;
/**
* The VAT number of the company.
* This can be unset by updating the value to null and then saving.
*/
vat_id?: string;
}
interface ICompany extends ICompanyShared {
/**
* Whether the companys business ID number was provided.
*/
tax_id_provided?: boolean;
/**
* Whether the companys business VAT number was provided.
*/
vat_id_provided?: boolean;
}
interface IIndividualShared {
/**
* The individuals primary address.
*/
address?: IAddress;
/**
* The Kana variation of the the individuals primary address (Japan only).
*/
address_kana?: IAddressKana;
/**
* The Kanji variation of the the individuals primary address (Japan only).
*/
address_kanji?: IAddressKanji;
/**
* The individuals date of birth.
*/
dob?: {
/**
* The day of birth, between 1 and 31.
*/
day: number;
/**
* The month of birth, between 1 and 12.
*/
month: number;
/**
* The four-digit year of birth.
*/
year: number;
};
/**
* The individual's email address.
*/
email?: string;
/**
* The individuals first name.
* This can be unset by updating the value to null and then saving.
*/
first_name?: string;
/**
* The Kana variation of the the individuals first name (Japan only).
* This can be unset by updating the value to null and then saving.
*/
first_name_kana?: string;
/**
* The Kanji variation of the individuals first name (Japan only).
* This can be unset by updating the value to null and then saving.
*/
first_name_kanji?: string;
/**
* The individuals gender (International regulations require either male or female).
* This can be unset by updating the value to null and then saving.
*/
gender?: "male" | "female";
/**
* The individuals last name.
* This can be unset by updating the value to null and then saving.
*/
last_name?: string;
/**
* The Kana varation of the individuals last name (Japan only).
* This can be unset by updating the value to null and then saving.
*/
last_name_kana?: string;
/**
* The Kanji varation of the individuals last name (Japan only).
* This can be unset by updating the value to null and then saving.
*/
last_name_kanji?: string;
/**
* The individuals maiden name.
* This can be unset by updating the value to null and then saving.
*/
maiden_name?: string;
/**
* Set of key-value pairs that you can attach to an object. This can be useful
* for storing additional information about the object in a structured format.
* Individual keys can be unset by posting an empty value to them.
* All keys can be unset by posting an empty value to metadata.
*/
metadata?: {
[key: string]: string;
};
/**
* The individuals phone number.
*/
phone?: string;
/**
* The individuals verification document information.
*/
verification?: {
/**
* An identifying document, either a passport or local ID card.
*/
document?: {
/**
* The back of an ID returned by a file upload with a purpose value of identity_document.
* This can be unset by updating the value to null and then saving.
*/
back?: string;
/**
* The front of an ID returned by a file upload with a purpose value of identity_document.
* This can be unset by updating the value to null and then saving.
*/
front?: string;
}
};
}
interface IIndividual extends IIndividualShared {
/**
* Whether the individuals personal ID number was provided.
*/
id_number_provided: boolean;
/**
* Whether the individuals last 4 SSN digits was provided.
*/
ssn_last_4_provided: boolean;
}
interface IIndividualCreateUpdateOptions extends IIndividualShared {
/**
* The government-issued ID number of the individual, as appropriate for the representatives country.
* (Examples are a Social Security Number in the U.S., or a Social Insurance Number in Canada).
* Instead of the number itself, you can also provide a PII token created with Stripe.js.
* This can be unset by updating the value to null and then saving.
*/
id_number?: string;
/**
* The last four digits of the individuals Social Security Number (U.S. only).
* This can be unset by updating the value to null and then saving.
*/
ssn_last_4?: string;
}
}
namespace applicationFees {
@ -1187,7 +1362,7 @@ declare namespace Stripe {
amount: number;
/**
* 3-letter ISO code for currency.
* Three-letter ISO currency code, in lowercase. Must be a supported currency.
*/
currency: string;
@ -1216,29 +1391,6 @@ declare namespace Stripe {
*/
description?: string;
/**
* An account to make the charge on behalf of. If specified, the charge will be
* attributed to the destination account for tax reporting, and the funds from
* the charge will be transferred to the destination account. The ID of the
* resulting transfer will be returned in the transfer field of the response. See
* the documentation for details.
*
* Connect only.
*/
destination?: string | {
/**
* ID of the Stripe account this fee will be transferred to.
*/
account: string;
/**
* A positive integer in the smallest currency unit (e.g 100 cents to charge
* $1.00, or 1 to charge ¥1, a 0-decimal currency) reflecting the amount of the
* charge to be transferred to the destination[account].
*/
amount?: number;
};
/**
* A string that identifies this transaction as part of a group.
* See the Connect documentation for details.
@ -1301,6 +1453,23 @@ declare namespace Stripe {
* incorrectly or not at all.
*/
statement_descriptor?: string;
/**
* An optional dictionary including the account to automatically transfer
* to as part of a destination charge. See the Connect documentation for details.
*/
transfer_data?: {
/**
* ID of an existing, connected Stripe account.
*/
destination: string;
/**
* The amount transferred to the destination account, if specified.
* By default, the entire charge amount is transferred to the destination account.
*/
amount?: number;
};
}
interface IChargeCaptureOptions extends IDataOptions {
@ -8717,6 +8886,94 @@ declare namespace Stripe {
country?: string;
}
interface IAddressKana {
/**
* City or ward.
* This can be unset by updating the value to null and then saving.
*/
city?: string;
/**
* Two-letter country code (ISO 3166-1 alpha-2).
* This can be unset by updating the value to null and then saving.
*/
country?: string;
/**
* Block or building number.
* This can be unset by updating the value to null and then saving.
*/
line1?: string;
/**
* Building details.
* This can be unset by updating the value to null and then saving.
*/
line2?: string;
/**
* Postal code.
* This can be unset by updating the value to null and then saving.
*/
postal_code?: string;
/**
* Prefecture.
* This can be unset by updating the value to null and then saving.
*/
state?: string;
/**
* Town or cho-me.
* This can be unset by updating the value to null and then saving.
*/
town?: string;
}
interface IAddressKanji {
/**
* City or ward.
* This can be unset by updating the value to null and then saving.
*/
city?: string;
/**
* Two-letter country code (ISO 3166-1 alpha-2).
* This can be unset by updating the value to null and then saving.
*/
country?: string;
/**
* Block or building number.
* This can be unset by updating the value to null and then saving.
*/
line1?: string;
/**
* Building details.
* This can be unset by updating the value to null and then saving.
*/
line2?: string;
/**
* Postal code.
* This can be unset by updating the value to null and then saving.
*/
postal_code?: string;
/**
* Prefecture.
* This can be unset by updating the value to null and then saving.
*/
state?: string;
/**
* Town or cho-me.
* This can be unset by updating the value to null and then saving.
*/
town?: string;
}
interface IShippingInformation {
/**
* Shipping address.

View File

@ -78,6 +78,17 @@ stripe.charges.create({
charge.refunds.list().then((refund) => {
});
});
stripe.charges.create({
amount: 400,
currency: "gbp",
source: "tok_17wV94BoqMA9o2xkhlAd3ALf", // obtained with Stripe.js
description: "Charge for test@example.com",
transfer_data: {
destination: "acct_17wV8KBoqMA9o2xk"
}
}, (err, charge) => {
// asynchronously called
});
stripe.charges.retrieve("ch_15fvyXEe31JkLCeQOo0SwFk9", (err, charge) => {
// asynchronously called
@ -680,6 +691,23 @@ stripe.accounts.create({
// asynchronously called
}
);
stripe.accounts.create({
type: "custom",
business_type: "individual",
individual: {
first_name: "John",
last_name: "Smith",
email: "test@example.com",
dob: {
day: 1,
month: 1,
year: 1970
},
}
}).then((customer) => {
// asynchronously called
}
);
stripe.accounts.retrieve(
"acct_17wV8KBoqMA9o2xk",
@ -696,7 +724,9 @@ stripe.accounts.retrieve(
stripe.accounts.update("acct_17wV8KBoqMA9o2xk",
{
support_phone: "555-867-5309"
business_profile: {
support_phone: "555-867-5309"
}
},
(err, account) => {
// asynchronously called
@ -704,7 +734,9 @@ stripe.accounts.update("acct_17wV8KBoqMA9o2xk",
);
stripe.accounts.update("acct_17wV8KBoqMA9o2xk",
{
support_phone: "555-867-5309"
business_profile: {
support_phone: "555-867-5309"
}
}).then(
(account) => {
// asynchronously called
@ -713,7 +745,11 @@ stripe.accounts.update("acct_17wV8KBoqMA9o2xk",
stripe.accounts.update("acct_17wV8KBoqMA9o2xk",
{
payout_statement_descriptor: "From Stripe"
settings: {
payouts: {
statement_descriptor: "From Stripe"
}
}
}).then(
(account) => {
// asynchronously called
@ -722,11 +758,15 @@ stripe.accounts.update("acct_17wV8KBoqMA9o2xk",
stripe.accounts.update("acct_17wV8KBoqMA9o2xk",
{
payout_schedule: {
delay_days: 5,
interval: "monthly",
monthly_anchor: 4,
weekly_anchor: "monday"
settings: {
payouts: {
schedule: {
delay_days: 5,
interval: "monthly",
monthly_anchor: 4,
weekly_anchor: "monday"
}
}
}
}).then(
(account) => {