@develit-services/bank 0.7.0 → 0.7.2

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