@lucianpacurar/iso20022.js 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +212 -0
- package/dist/index.d.ts +1896 -0
- package/dist/index.js +10039 -0
- package/dist/index.mjs +10023 -0
- package/dist/src/camt/003/cash-management-get-account.d.ts +26 -0
- package/dist/src/camt/004/cash-management-return-account.d.ts +30 -0
- package/dist/src/camt/005/cash-management-get-transaction.d.ts +26 -0
- package/dist/src/camt/006/cash-management-return-transaction.d.ts +43 -0
- package/dist/src/camt/053/cash-management-end-of-day-report.d.ts +90 -0
- package/dist/src/camt/index.d.ts +5 -0
- package/dist/src/camt/types.d.ts +191 -0
- package/dist/src/camt/utils.d.ts +12 -0
- package/dist/src/errors.d.ts +24 -0
- package/dist/src/index.d.ts +61 -0
- package/dist/src/iso20022.d.ts +375 -0
- package/dist/src/lib/countries.d.ts +254 -0
- package/dist/src/lib/currencies.d.ts +1 -0
- package/dist/src/lib/index.d.ts +4 -0
- package/dist/src/lib/interfaces.d.ts +30 -0
- package/dist/src/lib/types.d.ts +376 -0
- package/dist/src/pain/001/ach-credit-payment-initiation.d.ts +159 -0
- package/dist/src/pain/001/payment-initiation.d.ts +105 -0
- package/dist/src/pain/001/rtp-credit-payment-initiation.d.ts +118 -0
- package/dist/src/pain/001/sepa-credit-payment-initiation.d.ts +126 -0
- package/dist/src/pain/001/swift-credit-payment-initiation.d.ts +72 -0
- package/dist/src/pain/002/payment-status-report.d.ts +75 -0
- package/dist/src/pain/002/types.d.ts +73 -0
- package/dist/src/pain/002/utils.d.ts +4 -0
- package/dist/src/parseUtils.d.ts +21 -0
- package/dist/src/utils/format.d.ts +1 -0
- package/dist/test/camt/003/cash-management-get-account.test.d.ts +1 -0
- package/dist/test/camt/004/cash-management-return-account.test.d.ts +1 -0
- package/dist/test/camt/005/cash-management-get-transaction.test.d.ts +1 -0
- package/dist/test/camt/006/cash-management-return-transaction.test.d.ts +1 -0
- package/dist/test/camt/053/cash-management-end-of-day-report.test.d.ts +1 -0
- package/dist/test/pain/001/ach-credit-payment-initiation.test.d.ts +1 -0
- package/dist/test/pain/001/rtp-credit-payment-initiation.test.d.ts +1 -0
- package/dist/test/pain/001/sepa-credit-payment-initiation.test.d.ts +1 -0
- package/dist/test/pain/001/swift-credit-payment-initiation.test.d.ts +1 -0
- package/dist/test/pain/002/payment-status-report.test.d.ts +1 -0
- package/dist/test/parseUtils.test.d.ts +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { Currency } from 'dinero.js';
|
|
2
|
+
import { Alpha2Country } from './countries';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a payment instruction with essential details.
|
|
5
|
+
*/
|
|
6
|
+
export interface PaymentInstruction {
|
|
7
|
+
/** Unique identifier for the payment instruction. */
|
|
8
|
+
id?: string;
|
|
9
|
+
/** Unique end-to-end identifier for the payment. */
|
|
10
|
+
endToEndId?: string;
|
|
11
|
+
/** Indicates whether the payment is a credit or debit. */
|
|
12
|
+
direction?: 'credit' | 'debit';
|
|
13
|
+
/** The amount of the payment. Usually in cents. */
|
|
14
|
+
amount: number;
|
|
15
|
+
/** The currency of the payment. */
|
|
16
|
+
currency: Currency;
|
|
17
|
+
/** The party from which the payment is debited. */
|
|
18
|
+
debtor?: Party;
|
|
19
|
+
/** The party to which the payment is credited. */
|
|
20
|
+
creditor?: Party;
|
|
21
|
+
/** Additional information about the payment. */
|
|
22
|
+
remittanceInformation?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents a credit payment instruction, extending the base PaymentInstruction.
|
|
26
|
+
*/
|
|
27
|
+
export interface CreditPaymentInstruction extends PaymentInstruction {
|
|
28
|
+
direction?: 'credit';
|
|
29
|
+
creditor: Party;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Represents a SWIFT credit payment instruction, extending the base PaymentInstruction.
|
|
33
|
+
*/
|
|
34
|
+
export interface SWIFTCreditPaymentInstruction extends CreditPaymentInstruction {
|
|
35
|
+
/** Specifies that this is a SWIFT payment. */
|
|
36
|
+
type?: 'swift';
|
|
37
|
+
}
|
|
38
|
+
export interface SEPACreditPaymentInstruction extends CreditPaymentInstruction {
|
|
39
|
+
type?: 'sepa';
|
|
40
|
+
currency: 'EUR';
|
|
41
|
+
}
|
|
42
|
+
export interface RTPCreditPaymentInstruction extends CreditPaymentInstruction {
|
|
43
|
+
type?: 'rtp';
|
|
44
|
+
currency: 'USD';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Represents an ACH credit payment instruction, extending the base PaymentInstruction.
|
|
48
|
+
*/
|
|
49
|
+
export interface ACHCreditPaymentInstruction extends CreditPaymentInstruction {
|
|
50
|
+
/** Specifies that this is an ACH payment. */
|
|
51
|
+
type?: 'ach';
|
|
52
|
+
/** ACH payments must use USD as currency. */
|
|
53
|
+
currency: 'USD';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Category purpose codes as defined in ISO 20022 ExternalCategoryPurpose1Code.
|
|
57
|
+
* @see {@link https://www.iso20022.org/catalogue-messages/additional-content-messages/external-code-sets}
|
|
58
|
+
*/
|
|
59
|
+
export declare const ExternalCategoryPurposeCode: {
|
|
60
|
+
/** Transaction is the payment of a bonus */
|
|
61
|
+
readonly Bonus: "BONU";
|
|
62
|
+
/** Transaction is a general cash management instruction */
|
|
63
|
+
readonly CashManagement: "CASH";
|
|
64
|
+
/** A service that is settling money for a bulk of card transactions */
|
|
65
|
+
readonly CardBulk: "CBLK";
|
|
66
|
+
/** Transaction is related to a payment of credit card */
|
|
67
|
+
readonly CreditCard: "CCRD";
|
|
68
|
+
/** Transaction is related to settlement of a trade */
|
|
69
|
+
readonly TradeSettlement: "CORT";
|
|
70
|
+
/** Transaction is related to a payment of debit card */
|
|
71
|
+
readonly DebitCard: "DCRD";
|
|
72
|
+
/** Transaction is the payment of dividends */
|
|
73
|
+
readonly Dividends: "DIVI";
|
|
74
|
+
/** Code used to pre-advise forthcoming deliver against payment instruction */
|
|
75
|
+
readonly DeliverAgainstPayment: "DVPM";
|
|
76
|
+
/** Transaction is related to ePayment */
|
|
77
|
+
readonly EPayment: "EPAY";
|
|
78
|
+
/** Transaction is related to the payment of a fee and interest */
|
|
79
|
+
readonly FeeAndInterest: "FCIN";
|
|
80
|
+
/** A service that is settling card transaction related fees between two parties */
|
|
81
|
+
readonly CardFeeSettlement: "FCOL";
|
|
82
|
+
/** General Person-to-Person Payment */
|
|
83
|
+
readonly GeneralP2P: "GP2P";
|
|
84
|
+
/** Transaction is a payment to or from a government department */
|
|
85
|
+
readonly Government: "GOVT";
|
|
86
|
+
/** Transaction is related to the payment of a hedging operation */
|
|
87
|
+
readonly Hedging: "HEDG";
|
|
88
|
+
/** Transaction is reimbursement of credit card payment */
|
|
89
|
+
readonly CreditCardReimbursement: "ICCP";
|
|
90
|
+
/** Transaction is reimbursement of debit card payment */
|
|
91
|
+
readonly DebitCardReimbursement: "IDCP";
|
|
92
|
+
/** Transaction is an intra-company payment */
|
|
93
|
+
readonly IntraCompany: "INTC";
|
|
94
|
+
/** Transaction is the payment of interest */
|
|
95
|
+
readonly Interest: "INTE";
|
|
96
|
+
/** Transaction is related to identify cash handling via Night Safe or Lockbox */
|
|
97
|
+
readonly Lockbox: "LBOX";
|
|
98
|
+
/** Transaction is related to the transfer of a loan to a borrower */
|
|
99
|
+
readonly Loan: "LOAN";
|
|
100
|
+
/** Mobile P2B Payment */
|
|
101
|
+
readonly MobileP2B: "MP2B";
|
|
102
|
+
/** Mobile P2P Payment */
|
|
103
|
+
readonly MobileP2P: "MP2P";
|
|
104
|
+
/** Other payment purpose */
|
|
105
|
+
readonly Other: "OTHR";
|
|
106
|
+
/** Transaction is the payment of pension */
|
|
107
|
+
readonly Pension: "PENS";
|
|
108
|
+
/** Collection used to re-present previously reversed or returned direct debit transactions */
|
|
109
|
+
readonly Represent: "RPRE";
|
|
110
|
+
/** Transaction is related to a reimbursement for commercial reasons */
|
|
111
|
+
readonly CommercialReimbursement: "RRCT";
|
|
112
|
+
/** Code used to pre-advise forthcoming receive against payment instruction */
|
|
113
|
+
readonly ReceiveAgainstPayment: "RVPM";
|
|
114
|
+
/** Transaction is the payment of salaries */
|
|
115
|
+
readonly Salary: "SALA";
|
|
116
|
+
/** Transaction is the payment of securities */
|
|
117
|
+
readonly Securities: "SECU";
|
|
118
|
+
/** Transaction is a social security benefit */
|
|
119
|
+
readonly SocialSecurityBenefit: "SSBE";
|
|
120
|
+
/** Transaction is related to a payment to a supplier */
|
|
121
|
+
readonly Supplier: "SUPP";
|
|
122
|
+
/** Transaction is the payment of taxes */
|
|
123
|
+
readonly Taxes: "TAXS";
|
|
124
|
+
/** Transaction is related to the payment of a trade finance transaction */
|
|
125
|
+
readonly Trade: "TRAD";
|
|
126
|
+
/** Transaction is related to treasury operations */
|
|
127
|
+
readonly Treasury: "TREA";
|
|
128
|
+
/** Transaction is the payment of value added tax */
|
|
129
|
+
readonly VAT: "VATX";
|
|
130
|
+
/** Transaction is the payment of withholding tax */
|
|
131
|
+
readonly WithholdingTax: "WHLD";
|
|
132
|
+
/** Transaction relates to a cash management sweep instruction */
|
|
133
|
+
readonly Sweep: "SWEP";
|
|
134
|
+
/** Transaction relates to a cash management top-up instruction */
|
|
135
|
+
readonly TopUp: "TOPG";
|
|
136
|
+
/** Transaction relates to a zero balance account instruction */
|
|
137
|
+
readonly ZeroBalance: "ZABA";
|
|
138
|
+
/** Transaction to be processed as a domestic payment instruction from foreign bank */
|
|
139
|
+
readonly DomesticFromForeign: "VOST";
|
|
140
|
+
/** Foreign Currency Transaction between domestic financial institutions */
|
|
141
|
+
readonly ForeignCurrencyDomestic: "FCDT";
|
|
142
|
+
/** Transaction is a direct debit for a cash order of notes and/or coins */
|
|
143
|
+
readonly CashOrder: "CIPC";
|
|
144
|
+
/** Transaction is a direct debit for a cash order of notes and/or coins */
|
|
145
|
+
readonly CashOrderConsolidated: "CONC";
|
|
146
|
+
/** Transaction is a payment for cash collection by Cash in Transit company */
|
|
147
|
+
readonly CashInTransit: "CGWV";
|
|
148
|
+
/** Transfer to/from savings or retirement account */
|
|
149
|
+
readonly Savings: "SAVG";
|
|
150
|
+
/** Cross border transaction subject to Dodd Frank 1073 */
|
|
151
|
+
readonly CrossBorderDoddFrank: "CTDF";
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Description mapping of ExternalCategoryPurposeCode values to their names.
|
|
155
|
+
*/
|
|
156
|
+
export declare const ExternalCategoryPurposeCodeDescriptionMap: {
|
|
157
|
+
readonly BONU: "Bonus Payment";
|
|
158
|
+
readonly CASH: "Cash Management";
|
|
159
|
+
readonly CBLK: "Card Bulk Settlement";
|
|
160
|
+
readonly CCRD: "Credit Card Payment";
|
|
161
|
+
readonly CORT: "Trade Settlement";
|
|
162
|
+
readonly DCRD: "Debit Card Payment";
|
|
163
|
+
readonly DIVI: "Dividends";
|
|
164
|
+
readonly DVPM: "Deliver Against Payment";
|
|
165
|
+
readonly EPAY: "Electronic Payment";
|
|
166
|
+
readonly FCIN: "Fee and Interest";
|
|
167
|
+
readonly FCOL: "Card Fee Settlement";
|
|
168
|
+
readonly GP2P: "General Person-to-Person";
|
|
169
|
+
readonly GOVT: "Government Payment";
|
|
170
|
+
readonly HEDG: "Hedging Operation";
|
|
171
|
+
readonly ICCP: "Credit Card Reimbursement";
|
|
172
|
+
readonly IDCP: "Debit Card Reimbursement";
|
|
173
|
+
readonly INTC: "Intra-Company Payment";
|
|
174
|
+
readonly INTE: "Interest Payment";
|
|
175
|
+
readonly LBOX: "Lockbox";
|
|
176
|
+
readonly LOAN: "Loan Transfer";
|
|
177
|
+
readonly MP2B: "Mobile Person-to-Business";
|
|
178
|
+
readonly MP2P: "Mobile Person-to-Person";
|
|
179
|
+
readonly OTHR: "Other";
|
|
180
|
+
readonly PENS: "Pension Payment";
|
|
181
|
+
readonly RPRE: "Re-Present Transaction";
|
|
182
|
+
readonly RRCT: "Commercial Reimbursement";
|
|
183
|
+
readonly RVPM: "Receive Against Payment";
|
|
184
|
+
readonly SALA: "Salary Payment";
|
|
185
|
+
readonly SECU: "Securities Payment";
|
|
186
|
+
readonly SSBE: "Social Security Benefit";
|
|
187
|
+
readonly SUPP: "Supplier Payment";
|
|
188
|
+
readonly TAXS: "Tax Payment";
|
|
189
|
+
readonly TRAD: "Trade Finance";
|
|
190
|
+
readonly TREA: "Treasury Operation";
|
|
191
|
+
readonly VATX: "Value Added Tax";
|
|
192
|
+
readonly WHLD: "Withholding Tax";
|
|
193
|
+
readonly SWEP: "Sweep Instruction";
|
|
194
|
+
readonly TOPG: "Top-up Instruction";
|
|
195
|
+
readonly ZABA: "Zero Balance";
|
|
196
|
+
readonly VOST: "Domestic from Foreign";
|
|
197
|
+
readonly FCDT: "Foreign Currency Domestic";
|
|
198
|
+
readonly CIPC: "Cash Order";
|
|
199
|
+
readonly CONC: "Cash Order Consolidated";
|
|
200
|
+
readonly CGWV: "Cash in Transit";
|
|
201
|
+
readonly SAVG: "Savings Transfer";
|
|
202
|
+
readonly CTDF: "Cross Border Dodd Frank";
|
|
203
|
+
};
|
|
204
|
+
export type ExternalCategoryPurpose = (typeof ExternalCategoryPurposeCode)[keyof typeof ExternalCategoryPurposeCode];
|
|
205
|
+
/**
|
|
206
|
+
* Represents a structured address format.
|
|
207
|
+
*/
|
|
208
|
+
export interface StructuredAddress {
|
|
209
|
+
/** The name of the street. */
|
|
210
|
+
streetName?: string;
|
|
211
|
+
/** The building number on the street. */
|
|
212
|
+
buildingNumber?: string;
|
|
213
|
+
/** The name of the town or city. */
|
|
214
|
+
townName?: string;
|
|
215
|
+
/** The subdivision of the country (e.g., state, province). */
|
|
216
|
+
countrySubDivision?: string;
|
|
217
|
+
/** The postal or ZIP code. */
|
|
218
|
+
postalCode?: string;
|
|
219
|
+
/** The country, typically represented by a country code. */
|
|
220
|
+
country?: Alpha2Country;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Represents a party involved in a payment transaction.
|
|
224
|
+
*/
|
|
225
|
+
export interface Party {
|
|
226
|
+
/** Unique identifier for the party. */
|
|
227
|
+
id?: string;
|
|
228
|
+
/** The name of the party. */
|
|
229
|
+
name?: string;
|
|
230
|
+
/** The structured address of the party. */
|
|
231
|
+
address?: StructuredAddress;
|
|
232
|
+
/** The account details of the party. */
|
|
233
|
+
account?: Account;
|
|
234
|
+
/** The financial agent (e.g., bank) of the party. */
|
|
235
|
+
agent?: Agent;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Represents an account identified by IBAN.
|
|
239
|
+
*/
|
|
240
|
+
export interface IBANAccount {
|
|
241
|
+
/** The International Bank Account Number. */
|
|
242
|
+
iban: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Represents a basic account with account number and optional type.
|
|
246
|
+
*/
|
|
247
|
+
export interface BaseAccount {
|
|
248
|
+
/** The account number. */
|
|
249
|
+
accountNumber: string;
|
|
250
|
+
/** The type of the account. */
|
|
251
|
+
accountType?: 'checking' | 'savings';
|
|
252
|
+
/** The currency of the account. */
|
|
253
|
+
currency?: Currency;
|
|
254
|
+
/** The name of the account. */
|
|
255
|
+
name?: string;
|
|
256
|
+
}
|
|
257
|
+
export type AccountIdentification = AccountIdentificationIBAN | AccountIdentificationOther;
|
|
258
|
+
export interface AccountIdentificationIBAN {
|
|
259
|
+
iban: string;
|
|
260
|
+
}
|
|
261
|
+
export interface AccountIdentificationOther {
|
|
262
|
+
id: string;
|
|
263
|
+
schemeName?: string;
|
|
264
|
+
issuer?: string;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Represents either an IBAN account or a basic account.
|
|
268
|
+
*/
|
|
269
|
+
export type Account = IBANAccount | BaseAccount;
|
|
270
|
+
/**
|
|
271
|
+
* Represents a financial agent identified by BIC.
|
|
272
|
+
*/
|
|
273
|
+
export interface BICAgent {
|
|
274
|
+
/** The Bank Identifier Code. */
|
|
275
|
+
bic: string;
|
|
276
|
+
/** The structured address of the bank. */
|
|
277
|
+
bankAddress?: StructuredAddress;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Represents a financial agent identified by ABA routing number.
|
|
281
|
+
*/
|
|
282
|
+
export interface ABAAgent {
|
|
283
|
+
/** The ABA routing number. */
|
|
284
|
+
abaRoutingNumber: string;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Represents either a BIC or ABA identified financial agent.
|
|
288
|
+
* NOTE: Sometimes an agent can include both a BIC and ABA routing number.
|
|
289
|
+
* This library does not support that yet, but we will need to.
|
|
290
|
+
*/
|
|
291
|
+
export type Agent = BICAgent | ABAAgent;
|
|
292
|
+
/**
|
|
293
|
+
* ACH Local Instrument Codes as defined in NACHA standards.
|
|
294
|
+
* These codes identify the specific type of ACH transaction.
|
|
295
|
+
*/
|
|
296
|
+
export declare const ACHLocalInstrumentCode: {
|
|
297
|
+
/** Corporate Credit or Debit */
|
|
298
|
+
readonly CorporateCreditDebit: "CCD";
|
|
299
|
+
/** Prearranged Payment and Deposit */
|
|
300
|
+
readonly PrearrangedPaymentDeposit: "PPD";
|
|
301
|
+
/** Internet-Initiated Entry */
|
|
302
|
+
readonly InternetInitiated: "WEB";
|
|
303
|
+
/** Telephone-Initiated Entry */
|
|
304
|
+
readonly TelephoneInitiated: "TEL";
|
|
305
|
+
/** Point-of-Purchase Entry */
|
|
306
|
+
readonly PointOfPurchase: "POP";
|
|
307
|
+
/** Accounts Receivable Entry */
|
|
308
|
+
readonly AccountsReceivable: "ARC";
|
|
309
|
+
/** Back Office Conversion */
|
|
310
|
+
readonly BackOfficeConversion: "BOC";
|
|
311
|
+
/** Represented Check Entry */
|
|
312
|
+
readonly RepresentedCheck: "RCK";
|
|
313
|
+
};
|
|
314
|
+
export type ACHLocalInstrument = (typeof ACHLocalInstrumentCode)[keyof typeof ACHLocalInstrumentCode];
|
|
315
|
+
export declare const ACHLocalInstrumentCodeDescriptionMap: {
|
|
316
|
+
readonly CCD: "Corporate Credit or Debit";
|
|
317
|
+
readonly PPD: "Prearranged Payment and Deposit";
|
|
318
|
+
readonly WEB: "Internet-Initiated Entry";
|
|
319
|
+
readonly TEL: "Telephone-Initiated Entry";
|
|
320
|
+
readonly POP: "Point-of-Purchase Entry";
|
|
321
|
+
readonly ARC: "Accounts Receivable Entry";
|
|
322
|
+
readonly BOC: "Back Office Conversion";
|
|
323
|
+
readonly RCK: "Represented Check Entry";
|
|
324
|
+
};
|
|
325
|
+
export interface MessageHeader {
|
|
326
|
+
id: string;
|
|
327
|
+
creationDateTime?: Date;
|
|
328
|
+
originalMessageHeader?: Partial<MessageHeader>;
|
|
329
|
+
requestType?: string;
|
|
330
|
+
queryName?: string;
|
|
331
|
+
}
|
|
332
|
+
export declare const CashAccountTypeCode: {
|
|
333
|
+
readonly Current: "CACC";
|
|
334
|
+
readonly CashPayment: "CASH";
|
|
335
|
+
readonly Charges: "CHAR";
|
|
336
|
+
readonly CashIncome: "CISH";
|
|
337
|
+
readonly Commission: "COMM";
|
|
338
|
+
readonly ClearingParticipantSettlementAccount: "CPAC";
|
|
339
|
+
readonly LimitedLiquiditySavingsAccount: "LLSV";
|
|
340
|
+
readonly Loan: "LOAN";
|
|
341
|
+
readonly MarginalLending: "MGLD";
|
|
342
|
+
readonly MoneyMarket: "MOMA";
|
|
343
|
+
readonly NonResidentExternal: "NREX";
|
|
344
|
+
readonly Overdraft: "ODFT";
|
|
345
|
+
readonly OverNightDeposit: "ONDP";
|
|
346
|
+
readonly OtherAccount: "OTHR";
|
|
347
|
+
readonly Settlement: "SACC";
|
|
348
|
+
readonly Salary: "SLRY";
|
|
349
|
+
readonly Savings: "SVGS";
|
|
350
|
+
readonly Tax: "TAXE";
|
|
351
|
+
readonly TransactingAccount: "TRAN";
|
|
352
|
+
readonly CashTrading: "TRAS";
|
|
353
|
+
};
|
|
354
|
+
export type CashAccountType = (typeof CashAccountTypeCode)[keyof typeof CashAccountTypeCode];
|
|
355
|
+
export declare const CashAccountTypeCodeDescriptionMap: {
|
|
356
|
+
readonly CACC: "Current";
|
|
357
|
+
readonly CASH: "Cash Payment";
|
|
358
|
+
readonly CHAR: "Charges";
|
|
359
|
+
readonly CISH: "Cash Income";
|
|
360
|
+
readonly COMM: "Commission";
|
|
361
|
+
readonly CPAC: "Clearing Participant Settlement Account";
|
|
362
|
+
readonly LLSV: "Limited Liquidity Savings Account";
|
|
363
|
+
readonly LOAN: "Loan";
|
|
364
|
+
readonly MGLD: "Marginal Lending";
|
|
365
|
+
readonly MOMA: "Money Market";
|
|
366
|
+
readonly NREX: "Non Resident External";
|
|
367
|
+
readonly ODFT: "Overdraft";
|
|
368
|
+
readonly ONDP: "Over Night Deposit";
|
|
369
|
+
readonly OTHR: "Other Account";
|
|
370
|
+
readonly SACC: "Settlement";
|
|
371
|
+
readonly SLRY: "Salary";
|
|
372
|
+
readonly SVGS: "Savings";
|
|
373
|
+
readonly TAXE: "Tax";
|
|
374
|
+
readonly TRAN: "Transacting Account";
|
|
375
|
+
readonly TRAS: "Cash Trading";
|
|
376
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { ACHCreditPaymentInstruction, ACHLocalInstrument, Party } from '../../lib/types';
|
|
2
|
+
import { PaymentInitiation } from './payment-initiation';
|
|
3
|
+
type AtLeastOne<T> = [T, ...T[]];
|
|
4
|
+
/**
|
|
5
|
+
* Configuration for ACH Credit Payment Initiation.
|
|
6
|
+
*
|
|
7
|
+
* @property {Party} initiatingParty - The party initiating the ACH credit transfer.
|
|
8
|
+
* @property {AtLeastOne<ACHCreditPaymentInstruction>} paymentInstructions - Array containing at least one payment instruction for the ACH credit transfer.
|
|
9
|
+
* @property {string} [messageId] - Optional unique identifier for the message. If not provided, a UUID will be generated.
|
|
10
|
+
* @property {Date} [creationDate] - Optional creation date for the message. If not provided, current date will be used.
|
|
11
|
+
*/
|
|
12
|
+
export interface ACHCreditPaymentInitiationConfig {
|
|
13
|
+
/** The party initiating the ACH credit transfer. */
|
|
14
|
+
initiatingParty: Party;
|
|
15
|
+
/** Array containing at least one payment instruction for the ACH credit transfer. */
|
|
16
|
+
paymentInstructions: AtLeastOne<ACHCreditPaymentInstruction>;
|
|
17
|
+
/** Optional unique identifier for the message. If not provided, a UUID will be generated. */
|
|
18
|
+
messageId?: string;
|
|
19
|
+
/** Optional creation date for the message. If not provided, current date will be used. */
|
|
20
|
+
creationDate?: Date;
|
|
21
|
+
/** Optional local instrument code for the ACH credit transfer. If not provided, 'CCD' (Corporate Credit or Debit) will be used. */
|
|
22
|
+
localInstrument?: ACHLocalInstrument;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents an ACH Credit Payment Initiation.
|
|
26
|
+
* This class handles the creation and serialization of ACH credit transfer messages
|
|
27
|
+
* according to the ISO20022 standard.
|
|
28
|
+
* @class
|
|
29
|
+
* @extends PaymentInitiation
|
|
30
|
+
* @param {ACHCreditPaymentInitiationConfig} config - The configuration for the ACH Credit Payment Initiation message.
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* // Creating a payment message
|
|
34
|
+
* const payment = new ACHCreditPaymentInitiation({
|
|
35
|
+
* initiatingParty: {
|
|
36
|
+
* name: 'John Doe Corporation',
|
|
37
|
+
* id: 'JOHNDOE99',
|
|
38
|
+
* account: {
|
|
39
|
+
* accountNumber: '0123456789'
|
|
40
|
+
* },
|
|
41
|
+
* agent: {
|
|
42
|
+
* abaRoutingNumber: '123456789',
|
|
43
|
+
* }
|
|
44
|
+
* },
|
|
45
|
+
* paymentInstructions: [{
|
|
46
|
+
* type: 'ach',
|
|
47
|
+
* direction: 'credit',
|
|
48
|
+
* amount: 1000,
|
|
49
|
+
* currency: 'USD',
|
|
50
|
+
* creditor: {
|
|
51
|
+
* name: 'John Doe Funding LLC',
|
|
52
|
+
* account: {
|
|
53
|
+
* accountNumber: '0123456789'
|
|
54
|
+
* },
|
|
55
|
+
* agent: {
|
|
56
|
+
* abaRoutingNumber: '0123456789'
|
|
57
|
+
* }
|
|
58
|
+
* }
|
|
59
|
+
* }]
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Serializing to XML
|
|
63
|
+
* const xml = payment.serialize();
|
|
64
|
+
*
|
|
65
|
+
* // Parsing from XML
|
|
66
|
+
* const parsedPayment = ACHCreditPaymentInitiation.fromXML(xml);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare class ACHCreditPaymentInitiation extends PaymentInitiation {
|
|
70
|
+
initiatingParty: Party;
|
|
71
|
+
paymentInstructions: AtLeastOne<ACHCreditPaymentInstruction>;
|
|
72
|
+
messageId: string;
|
|
73
|
+
creationDate: Date;
|
|
74
|
+
paymentInformationId: string;
|
|
75
|
+
localInstrument: string;
|
|
76
|
+
serviceLevel: string;
|
|
77
|
+
instructionPriority: string;
|
|
78
|
+
private formattedPaymentSum;
|
|
79
|
+
constructor(config: ACHCreditPaymentInitiationConfig);
|
|
80
|
+
/**
|
|
81
|
+
* Calculates the sum of all payment instructions.
|
|
82
|
+
* @private
|
|
83
|
+
* @param {AtLeastOne<ACHCreditPaymentInstruction>} instructions - Array of payment instructions.
|
|
84
|
+
* @returns {string} The total sum formatted as a string with 2 decimal places.
|
|
85
|
+
* @throws {Error} If payment instructions have different currencies.
|
|
86
|
+
*/
|
|
87
|
+
private sumPaymentInstructions;
|
|
88
|
+
/**
|
|
89
|
+
* Validates the payment initiation data according to ACH requirements.
|
|
90
|
+
* @private
|
|
91
|
+
* @throws {Error} If messageId exceeds 35 characters.
|
|
92
|
+
* @throws {Error} If payment instructions have different currencies.
|
|
93
|
+
* @throws {Error} If any creditor has incomplete information.
|
|
94
|
+
*/
|
|
95
|
+
private validate;
|
|
96
|
+
/**
|
|
97
|
+
* Generates payment information for a single ACH credit transfer instruction.
|
|
98
|
+
* @param {ACHCreditPaymentInstruction} instruction - The payment instruction.
|
|
99
|
+
* @returns {Object} The payment information object formatted according to ACH specifications.
|
|
100
|
+
*/
|
|
101
|
+
creditTransfer(instruction: ACHCreditPaymentInstruction): {
|
|
102
|
+
PmtId: {
|
|
103
|
+
InstrId: string;
|
|
104
|
+
EndToEndId: string;
|
|
105
|
+
};
|
|
106
|
+
Amt: {
|
|
107
|
+
InstdAmt: {
|
|
108
|
+
'#': string;
|
|
109
|
+
'@Ccy': "USD";
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
CdtrAgt: {
|
|
113
|
+
FinInstnId: {
|
|
114
|
+
BIC: string;
|
|
115
|
+
ClrSysMmbId?: undefined;
|
|
116
|
+
};
|
|
117
|
+
} | {
|
|
118
|
+
FinInstnId: {
|
|
119
|
+
ClrSysMmbId: {
|
|
120
|
+
ClrSysId: {
|
|
121
|
+
Cd: string;
|
|
122
|
+
};
|
|
123
|
+
MmbId: string;
|
|
124
|
+
};
|
|
125
|
+
BIC?: undefined;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
Cdtr: any;
|
|
129
|
+
CdtrAcct: {
|
|
130
|
+
Id: {
|
|
131
|
+
Othr: {
|
|
132
|
+
Id: string;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
Tp: {
|
|
136
|
+
Cd: string;
|
|
137
|
+
};
|
|
138
|
+
Ccy: "USD";
|
|
139
|
+
};
|
|
140
|
+
RmtInf: {
|
|
141
|
+
Ustrd: string;
|
|
142
|
+
} | undefined;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Serializes the ACH credit transfer initiation to an XML string.
|
|
146
|
+
* @returns {string} The XML representation of the ACH credit transfer initiation.
|
|
147
|
+
*/
|
|
148
|
+
serialize(): string;
|
|
149
|
+
/**
|
|
150
|
+
* Creates an ACHCreditPaymentInitiation instance from an XML string.
|
|
151
|
+
* @param {string} rawXml - The XML string to parse.
|
|
152
|
+
* @returns {ACHCreditPaymentInitiation} A new ACHCreditPaymentInitiation instance.
|
|
153
|
+
* @throws {InvalidXmlError} If the XML format is invalid.
|
|
154
|
+
* @throws {InvalidXmlNamespaceError} If the XML namespace is invalid.
|
|
155
|
+
* @throws {Error} If multiple payment information blocks are found.
|
|
156
|
+
*/
|
|
157
|
+
static fromXML(rawXml: string): ACHCreditPaymentInitiation;
|
|
158
|
+
}
|
|
159
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { XMLBuilder } from 'fast-xml-parser';
|
|
2
|
+
import { Party, IBANAccount, Account, Agent } from '../../lib/types';
|
|
3
|
+
/**
|
|
4
|
+
* Abstract base class for ISO20022 payment initiation (PAIN) messages.
|
|
5
|
+
* @abstract
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class PaymentInitiation {
|
|
8
|
+
type: "swift" | "rtp" | "sepa" | "ach";
|
|
9
|
+
constructor({ type }: {
|
|
10
|
+
type: "swift" | "rtp" | "sepa" | "ach";
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Serializes the payment initiation to a string format.
|
|
14
|
+
* @abstract
|
|
15
|
+
* @returns {string} The serialized payment initiation.
|
|
16
|
+
*/
|
|
17
|
+
abstract serialize(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Formats a party's information according to ISO20022 standards.
|
|
20
|
+
* @param {Party} party - The party's information.
|
|
21
|
+
* @returns {Object} Formatted XML party information.
|
|
22
|
+
*/
|
|
23
|
+
party(party: Party): any;
|
|
24
|
+
/**
|
|
25
|
+
* Formats an account according to ISO20022 standards.
|
|
26
|
+
* This method handles both IBAN and non-IBAN accounts.
|
|
27
|
+
*
|
|
28
|
+
* @param {Account} account - The account to be formatted. Can be either an IBANAccount or a BaseAccount.
|
|
29
|
+
* @returns {Object} An object representing the formatted account information.
|
|
30
|
+
* For IBAN accounts, it returns an object with an IBAN identifier.
|
|
31
|
+
* For non-IBAN accounts, it returns an object with an 'Other' identifier.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // For an IBAN account
|
|
35
|
+
* account({ iban: 'DE89370400440532013000' })
|
|
36
|
+
* // Returns: { Id: { IBAN: 'DE89370400440532013000' } }
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // For a non-IBAN account
|
|
40
|
+
* account({ accountNumber: '1234567890' })
|
|
41
|
+
* // Returns: { Id: { Othr: { Id: '1234567890' } } }
|
|
42
|
+
*/
|
|
43
|
+
account(account: Account): {
|
|
44
|
+
Id: {
|
|
45
|
+
IBAN: string;
|
|
46
|
+
};
|
|
47
|
+
} | {
|
|
48
|
+
Id: {
|
|
49
|
+
Othr: {
|
|
50
|
+
Id: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Formats an IBAN account according to ISO20022 standards.
|
|
56
|
+
* @param {IBANAccount} account - The IBAN account information.
|
|
57
|
+
* @returns {Object} Formatted XML IBAN account information.
|
|
58
|
+
*/
|
|
59
|
+
internationalAccount(account: IBANAccount): {
|
|
60
|
+
Id: {
|
|
61
|
+
IBAN: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Formats an agent according to ISO20022 standards.
|
|
66
|
+
* This method handles both BIC and ABA agents.
|
|
67
|
+
*
|
|
68
|
+
* @param {Agent} agent - The agent to be formatted. Can be either a BICAgent or an ABAAgent.
|
|
69
|
+
* @returns {Object} An object representing the formatted agent information.
|
|
70
|
+
* For BIC agents, it returns an object with a BIC identifier.
|
|
71
|
+
* For ABA agents, it returns an object with clearing system member identification.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // For a BIC agent
|
|
75
|
+
* agent({ bic: 'BOFAUS3NXXX' })
|
|
76
|
+
* // Returns: { FinInstnId: { BIC: 'BOFAUS3NXXX' } }
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // For an ABA agent
|
|
80
|
+
* agent({ abaRoutingNumber: '026009593' })
|
|
81
|
+
* // Returns: { FinInstnId: { ClrSysMmbId: { MmbId: '026009593' } } }
|
|
82
|
+
*/
|
|
83
|
+
agent(agent: Agent): {
|
|
84
|
+
FinInstnId: {
|
|
85
|
+
BIC: string;
|
|
86
|
+
ClrSysMmbId?: undefined;
|
|
87
|
+
};
|
|
88
|
+
} | {
|
|
89
|
+
FinInstnId: {
|
|
90
|
+
ClrSysMmbId: {
|
|
91
|
+
ClrSysId: {
|
|
92
|
+
Cd: string;
|
|
93
|
+
};
|
|
94
|
+
MmbId: string;
|
|
95
|
+
};
|
|
96
|
+
BIC?: undefined;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Returns the string representation of the payment initiation.
|
|
101
|
+
* @returns {string} The serialized payment initiation.
|
|
102
|
+
*/
|
|
103
|
+
toString(): string;
|
|
104
|
+
static getBuilder(): XMLBuilder;
|
|
105
|
+
}
|