/
FinancialConnections.ts
126 lines (111 loc) · 4.88 KB
/
FinancialConnections.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import type { BankAccount } from './Token';
import type { StripeError } from './Errors';
export type SessionResult =
| {
/** The updated Financial Connections Session object. */
session: Session;
error?: undefined;
}
| {
session?: undefined;
error: StripeError<FinancialConnectionsSheetError>;
};
export type TokenResult =
| {
/** The updated Financial Connections Session object. */
session: Session;
/** The Stripe token object associated with the bank account. */
token: BankAccountToken;
error?: undefined;
}
| {
session?: undefined;
token?: undefined;
error: StripeError<FinancialConnectionsSheetError>;
};
export type Session = {
/** A unique ID for this session. */
id: string;
/** The client secret for this session. */
clientSecret: string;
/** Has the value true if the object exists in live mode or the value false if the object exists in test mode. */
livemode: boolean;
/** The accounts that were collected as part of this Session. */
accounts: Array<Account>;
};
export type BankAccountToken = {
/** Bank account details. */
bankAccount: BankAccount | null;
/** Has the value true if the object exists in live mode or the value false if the object exists in test mode. */
livemode: boolean;
/** A unique ID for this token. */
id: string | null;
used: boolean;
type: 'BankAccount';
/** The UNIX timestamp (in milliseconds) of the date this token was created. */
created: number | null;
};
export type Account = {
/** A unique ID for this Financial Connections Account. */
id: string;
/** Has the value true if the object exists in live mode or the value false if the object exists in test mode. */
livemode: boolean;
displayName: string | null;
/** The current status of the account. Either active, inactive, or disconnected. */
status: AccountStatus;
institutionName: string;
last4: string | null;
/** The UNIX timestamp (in milliseconds) of the date this account was created. */
created: number;
/** The balance of this account. */
balance: Balance | null;
/** The last balance refresh. Includes the timestamp and the status. */
balanceRefresh: BalanceRefresh | null;
/** The category of this account, either cash, credit, investment, or other. */
category: Category;
/** The subcategory of this account, either checking, credit_card, line_of_credit, mortgage, savings, or other. */
subcategory: Subcategory;
/** Permissions requested for accounts collected during this session. */
permissions: Array<Permission> | null;
/** The supported payment method types for this account. */
supportedPaymentMethodTypes: Array<PaymentMethodType>;
};
export type AccountStatus = 'active' | 'inactive' | 'disconnected';
export type Category = 'cash' | 'credit' | 'investment' | 'other';
export type PaymentMethodType = 'us_bank_account' | 'link';
export type Subcategory =
| 'checking'
| 'creditCard'
| 'lineOfCredit'
| 'mortgage'
| 'other'
| 'savings';
export type Permission =
| 'balances'
| 'ownership'
| 'paymentMethod'
| 'transactions'
| 'accountNumbers';
export type Balance = {
/** The UNIX timestamp (in milliseconds) of time that the external institution calculated this balance. */
asOf: number;
/** The type of this balance, either cash or credit. */
type: BalanceType;
/** The funds available to the account holder. Typically this is the current balance less any holds. Each key is a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Each value is an integer amount. A positive amount indicates money owed to the account holder. A negative amount indicates money owed by the account holder. */
cash: { available: Map<String, number> | null };
/** The credit that has been used by the account holder. Each key is a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Each value is a integer amount. A positive amount indicates money owed to the account holder. A negative amount indicates money owed by the account holder. */
credit: { used: Map<String, number> | null };
/** The balances owed to (or by) the account holder. Each key is a three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. Each value is a integer amount. A positive amount indicates money owed to the account holder. A negative amount indicates money owed by the account holder. */
current: Map<String, number>;
};
export type BalanceRefresh = {
status: BalanceRefreshStatus;
/** The UNIX timestamp (in milliseconds) of the time at which the last refresh attempt was initiated. */
lastAttemptedAt: number;
};
export type BalanceType = 'cash' | 'credit';
export type BalanceRefreshStatus = 'failed' | 'pending' | 'succeeded';
export enum FinancialConnectionsSheetError {
Failed = 'Failed',
Canceled = 'Canceled',
}