forked from Modern-Treasury/modern-treasury-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulk-requests.ts
More file actions
2045 lines (1742 loc) · 63.4 KB
/
Copy pathbulk-requests.ts
File metadata and controls
2045 lines (1742 loc) · 63.4 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
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
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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 BulkRequestsAPI from './bulk-requests';
import * as ExpectedPaymentsAPI from './expected-payments';
import * as ExternalAccountsAPI from './external-accounts';
import * as Shared from './shared';
import * as PaymentOrdersAPI from './payment-orders/payment-orders';
import { Page, type PageParams } from '../pagination';
export class BulkRequests extends APIResource {
/**
* create bulk_request
*/
create(params: BulkRequestCreateParams, options?: Core.RequestOptions): Core.APIPromise<BulkRequest> {
// @ts-expect-error idempotency key header isn't defined anymore but is included here for back-compat
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
if (idempotencyKey) {
console.warn(
"The Idempotency-Key request param is deprecated, the 'idempotencyToken' option should be set instead",
);
}
return this._client.post('/api/bulk_requests', {
body,
...options,
headers: { 'Idempotency-Key': idempotencyKey, ...options?.headers },
});
}
/**
* get bulk_request
*/
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<BulkRequest> {
return this._client.get(`/api/bulk_requests/${id}`, options);
}
/**
* list bulk_requests
*/
list(
query?: BulkRequestListParams,
options?: Core.RequestOptions,
): Core.PagePromise<BulkRequestsPage, BulkRequest>;
list(options?: Core.RequestOptions): Core.PagePromise<BulkRequestsPage, BulkRequest>;
list(
query: BulkRequestListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<BulkRequestsPage, BulkRequest> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/api/bulk_requests', BulkRequestsPage, { query, ...options });
}
}
export class BulkRequestsPage extends Page<BulkRequest> {}
export interface BulkRequest {
id: string;
/**
* One of create, or update.
*/
action_type: 'create' | 'update';
created_at: string;
/**
* Total number of failed bulk results so far for this request
*/
failed_result_count: number;
/**
* This field will be true if this object exists in the live environment or false
* if it exists in the test environment.
*/
live_mode: boolean;
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata: Record<string, string>;
object: string;
/**
* One of payment_order, expected_payment, or ledger_transaction.
*/
resource_type: 'payment_order' | 'ledger_transaction' | 'transaction' | 'expected_payment';
/**
* One of pending, processing, or completed.
*/
status: 'pending' | 'processing' | 'completed';
/**
* Total number of successful bulk results so far for this request
*/
success_result_count: number;
/**
* Total number of items in the `resources` array. Once a bulk request is
* completed, `success_result_count` + `failed_result_count` will be equal to
* `total_result_count`.
*/
total_resource_count: number;
updated_at: string;
}
export interface BulkRequestCreateParams {
/**
* One of create, or update.
*/
action_type: 'create' | 'update';
/**
* One of payment_order, expected_payment, or ledger_transaction.
*/
resource_type: 'payment_order' | 'ledger_transaction' | 'transaction' | 'expected_payment';
/**
* An array of objects where each object contains the input params for a single
* `action_type` request on a `resource_type` resource
*/
resources: Array<
| BulkRequestCreateParams.PaymentOrderAsyncCreateRequest
| BulkRequestCreateParams.ExpectedPaymentCreateRequest
| BulkRequestCreateParams.LedgerTransactionCreateRequest
| BulkRequestCreateParams.TransactionCreateRequest
| BulkRequestCreateParams.ID
| BulkRequestCreateParams.PaymentOrderUpdateRequestWithID
| BulkRequestCreateParams.ExpectedPaymentUpdateRequestWithID
| BulkRequestCreateParams.TransactionUpdateRequestWithID
| BulkRequestCreateParams.LedgerTransactionUpdateRequestWithID
>;
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
}
export namespace BulkRequestCreateParams {
export interface PaymentOrderAsyncCreateRequest {
/**
* Value in specified currency's smallest unit. e.g. $10 would be represented as
* 1000 (cents). For RTP, the maximum amount allowed by the network is $100,000.
*/
amount: number;
/**
* One of `credit`, `debit`. Describes the direction money is flowing in the
* transaction. A `credit` moves money from your account to someone else's. A
* `debit` pulls money from someone else's account to your own. Note that wire,
* rtp, and check payments will always be `credit`.
*/
direction: 'credit' | 'debit';
/**
* The ID of one of your organization's internal accounts.
*/
originating_account_id: string;
/**
* One of `ach`, `bankgirot`, `eft`, `wire`, `check`, `sen`, `book`, `rtp`, `sepa`,
* `bacs`, `au_becs`, `interac`, `neft`, `nics`, `nz_national_clearing_code`,
* `sic`, `signet`, `provexchange`, `zengin`.
*/
type: PaymentOrdersAPI.PaymentOrderType;
accounting?: PaymentOrderAsyncCreateRequest.Accounting;
/**
* @deprecated: The ID of one of your accounting categories. Note that these will
* only be accessible if your accounting system has been connected.
*/
accounting_category_id?: string | null;
/**
* @deprecated: The ID of one of your accounting ledger classes. Note that these
* will only be accessible if your accounting system has been connected.
*/
accounting_ledger_class_id?: string | null;
/**
* The party that will pay the fees for the payment order. Only applies to wire
* payment orders. Can be one of shared, sender, or receiver, which correspond
* respectively with the SWIFT 71A values `SHA`, `OUR`, `BEN`.
*/
charge_bearer?: 'shared' | 'sender' | 'receiver' | null;
/**
* Defaults to the currency of the originating account.
*/
currency?: Shared.Currency;
/**
* An optional description for internal use.
*/
description?: string | null;
/**
* Date transactions are to be posted to the participants' account. Defaults to the
* current business day or the next business day if the current day is a bank
* holiday or weekend. Format: yyyy-mm-dd.
*/
effective_date?: string;
/**
* RFP payments require an expires_at. This value must be past the effective_date.
*/
expires_at?: string | null;
/**
* A payment type to fallback to if the original type is not valid for the
* receiving account. Currently, this only supports falling back from RTP to ACH
* (type=rtp and fallback_type=ach)
*/
fallback_type?: 'ach';
/**
* If present, indicates a specific foreign exchange contract number that has been
* generated by your financial institution.
*/
foreign_exchange_contract?: string | null;
/**
* Indicates the type of FX transfer to initiate, can be either
* `variable_to_fixed`, `fixed_to_variable`, or `null` if the payment order
* currency matches the originating account currency.
*/
foreign_exchange_indicator?: 'fixed_to_variable' | 'variable_to_fixed' | null;
/**
* Specifies a ledger transaction object that will be created with the payment
* order. If the ledger transaction cannot be created, then the payment order
* creation will fail. The resulting ledger transaction will mirror the status of
* the payment order.
*/
ledger_transaction?: PaymentOrderAsyncCreateRequest.LedgerTransaction;
/**
* Either ledger_transaction or ledger_transaction_id can be provided. Only a
* pending ledger transaction can be attached upon payment order creation. Once the
* payment order is created, the status of the ledger transaction tracks the
* payment order automatically.
*/
ledger_transaction_id?: string;
/**
* An array of line items that must sum up to the amount of the payment order.
*/
line_items?: Array<PaymentOrderAsyncCreateRequest.LineItem>;
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
/**
* A boolean to determine if NSF Protection is enabled for this payment order. Note
* that this setting must also be turned on in your organization settings page.
*/
nsf_protected?: boolean;
/**
* If present, this will replace your default company name on receiver's bank
* statement. This field can only be used for ACH payments currently. For ACH, only
* the first 16 characters of this string will be used. Any additional characters
* will be truncated.
*/
originating_party_name?: string | null;
/**
* Either `normal` or `high`. For ACH and EFT payments, `high` represents a
* same-day ACH or EFT transfer, respectively. For check payments, `high` can mean
* an overnight check rather than standard mail.
*/
priority?: 'high' | 'normal';
/**
* If present, Modern Treasury will not process the payment until after this time.
* If `process_after` is past the cutoff for `effective_date`, `process_after` will
* take precedence and `effective_date` will automatically update to reflect the
* earliest possible sending date after `process_after`. Format is ISO8601
* timestamp.
*/
process_after?: string | null;
/**
* For `wire`, this is usually the purpose which is transmitted via the
* "InstrForDbtrAgt" field in the ISO20022 file. For `eft`, this field is the 3
* digit CPA Code that will be attached to the payment.
*/
purpose?: string | null;
/**
* Either `receiving_account` or `receiving_account_id` must be present. When using
* `receiving_account_id`, you may pass the id of an external account or an
* internal account.
*/
receiving_account?: PaymentOrderAsyncCreateRequest.ReceivingAccount;
/**
* Either `receiving_account` or `receiving_account_id` must be present. When using
* `receiving_account_id`, you may pass the id of an external account or an
* internal account.
*/
receiving_account_id?: string;
/**
* For `ach`, this field will be passed through on an addenda record. For `wire`
* payments the field will be passed through as the "Originator to Beneficiary
* Information", also known as OBI or Fedwire tag 6000.
*/
remittance_information?: string | null;
/**
* Send an email to the counterparty when the payment order is sent to the bank. If
* `null`, `send_remittance_advice` on the Counterparty is used.
*/
send_remittance_advice?: boolean | null;
/**
* An optional descriptor which will appear in the receiver's statement. For
* `check` payments this field will be used as the memo line. For `ach` the maximum
* length is 10 characters. Note that for ACH payments, the name on your bank
* account will be included automatically by the bank, so you can use the
* characters for other useful information. For `eft` the maximum length is 15
* characters.
*/
statement_descriptor?: string | null;
/**
* An additional layer of classification for the type of payment order you are
* doing. This field is only used for `ach` payment orders currently. For `ach`
* payment orders, the `subtype` represents the SEC code. We currently support
* `CCD`, `PPD`, `IAT`, `CTX`, `WEB`, `CIE`, and `TEL`.
*/
subtype?: PaymentOrdersAPI.PaymentOrderSubtype | null;
/**
* A flag that determines whether a payment order should go through transaction
* monitoring.
*/
transaction_monitoring_enabled?: boolean;
/**
* Identifier of the ultimate originator of the payment order.
*/
ultimate_originating_party_identifier?: string | null;
/**
* Name of the ultimate originator of the payment order.
*/
ultimate_originating_party_name?: string | null;
/**
* Identifier of the ultimate funds recipient.
*/
ultimate_receiving_party_identifier?: string | null;
/**
* Name of the ultimate funds recipient.
*/
ultimate_receiving_party_name?: string | null;
}
export namespace PaymentOrderAsyncCreateRequest {
export interface Accounting {
/**
* The ID of one of your accounting categories. Note that these will only be
* accessible if your accounting system has been connected.
*/
account_id?: string | null;
/**
* The ID of one of the class objects in your accounting system. Class objects
* track segments of your business independent of client or project. Note that
* these will only be accessible if your accounting system has been connected.
*/
class_id?: string | null;
}
/**
* Specifies a ledger transaction object that will be created with the payment
* order. If the ledger transaction cannot be created, then the payment order
* creation will fail. The resulting ledger transaction will mirror the status of
* the payment order.
*/
export interface LedgerTransaction {
/**
* An array of ledger entry objects.
*/
ledger_entries: Array<LedgerTransaction.LedgerEntry>;
/**
* An optional description for internal use.
*/
description?: string | null;
/**
* The timestamp (ISO8601 format) at which the ledger transaction happened for
* reporting purposes.
*/
effective_at?: string;
/**
* The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
* purposes.
*/
effective_date?: string;
/**
* A unique string to represent the ledger transaction. Only one pending or posted
* ledger transaction may have this ID in the ledger.
*/
external_id?: string;
/**
* If the ledger transaction can be reconciled to another object in Modern
* Treasury, the id will be populated here, otherwise null.
*/
ledgerable_id?: string;
/**
* If the ledger transaction can be reconciled to another object in Modern
* Treasury, the type will be populated here, otherwise null. This can be one of
* payment_order, incoming_payment_detail, expected_payment, return, paper_item, or
* reversal.
*/
ledgerable_type?:
| 'expected_payment'
| 'incoming_payment_detail'
| 'paper_item'
| 'payment_order'
| 'return'
| 'reversal';
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
/**
* To post a ledger transaction at creation, use `posted`.
*/
status?: 'archived' | 'pending' | 'posted';
}
export namespace LedgerTransaction {
export interface LedgerEntry {
/**
* Value in specified currency's smallest unit. e.g. $10 would be represented
* as 1000. Can be any integer up to 36 digits.
*/
amount: number;
/**
* One of `credit`, `debit`. Describes the direction money is flowing in the
* transaction. A `credit` moves money from your account to someone else's. A
* `debit` pulls money from someone else's account to your own. Note that wire,
* rtp, and check payments will always be `credit`.
*/
direction: Shared.TransactionDirection;
/**
* The ledger account that this ledger entry is associated with.
*/
ledger_account_id: string;
/**
* Use `gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the
* account’s available balance. If any of these conditions would be false after the
* transaction is created, the entire call will fail with error code 422.
*/
available_balance_amount?: Record<string, number> | null;
/**
* Lock version of the ledger account. This can be passed when creating a ledger
* transaction to only succeed if no ledger transactions have posted since the
* given version. See our post about Designing the Ledgers API with Optimistic
* Locking for more details.
*/
lock_version?: number | null;
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
/**
* Use `gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the
* account’s pending balance. If any of these conditions would be false after the
* transaction is created, the entire call will fail with error code 422.
*/
pending_balance_amount?: Record<string, number> | null;
/**
* Use `gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the
* account’s posted balance. If any of these conditions would be false after the
* transaction is created, the entire call will fail with error code 422.
*/
posted_balance_amount?: Record<string, number> | null;
/**
* If true, response will include the balance of the associated ledger account for
* the entry.
*/
show_resulting_ledger_account_balances?: boolean | null;
}
}
export interface LineItem {
/**
* Value in specified currency's smallest unit. e.g. $10 would be represented
* as 1000.
*/
amount: number;
/**
* The ID of one of your accounting categories. Note that these will only be
* accessible if your accounting system has been connected.
*/
accounting_category_id?: string | null;
/**
* A free-form description of the line item.
*/
description?: string | null;
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
}
/**
* Either `receiving_account` or `receiving_account_id` must be present. When using
* `receiving_account_id`, you may pass the id of an external account or an
* internal account.
*/
export interface ReceivingAccount {
account_details?: Array<ReceivingAccount.AccountDetail>;
/**
* Can be `checking`, `savings` or `other`.
*/
account_type?: ExternalAccountsAPI.ExternalAccountType;
contact_details?: Array<ReceivingAccount.ContactDetail>;
/**
* Specifies a ledger account object that will be created with the external
* account. The resulting ledger account is linked to the external account for
* auto-ledgering Payment objects. See
* https://docs.moderntreasury.com/docs/linking-to-other-modern-treasury-objects
* for more details.
*/
ledger_account?: ReceivingAccount.LedgerAccount;
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
/**
* A nickname for the external account. This is only for internal usage and won't
* affect any payments
*/
name?: string | null;
/**
* Required if receiving wire payments.
*/
party_address?: ReceivingAccount.PartyAddress;
party_identifier?: string;
/**
* If this value isn't provided, it will be inherited from the counterparty's name.
*/
party_name?: string;
/**
* Either `individual` or `business`.
*/
party_type?: 'business' | 'individual' | null;
/**
* If you've enabled the Modern Treasury + Plaid integration in your Plaid account,
* you can pass the processor token in this field.
*/
plaid_processor_token?: string;
routing_details?: Array<ReceivingAccount.RoutingDetail>;
}
export namespace ReceivingAccount {
export interface AccountDetail {
account_number: string;
account_number_type?:
| 'au_number'
| 'clabe'
| 'hk_number'
| 'iban'
| 'id_number'
| 'nz_number'
| 'other'
| 'pan'
| 'sg_number'
| 'wallet_address';
}
export interface ContactDetail {
contact_identifier?: string;
contact_identifier_type?: 'email' | 'phone_number' | 'website';
}
/**
* Specifies a ledger account object that will be created with the external
* account. The resulting ledger account is linked to the external account for
* auto-ledgering Payment objects. See
* https://docs.moderntreasury.com/docs/linking-to-other-modern-treasury-objects
* for more details.
*/
export interface LedgerAccount {
/**
* The currency of the ledger account.
*/
currency: string;
/**
* The id of the ledger that this account belongs to.
*/
ledger_id: string;
/**
* The name of the ledger account.
*/
name: string;
/**
* The normal balance of the ledger account.
*/
normal_balance: Shared.TransactionDirection;
/**
* The currency exponent of the ledger account.
*/
currency_exponent?: number | null;
/**
* The description of the ledger account.
*/
description?: string | null;
/**
* The array of ledger account category ids that this ledger account should be a
* child of.
*/
ledger_account_category_ids?: Array<string>;
/**
* If the ledger account links to another object in Modern Treasury, the id will be
* populated here, otherwise null.
*/
ledgerable_id?: string;
/**
* If the ledger account links to another object in Modern Treasury, the type will
* be populated here, otherwise null. The value is one of internal_account or
* external_account.
*/
ledgerable_type?: 'counterparty' | 'external_account' | 'internal_account' | 'virtual_account';
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
}
/**
* Required if receiving wire payments.
*/
export interface PartyAddress {
/**
* Country code conforms to [ISO 3166-1 alpha-2]
*/
country?: string | null;
line1?: string | null;
line2?: string | null;
/**
* Locality or City.
*/
locality?: string | null;
/**
* The postal code of the address.
*/
postal_code?: string | null;
/**
* Region or State.
*/
region?: string | null;
}
export interface RoutingDetail {
routing_number: string;
routing_number_type:
| 'aba'
| 'au_bsb'
| 'br_codigo'
| 'ca_cpa'
| 'chips'
| 'cnaps'
| 'dk_interbank_clearing_code'
| 'gb_sort_code'
| 'hk_interbank_clearing_code'
| 'hu_interbank_clearing_code'
| 'id_sknbi_code'
| 'in_ifsc'
| 'jp_zengin_code'
| 'my_branch_code'
| 'mx_bank_identifier'
| 'nz_national_clearing_code'
| 'pl_national_clearing_code'
| 'se_bankgiro_clearing_code'
| 'swift'
| 'za_national_clearing_code';
payment_type?:
| 'ach'
| 'au_becs'
| 'bacs'
| 'book'
| 'card'
| 'chats'
| 'check'
| 'cross_border'
| 'dk_nets'
| 'eft'
| 'hu_ics'
| 'interac'
| 'masav'
| 'mx_ccen'
| 'neft'
| 'nics'
| 'nz_becs'
| 'pl_elixir'
| 'provxchange'
| 'ro_sent'
| 'rtp'
| 'se_bankgirot'
| 'sen'
| 'sepa'
| 'sg_giro'
| 'sic'
| 'signet'
| 'sknbi'
| 'wire'
| 'zengin';
}
}
}
export interface ExpectedPaymentCreateRequest {
/**
* The lowest amount this expected payment may be equal to. Value in specified
* currency's smallest unit. e.g. $10 would be represented as 1000.
*/
amount_lower_bound: number;
/**
* The highest amount this expected payment may be equal to. Value in specified
* currency's smallest unit. e.g. $10 would be represented as 1000.
*/
amount_upper_bound: number;
/**
* One of credit or debit. When you are receiving money, use credit. When you are
* being charged, use debit.
*/
direction: Shared.TransactionDirection;
/**
* The ID of the Internal Account for the expected payment.
*/
internal_account_id: string;
/**
* The ID of the counterparty you expect for this payment.
*/
counterparty_id?: string | null;
/**
* Must conform to ISO 4217. Defaults to the currency of the internal account.
*/
currency?: Shared.Currency;
/**
* The earliest date the payment may come in. Format: yyyy-mm-dd
*/
date_lower_bound?: string | null;
/**
* The latest date the payment may come in. Format: yyyy-mm-dd
*/
date_upper_bound?: string | null;
/**
* An optional description for internal use.
*/
description?: string | null;
/**
* Specifies a ledger transaction object that will be created with the expected
* payment. If the ledger transaction cannot be created, then the expected payment
* creation will fail. The resulting ledger transaction will mirror the status of
* the expected payment.
*/
ledger_transaction?: ExpectedPaymentCreateRequest.LedgerTransaction;
/**
* Either ledger_transaction or ledger_transaction_id can be provided. Only a
* pending ledger transaction can be attached upon expected payment creation. Once
* the expected payment is created, the status of the ledger transaction tracks the
* expected payment automatically.
*/
ledger_transaction_id?: string;
line_items?: Array<ExpectedPaymentCreateRequest.LineItem>;
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
/**
* The reconciliation filters you have for this payment.
*/
reconciliation_filters?: unknown | null;
/**
* The reconciliation groups you have for this payment.
*/
reconciliation_groups?: unknown | null;
/**
* An array of reconciliation rule variables for this payment.
*/
reconciliation_rule_variables?: Array<Record<string, string>> | null;
/**
* For `ach`, this field will be passed through on an addenda record. For `wire`
* payments the field will be passed through as the "Originator to Beneficiary
* Information", also known as OBI or Fedwire tag 6000.
*/
remittance_information?: string | null;
/**
* The statement description you expect to see on the transaction. For ACH
* payments, this will be the full line item passed from the bank. For wire
* payments, this will be the OBI field on the wire. For check payments, this will
* be the memo field.
*/
statement_descriptor?: string | null;
/**
* One of: ach, au_becs, bacs, book, check, eft, interac, provxchange, rtp, sen,
* sepa, signet, wire.
*/
type?: ExpectedPaymentsAPI.ExpectedPaymentType | null;
}
export namespace ExpectedPaymentCreateRequest {
/**
* Specifies a ledger transaction object that will be created with the expected
* payment. If the ledger transaction cannot be created, then the expected payment
* creation will fail. The resulting ledger transaction will mirror the status of
* the expected payment.
*/
export interface LedgerTransaction {
/**
* An array of ledger entry objects.
*/
ledger_entries: Array<LedgerTransaction.LedgerEntry>;
/**
* An optional description for internal use.
*/
description?: string | null;
/**
* The timestamp (ISO8601 format) at which the ledger transaction happened for
* reporting purposes.
*/
effective_at?: string;
/**
* The date (YYYY-MM-DD) on which the ledger transaction happened for reporting
* purposes.
*/
effective_date?: string;
/**
* A unique string to represent the ledger transaction. Only one pending or posted
* ledger transaction may have this ID in the ledger.
*/
external_id?: string;
/**
* If the ledger transaction can be reconciled to another object in Modern
* Treasury, the id will be populated here, otherwise null.
*/
ledgerable_id?: string;
/**
* If the ledger transaction can be reconciled to another object in Modern
* Treasury, the type will be populated here, otherwise null. This can be one of
* payment_order, incoming_payment_detail, expected_payment, return, paper_item, or
* reversal.
*/
ledgerable_type?:
| 'expected_payment'
| 'incoming_payment_detail'
| 'paper_item'
| 'payment_order'
| 'return'
| 'reversal';
/**
* Additional data represented as key-value pairs. Both the key and value must be
* strings.
*/
metadata?: Record<string, string>;
/**
* To post a ledger transaction at creation, use `posted`.
*/
status?: 'archived' | 'pending' | 'posted';
}
export namespace LedgerTransaction {
export interface LedgerEntry {
/**
* Value in specified currency's smallest unit. e.g. $10 would be represented
* as 1000. Can be any integer up to 36 digits.
*/
amount: number;
/**
* One of `credit`, `debit`. Describes the direction money is flowing in the
* transaction. A `credit` moves money from your account to someone else's. A
* `debit` pulls money from someone else's account to your own. Note that wire,
* rtp, and check payments will always be `credit`.
*/
direction: Shared.TransactionDirection;
/**
* The ledger account that this ledger entry is associated with.
*/
ledger_account_id: string;
/**
* Use `gt` (>), `gte` (>=), `lt` (<), `lte` (<=), or `eq` (=) to lock on the
* account’s available balance. If any of these conditions would be false after the
* transaction is created, the entire call will fail with error code 422.
*/
available_balance_amount?: Record<string, number> | null;
/**
* Lock version of the ledger account. This can be passed when creating a ledger
* transaction to only succeed if no ledger transactions have posted since the
* given version. See our post about Designing the Ledgers API with Optimistic
* Locking for more details.
*/
lock_version?: number | null;
/**
* Additional data represented as key-value pairs. Both the key and value must be