-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathaccounts.ts
More file actions
464 lines (407 loc) · 15 KB
/
accounts.ts
File metadata and controls
464 lines (407 loc) · 15 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { CursorPage, type CursorPageParams, PagePromise } from '../core/pagination';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
export class Accounts extends APIResource {
/**
* Get account configuration such as spend limits.
*
* @example
* ```ts
* const account = await client.accounts.retrieve(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* );
* ```
*/
retrieve(accountToken: string, options?: RequestOptions): APIPromise<Account> {
return this._client.get(path`/v1/accounts/${accountToken}`, options);
}
/**
* Update account configuration such as state or spend limits. Can only be run on
* accounts that are part of the program managed by this API key. Accounts that are
* in the `PAUSED` state will not be able to transact or create new cards.
*
* @example
* ```ts
* const account = await client.accounts.update(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { daily_spend_limit: 1000 },
* );
* ```
*/
update(accountToken: string, body: AccountUpdateParams, options?: RequestOptions): APIPromise<Account> {
return this._client.patch(path`/v1/accounts/${accountToken}`, { body, ...options });
}
/**
* List account configurations.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const account of client.accounts.list()) {
* // ...
* }
* ```
*/
list(
query: AccountListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<AccountsCursorPage, Account> {
return this._client.getAPIList('/v1/accounts', CursorPage<Account>, { query, ...options });
}
/**
* Get an Account's available spend limits, which is based on the spend limit
* configured on the Account and the amount already spent over the spend limit's
* duration. For example, if the Account has a daily spend limit of $1000
* configured, and has spent $600 in the last 24 hours, the available spend limit
* returned would be $400.
*
* @example
* ```ts
* const accountSpendLimits =
* await client.accounts.retrieveSpendLimits(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* );
* ```
*/
retrieveSpendLimits(accountToken: string, options?: RequestOptions): APIPromise<AccountSpendLimits> {
return this._client.get(path`/v1/accounts/${accountToken}/spend_limits`, options);
}
}
export type AccountsCursorPage = CursorPage<Account>;
export interface Account {
/**
* Globally unique identifier for the account. This is the same as the
* account_token returned by the enroll endpoint. If using this parameter, do not
* include pagination.
*/
token: string;
/**
* Timestamp of when the account was created.
*/
created: string | null;
/**
* Spend limit information for the user containing the daily, monthly, and lifetime
* spend limit of the account. Any charges to a card owned by this account will be
* declined once their transaction volume has surpassed the value in the applicable
* time limit (rolling). A lifetime limit of 0 indicates that the lifetime limit
* feature is disabled.
*/
spend_limit: Account.SpendLimit;
/**
* Account state:
*
* - `ACTIVE` - Account is able to transact and create new cards.
* - `PAUSED` - Account will not be able to transact or create new cards. It can be
* set back to `ACTIVE`.
* - `CLOSED` - Account will not be able to transact or create new cards. `CLOSED`
* accounts are unable to be transitioned to `ACTIVE` or `PAUSED` states.
* Accounts can be manually set to `CLOSED`, or this can be done by Lithic due to
* failure to pass KYB/KYC or for risk/compliance reasons. Please contact
* [support@lithic.com](mailto:support@lithic.com) if you believe this was done
* by mistake.
*/
state: 'ACTIVE' | 'PAUSED' | 'CLOSED';
account_holder?: Account.AccountHolder;
/**
* @deprecated List of identifiers for the Auth Rule(s) that are applied on the
* account. This field is deprecated and will no longer be populated in the
* `account_holder` object. The key will be removed from the schema in a future
* release. Use the `/auth_rules` endpoints to fetch Auth Rule information instead.
*/
auth_rule_tokens?: Array<string>;
/**
* 3-character alphabetic ISO 4217 code for the currency of the cardholder.
*/
cardholder_currency?: string;
/**
* Additional context or information related to the account.
*/
comment?: string;
/**
* Account state substatus values:
*
* - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used
* with stolen or fabricated identity information, encompassing both true
* identity theft and synthetic identities.
* - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as
* unauthorized access or fraudulent transactions, necessitating further
* investigation.
* - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the
* legitimate account holder. Examples include disputing valid transactions
* without cause, falsely claiming non-receipt of goods, or engaging in
* intentional bust-out schemes to exploit account services.
* - `END_USER_REQUEST` - The account holder has voluntarily requested the closure
* of the account for personal reasons. This encompasses situations such as
* bankruptcy, other financial considerations, or the account holder's death.
* - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to
* business strategy, risk management, inactivity, product changes, regulatory
* concerns, or violations of terms and conditions.
* - `NOT_ACTIVE` - The account has not had any transactions or payment activity
* within a specified period. This status applies to accounts that are paused or
* closed due to inactivity.
* - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal
* review. In future implementations, this status may prevent clients from
* activating the account via APIs until the review is completed.
* - `OTHER` - The reason for the account's current status does not fall into any
* of the above categories. A comment should be provided to specify the
* particular reason.
*/
substatus?:
| 'FRAUD_IDENTIFIED'
| 'SUSPICIOUS_ACTIVITY'
| 'RISK_VIOLATION'
| 'END_USER_REQUEST'
| 'ISSUER_REQUEST'
| 'NOT_ACTIVE'
| 'INTERNAL_REVIEW'
| 'OTHER';
/**
* @deprecated
*/
verification_address?: Account.VerificationAddress;
}
export namespace Account {
/**
* Spend limit information for the user containing the daily, monthly, and lifetime
* spend limit of the account. Any charges to a card owned by this account will be
* declined once their transaction volume has surpassed the value in the applicable
* time limit (rolling). A lifetime limit of 0 indicates that the lifetime limit
* feature is disabled.
*/
export interface SpendLimit {
/**
* Daily spend limit (in cents).
*/
daily: number;
/**
* Total spend limit over account lifetime (in cents).
*/
lifetime: number;
/**
* Monthly spend limit (in cents).
*/
monthly: number;
}
export interface AccountHolder {
/**
* Globally unique identifier for the account holder.
*/
token: string;
/**
* Only applicable for customers using the KYC-Exempt workflow to enroll authorized
* users of businesses. Account_token of the enrolled business associated with an
* enrolled AUTHORIZED_USER individual.
*/
business_account_token: string;
/**
* Email address.
*/
email: string;
/**
* Phone number of the individual.
*/
phone_number: string;
}
/**
* @deprecated
*/
export interface VerificationAddress {
/**
* Valid deliverable address (no PO boxes).
*/
address1: string;
/**
* City name.
*/
city: string;
/**
* Country name. Only USA is currently supported.
*/
country: string;
/**
* Valid postal code. Only USA postal codes (ZIP codes) are currently supported,
* entered as a five-digit postal code or nine-digit postal code (ZIP+4) using the
* format 12345-1234.
*/
postal_code: string;
/**
* Valid state code. Only USA state codes are currently supported, entered in
* uppercase ISO 3166-2 two-character format.
*/
state: string;
/**
* Unit or apartment number (if applicable).
*/
address2?: string;
}
}
export interface AccountSpendLimits {
available_spend_limit: AccountSpendLimits.AvailableSpendLimit;
spend_limit?: AccountSpendLimits.SpendLimit;
spend_velocity?: AccountSpendLimits.SpendVelocity;
}
export namespace AccountSpendLimits {
export interface AvailableSpendLimit {
/**
* The available spend limit (in cents) relative to the daily limit configured on
* the Account (e.g. 100000 would be a $1,000 limit).
*/
daily?: number;
/**
* The available spend limit (in cents) relative to the lifetime limit configured
* on the Account.
*/
lifetime?: number;
/**
* The available spend limit (in cents) relative to the monthly limit configured on
* the Account.
*/
monthly?: number;
}
export interface SpendLimit {
/**
* The configured daily spend limit (in cents) on the Account.
*/
daily?: number;
/**
* The configured lifetime spend limit (in cents) on the Account.
*/
lifetime?: number;
/**
* The configured monthly spend limit (in cents) on the Account.
*/
monthly?: number;
}
export interface SpendVelocity {
/**
* Current daily spend velocity (in cents) on the Account. Present if daily spend
* limit is set.
*/
daily?: number;
/**
* Current lifetime spend velocity (in cents) on the Account. Present if lifetime
* spend limit is set.
*/
lifetime?: number;
/**
* Current monthly spend velocity (in cents) on the Account. Present if monthly
* spend limit is set.
*/
monthly?: number;
}
}
export interface AccountUpdateParams {
/**
* Additional context or information related to the account.
*/
comment?: string;
/**
* Amount (in cents) for the account's daily spend limit (e.g. 100000 would be a
* $1,000 limit). By default the daily spend limit is set to $1,250.
*/
daily_spend_limit?: number;
/**
* Amount (in cents) for the account's lifetime spend limit (e.g. 100000 would be a
* $1,000 limit). Once this limit is reached, no transactions will be accepted on
* any card created for this account until the limit is updated. Note that a spend
* limit of 0 is effectively no limit, and should only be used to reset or remove a
* prior limit. Only a limit of 1 or above will result in declined transactions due
* to checks against the account limit. This behavior differs from the daily spend
* limit and the monthly spend limit.
*/
lifetime_spend_limit?: number;
/**
* Amount (in cents) for the account's monthly spend limit (e.g. 100000 would be a
* $1,000 limit). By default the monthly spend limit is set to $5,000.
*/
monthly_spend_limit?: number;
/**
* Account states.
*/
state?: 'ACTIVE' | 'PAUSED' | 'CLOSED';
/**
* Account state substatus values:
*
* - `FRAUD_IDENTIFIED` - The account has been recognized as being created or used
* with stolen or fabricated identity information, encompassing both true
* identity theft and synthetic identities.
* - `SUSPICIOUS_ACTIVITY` - The account has exhibited suspicious behavior, such as
* unauthorized access or fraudulent transactions, necessitating further
* investigation.
* - `RISK_VIOLATION` - The account has been involved in deliberate misuse by the
* legitimate account holder. Examples include disputing valid transactions
* without cause, falsely claiming non-receipt of goods, or engaging in
* intentional bust-out schemes to exploit account services.
* - `END_USER_REQUEST` - The account holder has voluntarily requested the closure
* of the account for personal reasons. This encompasses situations such as
* bankruptcy, other financial considerations, or the account holder's death.
* - `ISSUER_REQUEST` - The issuer has initiated the closure of the account due to
* business strategy, risk management, inactivity, product changes, regulatory
* concerns, or violations of terms and conditions.
* - `NOT_ACTIVE` - The account has not had any transactions or payment activity
* within a specified period. This status applies to accounts that are paused or
* closed due to inactivity.
* - `INTERNAL_REVIEW` - The account is temporarily paused pending further internal
* review. In future implementations, this status may prevent clients from
* activating the account via APIs until the review is completed.
* - `OTHER` - The reason for the account's current status does not fall into any
* of the above categories. A comment should be provided to specify the
* particular reason.
*/
substatus?:
| 'FRAUD_IDENTIFIED'
| 'SUSPICIOUS_ACTIVITY'
| 'RISK_VIOLATION'
| 'END_USER_REQUEST'
| 'ISSUER_REQUEST'
| 'NOT_ACTIVE'
| 'INTERNAL_REVIEW'
| 'OTHER';
/**
* @deprecated Address used during Address Verification Service (AVS) checks during
* transactions if enabled via Auth Rules. This field is deprecated as AVS checks
* are no longer supported by Auth Rules. The field will be removed from the schema
* in a future release.
*/
verification_address?: AccountUpdateParams.VerificationAddress;
}
export namespace AccountUpdateParams {
/**
* @deprecated Address used during Address Verification Service (AVS) checks during
* transactions if enabled via Auth Rules. This field is deprecated as AVS checks
* are no longer supported by Auth Rules. The field will be removed from the schema
* in a future release.
*/
export interface VerificationAddress {
address1?: string;
address2?: string;
city?: string;
country?: string;
postal_code?: string;
state?: string;
}
}
export interface AccountListParams extends CursorPageParams {
/**
* Date string in RFC 3339 format. Only entries created after the specified time
* will be included. UTC time zone.
*/
begin?: string;
/**
* Date string in RFC 3339 format. Only entries created before the specified time
* will be included. UTC time zone.
*/
end?: string;
}
export declare namespace Accounts {
export {
type Account as Account,
type AccountSpendLimits as AccountSpendLimits,
type AccountsCursorPage as AccountsCursorPage,
type AccountUpdateParams as AccountUpdateParams,
type AccountListParams as AccountListParams,
};
}