@develit-services/bank 0.8.19 → 1.0.0
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 +33 -0
- package/dist/database/schema.cjs +10 -10
- package/dist/database/schema.d.cts +2 -1
- package/dist/database/schema.d.mts +2 -1
- package/dist/database/schema.d.ts +2 -1
- package/dist/database/schema.mjs +2 -2
- package/dist/export/worker.cjs +170 -175
- package/dist/export/worker.d.cts +2089 -945
- package/dist/export/worker.d.mts +2089 -945
- package/dist/export/worker.d.ts +2089 -945
- package/dist/export/worker.mjs +54 -59
- package/dist/export/workflows.cjs +33 -47
- package/dist/export/workflows.mjs +8 -22
- package/dist/export/wrangler.d.cts +2 -1
- package/dist/export/wrangler.d.mts +2 -1
- package/dist/export/wrangler.d.ts +2 -1
- package/dist/shared/{bank.B6dkPRYF.mjs → bank.B4EjD9Ok.mjs} +47 -9
- package/dist/shared/{bank.xB9eTN77.mjs → bank.B9-zZrEf.mjs} +2 -5
- package/dist/shared/{bank.C75Z9vML.cjs → bank.BXGLMl7o.cjs} +47 -9
- package/dist/shared/{bank.Cev1E9sk.cjs → bank.BbltNpz3.cjs} +14 -18
- package/dist/shared/{bank.DMjtitKo.d.cts → bank.CVJosema.d.cts} +1 -0
- package/dist/shared/{bank.DMjtitKo.d.mts → bank.CVJosema.d.mts} +1 -0
- package/dist/shared/{bank.DMjtitKo.d.ts → bank.CVJosema.d.ts} +1 -0
- package/dist/shared/{bank.CXBeULUL.mjs → bank.CiB2ECAF.mjs} +60 -7
- package/dist/shared/{bank.DzxhtOpm.d.mts → bank.DAfpDA5W.d.mts} +890 -17
- package/dist/shared/{bank.D8BIM2O3.d.cts → bank.DB0MCjZ8.d.cts} +1800 -1635
- package/dist/shared/{bank.D8BIM2O3.d.mts → bank.DB0MCjZ8.d.mts} +1800 -1635
- package/dist/shared/{bank.D8BIM2O3.d.ts → bank.DB0MCjZ8.d.ts} +1800 -1635
- package/dist/shared/{bank.UJe0t85A.d.cts → bank.DaEiUdrR.d.ts} +890 -17
- package/dist/shared/{bank.BsIiXsFH.cjs → bank.NF8bZBy0.cjs} +0 -9
- package/dist/shared/{bank.BBXoZ5QU.cjs → bank.Qg6TA8fX.cjs} +65 -5
- package/dist/shared/{bank.vz1uqEYa.mjs → bank.XqSw509X.mjs} +1 -8
- package/dist/shared/{bank.C695fceV.d.ts → bank.n1wkvbjN.d.cts} +890 -17
- package/dist/types.cjs +32 -29
- package/dist/types.d.cts +13 -8
- package/dist/types.d.mts +13 -8
- package/dist/types.d.ts +13 -8
- package/dist/types.mjs +4 -4
- package/package.json +1 -1
- package/dist/shared/bank.CR0UlyRi.mjs +0 -15
- package/dist/shared/bank.CVi6R7fr.cjs +0 -17
|
@@ -1,7 +1,7 @@
|
|
|
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.CiB2ECAF.mjs';
|
|
5
5
|
import 'drizzle-orm';
|
|
6
6
|
import { importPKCS8, SignJWT } from 'jose';
|
|
7
7
|
import 'node:crypto';
|
|
@@ -496,7 +496,14 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
496
496
|
)[0] : account.number || void 0,
|
|
497
497
|
bankCode: isIncoming ? account.bankCode || void 0 : related?.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
|
|
498
498
|
"/"
|
|
499
|
-
)[1] : account.bankCode || void 0
|
|
499
|
+
)[1] : account.bankCode || void 0,
|
|
500
|
+
address: related?.creditor?.postalAddress ? {
|
|
501
|
+
streetName: related.creditor.postalAddress.streetName,
|
|
502
|
+
buildingNumber: related.creditor.postalAddress.buildingNumber,
|
|
503
|
+
city: related.creditor.postalAddress.townName,
|
|
504
|
+
postalCode: related.creditor.postalAddress.postCode,
|
|
505
|
+
countryCode: related.creditor.postalAddress.country
|
|
506
|
+
} : void 0
|
|
500
507
|
},
|
|
501
508
|
debtor: {
|
|
502
509
|
holderName: related?.debtorAccount?.name || related?.debtor?.name || "Unknown",
|
|
@@ -506,7 +513,14 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
506
513
|
)[0] : account.number || void 0 : account.number || void 0,
|
|
507
514
|
bankCode: isIncoming ? related?.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
|
|
508
515
|
"/"
|
|
509
|
-
)[1] : account.bankCode || void 0 : account.bankCode || void 0
|
|
516
|
+
)[1] : account.bankCode || void 0 : account.bankCode || void 0,
|
|
517
|
+
address: related?.debtor?.postalAddress ? {
|
|
518
|
+
streetName: related.debtor.postalAddress.streetName,
|
|
519
|
+
buildingNumber: related.debtor.postalAddress.buildingNumber,
|
|
520
|
+
city: related.debtor.postalAddress.townName,
|
|
521
|
+
postalCode: related.debtor.postalAddress.postCode,
|
|
522
|
+
countryCode: related.debtor.postalAddress.country
|
|
523
|
+
} : void 0
|
|
510
524
|
},
|
|
511
525
|
direction: isIncoming ? "INCOMING" : "OUTGOING"
|
|
512
526
|
};
|
|
@@ -520,6 +534,15 @@ function autoVariableSymbol(paymentId) {
|
|
|
520
534
|
}
|
|
521
535
|
return String(Math.abs(hash) % 1e10).padStart(10, "0");
|
|
522
536
|
}
|
|
537
|
+
function mapToFinbricksAddress(addr) {
|
|
538
|
+
if (!addr) return void 0;
|
|
539
|
+
return {
|
|
540
|
+
...addr.streetName && { streetName: addr.streetName },
|
|
541
|
+
...addr.buildingNumber && { buildingNumber: addr.buildingNumber },
|
|
542
|
+
...addr.city && { town: addr.city },
|
|
543
|
+
...addr.countryCode && { country: addr.countryCode }
|
|
544
|
+
};
|
|
545
|
+
}
|
|
523
546
|
class FinbricksConnector extends IBankConnector {
|
|
524
547
|
constructor(provider, {
|
|
525
548
|
BASE_URI,
|
|
@@ -767,6 +790,7 @@ class FinbricksConnector extends IBankConnector {
|
|
|
767
790
|
(acc) => acc.iban === payment.debtorIban
|
|
768
791
|
);
|
|
769
792
|
const clientId = await this.getClientId(debtorAccount.id);
|
|
793
|
+
const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
|
|
770
794
|
const bankRefId = uuidv4();
|
|
771
795
|
const [response, error] = await useResult(
|
|
772
796
|
this.finbricks.request({
|
|
@@ -798,7 +822,8 @@ class FinbricksConnector extends IBankConnector {
|
|
|
798
822
|
type: "IBAN",
|
|
799
823
|
value: payment.creditor.iban
|
|
800
824
|
},
|
|
801
|
-
creditorName: payment.creditor.holderName || ""
|
|
825
|
+
creditorName: payment.creditor.holderName || "",
|
|
826
|
+
...creditorAddress && { postalAddress: creditorAddress }
|
|
802
827
|
},
|
|
803
828
|
callbackUrl: `${this.finbricks.REDIRECT_URI}?type=paymentRequest&paymentRequestId=${payment.id}`
|
|
804
829
|
}
|
|
@@ -830,6 +855,7 @@ class FinbricksConnector extends IBankConnector {
|
|
|
830
855
|
(acc) => acc.iban === payment.debtorIban
|
|
831
856
|
);
|
|
832
857
|
const clientId = await this.getClientId(debtorAccount.id);
|
|
858
|
+
const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
|
|
833
859
|
const bankRefId = uuidv4();
|
|
834
860
|
const [response, error] = await useResult(
|
|
835
861
|
this.finbricks.request({
|
|
@@ -852,7 +878,8 @@ class FinbricksConnector extends IBankConnector {
|
|
|
852
878
|
},
|
|
853
879
|
creditor: {
|
|
854
880
|
creditorAccountIban: payment.creditor.iban,
|
|
855
|
-
creditorName: payment.creditor.holderName
|
|
881
|
+
creditorName: payment.creditor.holderName,
|
|
882
|
+
...creditorAddress && { postalAddress: creditorAddress }
|
|
856
883
|
},
|
|
857
884
|
callbackUrl: `${this.finbricks.REDIRECT_URI}?type=paymentRequest&paymentRequestId=${payment.id}`
|
|
858
885
|
}
|
|
@@ -1212,6 +1239,7 @@ const initiateConnector = async ({
|
|
|
1212
1239
|
return new DbuConnector({
|
|
1213
1240
|
BASE_URL: env.DBUCS_BASE_URI,
|
|
1214
1241
|
USERNAME: env.DBUCS_USERNAME,
|
|
1242
|
+
APPLICATION_CODE: env.DBUCS_APPLICATION_CODE,
|
|
1215
1243
|
KV: env.BANK_KV,
|
|
1216
1244
|
API: env.DBU_CBS_BACKOFFICE_DEV,
|
|
1217
1245
|
REDIRECT_URI: env.REDIRECT_URI,
|
|
@@ -1271,6 +1299,7 @@ class DbuConnector extends IBankConnector {
|
|
|
1271
1299
|
constructor({
|
|
1272
1300
|
BASE_URL,
|
|
1273
1301
|
USERNAME,
|
|
1302
|
+
APPLICATION_CODE,
|
|
1274
1303
|
KV,
|
|
1275
1304
|
API,
|
|
1276
1305
|
REDIRECT_URI,
|
|
@@ -1282,6 +1311,7 @@ class DbuConnector extends IBankConnector {
|
|
|
1282
1311
|
this.connectedAccounts = [];
|
|
1283
1312
|
this.baseUrl = BASE_URL;
|
|
1284
1313
|
this.username = USERNAME;
|
|
1314
|
+
this.applicationCode = APPLICATION_CODE;
|
|
1285
1315
|
this.kv = KV;
|
|
1286
1316
|
this.api = API;
|
|
1287
1317
|
this.redirectUri = REDIRECT_URI;
|
|
@@ -1381,11 +1411,13 @@ class DbuConnector extends IBankConnector {
|
|
|
1381
1411
|
number: transaction.accountNumberCredit,
|
|
1382
1412
|
bankCode: transaction.bankCodeCredit,
|
|
1383
1413
|
iban: creditorIban
|
|
1414
|
+
// Note: DBU API does not provide address data in transaction responses
|
|
1384
1415
|
},
|
|
1385
1416
|
debtor: {
|
|
1386
1417
|
number: transaction.accountNumberDebit,
|
|
1387
1418
|
bankCode: transaction.bankCodeDebit,
|
|
1388
1419
|
iban: debtorIban
|
|
1420
|
+
// Note: DBU API does not provide address data in transaction responses
|
|
1389
1421
|
},
|
|
1390
1422
|
debtorIban
|
|
1391
1423
|
};
|
|
@@ -1543,7 +1575,8 @@ class DbuConnector extends IBankConnector {
|
|
|
1543
1575
|
specSymbol: payment.ss,
|
|
1544
1576
|
constSymbol: payment.ks,
|
|
1545
1577
|
uniqueExternalId: payment.id,
|
|
1546
|
-
standardPaymentFallback: "N"
|
|
1578
|
+
standardPaymentFallback: "N",
|
|
1579
|
+
applicationCode: this.applicationCode
|
|
1547
1580
|
};
|
|
1548
1581
|
const response = await this.makeRequest(
|
|
1549
1582
|
"/required-transactions/instant-payments",
|
|
@@ -1554,11 +1587,12 @@ class DbuConnector extends IBankConnector {
|
|
|
1554
1587
|
}
|
|
1555
1588
|
);
|
|
1556
1589
|
const bankRefId = response.idRequiredTransaction.toString();
|
|
1590
|
+
const status = this.mapDbuStatusToPaymentRequestStatus(response.status);
|
|
1557
1591
|
return {
|
|
1558
1592
|
authorizationUrl: `${this.txAuthUri}/${bankRefId}`,
|
|
1559
1593
|
payment: {
|
|
1560
1594
|
...payment,
|
|
1561
|
-
status
|
|
1595
|
+
status,
|
|
1562
1596
|
bankRefId
|
|
1563
1597
|
}
|
|
1564
1598
|
};
|
|
@@ -1589,7 +1623,8 @@ class DbuConnector extends IBankConnector {
|
|
|
1589
1623
|
specSymbol: payment.ss,
|
|
1590
1624
|
constSymbol: payment.ks,
|
|
1591
1625
|
uniqueExternalId: payment.id,
|
|
1592
|
-
with4EyeApproval: "Y"
|
|
1626
|
+
with4EyeApproval: "Y",
|
|
1627
|
+
applicationCode: this.applicationCode
|
|
1593
1628
|
};
|
|
1594
1629
|
const response = await this.makeRequest(
|
|
1595
1630
|
"/required-transactions",
|
|
@@ -1600,11 +1635,12 @@ class DbuConnector extends IBankConnector {
|
|
|
1600
1635
|
}
|
|
1601
1636
|
);
|
|
1602
1637
|
const bankRefId = response.idRequiredTransaction.toString();
|
|
1638
|
+
const status = this.mapDbuStatusToPaymentRequestStatus(response.status);
|
|
1603
1639
|
return {
|
|
1604
1640
|
authorizationUrl: `${this.txAuthUri}/${bankRefId}`,
|
|
1605
1641
|
payment: {
|
|
1606
1642
|
...payment,
|
|
1607
|
-
status
|
|
1643
|
+
status,
|
|
1608
1644
|
bankRefId
|
|
1609
1645
|
}
|
|
1610
1646
|
};
|
|
@@ -2007,6 +2043,7 @@ class ErsteConnector extends IBankConnector {
|
|
|
2007
2043
|
bankCode: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.debtorAccount.identification.other.identification.split(
|
|
2008
2044
|
"/"
|
|
2009
2045
|
)[1] : void 0
|
|
2046
|
+
// Note: Erste API does not provide postalAddress in transaction responses
|
|
2010
2047
|
},
|
|
2011
2048
|
creditor: {
|
|
2012
2049
|
holderName: payment.entryDetails.transactionDetails.relatedParties.creditor?.name,
|
|
@@ -2017,6 +2054,7 @@ class ErsteConnector extends IBankConnector {
|
|
|
2017
2054
|
bankCode: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.creditorAccount.identification.other.identification.split(
|
|
2018
2055
|
"/"
|
|
2019
2056
|
)[1] : void 0
|
|
2057
|
+
// Note: Erste API does not provide postalAddress in transaction responses
|
|
2020
2058
|
},
|
|
2021
2059
|
paymentType: "DOMESTIC",
|
|
2022
2060
|
direction: "INCOMING",
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { sql, and, eq, isNull } from 'drizzle-orm';
|
|
2
|
+
import { v as tables } from './bank.CiB2ECAF.mjs';
|
|
2
3
|
import { uuidv4 } from '@develit-io/backend-sdk';
|
|
3
|
-
import './bank.CXBeULUL.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.CR0UlyRi.mjs';
|
|
9
8
|
|
|
10
9
|
const createPaymentCommand = (db, { payment }) => {
|
|
11
10
|
return {
|
|
@@ -142,6 +141,4 @@ const createCredentialsResolver = async (db, env) => {
|
|
|
142
141
|
return (accountId) => getCredentialsByAccountId(db, encryptionKey, { accountId });
|
|
143
142
|
};
|
|
144
143
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
export { getPaymentRequestsByBatchIdQuery as a, getAccountByIdQuery as b, checksum as c, createCredentialsResolver as d, updatePaymentRequestStatusCommand as e, createPaymentCommand as f, getBatchByIdQuery as g, encrypt as h, importAesKey as i, tables as t, upsertBatchCommand as u };
|
|
144
|
+
export { getPaymentRequestsByBatchIdQuery as a, getAccountByIdQuery as b, checksum as c, createCredentialsResolver as d, updatePaymentRequestStatusCommand as e, createPaymentCommand as f, getBatchByIdQuery as g, encrypt as h, importAesKey as i, upsertBatchCommand as u };
|
|
@@ -3,7 +3,7 @@
|
|
|
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.
|
|
6
|
+
require('./bank.Qg6TA8fX.cjs');
|
|
7
7
|
require('drizzle-orm');
|
|
8
8
|
const jose = require('jose');
|
|
9
9
|
require('node:crypto');
|
|
@@ -498,7 +498,14 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
498
498
|
)[0] : account.number || void 0,
|
|
499
499
|
bankCode: isIncoming ? account.bankCode || void 0 : related?.creditorAccount?.identification?.other?.identification ? related.creditorAccount.identification.other.identification.split(
|
|
500
500
|
"/"
|
|
501
|
-
)[1] : account.bankCode || void 0
|
|
501
|
+
)[1] : account.bankCode || void 0,
|
|
502
|
+
address: related?.creditor?.postalAddress ? {
|
|
503
|
+
streetName: related.creditor.postalAddress.streetName,
|
|
504
|
+
buildingNumber: related.creditor.postalAddress.buildingNumber,
|
|
505
|
+
city: related.creditor.postalAddress.townName,
|
|
506
|
+
postalCode: related.creditor.postalAddress.postCode,
|
|
507
|
+
countryCode: related.creditor.postalAddress.country
|
|
508
|
+
} : void 0
|
|
502
509
|
},
|
|
503
510
|
debtor: {
|
|
504
511
|
holderName: related?.debtorAccount?.name || related?.debtor?.name || "Unknown",
|
|
@@ -508,7 +515,14 @@ const mapFinbricksTransactionToPayment = (tx, account) => {
|
|
|
508
515
|
)[0] : account.number || void 0 : account.number || void 0,
|
|
509
516
|
bankCode: isIncoming ? related?.debtorAccount?.identification?.other?.identification ? related.debtorAccount.identification.other.identification.split(
|
|
510
517
|
"/"
|
|
511
|
-
)[1] : account.bankCode || void 0 : account.bankCode || void 0
|
|
518
|
+
)[1] : account.bankCode || void 0 : account.bankCode || void 0,
|
|
519
|
+
address: related?.debtor?.postalAddress ? {
|
|
520
|
+
streetName: related.debtor.postalAddress.streetName,
|
|
521
|
+
buildingNumber: related.debtor.postalAddress.buildingNumber,
|
|
522
|
+
city: related.debtor.postalAddress.townName,
|
|
523
|
+
postalCode: related.debtor.postalAddress.postCode,
|
|
524
|
+
countryCode: related.debtor.postalAddress.country
|
|
525
|
+
} : void 0
|
|
512
526
|
},
|
|
513
527
|
direction: isIncoming ? "INCOMING" : "OUTGOING"
|
|
514
528
|
};
|
|
@@ -522,6 +536,15 @@ function autoVariableSymbol(paymentId) {
|
|
|
522
536
|
}
|
|
523
537
|
return String(Math.abs(hash) % 1e10).padStart(10, "0");
|
|
524
538
|
}
|
|
539
|
+
function mapToFinbricksAddress(addr) {
|
|
540
|
+
if (!addr) return void 0;
|
|
541
|
+
return {
|
|
542
|
+
...addr.streetName && { streetName: addr.streetName },
|
|
543
|
+
...addr.buildingNumber && { buildingNumber: addr.buildingNumber },
|
|
544
|
+
...addr.city && { town: addr.city },
|
|
545
|
+
...addr.countryCode && { country: addr.countryCode }
|
|
546
|
+
};
|
|
547
|
+
}
|
|
525
548
|
class FinbricksConnector extends IBankConnector {
|
|
526
549
|
constructor(provider, {
|
|
527
550
|
BASE_URI,
|
|
@@ -769,6 +792,7 @@ class FinbricksConnector extends IBankConnector {
|
|
|
769
792
|
(acc) => acc.iban === payment.debtorIban
|
|
770
793
|
);
|
|
771
794
|
const clientId = await this.getClientId(debtorAccount.id);
|
|
795
|
+
const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
|
|
772
796
|
const bankRefId = backendSdk.uuidv4();
|
|
773
797
|
const [response, error] = await backendSdk.useResult(
|
|
774
798
|
this.finbricks.request({
|
|
@@ -800,7 +824,8 @@ class FinbricksConnector extends IBankConnector {
|
|
|
800
824
|
type: "IBAN",
|
|
801
825
|
value: payment.creditor.iban
|
|
802
826
|
},
|
|
803
|
-
creditorName: payment.creditor.holderName || ""
|
|
827
|
+
creditorName: payment.creditor.holderName || "",
|
|
828
|
+
...creditorAddress && { postalAddress: creditorAddress }
|
|
804
829
|
},
|
|
805
830
|
callbackUrl: `${this.finbricks.REDIRECT_URI}?type=paymentRequest&paymentRequestId=${payment.id}`
|
|
806
831
|
}
|
|
@@ -832,6 +857,7 @@ class FinbricksConnector extends IBankConnector {
|
|
|
832
857
|
(acc) => acc.iban === payment.debtorIban
|
|
833
858
|
);
|
|
834
859
|
const clientId = await this.getClientId(debtorAccount.id);
|
|
860
|
+
const creditorAddress = mapToFinbricksAddress(payment.creditor.address);
|
|
835
861
|
const bankRefId = backendSdk.uuidv4();
|
|
836
862
|
const [response, error] = await backendSdk.useResult(
|
|
837
863
|
this.finbricks.request({
|
|
@@ -854,7 +880,8 @@ class FinbricksConnector extends IBankConnector {
|
|
|
854
880
|
},
|
|
855
881
|
creditor: {
|
|
856
882
|
creditorAccountIban: payment.creditor.iban,
|
|
857
|
-
creditorName: payment.creditor.holderName
|
|
883
|
+
creditorName: payment.creditor.holderName,
|
|
884
|
+
...creditorAddress && { postalAddress: creditorAddress }
|
|
858
885
|
},
|
|
859
886
|
callbackUrl: `${this.finbricks.REDIRECT_URI}?type=paymentRequest&paymentRequestId=${payment.id}`
|
|
860
887
|
}
|
|
@@ -1214,6 +1241,7 @@ const initiateConnector = async ({
|
|
|
1214
1241
|
return new DbuConnector({
|
|
1215
1242
|
BASE_URL: env.DBUCS_BASE_URI,
|
|
1216
1243
|
USERNAME: env.DBUCS_USERNAME,
|
|
1244
|
+
APPLICATION_CODE: env.DBUCS_APPLICATION_CODE,
|
|
1217
1245
|
KV: env.BANK_KV,
|
|
1218
1246
|
API: env.DBU_CBS_BACKOFFICE_DEV,
|
|
1219
1247
|
REDIRECT_URI: env.REDIRECT_URI,
|
|
@@ -1273,6 +1301,7 @@ class DbuConnector extends IBankConnector {
|
|
|
1273
1301
|
constructor({
|
|
1274
1302
|
BASE_URL,
|
|
1275
1303
|
USERNAME,
|
|
1304
|
+
APPLICATION_CODE,
|
|
1276
1305
|
KV,
|
|
1277
1306
|
API,
|
|
1278
1307
|
REDIRECT_URI,
|
|
@@ -1284,6 +1313,7 @@ class DbuConnector extends IBankConnector {
|
|
|
1284
1313
|
this.connectedAccounts = [];
|
|
1285
1314
|
this.baseUrl = BASE_URL;
|
|
1286
1315
|
this.username = USERNAME;
|
|
1316
|
+
this.applicationCode = APPLICATION_CODE;
|
|
1287
1317
|
this.kv = KV;
|
|
1288
1318
|
this.api = API;
|
|
1289
1319
|
this.redirectUri = REDIRECT_URI;
|
|
@@ -1383,11 +1413,13 @@ class DbuConnector extends IBankConnector {
|
|
|
1383
1413
|
number: transaction.accountNumberCredit,
|
|
1384
1414
|
bankCode: transaction.bankCodeCredit,
|
|
1385
1415
|
iban: creditorIban
|
|
1416
|
+
// Note: DBU API does not provide address data in transaction responses
|
|
1386
1417
|
},
|
|
1387
1418
|
debtor: {
|
|
1388
1419
|
number: transaction.accountNumberDebit,
|
|
1389
1420
|
bankCode: transaction.bankCodeDebit,
|
|
1390
1421
|
iban: debtorIban
|
|
1422
|
+
// Note: DBU API does not provide address data in transaction responses
|
|
1391
1423
|
},
|
|
1392
1424
|
debtorIban
|
|
1393
1425
|
};
|
|
@@ -1545,7 +1577,8 @@ class DbuConnector extends IBankConnector {
|
|
|
1545
1577
|
specSymbol: payment.ss,
|
|
1546
1578
|
constSymbol: payment.ks,
|
|
1547
1579
|
uniqueExternalId: payment.id,
|
|
1548
|
-
standardPaymentFallback: "N"
|
|
1580
|
+
standardPaymentFallback: "N",
|
|
1581
|
+
applicationCode: this.applicationCode
|
|
1549
1582
|
};
|
|
1550
1583
|
const response = await this.makeRequest(
|
|
1551
1584
|
"/required-transactions/instant-payments",
|
|
@@ -1556,11 +1589,12 @@ class DbuConnector extends IBankConnector {
|
|
|
1556
1589
|
}
|
|
1557
1590
|
);
|
|
1558
1591
|
const bankRefId = response.idRequiredTransaction.toString();
|
|
1592
|
+
const status = this.mapDbuStatusToPaymentRequestStatus(response.status);
|
|
1559
1593
|
return {
|
|
1560
1594
|
authorizationUrl: `${this.txAuthUri}/${bankRefId}`,
|
|
1561
1595
|
payment: {
|
|
1562
1596
|
...payment,
|
|
1563
|
-
status
|
|
1597
|
+
status,
|
|
1564
1598
|
bankRefId
|
|
1565
1599
|
}
|
|
1566
1600
|
};
|
|
@@ -1591,7 +1625,8 @@ class DbuConnector extends IBankConnector {
|
|
|
1591
1625
|
specSymbol: payment.ss,
|
|
1592
1626
|
constSymbol: payment.ks,
|
|
1593
1627
|
uniqueExternalId: payment.id,
|
|
1594
|
-
with4EyeApproval: "Y"
|
|
1628
|
+
with4EyeApproval: "Y",
|
|
1629
|
+
applicationCode: this.applicationCode
|
|
1595
1630
|
};
|
|
1596
1631
|
const response = await this.makeRequest(
|
|
1597
1632
|
"/required-transactions",
|
|
@@ -1602,11 +1637,12 @@ class DbuConnector extends IBankConnector {
|
|
|
1602
1637
|
}
|
|
1603
1638
|
);
|
|
1604
1639
|
const bankRefId = response.idRequiredTransaction.toString();
|
|
1640
|
+
const status = this.mapDbuStatusToPaymentRequestStatus(response.status);
|
|
1605
1641
|
return {
|
|
1606
1642
|
authorizationUrl: `${this.txAuthUri}/${bankRefId}`,
|
|
1607
1643
|
payment: {
|
|
1608
1644
|
...payment,
|
|
1609
|
-
status
|
|
1645
|
+
status,
|
|
1610
1646
|
bankRefId
|
|
1611
1647
|
}
|
|
1612
1648
|
};
|
|
@@ -2009,6 +2045,7 @@ class ErsteConnector extends IBankConnector {
|
|
|
2009
2045
|
bankCode: payment.entryDetails.transactionDetails.relatedParties.debtorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.debtorAccount.identification.other.identification.split(
|
|
2010
2046
|
"/"
|
|
2011
2047
|
)[1] : void 0
|
|
2048
|
+
// Note: Erste API does not provide postalAddress in transaction responses
|
|
2012
2049
|
},
|
|
2013
2050
|
creditor: {
|
|
2014
2051
|
holderName: payment.entryDetails.transactionDetails.relatedParties.creditor?.name,
|
|
@@ -2019,6 +2056,7 @@ class ErsteConnector extends IBankConnector {
|
|
|
2019
2056
|
bankCode: payment.entryDetails.transactionDetails.relatedParties.creditorAccount?.identification.other?.identification ? payment.entryDetails.transactionDetails.relatedParties.creditorAccount.identification.other.identification.split(
|
|
2020
2057
|
"/"
|
|
2021
2058
|
)[1] : void 0
|
|
2059
|
+
// Note: Erste API does not provide postalAddress in transaction responses
|
|
2022
2060
|
},
|
|
2023
2061
|
paymentType: "DOMESTIC",
|
|
2024
2062
|
direction: "INCOMING",
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const drizzleOrm = require('drizzle-orm');
|
|
4
|
+
const database_schema = require('./bank.Qg6TA8fX.cjs');
|
|
4
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
5
|
-
require('./bank.BBXoZ5QU.cjs');
|
|
6
6
|
require('date-fns');
|
|
7
7
|
require('jose');
|
|
8
8
|
require('@develit-io/general-codes');
|
|
9
9
|
const node_crypto = require('node:crypto');
|
|
10
|
-
const database_schema = require('./bank.CVi6R7fr.cjs');
|
|
11
10
|
|
|
12
11
|
const createPaymentCommand = (db, { payment }) => {
|
|
13
12
|
return {
|
|
14
|
-
command: db.insert(tables.payment).values({
|
|
13
|
+
command: db.insert(database_schema.tables.payment).values({
|
|
15
14
|
...payment,
|
|
16
15
|
creditorIban: payment.creditor.iban,
|
|
17
16
|
debtorIban: payment.debtor.iban
|
|
18
17
|
}).onConflictDoUpdate({
|
|
19
18
|
// Unique index: (connector_key, bank_ref_id)
|
|
20
|
-
target: [tables.payment.connectorKey, tables.payment.bankRefId],
|
|
19
|
+
target: [database_schema.tables.payment.connectorKey, database_schema.tables.payment.bankRefId],
|
|
21
20
|
set: {
|
|
22
21
|
status: drizzleOrm.sql`excluded.status`,
|
|
23
22
|
statusReason: drizzleOrm.sql`excluded.status_reason`,
|
|
@@ -34,11 +33,11 @@ const createPaymentCommand = (db, { payment }) => {
|
|
|
34
33
|
|
|
35
34
|
const upsertBatchCommand = (db, { batch }) => {
|
|
36
35
|
const id = batch.id || backendSdk.uuidv4();
|
|
37
|
-
const command = db.insert(tables.batch).values({
|
|
36
|
+
const command = db.insert(database_schema.tables.batch).values({
|
|
38
37
|
...batch,
|
|
39
38
|
id
|
|
40
39
|
}).onConflictDoUpdate({
|
|
41
|
-
target: tables.batch.id,
|
|
40
|
+
target: database_schema.tables.batch.id,
|
|
42
41
|
set: {
|
|
43
42
|
...batch
|
|
44
43
|
}
|
|
@@ -52,25 +51,25 @@ const upsertBatchCommand = (db, { batch }) => {
|
|
|
52
51
|
const updatePaymentRequestStatusCommand = (db, values) => {
|
|
53
52
|
const { id, ...set } = values;
|
|
54
53
|
return {
|
|
55
|
-
command: db.update(tables.paymentRequest).set(set).where(
|
|
54
|
+
command: db.update(database_schema.tables.paymentRequest).set(set).where(
|
|
56
55
|
drizzleOrm.and(
|
|
57
|
-
drizzleOrm.eq(tables.paymentRequest.id, id),
|
|
58
|
-
drizzleOrm.isNull(tables.paymentRequest.deletedAt)
|
|
56
|
+
drizzleOrm.eq(database_schema.tables.paymentRequest.id, id),
|
|
57
|
+
drizzleOrm.isNull(database_schema.tables.paymentRequest.deletedAt)
|
|
59
58
|
)
|
|
60
59
|
).returning()
|
|
61
60
|
};
|
|
62
61
|
};
|
|
63
62
|
|
|
64
63
|
const getAccountByIdQuery = async (db, { accountId }) => {
|
|
65
|
-
return await db.select().from(tables.account).where(drizzleOrm.eq(tables.account.id, accountId)).get();
|
|
64
|
+
return await db.select().from(database_schema.tables.account).where(drizzleOrm.eq(database_schema.tables.account.id, accountId)).get();
|
|
66
65
|
};
|
|
67
66
|
|
|
68
67
|
const getBatchByIdQuery = async (db, { batchId }) => {
|
|
69
|
-
return await db.select().from(tables.batch).where(drizzleOrm.eq(tables.batch.id, batchId)).get();
|
|
68
|
+
return await db.select().from(database_schema.tables.batch).where(drizzleOrm.eq(database_schema.tables.batch.id, batchId)).get();
|
|
70
69
|
};
|
|
71
70
|
|
|
72
71
|
const getCredentialsByAccountId = async (db, encryptionKey, { accountId }) => {
|
|
73
|
-
const cred = await db.select().from(tables.accountCredentials).where(drizzleOrm.eq(tables.accountCredentials.accountId, accountId)).get();
|
|
72
|
+
const cred = await db.select().from(database_schema.tables.accountCredentials).where(drizzleOrm.eq(database_schema.tables.accountCredentials.accountId, accountId)).get();
|
|
74
73
|
return cred ? {
|
|
75
74
|
...cred,
|
|
76
75
|
value: await decrypt(cred.value, encryptionKey)
|
|
@@ -78,10 +77,10 @@ const getCredentialsByAccountId = async (db, encryptionKey, { accountId }) => {
|
|
|
78
77
|
};
|
|
79
78
|
|
|
80
79
|
const getPaymentRequestsByBatchIdQuery = async (db, { batchId }) => {
|
|
81
|
-
return await db.select().from(tables.paymentRequest).where(
|
|
80
|
+
return await db.select().from(database_schema.tables.paymentRequest).where(
|
|
82
81
|
drizzleOrm.and(
|
|
83
|
-
drizzleOrm.eq(tables.paymentRequest.batchId, batchId),
|
|
84
|
-
drizzleOrm.isNull(tables.paymentRequest.deletedAt)
|
|
82
|
+
drizzleOrm.eq(database_schema.tables.paymentRequest.batchId, batchId),
|
|
83
|
+
drizzleOrm.isNull(database_schema.tables.paymentRequest.deletedAt)
|
|
85
84
|
)
|
|
86
85
|
);
|
|
87
86
|
};
|
|
@@ -144,8 +143,6 @@ const createCredentialsResolver = async (db, env) => {
|
|
|
144
143
|
return (accountId) => getCredentialsByAccountId(db, encryptionKey, { accountId });
|
|
145
144
|
};
|
|
146
145
|
|
|
147
|
-
const tables = database_schema.schema;
|
|
148
|
-
|
|
149
146
|
exports.checksum = checksum;
|
|
150
147
|
exports.createCredentialsResolver = createCredentialsResolver;
|
|
151
148
|
exports.createPaymentCommand = createPaymentCommand;
|
|
@@ -154,6 +151,5 @@ exports.getAccountByIdQuery = getAccountByIdQuery;
|
|
|
154
151
|
exports.getBatchByIdQuery = getBatchByIdQuery;
|
|
155
152
|
exports.getPaymentRequestsByBatchIdQuery = getPaymentRequestsByBatchIdQuery;
|
|
156
153
|
exports.importAesKey = importAesKey;
|
|
157
|
-
exports.tables = tables;
|
|
158
154
|
exports.updatePaymentRequestStatusCommand = updatePaymentRequestStatusCommand;
|
|
159
155
|
exports.upsertBatchCommand = upsertBatchCommand;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { bankAccount, base } from '@develit-io/backend-sdk';
|
|
2
|
-
import { relations } from 'drizzle-orm/relations';
|
|
1
|
+
import { bankAccount, base, structuredAddressSchema } from '@develit-io/backend-sdk';
|
|
3
2
|
import { sqliteTable, text, integer, unique, real, index } from 'drizzle-orm/sqlite-core';
|
|
4
3
|
import 'date-fns';
|
|
5
4
|
import 'jose';
|
|
6
5
|
import { COUNTRY_CODES_2, BANK_CODES } from '@develit-io/general-codes';
|
|
7
|
-
import 'drizzle-orm';
|
|
6
|
+
import { relations } from 'drizzle-orm/relations';
|
|
7
|
+
import { and, not, inArray, isNull } from 'drizzle-orm';
|
|
8
8
|
import 'node:crypto';
|
|
9
9
|
import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-zod';
|
|
10
10
|
|
|
@@ -42,6 +42,39 @@ const BATCH_MODES = ["NATIVE", "SINGLE"];
|
|
|
42
42
|
const ACCOUNT_STATUSES = ["AUTHORIZED", "DISABLED", "EXPIRED"];
|
|
43
43
|
const COUNTRY_CODES = COUNTRY_CODES_2;
|
|
44
44
|
|
|
45
|
+
const TERMINAL_STATUSES$1 = /* @__PURE__ */ new Set([
|
|
46
|
+
"SETTLED",
|
|
47
|
+
"REJECTED",
|
|
48
|
+
"CLOSED"
|
|
49
|
+
]);
|
|
50
|
+
const PENDING_STATUSES = /* @__PURE__ */ new Set([
|
|
51
|
+
"OPENED",
|
|
52
|
+
"AUTHORIZED"
|
|
53
|
+
]);
|
|
54
|
+
function isTerminalStatus(status) {
|
|
55
|
+
return TERMINAL_STATUSES$1.has(status);
|
|
56
|
+
}
|
|
57
|
+
function isPendingStatus(status) {
|
|
58
|
+
return PENDING_STATUSES.has(status);
|
|
59
|
+
}
|
|
60
|
+
function isProcessedStatus(status) {
|
|
61
|
+
return !isPendingStatus(status);
|
|
62
|
+
}
|
|
63
|
+
function hasPaymentAccountAssigned(payment) {
|
|
64
|
+
return "accountId" in payment && "connectorKey" in payment && payment.accountId !== void 0 && payment.connectorKey !== void 0;
|
|
65
|
+
}
|
|
66
|
+
function isPaymentCompleted(payment) {
|
|
67
|
+
return (payment.status === "COMPLETED" || payment.status === "BOOKED" || payment.status === "SETTLED" || payment.status === "REJECTED" || payment.status === "CLOSED") && "bankRefId" in payment && typeof payment.bankRefId === "string";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const TERMINAL_STATUSES = PAYMENT_REQUEST_STATUSES.filter(isTerminalStatus);
|
|
71
|
+
const getNonTerminalPaymentRequestsQuery = (db) => db.select().from(tables.paymentRequest).where(
|
|
72
|
+
and(
|
|
73
|
+
not(inArray(tables.paymentRequest.status, TERMINAL_STATUSES)),
|
|
74
|
+
isNull(tables.paymentRequest.deletedAt)
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
|
|
45
78
|
const CONNECTOR_KEYS = [
|
|
46
79
|
"ERSTE",
|
|
47
80
|
"FINBRICKS",
|
|
@@ -90,9 +123,15 @@ const account = sqliteTable(
|
|
|
90
123
|
(t) => [unique().on(t.iban)]
|
|
91
124
|
);
|
|
92
125
|
|
|
93
|
-
const accountInsertSchema = createInsertSchema(account)
|
|
94
|
-
|
|
95
|
-
|
|
126
|
+
const accountInsertSchema = createInsertSchema(account).extend({
|
|
127
|
+
address: structuredAddressSchema.nullable().optional()
|
|
128
|
+
});
|
|
129
|
+
const accountUpdateSchema = createUpdateSchema(account).extend({
|
|
130
|
+
address: structuredAddressSchema.nullable().optional()
|
|
131
|
+
});
|
|
132
|
+
const accountSelectSchema = createSelectSchema(account).extend({
|
|
133
|
+
address: structuredAddressSchema.nullable().optional()
|
|
134
|
+
});
|
|
96
135
|
|
|
97
136
|
const accountCredentials = sqliteTable("account_credentials", {
|
|
98
137
|
...base,
|
|
@@ -269,4 +308,18 @@ const paymentRequestRelations = relations(paymentRequest, ({ one }) => ({
|
|
|
269
308
|
})
|
|
270
309
|
}));
|
|
271
310
|
|
|
272
|
-
|
|
311
|
+
const schema = {
|
|
312
|
+
__proto__: null,
|
|
313
|
+
account: account,
|
|
314
|
+
accountCredentials: accountCredentials,
|
|
315
|
+
batch: batch,
|
|
316
|
+
ott: ott,
|
|
317
|
+
payment: payment,
|
|
318
|
+
paymentRelations: paymentRelations,
|
|
319
|
+
paymentRequest: paymentRequest,
|
|
320
|
+
paymentRequestRelations: paymentRequestRelations
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const tables = schema;
|
|
324
|
+
|
|
325
|
+
export { ACCOUNT_STATUSES as A, BATCH_MODES as B, CHARGE_BEARERS as C, ott as D, payment as E, paymentRelations as F, paymentRequest as G, paymentRequestRelations as H, INSTRUCTION_PRIORITIES as I, PAYMENT_DIRECTIONS as P, TOKEN_TYPES as T, BATCH_STATUSES as a, CONNECTOR_KEYS as b, COUNTRY_CODES as c, CREDENTIALS_TYPES as d, PAYMENT_REQUEST_STATUSES as e, PAYMENT_STATUSES as f, PAYMENT_TYPES as g, accountCredentialsInsertSchema as h, accountCredentialsSelectSchema as i, accountCredentialsUpdateSchema as j, accountInsertSchema as k, accountSelectSchema as l, accountUpdateSchema as m, hasPaymentAccountAssigned as n, isPaymentCompleted as o, isPendingStatus as p, isProcessedStatus as q, isTerminalStatus as r, ottInsertSchema as s, ottSelectSchema as t, ottUpdateSchema as u, tables as v, getNonTerminalPaymentRequestsQuery as w, account as x, accountCredentials as y, batch as z };
|