@develit-services/bank 0.7.0 → 0.7.1
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/README.md +381 -0
- 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 +47 -36
- package/dist/export/worker.d.cts +378 -77
- package/dist/export/worker.d.mts +378 -77
- package/dist/export/worker.d.ts +378 -77
- package/dist/export/worker.mjs +47 -36
- package/dist/export/workflows.cjs +24 -9
- package/dist/export/workflows.mjs +24 -9
- package/dist/export/wrangler.cjs +7 -0
- package/dist/export/wrangler.d.cts +7 -1
- package/dist/export/wrangler.d.mts +7 -1
- package/dist/export/wrangler.d.ts +7 -1
- package/dist/export/wrangler.mjs +7 -0
- package/dist/shared/{bank.Coi0lSqK.d.cts → bank.BC06Rbrx.d.cts} +1 -0
- package/dist/shared/{bank.Coi0lSqK.d.mts → bank.BC06Rbrx.d.mts} +1 -0
- package/dist/shared/{bank.Coi0lSqK.d.ts → bank.BC06Rbrx.d.ts} +1 -0
- package/dist/shared/{bank.DLWegh_f.mjs → bank.BnIYdBEF.mjs} +9 -0
- package/dist/shared/bank.C6_7Rch8.d.cts +4755 -0
- package/dist/shared/bank.C6_7Rch8.d.mts +4755 -0
- package/dist/shared/bank.C6_7Rch8.d.ts +4755 -0
- package/dist/shared/{bank.DEvSNsEs.cjs → bank.CTqIXnHg.cjs} +2 -2
- package/dist/shared/{bank.DFIwAQqg.mjs → bank.CTtFAN03.mjs} +1 -1
- package/dist/shared/{bank.Dq27-5wD.mjs → bank.CkUMU1sJ.mjs} +365 -50
- package/dist/shared/{bank.BeIpkWR-.cjs → bank.D7kwLMqF.cjs} +9 -0
- package/dist/shared/{bank.c38V_FCq.cjs → bank.DlW1XNug.cjs} +1 -1
- package/dist/shared/{bank.pd7-Rbo-.mjs → bank.e8T8fQDG.mjs} +2 -2
- package/dist/shared/{bank.DNHA-HFP.cjs → bank.iEgK7rge.cjs} +365 -50
- package/dist/types.cjs +2 -2
- package/dist/types.d.cts +452 -40
- package/dist/types.d.mts +452 -40
- package/dist/types.d.ts +452 -40
- package/dist/types.mjs +2 -2
- package/package.json +1 -1
- package/dist/shared/bank.Vj1x4v-K.d.cts +0 -2515
- package/dist/shared/bank.Vj1x4v-K.d.mts +0 -2515
- package/dist/shared/bank.Vj1x4v-K.d.ts +0 -2515
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
4
|
const drizzleOrm = require('drizzle-orm');
|
|
5
|
-
const database_schema = require('./bank.
|
|
5
|
+
const database_schema = require('./bank.DlW1XNug.cjs');
|
|
6
6
|
require('date-fns');
|
|
7
7
|
require('@develit-io/general-codes');
|
|
8
8
|
require('jose');
|
|
9
|
-
require('./bank.
|
|
9
|
+
require('./bank.D7kwLMqF.cjs');
|
|
10
10
|
const node_crypto = require('node:crypto');
|
|
11
11
|
|
|
12
12
|
const createPaymentCommand = (db, { payment }) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as account, p as accountCredentials, q as batch, r as ott, s as payment, t as paymentRelations } from './bank.
|
|
1
|
+
import { n as account, p as accountCredentials, q as batch, r as ott, s as payment, t as paymentRelations } from './bank.BnIYdBEF.mjs';
|
|
2
2
|
|
|
3
3
|
const schema = {
|
|
4
4
|
__proto__: null,
|
|
@@ -1,12 +1,97 @@
|
|
|
1
1
|
import { uuidv4, useResult, createInternalError } 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.BnIYdBEF.mjs';
|
|
5
5
|
import 'drizzle-orm';
|
|
6
6
|
import { importPKCS8, SignJWT } from 'jose';
|
|
7
7
|
import 'node:crypto';
|
|
8
8
|
|
|
9
9
|
class IBankConnector {
|
|
10
|
+
// ── Deprecated methods (backward compatibility) ────────────────────
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use initiateDomesticBatch, initiateSEPABatch, or initiateForeignBatch instead.
|
|
13
|
+
* Delegates to initiateDomesticBatch for backward compatibility.
|
|
14
|
+
*/
|
|
15
|
+
initiateBatch(args) {
|
|
16
|
+
return this.initiateDomesticBatch(args);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use initiateDomesticPayment instead.
|
|
20
|
+
* Delegates to initiateDomesticPayment for backward compatibility.
|
|
21
|
+
*/
|
|
22
|
+
initiateSinglePayment(payment) {
|
|
23
|
+
return this.initiateDomesticPayment(payment);
|
|
24
|
+
}
|
|
25
|
+
// ── Batch methods ─────────────────────────────────────────────────
|
|
26
|
+
/**
|
|
27
|
+
* Initiates a batch of domestic payments with the bank.
|
|
28
|
+
* Falls back to single payments if batch not supported.
|
|
29
|
+
* @param batchId - Unique identifier for the batch
|
|
30
|
+
* @param payments - Array of domestic payments to include in the batch
|
|
31
|
+
* @returns Batch initiation result with authorization URLs and prepared payments
|
|
32
|
+
*/
|
|
33
|
+
async initiateDomesticBatch({
|
|
34
|
+
batchId,
|
|
35
|
+
payments
|
|
36
|
+
}) {
|
|
37
|
+
if (!this.supportsBatch("DOMESTIC")) {
|
|
38
|
+
const authorizationUrls = [];
|
|
39
|
+
const preparedPayments = [];
|
|
40
|
+
for (const payment of payments) {
|
|
41
|
+
const initiated = await this.initiateDomesticPayment(payment);
|
|
42
|
+
authorizationUrls.push(initiated.authorizationUrl);
|
|
43
|
+
preparedPayments.push(initiated.payment);
|
|
44
|
+
}
|
|
45
|
+
return { id: batchId, authorizationUrls, payments: preparedPayments };
|
|
46
|
+
}
|
|
47
|
+
return this.initiateDomesticBatchImpl({ batchId, payments });
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Initiates a batch of SEPA payments with the bank.
|
|
51
|
+
* Falls back to single payments if batch not supported.
|
|
52
|
+
* @param batchId - Unique identifier for the batch
|
|
53
|
+
* @param payments - Array of SEPA payments to include in the batch
|
|
54
|
+
* @returns Batch initiation result with authorization URLs and prepared payments
|
|
55
|
+
*/
|
|
56
|
+
async initiateSEPABatch({
|
|
57
|
+
batchId,
|
|
58
|
+
payments
|
|
59
|
+
}) {
|
|
60
|
+
if (!this.supportsBatch("SEPA")) {
|
|
61
|
+
const authorizationUrls = [];
|
|
62
|
+
const preparedPayments = [];
|
|
63
|
+
for (const payment of payments) {
|
|
64
|
+
const initiated = await this.initiateSEPAPayment(payment);
|
|
65
|
+
authorizationUrls.push(initiated.authorizationUrl);
|
|
66
|
+
preparedPayments.push(initiated.payment);
|
|
67
|
+
}
|
|
68
|
+
return { id: batchId, authorizationUrls, payments: preparedPayments };
|
|
69
|
+
}
|
|
70
|
+
return this.initiateSEPABatchImpl({ batchId, payments });
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Initiates a batch of foreign (SWIFT) payments with the bank.
|
|
74
|
+
* Falls back to single payments if batch not supported.
|
|
75
|
+
* @param batchId - Unique identifier for the batch
|
|
76
|
+
* @param payments - Array of foreign payments to include in the batch
|
|
77
|
+
* @returns Batch initiation result with authorization URLs and prepared payments
|
|
78
|
+
*/
|
|
79
|
+
async initiateForeignBatch({
|
|
80
|
+
batchId,
|
|
81
|
+
payments
|
|
82
|
+
}) {
|
|
83
|
+
if (!this.supportsBatch("SWIFT")) {
|
|
84
|
+
const authorizationUrls = [];
|
|
85
|
+
const preparedPayments = [];
|
|
86
|
+
for (const payment of payments) {
|
|
87
|
+
const initiated = await this.initiateForeignPayment(payment);
|
|
88
|
+
authorizationUrls.push(initiated.authorizationUrl);
|
|
89
|
+
preparedPayments.push(initiated.payment);
|
|
90
|
+
}
|
|
91
|
+
return { id: batchId, authorizationUrls, payments: preparedPayments };
|
|
92
|
+
}
|
|
93
|
+
return this.initiateForeignBatchImpl({ batchId, payments });
|
|
94
|
+
}
|
|
10
95
|
}
|
|
11
96
|
|
|
12
97
|
function toIncomingPayment(input) {
|
|
@@ -32,7 +117,9 @@ function toIncomingPayment(input) {
|
|
|
32
117
|
creditorIban: input.creditor.iban || null,
|
|
33
118
|
debtor: input.debtor,
|
|
34
119
|
debtorIban: input.debtor.iban || null,
|
|
35
|
-
sendAsSinglePayment: input.sendAsSinglePayment
|
|
120
|
+
sendAsSinglePayment: input.sendAsSinglePayment,
|
|
121
|
+
chargeBearer: input.chargeBearer,
|
|
122
|
+
instructionPriority: input.instructionPriority
|
|
36
123
|
};
|
|
37
124
|
}
|
|
38
125
|
function assignAccount(payment, account) {
|
|
@@ -270,21 +357,21 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
270
357
|
),
|
|
271
358
|
creditor: {
|
|
272
359
|
holderName: related?.creditorAccount?.name || related?.creditor?.name || "Unknown",
|
|
273
|
-
iban: isIncoming ? account.iban || void 0 : related
|
|
274
|
-
number: isIncoming ? account.number || void 0 : related
|
|
360
|
+
iban: isIncoming ? account.iban || void 0 : related?.creditorAccount?.identification?.iban || account.iban || void 0,
|
|
361
|
+
number: isIncoming ? account.number || void 0 : related?.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
|
|
275
362
|
"/"
|
|
276
363
|
)[0] : account.number || void 0,
|
|
277
|
-
bankCode: isIncoming ? account.bankCode || void 0 : related
|
|
364
|
+
bankCode: isIncoming ? account.bankCode || void 0 : related?.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
|
|
278
365
|
"/"
|
|
279
366
|
)[1] : account.bankCode || void 0
|
|
280
367
|
},
|
|
281
368
|
debtor: {
|
|
282
369
|
holderName: related?.debtorAccount?.name || related?.debtor?.name || "Unknown",
|
|
283
|
-
iban: isIncoming ? related
|
|
284
|
-
number: isIncoming ? related
|
|
370
|
+
iban: isIncoming ? related?.debtorAccount?.identification?.iban || account.iban || void 0 : account.iban ?? void 0,
|
|
371
|
+
number: isIncoming ? related?.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
|
|
285
372
|
"/"
|
|
286
373
|
)[0] : account.number || void 0 : account.number || void 0,
|
|
287
|
-
bankCode: isIncoming ? related
|
|
374
|
+
bankCode: isIncoming ? related?.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
|
|
288
375
|
"/"
|
|
289
376
|
)[1] : account.bankCode || void 0 : account.bankCode || void 0
|
|
290
377
|
},
|
|
@@ -452,7 +539,11 @@ class FinbricksConnector extends IBankConnector {
|
|
|
452
539
|
}
|
|
453
540
|
return response.accounts;
|
|
454
541
|
}
|
|
455
|
-
|
|
542
|
+
/**
|
|
543
|
+
* Native domestic batch implementation using Finbricks API.
|
|
544
|
+
* Called by base class when supportsBatch('DOMESTIC') returns true.
|
|
545
|
+
*/
|
|
546
|
+
async initiateDomesticBatchImpl({
|
|
456
547
|
batchId,
|
|
457
548
|
payments
|
|
458
549
|
}) {
|
|
@@ -501,6 +592,12 @@ class FinbricksConnector extends IBankConnector {
|
|
|
501
592
|
)
|
|
502
593
|
};
|
|
503
594
|
}
|
|
595
|
+
initiateSEPABatchImpl(_args) {
|
|
596
|
+
throw new Error("Finbricks: SEPA batch not implemented");
|
|
597
|
+
}
|
|
598
|
+
initiateForeignBatchImpl(_args) {
|
|
599
|
+
throw new Error("Finbricks: Foreign batch not implemented");
|
|
600
|
+
}
|
|
504
601
|
async initiateForeignPayment(payment) {
|
|
505
602
|
const bankRefId = uuidv4();
|
|
506
603
|
const [response, error] = await useResult(
|
|
@@ -521,8 +618,7 @@ class FinbricksConnector extends IBankConnector {
|
|
|
521
618
|
value: payment.amount,
|
|
522
619
|
currency: payment.currency
|
|
523
620
|
},
|
|
524
|
-
|
|
525
|
-
chargeBearer: "SHA",
|
|
621
|
+
chargeBearer: payment.chargeBearer || "SHA",
|
|
526
622
|
debtor: {
|
|
527
623
|
accountIdentification: {
|
|
528
624
|
type: "IBAN",
|
|
@@ -614,7 +710,7 @@ class FinbricksConnector extends IBankConnector {
|
|
|
614
710
|
}
|
|
615
711
|
};
|
|
616
712
|
}
|
|
617
|
-
async
|
|
713
|
+
async initiateDomesticPayment(payment) {
|
|
618
714
|
const [response, error] = await useResult(
|
|
619
715
|
this.finbricks.request({
|
|
620
716
|
endpoint: FINBRICKS_ENDPOINTS.TRANSACTION_INIT,
|
|
@@ -752,30 +848,56 @@ class AirBankConnector extends FinbricksConnector {
|
|
|
752
848
|
constructor(config) {
|
|
753
849
|
super("AIRBANK", config);
|
|
754
850
|
}
|
|
851
|
+
supportsBatch(paymentType) {
|
|
852
|
+
return paymentType === "DOMESTIC";
|
|
853
|
+
}
|
|
755
854
|
}
|
|
756
855
|
|
|
757
856
|
class CreditasConnector extends FinbricksConnector {
|
|
758
857
|
constructor(config) {
|
|
759
858
|
super("CREDITAS", config);
|
|
760
859
|
}
|
|
860
|
+
/**
|
|
861
|
+
* Creditas bank doesn't support batch payments at all.
|
|
862
|
+
*/
|
|
863
|
+
supportsBatch() {
|
|
864
|
+
return false;
|
|
865
|
+
}
|
|
761
866
|
}
|
|
762
867
|
|
|
763
868
|
class CSASConnector extends FinbricksConnector {
|
|
764
869
|
constructor(config) {
|
|
765
870
|
super("CSAS", config);
|
|
766
871
|
}
|
|
872
|
+
supportsBatch(paymentType) {
|
|
873
|
+
return paymentType === "DOMESTIC";
|
|
874
|
+
}
|
|
767
875
|
}
|
|
768
876
|
|
|
769
877
|
class FioConnector extends FinbricksConnector {
|
|
770
878
|
constructor(config) {
|
|
771
879
|
super("FIO", config);
|
|
772
880
|
}
|
|
881
|
+
/**
|
|
882
|
+
* FIO supports batch only for DOMESTIC (CZK) payments.
|
|
883
|
+
* SEPA and SWIFT batch support is planned by Finbricks.
|
|
884
|
+
*/
|
|
885
|
+
supportsBatch(paymentType) {
|
|
886
|
+
return paymentType === "DOMESTIC";
|
|
887
|
+
}
|
|
773
888
|
}
|
|
774
889
|
|
|
775
890
|
class MonetaConnector extends FinbricksConnector {
|
|
776
891
|
constructor(config) {
|
|
777
892
|
super("MONETA", config);
|
|
778
893
|
}
|
|
894
|
+
/**
|
|
895
|
+
* MONETA supports batch only for DOMESTIC (CZK) payments.
|
|
896
|
+
* SEPA and SWIFT batch support is planned by Finbricks.
|
|
897
|
+
*/
|
|
898
|
+
supportsBatch(paymentType) {
|
|
899
|
+
return paymentType === "DOMESTIC";
|
|
900
|
+
}
|
|
779
901
|
}
|
|
780
902
|
|
|
781
903
|
const isDeposit = (payment, creditorIban) => {
|
|
@@ -873,7 +995,11 @@ const initiateConnector = async ({
|
|
|
873
995
|
return new DbuConnector({
|
|
874
996
|
BASE_URL: env.DBUCS_BASE_URI,
|
|
875
997
|
USERNAME: env.DBUCS_USERNAME,
|
|
876
|
-
KV: env.BANK_KV
|
|
998
|
+
KV: env.BANK_KV,
|
|
999
|
+
API: env.DBU_CBS_BACKOFFICE_DEV,
|
|
1000
|
+
REDIRECT_URI: env.REDIRECT_URI,
|
|
1001
|
+
TX_AUTH_URI: env.DBUCS_TX_AUTH_URI,
|
|
1002
|
+
connectedAccounts
|
|
877
1003
|
});
|
|
878
1004
|
default:
|
|
879
1005
|
const mockConnector = new MockConnector();
|
|
@@ -909,15 +1035,34 @@ const calculateCzechIban = (accountNumber, bankCode) => {
|
|
|
909
1035
|
};
|
|
910
1036
|
|
|
911
1037
|
class DbuConnector extends IBankConnector {
|
|
912
|
-
constructor({
|
|
1038
|
+
constructor({
|
|
1039
|
+
BASE_URL,
|
|
1040
|
+
USERNAME,
|
|
1041
|
+
KV,
|
|
1042
|
+
API,
|
|
1043
|
+
REDIRECT_URI,
|
|
1044
|
+
TX_AUTH_URI,
|
|
1045
|
+
connectedAccounts
|
|
1046
|
+
}) {
|
|
913
1047
|
super();
|
|
914
1048
|
this.connectorKey = "DBU";
|
|
915
1049
|
this.connectedAccounts = [];
|
|
916
1050
|
this.baseUrl = BASE_URL;
|
|
917
1051
|
this.username = USERNAME;
|
|
918
1052
|
this.kv = KV;
|
|
1053
|
+
this.api = API;
|
|
1054
|
+
this.redirectUri = REDIRECT_URI;
|
|
1055
|
+
this.txAuthUri = TX_AUTH_URI;
|
|
1056
|
+
this.connectedAccounts = connectedAccounts;
|
|
919
1057
|
this.sessionId = uuidv4();
|
|
920
|
-
this.allowedPostEndpoints = [
|
|
1058
|
+
this.allowedPostEndpoints = [
|
|
1059
|
+
"/required-transactions",
|
|
1060
|
+
"/required-transactions/instant-payments",
|
|
1061
|
+
"/import/data"
|
|
1062
|
+
];
|
|
1063
|
+
}
|
|
1064
|
+
supportsBatch(_paymentType) {
|
|
1065
|
+
return false;
|
|
921
1066
|
}
|
|
922
1067
|
async makeRequest(endpoint, requestId, options = {}) {
|
|
923
1068
|
const { method = "GET", headers = {}, query = {}, body } = options;
|
|
@@ -927,13 +1072,11 @@ class DbuConnector extends IBankConnector {
|
|
|
927
1072
|
code: "DBU_INVALID_METHOD"
|
|
928
1073
|
});
|
|
929
1074
|
}
|
|
930
|
-
const auth = btoa("devizova_burza:Fu7psMt7i59ct43D5Y3s");
|
|
931
1075
|
const defaultHeaders = {
|
|
932
1076
|
"x-dcs-username": this.username,
|
|
933
1077
|
"x-dcs-session-id": `session-${this.sessionId}`,
|
|
934
1078
|
"x-dcs-request-id": `request-${requestId}`,
|
|
935
1079
|
"Content-Type": "application/json",
|
|
936
|
-
Authorization: `Basic ${auth}`,
|
|
937
1080
|
...headers
|
|
938
1081
|
};
|
|
939
1082
|
const baseUrl = this.baseUrl.endsWith("/") ? this.baseUrl.slice(0, -1) : this.baseUrl;
|
|
@@ -948,16 +1091,16 @@ class DbuConnector extends IBankConnector {
|
|
|
948
1091
|
method,
|
|
949
1092
|
headers: defaultHeaders
|
|
950
1093
|
};
|
|
951
|
-
console.log("DBU Request:", url.toString(), fetchOptions);
|
|
952
1094
|
if (body && method !== "GET") {
|
|
953
1095
|
fetchOptions.body = JSON.stringify(body);
|
|
954
1096
|
}
|
|
955
|
-
const response = await fetch(url.toString(), fetchOptions);
|
|
1097
|
+
const response = await this.api.fetch(url.toString(), fetchOptions);
|
|
956
1098
|
if (!response.ok) {
|
|
1099
|
+
const errorBody = await response.text().catch(() => "unable to read body");
|
|
957
1100
|
throw createInternalError(
|
|
958
1101
|
new Error(`DBU API error: ${response.status}`),
|
|
959
1102
|
{
|
|
960
|
-
message: `DBU request failed
|
|
1103
|
+
message: `DBU request failed [${response.status}]: ${errorBody}`
|
|
961
1104
|
}
|
|
962
1105
|
);
|
|
963
1106
|
}
|
|
@@ -989,7 +1132,7 @@ class DbuConnector extends IBankConnector {
|
|
|
989
1132
|
connectorKey: "DBU",
|
|
990
1133
|
accountId: account.id,
|
|
991
1134
|
bankRefId: transaction.idRequiredTransaction.toString(),
|
|
992
|
-
amount: transaction.realizedAmount
|
|
1135
|
+
amount: transaction.realizedAmount ?? transaction.amount,
|
|
993
1136
|
direction,
|
|
994
1137
|
paymentType: "DOMESTIC",
|
|
995
1138
|
//TODO: DBU handles domestic transactions only?
|
|
@@ -1103,41 +1246,176 @@ class DbuConnector extends IBankConnector {
|
|
|
1103
1246
|
}
|
|
1104
1247
|
}
|
|
1105
1248
|
async getAuthUri({ ott }) {
|
|
1106
|
-
|
|
1107
|
-
message: "DBU connector does not require authorization",
|
|
1108
|
-
code: "DBU_NO_AUTH_REQUIRED"
|
|
1109
|
-
});
|
|
1249
|
+
return `${this.redirectUri}?type=auth&ott=${ott}`;
|
|
1110
1250
|
}
|
|
1111
1251
|
async authorizeAccount({ urlParams }) {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1252
|
+
const params = new URLSearchParams(urlParams);
|
|
1253
|
+
const accountNumber = params.get("accountNumber");
|
|
1254
|
+
const bankCode = params.get("bankCode");
|
|
1255
|
+
const iban = params.get("iban");
|
|
1256
|
+
const name = params.get("name");
|
|
1257
|
+
const idAccount = params.get("idAccount");
|
|
1258
|
+
if (!accountNumber || !bankCode || !iban || !idAccount) {
|
|
1259
|
+
throw createInternalError(null, {
|
|
1260
|
+
message: "DBU: missing required params (accountNumber, bankCode, iban, idAccount)",
|
|
1261
|
+
code: "DBU_MISSING_PARAMS",
|
|
1262
|
+
status: 400
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
const id = uuidv4();
|
|
1266
|
+
const account = {
|
|
1267
|
+
id,
|
|
1268
|
+
connectorKey: "DBU",
|
|
1269
|
+
status: "AUTHORIZED",
|
|
1270
|
+
number: accountNumber,
|
|
1271
|
+
bankCode,
|
|
1272
|
+
iban,
|
|
1273
|
+
name: name || `DBU ${accountNumber}`,
|
|
1274
|
+
holderName: name || `DBU ${accountNumber}`,
|
|
1275
|
+
countryCode: "CZ",
|
|
1276
|
+
bankRefId: idAccount,
|
|
1277
|
+
currency: "CZK"
|
|
1115
1278
|
};
|
|
1279
|
+
const credentials = [
|
|
1280
|
+
{
|
|
1281
|
+
accountId: id,
|
|
1282
|
+
connectorKey: "DBU",
|
|
1283
|
+
type: "API_KEY",
|
|
1284
|
+
value: "dbu-tunnel-auth",
|
|
1285
|
+
expiresAt: new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1e3)
|
|
1286
|
+
// 10 years
|
|
1287
|
+
}
|
|
1288
|
+
];
|
|
1289
|
+
return { credentials, accounts: [account] };
|
|
1116
1290
|
}
|
|
1117
1291
|
async listAccounts() {
|
|
1118
1292
|
return [];
|
|
1119
1293
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1294
|
+
// ── Single payment methods ──────────────────────────────────────────
|
|
1295
|
+
resolveIdAccountDebit(payment) {
|
|
1296
|
+
const account = this.connectedAccounts.find(
|
|
1297
|
+
(acc) => acc.id === payment.accountId
|
|
1298
|
+
);
|
|
1299
|
+
if (!account) {
|
|
1300
|
+
throw createInternalError(null, {
|
|
1301
|
+
message: `No connected account found for accountId: ${payment.accountId}`,
|
|
1302
|
+
code: "DBU_ACCOUNT_NOT_FOUND"
|
|
1303
|
+
});
|
|
1304
|
+
}
|
|
1305
|
+
return Number(account.bankRefId);
|
|
1128
1306
|
}
|
|
1129
|
-
async
|
|
1307
|
+
async initiateInstantPayment(payment) {
|
|
1308
|
+
const body = {
|
|
1309
|
+
accountNumberCredit: payment.creditor.number,
|
|
1310
|
+
idAccountDebit: this.resolveIdAccountDebit(payment),
|
|
1311
|
+
bankCodeCredit: payment.creditor.bankCode,
|
|
1312
|
+
amount: payment.amount,
|
|
1313
|
+
currencyCode: "CZK",
|
|
1314
|
+
channelCode: "WWW",
|
|
1315
|
+
textMessage: payment.message,
|
|
1316
|
+
varSymbol: payment.vs,
|
|
1317
|
+
specSymbol: payment.ss,
|
|
1318
|
+
constSymbol: payment.ks,
|
|
1319
|
+
uniqueExternalId: payment.id
|
|
1320
|
+
};
|
|
1321
|
+
const response = await this.makeRequest(
|
|
1322
|
+
"/required-transactions/instant-payments",
|
|
1323
|
+
payment.correlationId,
|
|
1324
|
+
{
|
|
1325
|
+
method: "POST",
|
|
1326
|
+
body
|
|
1327
|
+
}
|
|
1328
|
+
);
|
|
1329
|
+
const bankRefId = response.idRequiredTransaction.toString();
|
|
1330
|
+
return {
|
|
1331
|
+
authorizationUrl: `${this.txAuthUri}/${bankRefId}`,
|
|
1332
|
+
payment: {
|
|
1333
|
+
...payment,
|
|
1334
|
+
status: "PREPARED",
|
|
1335
|
+
bankRefId
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
async initiateDomesticPayment(payment) {
|
|
1340
|
+
if (payment.instructionPriority === "INST") {
|
|
1341
|
+
return this.initiateInstantPayment(payment);
|
|
1342
|
+
}
|
|
1343
|
+
const body = {
|
|
1344
|
+
accountNumberDebit: payment.debtor.number,
|
|
1345
|
+
accountNumberCredit: payment.creditor.number,
|
|
1346
|
+
bankCodeDebit: payment.debtor.bankCode,
|
|
1347
|
+
bankCodeCredit: payment.creditor.bankCode,
|
|
1348
|
+
amount: payment.amount,
|
|
1349
|
+
currencyCode: "CZK",
|
|
1350
|
+
actionTypeCode: "TRANSFER",
|
|
1351
|
+
channelCode: "WWW",
|
|
1352
|
+
textMessage: payment.message,
|
|
1353
|
+
transactionTypeCode: "TRANSFER",
|
|
1354
|
+
validFrom: format(/* @__PURE__ */ new Date(), "yyyy-MM-dd"),
|
|
1355
|
+
validTo: null,
|
|
1356
|
+
subEntity: "DOMESTIC",
|
|
1357
|
+
partialRealization: "N",
|
|
1358
|
+
forceRealization: "N",
|
|
1359
|
+
varSymbol: payment.vs,
|
|
1360
|
+
specSymbol: payment.ss,
|
|
1361
|
+
constSymbol: payment.ks,
|
|
1362
|
+
uniqueExternalId: payment.id,
|
|
1363
|
+
with4EyeApproval: "Y",
|
|
1364
|
+
debtorAddress: {
|
|
1365
|
+
streetName: null,
|
|
1366
|
+
buildingNumber: null,
|
|
1367
|
+
city: null,
|
|
1368
|
+
zip: null,
|
|
1369
|
+
countryCode: payment.debtor.countryCode || "CZ"
|
|
1370
|
+
},
|
|
1371
|
+
creditorAddress: {
|
|
1372
|
+
streetName: null,
|
|
1373
|
+
buildingNumber: null,
|
|
1374
|
+
city: null,
|
|
1375
|
+
zip: null,
|
|
1376
|
+
countryCode: payment.creditor.countryCode || "CZ"
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
const response = await this.makeRequest(
|
|
1380
|
+
"/required-transactions",
|
|
1381
|
+
payment.correlationId,
|
|
1382
|
+
{
|
|
1383
|
+
method: "POST",
|
|
1384
|
+
body
|
|
1385
|
+
}
|
|
1386
|
+
);
|
|
1387
|
+
const bankRefId = response.idRequiredTransaction.toString();
|
|
1388
|
+
return {
|
|
1389
|
+
authorizationUrl: `${this.txAuthUri}/${bankRefId}`,
|
|
1390
|
+
payment: {
|
|
1391
|
+
...payment,
|
|
1392
|
+
status: "PREPARED",
|
|
1393
|
+
bankRefId
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
async initiateSEPAPayment(_payment) {
|
|
1130
1398
|
throw createInternalError(null, {
|
|
1131
|
-
message: "DBU SEPA payment
|
|
1399
|
+
message: "DBU SEPA payment not implemented yet",
|
|
1132
1400
|
code: "DBU_SEPA_PAYMENT_NOT_IMPLEMENTED"
|
|
1133
1401
|
});
|
|
1134
1402
|
}
|
|
1135
|
-
async
|
|
1403
|
+
async initiateForeignPayment(_payment) {
|
|
1136
1404
|
throw createInternalError(null, {
|
|
1137
|
-
message: "DBU
|
|
1138
|
-
code: "
|
|
1405
|
+
message: "DBU foreign payment not implemented yet",
|
|
1406
|
+
code: "DBU_FOREIGN_PAYMENT_NOT_IMPLEMENTED"
|
|
1139
1407
|
});
|
|
1140
1408
|
}
|
|
1409
|
+
// ── Batch implementation methods ─────────────────────────────────────
|
|
1410
|
+
initiateDomesticBatchImpl(_args) {
|
|
1411
|
+
throw new Error("DBU: Domestic batch not implemented");
|
|
1412
|
+
}
|
|
1413
|
+
initiateSEPABatchImpl(_args) {
|
|
1414
|
+
throw new Error("DBU: SEPA batch not implemented");
|
|
1415
|
+
}
|
|
1416
|
+
initiateForeignBatchImpl(_args) {
|
|
1417
|
+
throw new Error("DBU: Foreign batch not implemented");
|
|
1418
|
+
}
|
|
1141
1419
|
async getAllAccountPayments({
|
|
1142
1420
|
account,
|
|
1143
1421
|
filter
|
|
@@ -1158,7 +1436,10 @@ class DbuConnector extends IBankConnector {
|
|
|
1158
1436
|
{
|
|
1159
1437
|
method: "GET",
|
|
1160
1438
|
query: {
|
|
1439
|
+
// Filter by account
|
|
1440
|
+
// 'filter.mainAccount': account.number!,
|
|
1161
1441
|
// Date filtering
|
|
1442
|
+
"filter.idAccount": account.bankRefId,
|
|
1162
1443
|
"filter.validFromStart": dateFrom,
|
|
1163
1444
|
"filter.validFromEnd": dateTo,
|
|
1164
1445
|
// Pagination parameters
|
|
@@ -1172,6 +1453,8 @@ class DbuConnector extends IBankConnector {
|
|
|
1172
1453
|
break;
|
|
1173
1454
|
}
|
|
1174
1455
|
for (const transaction of response.transactions.transaction) {
|
|
1456
|
+
const status = transaction.status.trim();
|
|
1457
|
+
if (status === "0" || status === "50") continue;
|
|
1175
1458
|
try {
|
|
1176
1459
|
const payment = this.mapDbuTransactionToPayment(
|
|
1177
1460
|
transaction,
|
|
@@ -1188,7 +1471,6 @@ class DbuConnector extends IBankConnector {
|
|
|
1188
1471
|
offset += limit;
|
|
1189
1472
|
pageNumber += 1;
|
|
1190
1473
|
}
|
|
1191
|
-
hasMoreData = false;
|
|
1192
1474
|
}
|
|
1193
1475
|
return allPayments;
|
|
1194
1476
|
} catch (error) {
|
|
@@ -1200,7 +1482,11 @@ class DbuConnector extends IBankConnector {
|
|
|
1200
1482
|
async getPaymentStatus({
|
|
1201
1483
|
paymentId
|
|
1202
1484
|
}) {
|
|
1203
|
-
|
|
1485
|
+
const response = await this.makeRequest(
|
|
1486
|
+
`/required-transactions/${paymentId}`,
|
|
1487
|
+
uuidv4()
|
|
1488
|
+
);
|
|
1489
|
+
return this.mapDbuStatusToPaymentStatus(response.status);
|
|
1204
1490
|
}
|
|
1205
1491
|
async getBatchStatus({
|
|
1206
1492
|
batchId
|
|
@@ -1226,9 +1512,18 @@ class ErsteConnector extends IBankConnector {
|
|
|
1226
1512
|
this.ACCOUNTS_URI = config.ACCOUNTS_URI;
|
|
1227
1513
|
this.connectedAccounts = config.connectedAccounts;
|
|
1228
1514
|
}
|
|
1229
|
-
|
|
1515
|
+
initiateDomesticPayment(_payment) {
|
|
1516
|
+
throw new Error("Method not implemented.");
|
|
1517
|
+
}
|
|
1518
|
+
initiateSEPAPayment(_payment) {
|
|
1519
|
+
throw new Error("Method not implemented.");
|
|
1520
|
+
}
|
|
1521
|
+
initiateForeignPayment(_payment) {
|
|
1230
1522
|
throw new Error("Method not implemented.");
|
|
1231
1523
|
}
|
|
1524
|
+
supportsBatch(paymentType) {
|
|
1525
|
+
return paymentType === "DOMESTIC";
|
|
1526
|
+
}
|
|
1232
1527
|
async getAuthUri({ ott }) {
|
|
1233
1528
|
const params = new URLSearchParams({
|
|
1234
1529
|
redirect_uri: `${this.REDIRECT_URI}?&ott=${ott}`,
|
|
@@ -1352,7 +1647,7 @@ class ErsteConnector extends IBankConnector {
|
|
|
1352
1647
|
connectorKey: "ERSTE"
|
|
1353
1648
|
};
|
|
1354
1649
|
}
|
|
1355
|
-
async
|
|
1650
|
+
async initiateDomesticBatchImpl({
|
|
1356
1651
|
batchId,
|
|
1357
1652
|
payments
|
|
1358
1653
|
}) {
|
|
@@ -1390,8 +1685,11 @@ class ErsteConnector extends IBankConnector {
|
|
|
1390
1685
|
metadata: signInfo
|
|
1391
1686
|
};
|
|
1392
1687
|
}
|
|
1393
|
-
|
|
1394
|
-
throw new Error("
|
|
1688
|
+
initiateSEPABatchImpl(_args) {
|
|
1689
|
+
throw new Error("Erste: SEPA batch not implemented");
|
|
1690
|
+
}
|
|
1691
|
+
initiateForeignBatchImpl(_args) {
|
|
1692
|
+
throw new Error("Erste: Foreign batch not implemented");
|
|
1395
1693
|
}
|
|
1396
1694
|
async sendBatchPaymentForAuthorization(paymentIds) {
|
|
1397
1695
|
const [data, error] = await useResult(
|
|
@@ -1525,6 +1823,9 @@ class MockCobsConnector extends FinbricksConnector {
|
|
|
1525
1823
|
constructor(config) {
|
|
1526
1824
|
super("MOCK_COBS", config);
|
|
1527
1825
|
}
|
|
1826
|
+
supportsBatch(_paymentType) {
|
|
1827
|
+
return true;
|
|
1828
|
+
}
|
|
1528
1829
|
}
|
|
1529
1830
|
|
|
1530
1831
|
class MockConnector extends IBankConnector {
|
|
@@ -1533,6 +1834,9 @@ class MockConnector extends IBankConnector {
|
|
|
1533
1834
|
this.connectorKey = "MOCK";
|
|
1534
1835
|
this.connectedAccounts = [];
|
|
1535
1836
|
}
|
|
1837
|
+
supportsBatch(_paymentType) {
|
|
1838
|
+
return true;
|
|
1839
|
+
}
|
|
1536
1840
|
async getAuthUri({
|
|
1537
1841
|
accountId
|
|
1538
1842
|
}) {
|
|
@@ -1544,7 +1848,8 @@ class MockConnector extends IBankConnector {
|
|
|
1544
1848
|
accounts: []
|
|
1545
1849
|
};
|
|
1546
1850
|
}
|
|
1547
|
-
|
|
1851
|
+
// ── Single payment methods ──────────────────────────────────────────
|
|
1852
|
+
async initiateDomesticPayment(payment) {
|
|
1548
1853
|
const preparedPayment = {
|
|
1549
1854
|
...payment,
|
|
1550
1855
|
bankRefId: uuidv4(),
|
|
@@ -1557,9 +1862,13 @@ class MockConnector extends IBankConnector {
|
|
|
1557
1862
|
};
|
|
1558
1863
|
}
|
|
1559
1864
|
async initiateSEPAPayment(payment) {
|
|
1560
|
-
return this.
|
|
1865
|
+
return this.initiateDomesticPayment(payment);
|
|
1561
1866
|
}
|
|
1562
|
-
async
|
|
1867
|
+
async initiateForeignPayment(payment) {
|
|
1868
|
+
return this.initiateDomesticPayment(payment);
|
|
1869
|
+
}
|
|
1870
|
+
// ── Batch implementation methods ─────────────────────────────────────
|
|
1871
|
+
async initiateDomesticBatchImpl({
|
|
1563
1872
|
batchId,
|
|
1564
1873
|
payments
|
|
1565
1874
|
}) {
|
|
@@ -1575,6 +1884,12 @@ class MockConnector extends IBankConnector {
|
|
|
1575
1884
|
payments: preparedPayments
|
|
1576
1885
|
};
|
|
1577
1886
|
}
|
|
1887
|
+
initiateSEPABatchImpl(args) {
|
|
1888
|
+
return this.initiateDomesticBatchImpl(args);
|
|
1889
|
+
}
|
|
1890
|
+
initiateForeignBatchImpl(args) {
|
|
1891
|
+
return this.initiateDomesticBatchImpl(args);
|
|
1892
|
+
}
|
|
1578
1893
|
async getAllAccountPayments({
|
|
1579
1894
|
account: _account,
|
|
1580
1895
|
filter: _filter
|