@develit-services/bank 0.8.5 → 0.8.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/dist/database/schema.cjs +1 -1
- package/dist/database/schema.d.cts +1 -1
- package/dist/database/schema.d.mts +1 -1
- package/dist/database/schema.d.ts +1 -1
- package/dist/database/schema.mjs +1 -1
- package/dist/export/worker.cjs +583 -146
- package/dist/export/worker.d.cts +286 -44
- package/dist/export/worker.d.mts +286 -44
- package/dist/export/worker.d.ts +286 -44
- package/dist/export/worker.mjs +584 -147
- package/dist/export/workflows.cjs +132 -16
- package/dist/export/workflows.mjs +133 -17
- package/dist/shared/{bank.C-T1FQxg.cjs → bank.62VzK9Aj.cjs} +1 -1
- package/dist/shared/{bank.SQ4Mmr8u.cjs → bank.BS7fFjGA.cjs} +34 -4
- package/dist/shared/{bank.6faPHUEY.d.ts → bank.BYRq3yJf.d.ts} +81 -11
- package/dist/shared/{bank.C4VOdIx1.mjs → bank.C0UN6luZ.mjs} +34 -4
- package/dist/shared/{bank.DDHrdFgy.mjs → bank.CA5ytXxp.mjs} +1 -1
- package/dist/shared/{bank.BoWCMu5n.d.cts → bank.CO89tR9U.d.cts} +81 -11
- package/dist/shared/{bank.BaMRCHk-.d.ts → bank.Cns5ss41.d.cts} +55 -18
- package/dist/shared/{bank.BaMRCHk-.d.cts → bank.Cns5ss41.d.mts} +55 -18
- package/dist/shared/{bank.BaMRCHk-.d.mts → bank.Cns5ss41.d.ts} +55 -18
- package/dist/shared/{bank.DOL1uM4n.d.mts → bank.CreoSb2d.d.mts} +81 -11
- package/dist/shared/{bank.DRrBrAdI.mjs → bank.D1jqaHaF.mjs} +91 -31
- package/dist/shared/{bank.Cpy9PULF.mjs → bank.DEmzZGZW.mjs} +31 -5
- package/dist/shared/{bank.BOnP9p9Y.cjs → bank.Dm8GHThw.cjs} +31 -5
- package/dist/shared/{bank.CQURey1E.cjs → bank.DwyCCyd0.cjs} +90 -31
- package/dist/types.cjs +3 -4
- package/dist/types.d.cts +8 -16
- package/dist/types.d.mts +8 -16
- package/dist/types.d.ts +8 -16
- package/dist/types.mjs +3 -3
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as CurrencyCode, J as BankCode, V as CountryCode } from './bank.Cns5ss41.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -210,6 +210,18 @@ type FinbricksAccountTransactionsResponse = {
|
|
|
210
210
|
transactions: FinbricksTransaction[];
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated Use IncomingPayment from './payment-lifecycle' instead
|
|
215
|
+
* This type is kept for backward compatibility during migration
|
|
216
|
+
*/
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Message pushed to PAYMENTS_READY_TO_BATCH_QUEUE after payment_request is created in DB
|
|
220
|
+
*/
|
|
221
|
+
type PaymentQueueMessage = {
|
|
222
|
+
paymentId: string;
|
|
223
|
+
};
|
|
224
|
+
|
|
213
225
|
declare const sendPaymentInputSchema: z.ZodObject<{
|
|
214
226
|
correlationId: z.ZodString;
|
|
215
227
|
refId: z.ZodOptional<z.ZodString>;
|
|
@@ -225,7 +237,6 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
225
237
|
OUR: "OUR";
|
|
226
238
|
BEN: "BEN";
|
|
227
239
|
}>>;
|
|
228
|
-
executionDate: z.ZodOptional<z.ZodString>;
|
|
229
240
|
instructionPriority: z.ZodOptional<z.ZodEnum<{
|
|
230
241
|
NORM: "NORM";
|
|
231
242
|
HIGH: "HIGH";
|
|
@@ -301,31 +312,42 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
301
312
|
"0710": "0710";
|
|
302
313
|
"0800": "0800";
|
|
303
314
|
2010: "2010";
|
|
315
|
+
2020: "2020";
|
|
316
|
+
2030: "2030";
|
|
304
317
|
2060: "2060";
|
|
305
318
|
2070: "2070";
|
|
306
319
|
2100: "2100";
|
|
307
320
|
2200: "2200";
|
|
321
|
+
2210: "2210";
|
|
308
322
|
2220: "2220";
|
|
323
|
+
2240: "2240";
|
|
309
324
|
2250: "2250";
|
|
310
325
|
2260: "2260";
|
|
326
|
+
2310: "2310";
|
|
311
327
|
2600: "2600";
|
|
312
328
|
2700: "2700";
|
|
313
329
|
3030: "3030";
|
|
330
|
+
3050: "3050";
|
|
314
331
|
3060: "3060";
|
|
315
332
|
3500: "3500";
|
|
333
|
+
4000: "4000";
|
|
316
334
|
4300: "4300";
|
|
317
335
|
5500: "5500";
|
|
336
|
+
5400: "5400";
|
|
318
337
|
5800: "5800";
|
|
319
338
|
6000: "6000";
|
|
339
|
+
6100: "6100";
|
|
320
340
|
6200: "6200";
|
|
321
341
|
6210: "6210";
|
|
322
342
|
6300: "6300";
|
|
323
343
|
6363: "6363";
|
|
324
344
|
6700: "6700";
|
|
325
345
|
6800: "6800";
|
|
346
|
+
7940: "7940";
|
|
326
347
|
7910: "7910";
|
|
327
348
|
7950: "7950";
|
|
328
349
|
7960: "7960";
|
|
350
|
+
7980: "7980";
|
|
329
351
|
7970: "7970";
|
|
330
352
|
7990: "7990";
|
|
331
353
|
8030: "8030";
|
|
@@ -335,11 +357,15 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
335
357
|
8150: "8150";
|
|
336
358
|
8190: "8190";
|
|
337
359
|
8198: "8198";
|
|
360
|
+
8200: "8200";
|
|
338
361
|
8220: "8220";
|
|
362
|
+
8230: "8230";
|
|
363
|
+
8240: "8240";
|
|
339
364
|
8250: "8250";
|
|
340
365
|
8255: "8255";
|
|
341
366
|
8265: "8265";
|
|
342
367
|
8500: "8500";
|
|
368
|
+
8610: "8610";
|
|
343
369
|
}>>;
|
|
344
370
|
holderName: z.ZodOptional<z.ZodString>;
|
|
345
371
|
iban: z.ZodOptional<z.ZodString>;
|
|
@@ -402,6 +428,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
402
428
|
AVAX: "AVAX";
|
|
403
429
|
}>>;
|
|
404
430
|
countryCode: z.ZodOptional<z.ZodEnum<{
|
|
431
|
+
IM: "IM";
|
|
405
432
|
AF: "AF";
|
|
406
433
|
AL: "AL";
|
|
407
434
|
DZ: "DZ";
|
|
@@ -490,7 +517,6 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
490
517
|
IR: "IR";
|
|
491
518
|
IQ: "IQ";
|
|
492
519
|
IE: "IE";
|
|
493
|
-
IM: "IM";
|
|
494
520
|
IL: "IL";
|
|
495
521
|
IT: "IT";
|
|
496
522
|
CI: "CI";
|
|
@@ -631,31 +657,42 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
631
657
|
"0710": "0710";
|
|
632
658
|
"0800": "0800";
|
|
633
659
|
2010: "2010";
|
|
660
|
+
2020: "2020";
|
|
661
|
+
2030: "2030";
|
|
634
662
|
2060: "2060";
|
|
635
663
|
2070: "2070";
|
|
636
664
|
2100: "2100";
|
|
637
665
|
2200: "2200";
|
|
666
|
+
2210: "2210";
|
|
638
667
|
2220: "2220";
|
|
668
|
+
2240: "2240";
|
|
639
669
|
2250: "2250";
|
|
640
670
|
2260: "2260";
|
|
671
|
+
2310: "2310";
|
|
641
672
|
2600: "2600";
|
|
642
673
|
2700: "2700";
|
|
643
674
|
3030: "3030";
|
|
675
|
+
3050: "3050";
|
|
644
676
|
3060: "3060";
|
|
645
677
|
3500: "3500";
|
|
678
|
+
4000: "4000";
|
|
646
679
|
4300: "4300";
|
|
647
680
|
5500: "5500";
|
|
681
|
+
5400: "5400";
|
|
648
682
|
5800: "5800";
|
|
649
683
|
6000: "6000";
|
|
684
|
+
6100: "6100";
|
|
650
685
|
6200: "6200";
|
|
651
686
|
6210: "6210";
|
|
652
687
|
6300: "6300";
|
|
653
688
|
6363: "6363";
|
|
654
689
|
6700: "6700";
|
|
655
690
|
6800: "6800";
|
|
691
|
+
7940: "7940";
|
|
656
692
|
7910: "7910";
|
|
657
693
|
7950: "7950";
|
|
658
694
|
7960: "7960";
|
|
695
|
+
7980: "7980";
|
|
659
696
|
7970: "7970";
|
|
660
697
|
7990: "7990";
|
|
661
698
|
8030: "8030";
|
|
@@ -665,11 +702,15 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
665
702
|
8150: "8150";
|
|
666
703
|
8190: "8190";
|
|
667
704
|
8198: "8198";
|
|
705
|
+
8200: "8200";
|
|
668
706
|
8220: "8220";
|
|
707
|
+
8230: "8230";
|
|
708
|
+
8240: "8240";
|
|
669
709
|
8250: "8250";
|
|
670
710
|
8255: "8255";
|
|
671
711
|
8265: "8265";
|
|
672
712
|
8500: "8500";
|
|
713
|
+
8610: "8610";
|
|
673
714
|
}>>;
|
|
674
715
|
holderName: z.ZodOptional<z.ZodString>;
|
|
675
716
|
iban: z.ZodOptional<z.ZodString>;
|
|
@@ -732,6 +773,7 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
732
773
|
AVAX: "AVAX";
|
|
733
774
|
}>>;
|
|
734
775
|
countryCode: z.ZodOptional<z.ZodEnum<{
|
|
776
|
+
IM: "IM";
|
|
735
777
|
AF: "AF";
|
|
736
778
|
AL: "AL";
|
|
737
779
|
DZ: "DZ";
|
|
@@ -820,7 +862,6 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
820
862
|
IR: "IR";
|
|
821
863
|
IQ: "IQ";
|
|
822
864
|
IE: "IE";
|
|
823
|
-
IM: "IM";
|
|
824
865
|
IL: "IL";
|
|
825
866
|
IT: "IT";
|
|
826
867
|
CI: "CI";
|
|
@@ -950,12 +991,13 @@ declare const sendPaymentInputSchema: z.ZodObject<{
|
|
|
950
991
|
bsb: z.ZodOptional<z.ZodString>;
|
|
951
992
|
brBankNumber: z.ZodOptional<z.ZodString>;
|
|
952
993
|
}, z.core.$strip>;
|
|
953
|
-
purpose: z.ZodOptional<z.ZodString>;
|
|
954
994
|
sendAsSinglePayment: z.ZodOptional<z.ZodBoolean>;
|
|
955
995
|
}, z.core.$strip>;
|
|
956
996
|
interface SendPaymentInput extends z.infer<typeof sendPaymentInputSchema> {
|
|
957
997
|
}
|
|
958
|
-
type SendPaymentOutput =
|
|
998
|
+
type SendPaymentOutput = {
|
|
999
|
+
paymentId: string;
|
|
1000
|
+
};
|
|
959
1001
|
|
|
960
1002
|
declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
961
1003
|
correlationId: z.ZodString;
|
|
@@ -972,7 +1014,6 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
972
1014
|
OUR: "OUR";
|
|
973
1015
|
BEN: "BEN";
|
|
974
1016
|
}>>;
|
|
975
|
-
executionDate: z.ZodOptional<z.ZodString>;
|
|
976
1017
|
instructionPriority: z.ZodOptional<z.ZodEnum<{
|
|
977
1018
|
NORM: "NORM";
|
|
978
1019
|
HIGH: "HIGH";
|
|
@@ -1048,31 +1089,42 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1048
1089
|
"0710": "0710";
|
|
1049
1090
|
"0800": "0800";
|
|
1050
1091
|
2010: "2010";
|
|
1092
|
+
2020: "2020";
|
|
1093
|
+
2030: "2030";
|
|
1051
1094
|
2060: "2060";
|
|
1052
1095
|
2070: "2070";
|
|
1053
1096
|
2100: "2100";
|
|
1054
1097
|
2200: "2200";
|
|
1098
|
+
2210: "2210";
|
|
1055
1099
|
2220: "2220";
|
|
1100
|
+
2240: "2240";
|
|
1056
1101
|
2250: "2250";
|
|
1057
1102
|
2260: "2260";
|
|
1103
|
+
2310: "2310";
|
|
1058
1104
|
2600: "2600";
|
|
1059
1105
|
2700: "2700";
|
|
1060
1106
|
3030: "3030";
|
|
1107
|
+
3050: "3050";
|
|
1061
1108
|
3060: "3060";
|
|
1062
1109
|
3500: "3500";
|
|
1110
|
+
4000: "4000";
|
|
1063
1111
|
4300: "4300";
|
|
1064
1112
|
5500: "5500";
|
|
1113
|
+
5400: "5400";
|
|
1065
1114
|
5800: "5800";
|
|
1066
1115
|
6000: "6000";
|
|
1116
|
+
6100: "6100";
|
|
1067
1117
|
6200: "6200";
|
|
1068
1118
|
6210: "6210";
|
|
1069
1119
|
6300: "6300";
|
|
1070
1120
|
6363: "6363";
|
|
1071
1121
|
6700: "6700";
|
|
1072
1122
|
6800: "6800";
|
|
1123
|
+
7940: "7940";
|
|
1073
1124
|
7910: "7910";
|
|
1074
1125
|
7950: "7950";
|
|
1075
1126
|
7960: "7960";
|
|
1127
|
+
7980: "7980";
|
|
1076
1128
|
7970: "7970";
|
|
1077
1129
|
7990: "7990";
|
|
1078
1130
|
8030: "8030";
|
|
@@ -1082,11 +1134,15 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1082
1134
|
8150: "8150";
|
|
1083
1135
|
8190: "8190";
|
|
1084
1136
|
8198: "8198";
|
|
1137
|
+
8200: "8200";
|
|
1085
1138
|
8220: "8220";
|
|
1139
|
+
8230: "8230";
|
|
1140
|
+
8240: "8240";
|
|
1086
1141
|
8250: "8250";
|
|
1087
1142
|
8255: "8255";
|
|
1088
1143
|
8265: "8265";
|
|
1089
1144
|
8500: "8500";
|
|
1145
|
+
8610: "8610";
|
|
1090
1146
|
}>>;
|
|
1091
1147
|
holderName: z.ZodOptional<z.ZodString>;
|
|
1092
1148
|
iban: z.ZodOptional<z.ZodString>;
|
|
@@ -1149,6 +1205,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1149
1205
|
AVAX: "AVAX";
|
|
1150
1206
|
}>>;
|
|
1151
1207
|
countryCode: z.ZodOptional<z.ZodEnum<{
|
|
1208
|
+
IM: "IM";
|
|
1152
1209
|
AF: "AF";
|
|
1153
1210
|
AL: "AL";
|
|
1154
1211
|
DZ: "DZ";
|
|
@@ -1237,7 +1294,6 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1237
1294
|
IR: "IR";
|
|
1238
1295
|
IQ: "IQ";
|
|
1239
1296
|
IE: "IE";
|
|
1240
|
-
IM: "IM";
|
|
1241
1297
|
IL: "IL";
|
|
1242
1298
|
IT: "IT";
|
|
1243
1299
|
CI: "CI";
|
|
@@ -1378,31 +1434,42 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1378
1434
|
"0710": "0710";
|
|
1379
1435
|
"0800": "0800";
|
|
1380
1436
|
2010: "2010";
|
|
1437
|
+
2020: "2020";
|
|
1438
|
+
2030: "2030";
|
|
1381
1439
|
2060: "2060";
|
|
1382
1440
|
2070: "2070";
|
|
1383
1441
|
2100: "2100";
|
|
1384
1442
|
2200: "2200";
|
|
1443
|
+
2210: "2210";
|
|
1385
1444
|
2220: "2220";
|
|
1445
|
+
2240: "2240";
|
|
1386
1446
|
2250: "2250";
|
|
1387
1447
|
2260: "2260";
|
|
1448
|
+
2310: "2310";
|
|
1388
1449
|
2600: "2600";
|
|
1389
1450
|
2700: "2700";
|
|
1390
1451
|
3030: "3030";
|
|
1452
|
+
3050: "3050";
|
|
1391
1453
|
3060: "3060";
|
|
1392
1454
|
3500: "3500";
|
|
1455
|
+
4000: "4000";
|
|
1393
1456
|
4300: "4300";
|
|
1394
1457
|
5500: "5500";
|
|
1458
|
+
5400: "5400";
|
|
1395
1459
|
5800: "5800";
|
|
1396
1460
|
6000: "6000";
|
|
1461
|
+
6100: "6100";
|
|
1397
1462
|
6200: "6200";
|
|
1398
1463
|
6210: "6210";
|
|
1399
1464
|
6300: "6300";
|
|
1400
1465
|
6363: "6363";
|
|
1401
1466
|
6700: "6700";
|
|
1402
1467
|
6800: "6800";
|
|
1468
|
+
7940: "7940";
|
|
1403
1469
|
7910: "7910";
|
|
1404
1470
|
7950: "7950";
|
|
1405
1471
|
7960: "7960";
|
|
1472
|
+
7980: "7980";
|
|
1406
1473
|
7970: "7970";
|
|
1407
1474
|
7990: "7990";
|
|
1408
1475
|
8030: "8030";
|
|
@@ -1412,11 +1479,15 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1412
1479
|
8150: "8150";
|
|
1413
1480
|
8190: "8190";
|
|
1414
1481
|
8198: "8198";
|
|
1482
|
+
8200: "8200";
|
|
1415
1483
|
8220: "8220";
|
|
1484
|
+
8230: "8230";
|
|
1485
|
+
8240: "8240";
|
|
1416
1486
|
8250: "8250";
|
|
1417
1487
|
8255: "8255";
|
|
1418
1488
|
8265: "8265";
|
|
1419
1489
|
8500: "8500";
|
|
1490
|
+
8610: "8610";
|
|
1420
1491
|
}>>;
|
|
1421
1492
|
holderName: z.ZodOptional<z.ZodString>;
|
|
1422
1493
|
iban: z.ZodOptional<z.ZodString>;
|
|
@@ -1479,6 +1550,7 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1479
1550
|
AVAX: "AVAX";
|
|
1480
1551
|
}>>;
|
|
1481
1552
|
countryCode: z.ZodOptional<z.ZodEnum<{
|
|
1553
|
+
IM: "IM";
|
|
1482
1554
|
AF: "AF";
|
|
1483
1555
|
AL: "AL";
|
|
1484
1556
|
DZ: "DZ";
|
|
@@ -1567,7 +1639,6 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1567
1639
|
IR: "IR";
|
|
1568
1640
|
IQ: "IQ";
|
|
1569
1641
|
IE: "IE";
|
|
1570
|
-
IM: "IM";
|
|
1571
1642
|
IL: "IL";
|
|
1572
1643
|
IT: "IT";
|
|
1573
1644
|
CI: "CI";
|
|
@@ -1697,7 +1768,6 @@ declare const sendPaymentSyncInputSchema: z.ZodObject<{
|
|
|
1697
1768
|
bsb: z.ZodOptional<z.ZodString>;
|
|
1698
1769
|
brBankNumber: z.ZodOptional<z.ZodString>;
|
|
1699
1770
|
}, z.core.$strip>;
|
|
1700
|
-
purpose: z.ZodOptional<z.ZodString>;
|
|
1701
1771
|
sendAsSinglePayment: z.ZodOptional<z.ZodBoolean>;
|
|
1702
1772
|
}, z.core.$strip>;
|
|
1703
1773
|
interface SendPaymentSyncInput extends z.infer<typeof sendPaymentSyncInputSchema> {
|
|
@@ -1707,4 +1777,4 @@ type SendPaymentSyncOutput = {
|
|
|
1707
1777
|
authorizationUrl: string;
|
|
1708
1778
|
};
|
|
1709
1779
|
|
|
1710
|
-
export type { FinbricksSupportedBanksResponse as F, ReferenceType as R, SendPaymentInput as S, SendPaymentOutput as a, SendPaymentSyncInput as b, SendPaymentSyncOutput as c, FinbricksAccount as d, FinbricksAccountTransactionsResponse as e, FinbricksAccountsListResponse as f, FinbricksAuthTokenResponse as g, FinbricksBatchResponse as h, FinbricksConnectAccountResponse as i, FinbricksPaymentResponse as j, FinbricksSupportedBank as k };
|
|
1780
|
+
export type { FinbricksSupportedBanksResponse as F, PaymentQueueMessage as P, ReferenceType as R, SendPaymentInput as S, SendPaymentOutput as a, SendPaymentSyncInput as b, SendPaymentSyncOutput as c, FinbricksAccount as d, FinbricksAccountTransactionsResponse as e, FinbricksAccountsListResponse as f, FinbricksAuthTokenResponse as g, FinbricksBatchResponse as h, FinbricksConnectAccountResponse as i, FinbricksPaymentResponse as j, FinbricksSupportedBank as k };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { uuidv4, createInternalError, useResult } from '@develit-io/backend-sdk';
|
|
2
2
|
import { format, parseISO } from 'date-fns';
|
|
3
3
|
import { CURRENCY_CODES } from '@develit-io/general-codes';
|
|
4
|
-
import './bank.
|
|
4
|
+
import './bank.C0UN6luZ.mjs';
|
|
5
5
|
import 'drizzle-orm';
|
|
6
|
+
import 'drizzle-orm/sqlite-core';
|
|
6
7
|
import { importPKCS8, SignJWT } from 'jose';
|
|
7
8
|
import 'node:crypto';
|
|
8
9
|
|
|
@@ -60,9 +61,6 @@ function toCompletedPayment(payment, status, bankRefId, processedAt) {
|
|
|
60
61
|
processedAt: processedAt ?? /* @__PURE__ */ new Date()
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
|
-
function batchTransform(payments, transformer) {
|
|
64
|
-
return payments.map(transformer);
|
|
65
|
-
}
|
|
66
64
|
function toPaymentRequestInsert(payment, batchId) {
|
|
67
65
|
return {
|
|
68
66
|
id: payment.id,
|
|
@@ -84,7 +82,8 @@ function toPaymentRequestInsert(payment, batchId) {
|
|
|
84
82
|
creditor: payment.creditor,
|
|
85
83
|
creditorIban: payment.creditorIban ?? null,
|
|
86
84
|
debtor: payment.debtor,
|
|
87
|
-
debtorIban: payment.debtorIban ?? null
|
|
85
|
+
debtorIban: payment.debtorIban ?? null,
|
|
86
|
+
sendAsSinglePayment: payment.sendAsSinglePayment ?? null
|
|
88
87
|
};
|
|
89
88
|
}
|
|
90
89
|
function toBatchedPaymentFromPaymentRequest(sp) {
|
|
@@ -117,6 +116,9 @@ function toBatchedPaymentFromPaymentRequest(sp) {
|
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
class IBankConnector {
|
|
119
|
+
supportsPaymentType(paymentType) {
|
|
120
|
+
return paymentType === "DOMESTIC";
|
|
121
|
+
}
|
|
120
122
|
// ── Deprecated methods (backward compatibility) ────────────────────
|
|
121
123
|
/**
|
|
122
124
|
* @deprecated Use initiateDomesticBatch, initiateSEPABatch, or initiateForeignBatch instead.
|
|
@@ -392,10 +394,13 @@ const mapReferencesToPayment = (reference) => {
|
|
|
392
394
|
const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
393
395
|
const isIncoming = tx.creditDebitIndicator === "CRDT";
|
|
394
396
|
const related = tx.entryDetails?.transactionDetails?.relatedParties;
|
|
397
|
+
const endToEndId = tx.entryDetails.transactionDetails?.references?.endToEndIdentification;
|
|
398
|
+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
399
|
+
const paymentRequestId = endToEndId && uuidRegex.test(endToEndId) ? endToEndId : null;
|
|
395
400
|
const base = {
|
|
396
401
|
id: uuidv4(),
|
|
397
402
|
correlationId: uuidv4(),
|
|
398
|
-
|
|
403
|
+
paymentRequestId,
|
|
399
404
|
connectorKey: account.connectorKey,
|
|
400
405
|
accountId: account.id,
|
|
401
406
|
bankRefId: tx.fbxReference,
|
|
@@ -406,7 +411,7 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
406
411
|
message: tx.entryDetails.transactionDetails?.remittanceInformation?.unstructured || tx.entryDetails.transactionDetails?.additionalRemittanceInformation || tx.entryDetails.transactionDetails?.additionalTransactionInformation || null,
|
|
407
412
|
processedAt: new Date(tx.bookingDate.date),
|
|
408
413
|
...mapReferencesToPayment(
|
|
409
|
-
tx.entryDetails.transactionDetails?.remittanceInformation?.structured?.creditorReferenceInformation?.reference ||
|
|
414
|
+
tx.entryDetails.transactionDetails?.remittanceInformation?.structured?.creditorReferenceInformation?.reference || (!paymentRequestId ? endToEndId : void 0)
|
|
410
415
|
),
|
|
411
416
|
creditor: {
|
|
412
417
|
holderName: related?.creditorAccount?.name || related?.creditor?.name || "Unknown",
|
|
@@ -455,6 +460,9 @@ class FinbricksConnector extends IBankConnector {
|
|
|
455
460
|
this.connectedAccounts = connectedAccounts;
|
|
456
461
|
this.resolveCredentials = resolveCredentials;
|
|
457
462
|
}
|
|
463
|
+
supportsPaymentType(paymentType) {
|
|
464
|
+
return paymentType === "DOMESTIC" || paymentType === "SEPA" || paymentType === "SWIFT";
|
|
465
|
+
}
|
|
458
466
|
async getClientId(accountId) {
|
|
459
467
|
if (!this.resolveCredentials) {
|
|
460
468
|
throw createInternalError(null, {
|
|
@@ -1145,24 +1153,64 @@ function mod97(string) {
|
|
|
1145
1153
|
}
|
|
1146
1154
|
return parseInt(checksum, 10);
|
|
1147
1155
|
}
|
|
1156
|
+
const parseCzechIban = (iban) => {
|
|
1157
|
+
const stripped = iban.replace(/\s/g, "").toUpperCase();
|
|
1158
|
+
if (!stripped.startsWith("CZ") || stripped.length !== 24) {
|
|
1159
|
+
throw new Error(`Invalid Czech IBAN: ${iban}`);
|
|
1160
|
+
}
|
|
1161
|
+
const bankCode = stripped.slice(4, 8);
|
|
1162
|
+
const prefix = stripped.slice(8, 14).replace(/^0+/, "");
|
|
1163
|
+
const main = stripped.slice(14, 24).replace(/^0+/, "");
|
|
1164
|
+
const accountNumber = prefix ? `${prefix}-${main}` : main;
|
|
1165
|
+
return { bankCode, accountNumber };
|
|
1166
|
+
};
|
|
1148
1167
|
const calculateCzechIban = (accountNumber, bankCode) => {
|
|
1149
1168
|
const paddedBankCode = bankCode.padStart(4, "0");
|
|
1150
1169
|
let prefix = "";
|
|
1151
1170
|
let mainAccount = accountNumber;
|
|
1152
1171
|
if (accountNumber.includes("-")) {
|
|
1153
1172
|
const parts = accountNumber.split("-");
|
|
1173
|
+
if (parts.length !== 2) {
|
|
1174
|
+
throw new Error(
|
|
1175
|
+
`Invalid account number format: expected "prefix-main" or "main", got "${accountNumber}"`
|
|
1176
|
+
);
|
|
1177
|
+
}
|
|
1154
1178
|
prefix = parts[0];
|
|
1155
1179
|
mainAccount = parts[1];
|
|
1156
1180
|
}
|
|
1157
1181
|
const paddedPrefix = prefix.padStart(6, "0");
|
|
1158
1182
|
const paddedAccount = mainAccount.padStart(10, "0");
|
|
1159
1183
|
const basicIban = paddedBankCode + paddedPrefix + paddedAccount;
|
|
1160
|
-
const rearranged = basicIban + "
|
|
1184
|
+
const rearranged = basicIban + "123500";
|
|
1161
1185
|
const remainder = mod97(rearranged);
|
|
1162
1186
|
const checkDigits = (98 - remainder).toString().padStart(2, "0");
|
|
1163
1187
|
return `CZ${checkDigits}${basicIban}`;
|
|
1164
1188
|
};
|
|
1165
1189
|
|
|
1190
|
+
function parseFlatAddress(addr, fallbackCountry) {
|
|
1191
|
+
if (!addr) {
|
|
1192
|
+
return {
|
|
1193
|
+
streetName: null,
|
|
1194
|
+
buildingNumber: null,
|
|
1195
|
+
city: null,
|
|
1196
|
+
zip: null,
|
|
1197
|
+
countryCode: fallbackCountry
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
const parts = addr.split(",").map((p) => p.trim());
|
|
1201
|
+
const streetPart = parts[0];
|
|
1202
|
+
const cityPart = parts[1];
|
|
1203
|
+
const countryCode = parts[2]?.trim() || fallbackCountry;
|
|
1204
|
+
const streetMatch = streetPart?.match(/^(.+?)\s+(\d+\w*)$/);
|
|
1205
|
+
const cityMatch = cityPart?.match(/^(\d[\d ]*?)\s+(.+)$/);
|
|
1206
|
+
return {
|
|
1207
|
+
streetName: streetMatch?.[1] ?? streetPart ?? null,
|
|
1208
|
+
buildingNumber: streetMatch?.[2] ?? null,
|
|
1209
|
+
city: cityMatch?.[2] ?? cityPart ?? null,
|
|
1210
|
+
zip: cityMatch?.[1]?.replace(/\s/g, "") ?? null,
|
|
1211
|
+
countryCode
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1166
1214
|
class DbuConnector extends IBankConnector {
|
|
1167
1215
|
constructor({
|
|
1168
1216
|
BASE_URL,
|
|
@@ -1258,6 +1306,7 @@ class DbuConnector extends IBankConnector {
|
|
|
1258
1306
|
const parsed = {
|
|
1259
1307
|
id: uuidv4(),
|
|
1260
1308
|
correlationId: uuidv4(),
|
|
1309
|
+
paymentRequestId: transaction.uniqueExternalId ?? null,
|
|
1261
1310
|
connectorKey: "DBU",
|
|
1262
1311
|
accountId: account.id,
|
|
1263
1312
|
bankRefId: transaction.idRequiredTransaction.toString(),
|
|
@@ -1423,11 +1472,25 @@ class DbuConnector extends IBankConnector {
|
|
|
1423
1472
|
}
|
|
1424
1473
|
return Number(account.bankRefId);
|
|
1425
1474
|
}
|
|
1475
|
+
resolveAccountDetails(account) {
|
|
1476
|
+
if (account.number && account.bankCode) {
|
|
1477
|
+
return { number: account.number, bankCode: account.bankCode };
|
|
1478
|
+
}
|
|
1479
|
+
if (account.iban) {
|
|
1480
|
+
const { bankCode, accountNumber } = parseCzechIban(account.iban);
|
|
1481
|
+
return { number: accountNumber, bankCode };
|
|
1482
|
+
}
|
|
1483
|
+
throw createInternalError(null, {
|
|
1484
|
+
message: "DBU: account has neither number+bankCode nor iban",
|
|
1485
|
+
code: "DBU_MISSING_ACCOUNT_DETAILS"
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1426
1488
|
async initiateInstantPayment(payment) {
|
|
1489
|
+
const creditor = this.resolveAccountDetails(payment.creditor);
|
|
1427
1490
|
const body = {
|
|
1428
|
-
accountNumberCredit:
|
|
1491
|
+
accountNumberCredit: creditor.number,
|
|
1429
1492
|
idAccountDebit: this.resolveIdAccountDebit(payment),
|
|
1430
|
-
bankCodeCredit:
|
|
1493
|
+
bankCodeCredit: creditor.bankCode,
|
|
1431
1494
|
amount: payment.amount,
|
|
1432
1495
|
currencyCode: "CZK",
|
|
1433
1496
|
channelCode: "WWW",
|
|
@@ -1459,11 +1522,13 @@ class DbuConnector extends IBankConnector {
|
|
|
1459
1522
|
if (payment.instructionPriority === "INST") {
|
|
1460
1523
|
return this.initiateInstantPayment(payment);
|
|
1461
1524
|
}
|
|
1525
|
+
const debtor = this.resolveAccountDetails(payment.debtor);
|
|
1526
|
+
const creditor = this.resolveAccountDetails(payment.creditor);
|
|
1462
1527
|
const body = {
|
|
1463
|
-
accountNumberDebit:
|
|
1464
|
-
accountNumberCredit:
|
|
1465
|
-
bankCodeDebit:
|
|
1466
|
-
bankCodeCredit:
|
|
1528
|
+
accountNumberDebit: debtor.number,
|
|
1529
|
+
accountNumberCredit: creditor.number,
|
|
1530
|
+
bankCodeDebit: debtor.bankCode,
|
|
1531
|
+
bankCodeCredit: creditor.bankCode,
|
|
1467
1532
|
amount: payment.amount,
|
|
1468
1533
|
currencyCode: "CZK",
|
|
1469
1534
|
actionTypeCode: "TRANSFER",
|
|
@@ -1480,20 +1545,14 @@ class DbuConnector extends IBankConnector {
|
|
|
1480
1545
|
constSymbol: payment.ks,
|
|
1481
1546
|
uniqueExternalId: payment.id,
|
|
1482
1547
|
with4EyeApproval: "Y",
|
|
1483
|
-
debtorAddress:
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
streetName: null,
|
|
1492
|
-
buildingNumber: null,
|
|
1493
|
-
city: null,
|
|
1494
|
-
zip: null,
|
|
1495
|
-
countryCode: payment.creditor.countryCode || "CZ"
|
|
1496
|
-
}
|
|
1548
|
+
debtorAddress: parseFlatAddress(
|
|
1549
|
+
payment.debtor.address,
|
|
1550
|
+
payment.debtor.countryCode || "CZ"
|
|
1551
|
+
),
|
|
1552
|
+
creditorAddress: parseFlatAddress(
|
|
1553
|
+
payment.creditor.address,
|
|
1554
|
+
payment.creditor.countryCode || "CZ"
|
|
1555
|
+
)
|
|
1497
1556
|
};
|
|
1498
1557
|
const response = await this.makeRequest(
|
|
1499
1558
|
"/required-transactions",
|
|
@@ -1547,7 +1606,7 @@ class DbuConnector extends IBankConnector {
|
|
|
1547
1606
|
const limit = 10;
|
|
1548
1607
|
let hasMoreData = true;
|
|
1549
1608
|
let pageNumber = 1;
|
|
1550
|
-
const baseRequestId = uuidv4();
|
|
1609
|
+
const baseRequestId = uuidv4().replace(/-/g, "");
|
|
1551
1610
|
while (hasMoreData) {
|
|
1552
1611
|
const response = await this.makeRequest(
|
|
1553
1612
|
"/required-transactions",
|
|
@@ -1573,7 +1632,7 @@ class DbuConnector extends IBankConnector {
|
|
|
1573
1632
|
}
|
|
1574
1633
|
for (const transaction of response.transactions.transaction) {
|
|
1575
1634
|
const status = transaction.status.trim();
|
|
1576
|
-
if (status === "0" || status === "50") continue;
|
|
1635
|
+
if (status === "0" || status === "50" || status === "51") continue;
|
|
1577
1636
|
try {
|
|
1578
1637
|
const payment = this.mapDbuTransactionToPayment(
|
|
1579
1638
|
transaction,
|
|
@@ -1886,6 +1945,7 @@ class ErsteConnector extends IBankConnector {
|
|
|
1886
1945
|
const paymentInsert = {
|
|
1887
1946
|
id: uuidv4(),
|
|
1888
1947
|
correlationId: uuidv4(),
|
|
1948
|
+
paymentRequestId: payment.entryDetails.transactionDetails.references.endToEndIdentification ?? null,
|
|
1889
1949
|
connectorKey: "ERSTE",
|
|
1890
1950
|
accountId: account.id,
|
|
1891
1951
|
bankRefId: payment.entryReference,
|
|
@@ -2027,4 +2087,4 @@ class MockConnector extends IBankConnector {
|
|
|
2027
2087
|
}
|
|
2028
2088
|
}
|
|
2029
2089
|
|
|
2030
|
-
export { CsobConnector as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, IBankConnector as I, KBConnector as K, MockCobsConnector as M, FinbricksClient as a, FinbricksConnector as b, MockConnector as c, assignAccount as d,
|
|
2090
|
+
export { CsobConnector as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, IBankConnector as I, KBConnector as K, MockCobsConnector as M, FinbricksClient as a, FinbricksConnector as b, MockConnector as c, assignAccount as d, toBatchedPaymentFromPaymentRequest as e, toCompletedPayment as f, toIncomingPayment as g, toPaymentRequestInsert as h, toPreparedPayment as i, initiateConnector as j, mapFinbricksTransactionStatus as m, signFinbricksJws as s, toBatchedPayment as t, useFinbricksFetch as u };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { sql, and, eq, isNull } from 'drizzle-orm';
|
|
1
2
|
import { uuidv4 } from '@develit-io/backend-sdk';
|
|
2
|
-
import
|
|
3
|
-
import './bank.C4VOdIx1.mjs';
|
|
3
|
+
import './bank.C0UN6luZ.mjs';
|
|
4
4
|
import 'date-fns';
|
|
5
5
|
import 'jose';
|
|
6
6
|
import '@develit-io/general-codes';
|
|
7
7
|
import { createHash } from 'node:crypto';
|
|
8
|
-
import { s as schema } from './bank.
|
|
8
|
+
import { s as schema } from './bank.CA5ytXxp.mjs';
|
|
9
|
+
import 'drizzle-orm/sqlite-core';
|
|
9
10
|
|
|
10
11
|
const createPaymentCommand = (db, { payment }) => {
|
|
11
12
|
return {
|
|
@@ -13,6 +14,21 @@ const createPaymentCommand = (db, { payment }) => {
|
|
|
13
14
|
...payment,
|
|
14
15
|
creditorIban: payment.creditor.iban,
|
|
15
16
|
debtorIban: payment.debtor.iban
|
|
17
|
+
}).onConflictDoUpdate({
|
|
18
|
+
// Unique index: (connector_key, bank_ref_id)
|
|
19
|
+
target: [tables.payment.connectorKey, tables.payment.bankRefId],
|
|
20
|
+
set: {
|
|
21
|
+
status: sql`excluded.status`,
|
|
22
|
+
statusReason: sql`excluded.status_reason`,
|
|
23
|
+
processedAt: sql`excluded.processed_at`,
|
|
24
|
+
updatedAt: sql`excluded.updated_at`,
|
|
25
|
+
// Keep existing paymentRequestId if already set, otherwise use new value
|
|
26
|
+
paymentRequestId: sql`coalesce(payment.payment_request_id, excluded.payment_request_id)`,
|
|
27
|
+
// Keep existing refId if already set, otherwise use enriched value
|
|
28
|
+
refId: sql`coalesce(payment.ref_id, excluded.ref_id)`,
|
|
29
|
+
// Keep existing batchId if already set, otherwise use enriched value
|
|
30
|
+
batchId: sql`coalesce(payment.bank_execution_batch_id, excluded.bank_execution_batch_id)`
|
|
31
|
+
}
|
|
16
32
|
}).returning()
|
|
17
33
|
};
|
|
18
34
|
};
|
|
@@ -37,7 +53,12 @@ const upsertBatchCommand = (db, { batch }) => {
|
|
|
37
53
|
const updatePaymentRequestStatusCommand = (db, values) => {
|
|
38
54
|
const { id, ...set } = values;
|
|
39
55
|
return {
|
|
40
|
-
command: db.update(tables.paymentRequest).set(set).where(
|
|
56
|
+
command: db.update(tables.paymentRequest).set(set).where(
|
|
57
|
+
and(
|
|
58
|
+
eq(tables.paymentRequest.id, id),
|
|
59
|
+
isNull(tables.paymentRequest.deletedAt)
|
|
60
|
+
)
|
|
61
|
+
).returning()
|
|
41
62
|
};
|
|
42
63
|
};
|
|
43
64
|
|
|
@@ -58,7 +79,12 @@ const getCredentialsByAccountId = async (db, encryptionKey, { accountId }) => {
|
|
|
58
79
|
};
|
|
59
80
|
|
|
60
81
|
const getPaymentRequestsByBatchIdQuery = async (db, { batchId }) => {
|
|
61
|
-
return await db.select().from(tables.paymentRequest).where(
|
|
82
|
+
return await db.select().from(tables.paymentRequest).where(
|
|
83
|
+
and(
|
|
84
|
+
eq(tables.paymentRequest.batchId, batchId),
|
|
85
|
+
isNull(tables.paymentRequest.deletedAt)
|
|
86
|
+
)
|
|
87
|
+
);
|
|
62
88
|
};
|
|
63
89
|
|
|
64
90
|
async function importAesKey(base64Key) {
|