-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpayments.ts
492 lines (407 loc) · 11.9 KB
/
payments.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
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../resource';
import { isRequestOptions } from '../core';
import * as Core from '../core';
import * as BalancesAPI from './balances';
import { CursorPage, type CursorPageParams } from '../pagination';
export class Payments extends APIResource {
/**
* Initiates a payment between a financial account and an external bank account.
*/
create(body: PaymentCreateParams, options?: Core.RequestOptions): Core.APIPromise<PaymentCreateResponse> {
return this._client.post('/v1/payments', { body, ...options });
}
/**
* Get the payment by token.
*/
retrieve(paymentToken: string, options?: Core.RequestOptions): Core.APIPromise<Payment> {
return this._client.get(`/v1/payments/${paymentToken}`, options);
}
/**
* List all the payments for the provided search criteria.
*/
list(
query?: PaymentListParams,
options?: Core.RequestOptions,
): Core.PagePromise<PaymentsCursorPage, Payment>;
list(options?: Core.RequestOptions): Core.PagePromise<PaymentsCursorPage, Payment>;
list(
query: PaymentListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<PaymentsCursorPage, Payment> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/v1/payments', PaymentsCursorPage, { query, ...options });
}
/**
* Retry an origination which has been returned.
*/
retry(paymentToken: string, options?: Core.RequestOptions): Core.APIPromise<PaymentRetryResponse> {
return this._client.post(`/v1/payments/${paymentToken}/retry`, options);
}
/**
* Simulate payment lifecycle event
*/
simulateAction(
paymentToken: string,
body: PaymentSimulateActionParams,
options?: Core.RequestOptions,
): Core.APIPromise<PaymentSimulateActionResponse> {
return this._client.post(`/v1/simulate/payments/${paymentToken}/action`, { body, ...options });
}
/**
* Simulates a receipt of a Payment.
*/
simulateReceipt(
body: PaymentSimulateReceiptParams,
options?: Core.RequestOptions,
): Core.APIPromise<PaymentSimulateReceiptResponse> {
return this._client.post('/v1/simulate/payments/receipt', { body, ...options });
}
/**
* Simulates a release of a Payment.
*/
simulateRelease(
body: PaymentSimulateReleaseParams,
options?: Core.RequestOptions,
): Core.APIPromise<PaymentSimulateReleaseResponse> {
return this._client.post('/v1/simulate/payments/release', { body, ...options });
}
/**
* Simulates a return of a Payment.
*/
simulateReturn(
body: PaymentSimulateReturnParams,
options?: Core.RequestOptions,
): Core.APIPromise<PaymentSimulateReturnResponse> {
return this._client.post('/v1/simulate/payments/return', { body, ...options });
}
}
export class PaymentsCursorPage extends CursorPage<Payment> {}
export interface Payment {
/**
* Globally unique identifier.
*/
token: string;
/**
* Payment category
*/
category: 'ACH';
/**
* Date and time when the payment first occurred. UTC time zone.
*/
created: string;
/**
* 3-digit alphabetic ISO 4217 code for the settling currency of the payment.
*/
currency: string;
/**
* A string that provides a description of the payment; may be useful to display to
* users.
*/
descriptor: string;
direction: 'CREDIT' | 'DEBIT';
/**
* A list of all payment events that have modified this payment.
*/
events: Array<Payment.Event>;
external_bank_account_token: string | null;
financial_account_token: string;
method: 'ACH_NEXT_DAY' | 'ACH_SAME_DAY';
method_attributes: Payment.MethodAttributes;
/**
* Pending amount of the payment in the currency's smallest unit (e.g., cents). The
* value of this field will go to zero over time once the payment is settled.
*/
pending_amount: number;
/**
* APPROVED payments were successful while DECLINED payments were declined by
* Lithic or returned.
*/
result: 'APPROVED' | 'DECLINED';
/**
* Amount of the payment that has been settled in the currency's smallest unit
* (e.g., cents).
*/
settled_amount: number;
source: 'CUSTOMER' | 'LITHIC';
/**
* Status types:
*
* - `DECLINED` - The payment was declined.
* - `PENDING` - The payment is being processed and has yet to settle or release
* (origination debit).
* - `RETURNED` - The payment has been returned.
* - `SETTLED` - The payment is completed.
*/
status: 'DECLINED' | 'PENDING' | 'RETURNED' | 'SETTLED';
/**
* Date and time when the financial transaction was last updated. UTC time zone.
*/
updated: string;
user_defined_id: string | null;
}
export namespace Payment {
export interface Event {
/**
* Globally unique identifier.
*/
token: string;
/**
* Amount of the financial event that has been settled in the currency's smallest
* unit (e.g., cents).
*/
amount: number;
/**
* Date and time when the financial event occurred. UTC time zone.
*/
created: string;
/**
* APPROVED financial events were successful while DECLINED financial events were
* declined by user, Lithic, or the network.
*/
result: 'APPROVED' | 'DECLINED';
/**
* Event types:
*
* - `ACH_ORIGINATION_INITIATED` - ACH origination received and pending
* approval/release from an ACH hold.
* - `ACH_ORIGINATION_REVIEWED` - ACH origination has completed the review process.
* - `ACH_ORIGINATION_CANCELLED` - ACH origination has been cancelled.
* - `ACH_ORIGINATION_PROCESSED` - ACH origination has been processed and sent to
* the fed.
* - `ACH_ORIGINATION_SETTLED` - ACH origination has settled.
* - `ACH_ORIGINATION_RELEASED` - ACH origination released from pending to
* available balance.
* - `ACH_RETURN_PROCESSED` - ACH origination returned by the Receiving Depository
* Financial Institution.
* - `ACH_RECEIPT_PROCESSED` - ACH receipt pending release from an ACH holder.
* - `ACH_RETURN_INITIATED` - ACH initiated return for a ACH receipt.
* - `ACH_RECEIPT_SETTLED` - ACH receipt funds have settled.
* - `ACH_RECEIPT_RELEASED` - ACH receipt released from pending to available
* balance.
* - `ACH_RETURN_SETTLED` - ACH receipt return settled by the Receiving Depository
* Financial Institution.
*/
type:
| 'ACH_ORIGINATION_CANCELLED'
| 'ACH_ORIGINATION_INITIATED'
| 'ACH_ORIGINATION_PROCESSED'
| 'ACH_ORIGINATION_SETTLED'
| 'ACH_ORIGINATION_RELEASED'
| 'ACH_ORIGINATION_REVIEWED'
| 'ACH_RECEIPT_PROCESSED'
| 'ACH_RECEIPT_SETTLED'
| 'ACH_RETURN_INITIATED'
| 'ACH_RETURN_PROCESSED'
| 'ACH_RETURN_SETTLED';
/**
* More detailed reasons for the event
*/
detailed_results?: Array<
| 'APPROVED'
| 'FUNDS_INSUFFICIENT'
| 'ACCOUNT_INVALID'
| 'PROGRAM_TRANSACTION_LIMIT_EXCEEDED'
| 'PROGRAM_DAILY_LIMIT_EXCEEDED'
| 'PROGRAM_MONTHLY_LIMIT_EXCEEDED'
>;
}
export interface MethodAttributes {
company_id: string | null;
receipt_routing_number: string | null;
retries: number | null;
return_reason_code: string | null;
sec_code: 'CCD' | 'PPD' | 'WEB';
trace_numbers: Array<string | null>;
}
}
export interface PaymentCreateResponse extends Payment {
/**
* Balance
*/
balance?: BalancesAPI.Balance;
}
export interface PaymentRetryResponse extends Payment {
/**
* Balance
*/
balance?: BalancesAPI.Balance;
}
export interface PaymentSimulateActionResponse {
/**
* Debugging Request Id
*/
debugging_request_id: string;
/**
* Request Result
*/
result: 'APPROVED' | 'DECLINED';
/**
* Transaction Event Token
*/
transaction_event_token: string;
}
export interface PaymentSimulateReceiptResponse {
/**
* Debugging Request Id
*/
debugging_request_id: string;
/**
* Request Result
*/
result: 'APPROVED' | 'DECLINED';
/**
* Transaction Event Token
*/
transaction_event_token: string;
}
export interface PaymentSimulateReleaseResponse {
/**
* Debugging Request Id
*/
debugging_request_id: string;
/**
* Request Result
*/
result: 'APPROVED' | 'DECLINED';
/**
* Transaction Event Token
*/
transaction_event_token: string;
}
export interface PaymentSimulateReturnResponse {
/**
* Debugging Request Id
*/
debugging_request_id: string;
/**
* Request Result
*/
result: 'APPROVED' | 'DECLINED';
/**
* Transaction Event Token
*/
transaction_event_token: string;
}
export interface PaymentCreateParams {
amount: number;
external_bank_account_token: string;
financial_account_token: string;
method: 'ACH_NEXT_DAY' | 'ACH_SAME_DAY';
method_attributes: PaymentCreateParams.MethodAttributes;
type: 'COLLECTION' | 'PAYMENT';
/**
* Customer-provided token that will serve as an idempotency token. This token will
* become the transaction token.
*/
token?: string;
memo?: string;
user_defined_id?: string;
}
export namespace PaymentCreateParams {
export interface MethodAttributes {
sec_code: 'CCD' | 'PPD' | 'WEB';
}
}
export interface PaymentListParams extends CursorPageParams {
account_token?: string;
/**
* Date string in RFC 3339 format. Only entries created after the specified time
* will be included. UTC time zone.
*/
begin?: string;
business_account_token?: string;
category?: 'ACH';
/**
* Date string in RFC 3339 format. Only entries created before the specified time
* will be included. UTC time zone.
*/
end?: string;
financial_account_token?: string;
result?: 'APPROVED' | 'DECLINED';
status?: 'DECLINED' | 'PENDING' | 'RETURNED' | 'SETTLED';
}
export interface PaymentSimulateActionParams {
/**
* Event Type
*/
event_type:
| 'ACH_ORIGINATION_REVIEWED'
| 'ACH_ORIGINATION_RELEASED'
| 'ACH_ORIGINATION_PROCESSED'
| 'ACH_ORIGINATION_SETTLED'
| 'ACH_RECEIPT_SETTLED'
| 'ACH_RETURN_INITIATED'
| 'ACH_RETURN_PROCESSED'
| 'ACH_RETURN_SETTLED';
/**
* Decline reason
*/
decline_reason?:
| 'PROGRAM_TRANSACTION_LIMIT_EXCEEDED'
| 'PROGRAM_DAILY_LIMIT_EXCEEDED'
| 'PROGRAM_MONTHLY_LIMIT_EXCEEDED';
/**
* Return Reason Code
*/
return_reason_code?: string;
}
export interface PaymentSimulateReceiptParams {
/**
* Payment token
*/
token: string;
/**
* Amount
*/
amount: number;
/**
* Financial Account Token
*/
financial_account_token: string;
/**
* Receipt Type
*/
receipt_type: 'RECEIPT_CREDIT' | 'RECEIPT_DEBIT';
/**
* Memo
*/
memo?: string;
}
export interface PaymentSimulateReleaseParams {
/**
* Payment Token
*/
payment_token: string;
}
export interface PaymentSimulateReturnParams {
/**
* Payment Token
*/
payment_token: string;
/**
* Return Reason Code
*/
return_reason_code?: string;
}
Payments.PaymentsCursorPage = PaymentsCursorPage;
export declare namespace Payments {
export {
type Payment as Payment,
type PaymentCreateResponse as PaymentCreateResponse,
type PaymentRetryResponse as PaymentRetryResponse,
type PaymentSimulateActionResponse as PaymentSimulateActionResponse,
type PaymentSimulateReceiptResponse as PaymentSimulateReceiptResponse,
type PaymentSimulateReleaseResponse as PaymentSimulateReleaseResponse,
type PaymentSimulateReturnResponse as PaymentSimulateReturnResponse,
PaymentsCursorPage as PaymentsCursorPage,
type PaymentCreateParams as PaymentCreateParams,
type PaymentListParams as PaymentListParams,
type PaymentSimulateActionParams as PaymentSimulateActionParams,
type PaymentSimulateReceiptParams as PaymentSimulateReceiptParams,
type PaymentSimulateReleaseParams as PaymentSimulateReleaseParams,
type PaymentSimulateReturnParams as PaymentSimulateReturnParams,
};
}