@develit-services/bank 4.2.0 → 4.2.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/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/export/worker.cjs +120 -17
- package/dist/export/worker.d.cts +14 -14
- package/dist/export/worker.d.mts +14 -14
- package/dist/export/worker.d.ts +14 -14
- package/dist/export/worker.mjs +120 -17
- package/dist/export/workflows.cjs +2 -2
- package/dist/export/workflows.mjs +2 -2
- package/dist/shared/{bank.BOI0GA-f.d.cts → bank.BCqBwSKC.d.cts} +23 -6
- package/dist/shared/{bank.BOI0GA-f.d.mts → bank.BCqBwSKC.d.mts} +23 -6
- package/dist/shared/{bank.BOI0GA-f.d.ts → bank.BCqBwSKC.d.ts} +23 -6
- package/dist/shared/{bank.qcrBpYcu.mjs → bank.BELDXSDV.mjs} +1 -1
- package/dist/shared/{bank.CL02VO9K.mjs → bank.BOMobxtA.mjs} +21 -14
- package/dist/shared/{bank.DDmes7Gx.d.ts → bank.BmX_IG66.d.ts} +1 -1
- package/dist/shared/{bank.DUd_XvqB.d.cts → bank.BnCJmT6k.d.mts} +1 -1
- package/dist/shared/{bank.Cfu7ZqyP.cjs → bank.CioJeFzf.cjs} +1 -1
- package/dist/shared/{bank.C2QV_SMx.cjs → bank.DiJmJkDt.cjs} +20 -12
- package/dist/shared/{bank.CT-uUhZB.d.mts → bank.mHFTrKBv.d.cts} +1 -1
- package/dist/types.cjs +2 -1
- package/dist/types.d.cts +4 -4
- package/dist/types.d.mts +4 -4
- package/dist/types.d.ts +4 -4
- package/dist/types.mjs +1 -1
- package/package.json +1 -1
package/dist/export/worker.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bankAccountMetadataSchema, structuredAddressSchema, uuidv4, first, buildMultiFilterConditions as buildMultiFilterConditions$1, workflowInstanceStatusSchema, develitWorker, createInternalError, action, service } from '@develit-io/backend-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { G as tables, g as accountInsertSchema, H as relations, J as initiateConnector, o as isProcessedStatus, p as isTerminalStatus, L as getNonTerminalPaymentRequestsQuery, x as toIncomingPayment, j as assignAccount, u as toBatchedPayment, y as toPaymentRequestInsert, a as FinbricksClient, F as FINBRICKS_ENDPOINTS } from '../shared/bank.BOMobxtA.mjs';
|
|
3
3
|
import { eq, sql, and, like, asc, desc, inArray, gte, lte, isNull, count } from 'drizzle-orm';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { drizzle } from 'drizzle-orm/d1';
|
|
@@ -9,7 +9,7 @@ import { I as INSTRUCTION_PRIORITIES, C as CHARGE_BEARERS, g as PAYMENT_TYPES, b
|
|
|
9
9
|
import { CURRENCY_CODES } from '@develit-io/general-codes';
|
|
10
10
|
import 'date-fns';
|
|
11
11
|
import 'node:crypto';
|
|
12
|
-
import { h as encrypt, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, i as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from '../shared/bank.
|
|
12
|
+
import { h as encrypt, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, a as getPaymentRequestsByBatchIdQuery, g as getBatchByIdQuery, u as upsertBatchCommand, i as importAesKey, f as createPaymentCommand, b as getAccountByIdQuery } from '../shared/bank.BELDXSDV.mjs';
|
|
13
13
|
import 'drizzle-orm/zod';
|
|
14
14
|
import 'drizzle-orm/sqlite-core';
|
|
15
15
|
|
|
@@ -814,6 +814,7 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
814
814
|
const byConnector = Map.groupBy(allPRs, (pr) => pr.connectorKey);
|
|
815
815
|
let processed = 0;
|
|
816
816
|
let statusChanged = 0;
|
|
817
|
+
let skippedNoBankRefId = 0;
|
|
817
818
|
const eventsToEmit = [];
|
|
818
819
|
for (const [connectorKey, requests] of byConnector) {
|
|
819
820
|
let connector;
|
|
@@ -826,10 +827,30 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
826
827
|
continue;
|
|
827
828
|
}
|
|
828
829
|
for (const pr of requests) {
|
|
830
|
+
if (!pr.bankRefId && pr.connectorKey === "DBU") {
|
|
831
|
+
skippedNoBankRefId++;
|
|
832
|
+
console.warn(
|
|
833
|
+
"[_resolvePaymentRequestStatuses] Skipping DBU PR without bankRefId",
|
|
834
|
+
{
|
|
835
|
+
prId: pr.id,
|
|
836
|
+
status: pr.status,
|
|
837
|
+
connectorKey: pr.connectorKey,
|
|
838
|
+
createdAt: pr.createdAt
|
|
839
|
+
}
|
|
840
|
+
);
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
829
843
|
try {
|
|
830
844
|
const paymentId = pr.bankRefId ?? pr.id;
|
|
831
845
|
const newStatus = await connector.getPaymentStatus({ paymentId });
|
|
832
846
|
if (newStatus !== pr.status) {
|
|
847
|
+
console.log("[_resolvePaymentRequestStatuses] Status changed", {
|
|
848
|
+
prId: pr.id,
|
|
849
|
+
connectorKey: pr.connectorKey,
|
|
850
|
+
bankRefId: pr.bankRefId,
|
|
851
|
+
oldStatus: pr.status,
|
|
852
|
+
newStatus
|
|
853
|
+
});
|
|
833
854
|
await updatePaymentRequestStatusCommand(this.db, {
|
|
834
855
|
id: pr.id,
|
|
835
856
|
status: newStatus,
|
|
@@ -842,17 +863,34 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
842
863
|
}
|
|
843
864
|
processed++;
|
|
844
865
|
} catch (err) {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
866
|
+
console.error(
|
|
867
|
+
"[_resolvePaymentRequestStatuses] Failed to get payment status",
|
|
868
|
+
{
|
|
869
|
+
prId: pr.id,
|
|
870
|
+
connectorKey: pr.connectorKey,
|
|
871
|
+
status: pr.status,
|
|
872
|
+
bankRefId: pr.bankRefId,
|
|
873
|
+
error: err instanceof Error ? err.message : String(err)
|
|
874
|
+
}
|
|
875
|
+
);
|
|
848
876
|
}
|
|
849
877
|
}
|
|
850
878
|
}
|
|
851
879
|
if (eventsToEmit.length > 0) {
|
|
852
|
-
|
|
853
|
-
this.
|
|
854
|
-
|
|
855
|
-
|
|
880
|
+
try {
|
|
881
|
+
await this.pushToQueue(
|
|
882
|
+
this.env.QUEUE_BUS_QUEUE,
|
|
883
|
+
eventsToEmit
|
|
884
|
+
);
|
|
885
|
+
} catch (err) {
|
|
886
|
+
console.error(
|
|
887
|
+
"[_resolvePaymentRequestStatuses] Failed to push events to queue",
|
|
888
|
+
{
|
|
889
|
+
eventCount: eventsToEmit.length,
|
|
890
|
+
error: err instanceof Error ? err.message : String(err)
|
|
891
|
+
}
|
|
892
|
+
);
|
|
893
|
+
}
|
|
856
894
|
}
|
|
857
895
|
const affectedBatchIds = [
|
|
858
896
|
...new Set(
|
|
@@ -860,7 +898,32 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
860
898
|
)
|
|
861
899
|
];
|
|
862
900
|
for (const batchId of affectedBatchIds) {
|
|
863
|
-
|
|
901
|
+
try {
|
|
902
|
+
await this._deriveBatchStatus(batchId);
|
|
903
|
+
} catch (err) {
|
|
904
|
+
console.error(
|
|
905
|
+
"[_resolvePaymentRequestStatuses] Failed to derive batch status",
|
|
906
|
+
{
|
|
907
|
+
batchId,
|
|
908
|
+
error: err instanceof Error ? err.message : String(err)
|
|
909
|
+
}
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
console.log("[_resolvePaymentRequestStatuses] Summary", {
|
|
914
|
+
total: allPRs.length,
|
|
915
|
+
processed,
|
|
916
|
+
statusChanged,
|
|
917
|
+
skippedNoBankRefId
|
|
918
|
+
});
|
|
919
|
+
if (skippedNoBankRefId > 5) {
|
|
920
|
+
console.warn(
|
|
921
|
+
"[_resolvePaymentRequestStatuses] HIGH NUMBER of PRs without bankRefId",
|
|
922
|
+
{
|
|
923
|
+
count: skippedNoBankRefId,
|
|
924
|
+
note: "These PRs may be orphaned - payment sent but bankRefId not saved"
|
|
925
|
+
}
|
|
926
|
+
);
|
|
864
927
|
}
|
|
865
928
|
return { processed, statusChanged };
|
|
866
929
|
}
|
|
@@ -875,8 +938,9 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
875
938
|
if (!batch || batch.status === "COMPLETED" || batch.status === "FAILED")
|
|
876
939
|
return;
|
|
877
940
|
if (allPRs.length === 0) return;
|
|
941
|
+
const connectorKey = allPRs[0]?.connectorKey;
|
|
878
942
|
const allTerminal = allPRs.every(
|
|
879
|
-
(pr) => isTerminalStatus(pr.status)
|
|
943
|
+
(pr) => isTerminalStatus(pr.status, connectorKey)
|
|
880
944
|
);
|
|
881
945
|
const allAuthorizedOrHigher = allPRs.every((pr) => pr.status !== "OPENED");
|
|
882
946
|
if (allTerminal) {
|
|
@@ -897,16 +961,49 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
897
961
|
null,
|
|
898
962
|
{ successMessage: "Payment request statuses updated" },
|
|
899
963
|
async () => {
|
|
964
|
+
const startTime = Date.now();
|
|
965
|
+
console.log("[updatePaymentRequestStatuses] Starting", {
|
|
966
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
967
|
+
});
|
|
900
968
|
const nonTerminalPRs = await getNonTerminalPaymentRequestsQuery(this.db);
|
|
901
969
|
if (nonTerminalPRs.length === 0) {
|
|
970
|
+
console.log(
|
|
971
|
+
"[updatePaymentRequestStatuses] No non-terminal PRs found",
|
|
972
|
+
{
|
|
973
|
+
duration: `${Date.now() - startTime}ms`
|
|
974
|
+
}
|
|
975
|
+
);
|
|
902
976
|
return { processed: 0, statusChanged: 0 };
|
|
903
977
|
}
|
|
978
|
+
const byConnector = nonTerminalPRs.reduce(
|
|
979
|
+
(acc, pr) => {
|
|
980
|
+
const key = pr.connectorKey || "unknown";
|
|
981
|
+
acc[key] = (acc[key] || 0) + 1;
|
|
982
|
+
return acc;
|
|
983
|
+
},
|
|
984
|
+
{}
|
|
985
|
+
);
|
|
986
|
+
console.log("[updatePaymentRequestStatuses] By connector", byConnector);
|
|
904
987
|
const now = Date.now();
|
|
905
988
|
const pollableIds = [];
|
|
906
989
|
for (const pr of nonTerminalPRs) {
|
|
907
990
|
const status = pr.status;
|
|
991
|
+
if (isTerminalStatus(status, pr.connectorKey)) {
|
|
992
|
+
continue;
|
|
993
|
+
}
|
|
908
994
|
if (status === "OPENED" || status === "AUTHORIZED") {
|
|
909
995
|
if (pr.createdAt != null && now - pr.createdAt.getTime() > this.POLLING_TIMEOUT_MS) {
|
|
996
|
+
console.warn(
|
|
997
|
+
"[updatePaymentRequestStatuses] Closing PR due to timeout",
|
|
998
|
+
{
|
|
999
|
+
prId: pr.id,
|
|
1000
|
+
status: pr.status,
|
|
1001
|
+
connectorKey: pr.connectorKey,
|
|
1002
|
+
createdAt: pr.createdAt,
|
|
1003
|
+
bankRefId: pr.bankRefId,
|
|
1004
|
+
age: `${Math.floor((now - pr.createdAt.getTime()) / (24 * 60 * 60 * 1e3))} days`
|
|
1005
|
+
}
|
|
1006
|
+
);
|
|
910
1007
|
await updatePaymentRequestStatusCommand(this.db, {
|
|
911
1008
|
id: pr.id,
|
|
912
1009
|
status: "CLOSED",
|
|
@@ -916,14 +1013,20 @@ let BankServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
916
1013
|
continue;
|
|
917
1014
|
}
|
|
918
1015
|
pollableIds.push(pr.id);
|
|
919
|
-
} else if (status === "COMPLETED" || status === "BOOKED") {
|
|
920
|
-
if (pr.processedAt != null && now - pr.processedAt.getTime() > this.COMPLETED_POLLING_WINDOW_MS) {
|
|
921
|
-
continue;
|
|
922
|
-
}
|
|
923
|
-
pollableIds.push(pr.id);
|
|
924
1016
|
}
|
|
925
1017
|
}
|
|
926
|
-
|
|
1018
|
+
const result = await this._resolvePaymentRequestStatuses(pollableIds);
|
|
1019
|
+
const duration = Date.now() - startTime;
|
|
1020
|
+
console.log("[updatePaymentRequestStatuses] Completed", {
|
|
1021
|
+
duration: `${duration}ms`,
|
|
1022
|
+
metrics: {
|
|
1023
|
+
total: nonTerminalPRs.length,
|
|
1024
|
+
polled: pollableIds.length,
|
|
1025
|
+
processed: result.processed,
|
|
1026
|
+
statusChanged: result.statusChanged
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
return result;
|
|
927
1030
|
}
|
|
928
1031
|
);
|
|
929
1032
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
4
|
-
const ott_zod = require('../shared/bank.
|
|
4
|
+
const ott_zod = require('../shared/bank.DiJmJkDt.cjs');
|
|
5
5
|
const batchLifecycle = require('../shared/bank.NF8bZBy0.cjs');
|
|
6
6
|
const drizzleOrm = require('drizzle-orm');
|
|
7
|
-
const credentialsResolver = require('../shared/bank.
|
|
7
|
+
const credentialsResolver = require('../shared/bank.CioJeFzf.cjs');
|
|
8
8
|
const cloudflare_workers = require('cloudflare:workers');
|
|
9
9
|
const cloudflare_workflows = require('cloudflare:workflows');
|
|
10
10
|
const d1 = require('drizzle-orm/d1');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { first, uuidv4, asNonEmpty } from '@develit-io/backend-sdk';
|
|
2
|
-
import {
|
|
2
|
+
import { G as tables, H as relations, v as toBatchedPaymentFromPaymentRequest, z as toPreparedPayment, J as initiateConnector, m as isPaymentCompleted } from '../shared/bank.BOMobxtA.mjs';
|
|
3
3
|
import { i as isBatchAuthorized, b as isBatchFailed, d as isBatchProcessing } from '../shared/bank.XqSw509X.mjs';
|
|
4
4
|
import { eq, and, inArray } from 'drizzle-orm';
|
|
5
|
-
import { g as getBatchByIdQuery, a as getPaymentRequestsByBatchIdQuery, c as checksum, u as upsertBatchCommand, b as getAccountByIdQuery, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.
|
|
5
|
+
import { g as getBatchByIdQuery, a as getPaymentRequestsByBatchIdQuery, c as checksum, u as upsertBatchCommand, b as getAccountByIdQuery, d as createCredentialsResolver, e as updatePaymentRequestStatusCommand, f as createPaymentCommand } from '../shared/bank.BELDXSDV.mjs';
|
|
6
6
|
import { WorkflowEntrypoint } from 'cloudflare:workers';
|
|
7
7
|
import { NonRetryableError } from 'cloudflare:workflows';
|
|
8
8
|
import { drizzle } from 'drizzle-orm/d1';
|
|
@@ -1943,7 +1943,24 @@ type AccountSelectType = z.infer<typeof accountSelectSchema>;
|
|
|
1943
1943
|
* 5. CompletedPayment - Fully processed (status: COMPLETED/BOOKED/SETTLED/REJECTED/CLOSED, has bankRefId)
|
|
1944
1944
|
*/
|
|
1945
1945
|
|
|
1946
|
-
|
|
1946
|
+
/**
|
|
1947
|
+
* Base terminal statuses - apply to ALL connectors
|
|
1948
|
+
* Exported for use in database queries (connector-agnostic filtering)
|
|
1949
|
+
*/
|
|
1950
|
+
declare const BASE_TERMINAL_STATUSES: ReadonlySet<PaymentRequestStatus>;
|
|
1951
|
+
/**
|
|
1952
|
+
* Check if status is terminal for given connector
|
|
1953
|
+
*
|
|
1954
|
+
* @param status - Payment request status to check
|
|
1955
|
+
* @param connectorKey - Optional connector key for connector-specific terminals
|
|
1956
|
+
* @returns true if status is terminal (no more polling needed)
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* isTerminalStatus('COMPLETED', 'DBU') // true - DBU-specific terminal
|
|
1960
|
+
* isTerminalStatus('COMPLETED', 'FINBRICKS') // false - not terminal for Finbricks
|
|
1961
|
+
* isTerminalStatus('SETTLED', 'DBU') // true - base terminal for all
|
|
1962
|
+
*/
|
|
1963
|
+
declare function isTerminalStatus(status: PaymentRequestStatus, connectorKey?: string): boolean;
|
|
1947
1964
|
declare function isPendingStatus(status: PaymentRequestStatus): boolean;
|
|
1948
1965
|
declare function isProcessedStatus(status: PaymentRequestStatus): boolean;
|
|
1949
1966
|
/**
|
|
@@ -2127,7 +2144,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2127
2144
|
name: string;
|
|
2128
2145
|
tableName: "batch";
|
|
2129
2146
|
dataType: "string enum";
|
|
2130
|
-
data: "AUTHORIZED" | "
|
|
2147
|
+
data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
|
|
2131
2148
|
driverParam: string;
|
|
2132
2149
|
notNull: false;
|
|
2133
2150
|
hasDefault: false;
|
|
@@ -2398,7 +2415,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2398
2415
|
name: string;
|
|
2399
2416
|
tableName: "payment";
|
|
2400
2417
|
dataType: "string enum";
|
|
2401
|
-
data: "
|
|
2418
|
+
data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
2402
2419
|
driverParam: string;
|
|
2403
2420
|
notNull: true;
|
|
2404
2421
|
hasDefault: false;
|
|
@@ -2797,7 +2814,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2797
2814
|
name: string;
|
|
2798
2815
|
tableName: "payment_request";
|
|
2799
2816
|
dataType: "string enum";
|
|
2800
|
-
data: "AUTHORIZED" | "
|
|
2817
|
+
data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
2801
2818
|
driverParam: string;
|
|
2802
2819
|
notNull: true;
|
|
2803
2820
|
hasDefault: false;
|
|
@@ -3508,5 +3525,5 @@ type ParsedBankPayment = {
|
|
|
3508
3525
|
*/
|
|
3509
3526
|
type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
|
|
3510
3527
|
|
|
3511
|
-
export { IBankConnector as I,
|
|
3512
|
-
export type {
|
|
3528
|
+
export { IBankConnector as I, BASE_TERMINAL_STATUSES as M, BATCH_MODES as N, BATCH_STATUSES as O, CHARGE_BEARERS as X, CONNECTOR_KEYS as Y, COUNTRY_CODES as Z, CREDENTIALS_TYPES as _, INSTRUCTION_PRIORITIES as a3, PAYMENT_DIRECTIONS as a5, PAYMENT_REQUEST_STATUSES as a6, PAYMENT_STATUSES as a7, PAYMENT_TYPES as a8, isTerminalStatus as aA, account as aB, accountCredentials as aC, batch as aD, ott as aE, payment as aF, paymentRequest as aG, TOKEN_TYPES as ai, accountCredentialsInsertSchema as ak, accountCredentialsSelectSchema as al, accountCredentialsUpdateSchema as am, accountInsertSchema as an, accountSelectSchema as ao, accountUpdateSchema as ap, hasPaymentAccountAssigned as aq, isBatchAuthorized as ar, isBatchCompleted as as, isBatchFailed as at, isBatchInitiated as au, isBatchProcessing as av, isBatchReadyToSign as aw, isPaymentCompleted as ax, isPendingStatus as ay, isProcessedStatus as az, tables as t, ACCOUNT_STATUSES as y };
|
|
3529
|
+
export type { ChargeBearer as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, PaymentRequestSelectType as P, BankAccountWithLastSync as Q, BankCode as R, BatchInsertType as S, BatchLifecycle as T, BatchMode as U, BatchPayment as V, BatchStatus as W, PaymentSelectType as a, CompletedBatch as a0, CountryCode as a1, CredentialsType as a2, InstructionPriority as a4, PaymentDirection as a9, PaymentFailedInsertType as aa, PaymentInsertType as ab, PaymentLifecycle as ac, PaymentPreparedInsertType as ad, PaymentStatus as ae, ProcessingBatch as af, ReadyToSignBatch as ag, ResolvedCredentials as ah, TokenType as aj, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
|
|
@@ -1943,7 +1943,24 @@ type AccountSelectType = z.infer<typeof accountSelectSchema>;
|
|
|
1943
1943
|
* 5. CompletedPayment - Fully processed (status: COMPLETED/BOOKED/SETTLED/REJECTED/CLOSED, has bankRefId)
|
|
1944
1944
|
*/
|
|
1945
1945
|
|
|
1946
|
-
|
|
1946
|
+
/**
|
|
1947
|
+
* Base terminal statuses - apply to ALL connectors
|
|
1948
|
+
* Exported for use in database queries (connector-agnostic filtering)
|
|
1949
|
+
*/
|
|
1950
|
+
declare const BASE_TERMINAL_STATUSES: ReadonlySet<PaymentRequestStatus>;
|
|
1951
|
+
/**
|
|
1952
|
+
* Check if status is terminal for given connector
|
|
1953
|
+
*
|
|
1954
|
+
* @param status - Payment request status to check
|
|
1955
|
+
* @param connectorKey - Optional connector key for connector-specific terminals
|
|
1956
|
+
* @returns true if status is terminal (no more polling needed)
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* isTerminalStatus('COMPLETED', 'DBU') // true - DBU-specific terminal
|
|
1960
|
+
* isTerminalStatus('COMPLETED', 'FINBRICKS') // false - not terminal for Finbricks
|
|
1961
|
+
* isTerminalStatus('SETTLED', 'DBU') // true - base terminal for all
|
|
1962
|
+
*/
|
|
1963
|
+
declare function isTerminalStatus(status: PaymentRequestStatus, connectorKey?: string): boolean;
|
|
1947
1964
|
declare function isPendingStatus(status: PaymentRequestStatus): boolean;
|
|
1948
1965
|
declare function isProcessedStatus(status: PaymentRequestStatus): boolean;
|
|
1949
1966
|
/**
|
|
@@ -2127,7 +2144,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2127
2144
|
name: string;
|
|
2128
2145
|
tableName: "batch";
|
|
2129
2146
|
dataType: "string enum";
|
|
2130
|
-
data: "AUTHORIZED" | "
|
|
2147
|
+
data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
|
|
2131
2148
|
driverParam: string;
|
|
2132
2149
|
notNull: false;
|
|
2133
2150
|
hasDefault: false;
|
|
@@ -2398,7 +2415,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2398
2415
|
name: string;
|
|
2399
2416
|
tableName: "payment";
|
|
2400
2417
|
dataType: "string enum";
|
|
2401
|
-
data: "
|
|
2418
|
+
data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
2402
2419
|
driverParam: string;
|
|
2403
2420
|
notNull: true;
|
|
2404
2421
|
hasDefault: false;
|
|
@@ -2797,7 +2814,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2797
2814
|
name: string;
|
|
2798
2815
|
tableName: "payment_request";
|
|
2799
2816
|
dataType: "string enum";
|
|
2800
|
-
data: "AUTHORIZED" | "
|
|
2817
|
+
data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
2801
2818
|
driverParam: string;
|
|
2802
2819
|
notNull: true;
|
|
2803
2820
|
hasDefault: false;
|
|
@@ -3508,5 +3525,5 @@ type ParsedBankPayment = {
|
|
|
3508
3525
|
*/
|
|
3509
3526
|
type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
|
|
3510
3527
|
|
|
3511
|
-
export { IBankConnector as I,
|
|
3512
|
-
export type {
|
|
3528
|
+
export { IBankConnector as I, BASE_TERMINAL_STATUSES as M, BATCH_MODES as N, BATCH_STATUSES as O, CHARGE_BEARERS as X, CONNECTOR_KEYS as Y, COUNTRY_CODES as Z, CREDENTIALS_TYPES as _, INSTRUCTION_PRIORITIES as a3, PAYMENT_DIRECTIONS as a5, PAYMENT_REQUEST_STATUSES as a6, PAYMENT_STATUSES as a7, PAYMENT_TYPES as a8, isTerminalStatus as aA, account as aB, accountCredentials as aC, batch as aD, ott as aE, payment as aF, paymentRequest as aG, TOKEN_TYPES as ai, accountCredentialsInsertSchema as ak, accountCredentialsSelectSchema as al, accountCredentialsUpdateSchema as am, accountInsertSchema as an, accountSelectSchema as ao, accountUpdateSchema as ap, hasPaymentAccountAssigned as aq, isBatchAuthorized as ar, isBatchCompleted as as, isBatchFailed as at, isBatchInitiated as au, isBatchProcessing as av, isBatchReadyToSign as aw, isPaymentCompleted as ax, isPendingStatus as ay, isProcessedStatus as az, tables as t, ACCOUNT_STATUSES as y };
|
|
3529
|
+
export type { ChargeBearer as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, PaymentRequestSelectType as P, BankAccountWithLastSync as Q, BankCode as R, BatchInsertType as S, BatchLifecycle as T, BatchMode as U, BatchPayment as V, BatchStatus as W, PaymentSelectType as a, CompletedBatch as a0, CountryCode as a1, CredentialsType as a2, InstructionPriority as a4, PaymentDirection as a9, PaymentFailedInsertType as aa, PaymentInsertType as ab, PaymentLifecycle as ac, PaymentPreparedInsertType as ad, PaymentStatus as ae, ProcessingBatch as af, ReadyToSignBatch as ag, ResolvedCredentials as ah, TokenType as aj, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
|
|
@@ -1943,7 +1943,24 @@ type AccountSelectType = z.infer<typeof accountSelectSchema>;
|
|
|
1943
1943
|
* 5. CompletedPayment - Fully processed (status: COMPLETED/BOOKED/SETTLED/REJECTED/CLOSED, has bankRefId)
|
|
1944
1944
|
*/
|
|
1945
1945
|
|
|
1946
|
-
|
|
1946
|
+
/**
|
|
1947
|
+
* Base terminal statuses - apply to ALL connectors
|
|
1948
|
+
* Exported for use in database queries (connector-agnostic filtering)
|
|
1949
|
+
*/
|
|
1950
|
+
declare const BASE_TERMINAL_STATUSES: ReadonlySet<PaymentRequestStatus>;
|
|
1951
|
+
/**
|
|
1952
|
+
* Check if status is terminal for given connector
|
|
1953
|
+
*
|
|
1954
|
+
* @param status - Payment request status to check
|
|
1955
|
+
* @param connectorKey - Optional connector key for connector-specific terminals
|
|
1956
|
+
* @returns true if status is terminal (no more polling needed)
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* isTerminalStatus('COMPLETED', 'DBU') // true - DBU-specific terminal
|
|
1960
|
+
* isTerminalStatus('COMPLETED', 'FINBRICKS') // false - not terminal for Finbricks
|
|
1961
|
+
* isTerminalStatus('SETTLED', 'DBU') // true - base terminal for all
|
|
1962
|
+
*/
|
|
1963
|
+
declare function isTerminalStatus(status: PaymentRequestStatus, connectorKey?: string): boolean;
|
|
1947
1964
|
declare function isPendingStatus(status: PaymentRequestStatus): boolean;
|
|
1948
1965
|
declare function isProcessedStatus(status: PaymentRequestStatus): boolean;
|
|
1949
1966
|
/**
|
|
@@ -2127,7 +2144,7 @@ declare const batch: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2127
2144
|
name: string;
|
|
2128
2145
|
tableName: "batch";
|
|
2129
2146
|
dataType: "string enum";
|
|
2130
|
-
data: "AUTHORIZED" | "
|
|
2147
|
+
data: "AUTHORIZED" | "COMPLETED" | "PROCESSING" | "READY_TO_SIGN" | "FAILED";
|
|
2131
2148
|
driverParam: string;
|
|
2132
2149
|
notNull: false;
|
|
2133
2150
|
hasDefault: false;
|
|
@@ -2398,7 +2415,7 @@ declare const payment: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2398
2415
|
name: string;
|
|
2399
2416
|
tableName: "payment";
|
|
2400
2417
|
dataType: "string enum";
|
|
2401
|
-
data: "
|
|
2418
|
+
data: "BOOKED" | "REJECTED" | "PENDING" | "PROCESSING" | "CANCELLED" | "SCHEDULED" | "HOLD" | "INFO";
|
|
2402
2419
|
driverParam: string;
|
|
2403
2420
|
notNull: true;
|
|
2404
2421
|
hasDefault: false;
|
|
@@ -2797,7 +2814,7 @@ declare const paymentRequest: drizzle_orm_sqlite_core.SQLiteTableWithColumns<{
|
|
|
2797
2814
|
name: string;
|
|
2798
2815
|
tableName: "payment_request";
|
|
2799
2816
|
dataType: "string enum";
|
|
2800
|
-
data: "AUTHORIZED" | "
|
|
2817
|
+
data: "AUTHORIZED" | "OPENED" | "COMPLETED" | "BOOKED" | "SETTLED" | "REJECTED" | "CLOSED";
|
|
2801
2818
|
driverParam: string;
|
|
2802
2819
|
notNull: true;
|
|
2803
2820
|
hasDefault: false;
|
|
@@ -3508,5 +3525,5 @@ type ParsedBankPayment = {
|
|
|
3508
3525
|
*/
|
|
3509
3526
|
type BatchPayment = Omit<PaymentInsertType, 'bankRefId'>;
|
|
3510
3527
|
|
|
3511
|
-
export { IBankConnector as I,
|
|
3512
|
-
export type {
|
|
3528
|
+
export { IBankConnector as I, BASE_TERMINAL_STATUSES as M, BATCH_MODES as N, BATCH_STATUSES as O, CHARGE_BEARERS as X, CONNECTOR_KEYS as Y, COUNTRY_CODES as Z, CREDENTIALS_TYPES as _, INSTRUCTION_PRIORITIES as a3, PAYMENT_DIRECTIONS as a5, PAYMENT_REQUEST_STATUSES as a6, PAYMENT_STATUSES as a7, PAYMENT_TYPES as a8, isTerminalStatus as aA, account as aB, accountCredentials as aC, batch as aD, ott as aE, payment as aF, paymentRequest as aG, TOKEN_TYPES as ai, accountCredentialsInsertSchema as ak, accountCredentialsSelectSchema as al, accountCredentialsUpdateSchema as am, accountInsertSchema as an, accountSelectSchema as ao, accountUpdateSchema as ap, hasPaymentAccountAssigned as aq, isBatchAuthorized as ar, isBatchCompleted as as, isBatchFailed as at, isBatchInitiated as au, isBatchProcessing as av, isBatchReadyToSign as aw, isPaymentCompleted as ax, isPendingStatus as ay, isProcessedStatus as az, tables as t, ACCOUNT_STATUSES as y };
|
|
3529
|
+
export type { ChargeBearer as $, AccountSelectType as A, BatchSelectType as B, ConnectorConfig as C, AccountCredentialsSelectType as D, AccountCredentialsUpdateType as E, AccountPatchType as F, AccountStatus as G, HandleAuthorizationCallbackInput as H, AccountUpdateType as J, AuthorizedBatch as K, LastSyncMetadata as L, PaymentRequestSelectType as P, BankAccountWithLastSync as Q, BankCode as R, BatchInsertType as S, BatchLifecycle as T, BatchMode as U, BatchPayment as V, BatchStatus as W, PaymentSelectType as a, CompletedBatch as a0, CountryCode as a1, CredentialsType as a2, InstructionPriority as a4, PaymentDirection as a9, PaymentFailedInsertType as aa, PaymentInsertType as ab, PaymentLifecycle as ac, PaymentPreparedInsertType as ad, PaymentStatus as ae, ProcessingBatch as af, ReadyToSignBatch as ag, ResolvedCredentials as ah, TokenType as aj, ConfigEnvironmentBank as b, ConnectorKey as c, PaymentType as d, CurrencyCode as e, HandleAuthorizationCallbackOutput as f, ConnectedAccount as g, CredentialsResolver as h, AccountCredentialsInsertType as i, AccountInsertType as j, BatchedPayment as k, InitiatedBatch as l, IncomingPayment as m, InitiatedPayment as n, ParsedBankPayment as o, PaymentRequestStatus as p, AuthorizationCallbackResult as q, BatchMetadata as r, Currency as s, AccountAssignedPayment as u, PreparedPayment as v, CompletedPayment as w, PaymentRequestInsertType as x, AccountCredentialsPatchType as z };
|
|
@@ -3,7 +3,7 @@ import { format, parseISO } from 'date-fns';
|
|
|
3
3
|
import { importPKCS8, SignJWT } from 'jose';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { CURRENCY_CODES } from '@develit-io/general-codes';
|
|
6
|
-
import { s as schema,
|
|
6
|
+
import { s as schema, h as account, i as accountCredentials, o as ott } from './bank.BzDNLxB_.mjs';
|
|
7
7
|
import { defineRelations, and, not, inArray, isNull } from 'drizzle-orm';
|
|
8
8
|
import { createInsertSchema, createUpdateSchema, createSelectSchema } from 'drizzle-orm/zod';
|
|
9
9
|
import 'node:crypto';
|
|
@@ -182,17 +182,24 @@ const FINBRICKS_ENDPOINTS = {
|
|
|
182
182
|
BANK_INFO: "/status/bankInfo"
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
"
|
|
188
|
-
|
|
189
|
-
|
|
185
|
+
const BASE_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["SETTLED", "REJECTED", "CLOSED"]);
|
|
186
|
+
const CONNECTOR_TERMINAL_STATUSES = {
|
|
187
|
+
DBU: /* @__PURE__ */ new Set(["COMPLETED", "BOOKED"])
|
|
188
|
+
// Finbricks: uses BASE only (polls until SETTLED)
|
|
189
|
+
// ERSTE: uses BASE only
|
|
190
|
+
};
|
|
190
191
|
const PENDING_STATUSES = /* @__PURE__ */ new Set([
|
|
191
192
|
"OPENED",
|
|
192
193
|
"AUTHORIZED"
|
|
193
194
|
]);
|
|
194
|
-
function isTerminalStatus(status) {
|
|
195
|
-
|
|
195
|
+
function isTerminalStatus(status, connectorKey) {
|
|
196
|
+
if (BASE_TERMINAL_STATUSES.has(status)) {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
if (connectorKey && CONNECTOR_TERMINAL_STATUSES[connectorKey]) {
|
|
200
|
+
return CONNECTOR_TERMINAL_STATUSES[connectorKey].has(status);
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
196
203
|
}
|
|
197
204
|
function isPendingStatus(status) {
|
|
198
205
|
return PENDING_STATUSES.has(status);
|
|
@@ -1630,10 +1637,10 @@ class DbuConnector extends IBankConnector {
|
|
|
1630
1637
|
case "15":
|
|
1631
1638
|
// RQT_STATUS_REJECTED
|
|
1632
1639
|
case "33":
|
|
1633
|
-
// RQT_STATUS_HD_CANCELLED
|
|
1634
|
-
case "39":
|
|
1635
1640
|
return "REJECTED";
|
|
1636
1641
|
// AUTHORIZED - All other processing states
|
|
1642
|
+
// Note: RQT_STATUS_CNC_CLEARING (39) is NOT terminal per corebanking team (2026-05-12)
|
|
1643
|
+
// It's a request for cancellation from clearing, not a final state - falls through to default
|
|
1637
1644
|
default:
|
|
1638
1645
|
return "AUTHORIZED";
|
|
1639
1646
|
}
|
|
@@ -1664,13 +1671,13 @@ class DbuConnector extends IBankConnector {
|
|
|
1664
1671
|
case "14":
|
|
1665
1672
|
// RQT_STATUS_EXPIRED
|
|
1666
1673
|
case "33":
|
|
1667
|
-
// RQT_STATUS_HD_CANCELLED
|
|
1668
|
-
case "39":
|
|
1669
1674
|
return "CANCELLED";
|
|
1670
1675
|
// REJECTED - Explicitly rejected by bank
|
|
1671
1676
|
case "15":
|
|
1672
1677
|
return "REJECTED";
|
|
1673
1678
|
// PENDING - All other processing states
|
|
1679
|
+
// Note: RQT_STATUS_CNC_CLEARING (39) is NOT terminal per corebanking team (2026-05-12)
|
|
1680
|
+
// It's a request for cancellation from clearing, not a final state - falls through to default
|
|
1674
1681
|
default:
|
|
1675
1682
|
return "PENDING";
|
|
1676
1683
|
}
|
|
@@ -2002,7 +2009,7 @@ class DbuConnector extends IBankConnector {
|
|
|
2002
2009
|
}
|
|
2003
2010
|
}
|
|
2004
2011
|
|
|
2005
|
-
const TERMINAL_STATUSES =
|
|
2012
|
+
const TERMINAL_STATUSES = Array.from(BASE_TERMINAL_STATUSES);
|
|
2006
2013
|
const getNonTerminalPaymentRequestsQuery = (db) => db.select().from(tables.paymentRequest).where(
|
|
2007
2014
|
and(
|
|
2008
2015
|
not(inArray(tables.paymentRequest.status, TERMINAL_STATUSES)),
|
|
@@ -2445,4 +2452,4 @@ const ottInsertSchema = createInsertSchema(ott);
|
|
|
2445
2452
|
const ottUpdateSchema = createUpdateSchema(ott);
|
|
2446
2453
|
const ottSelectSchema = createSelectSchema(ott);
|
|
2447
2454
|
|
|
2448
|
-
export { useFinbricksFetch as A,
|
|
2455
|
+
export { useFinbricksFetch as A, BASE_TERMINAL_STATUSES as B, CsobConnector as C, DbuConnector as D, ErsteConnector as E, FINBRICKS_ENDPOINTS as F, tables as G, relations as H, IBankConnector as I, initiateConnector as J, KBConnector as K, getNonTerminalPaymentRequestsQuery as L, MockCobsConnector as M, FinbricksClient as a, FinbricksConnector as b, MockConnector as c, accountCredentialsInsertSchema as d, accountCredentialsSelectSchema as e, accountCredentialsUpdateSchema as f, accountInsertSchema as g, accountSelectSchema as h, accountUpdateSchema as i, assignAccount as j, dbuAccountConfigSchema as k, hasPaymentAccountAssigned as l, isPaymentCompleted as m, isPendingStatus as n, isProcessedStatus as o, isTerminalStatus as p, ottInsertSchema as q, ottSelectSchema as r, ottUpdateSchema as s, signFinbricksJws as t, toBatchedPayment as u, toBatchedPaymentFromPaymentRequest as v, toCompletedPayment as w, toIncomingPayment as x, toPaymentRequestInsert as y, toPreparedPayment as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as CurrencyCode,
|
|
1
|
+
import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.BCqBwSKC.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { e as CurrencyCode,
|
|
1
|
+
import { e as CurrencyCode, R as BankCode, a1 as CountryCode, P as PaymentRequestSelectType } from './bank.BCqBwSKC.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
type ReferenceType = `${'VS' | 'SS' | 'KS'}:${number}`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const drizzleOrm = require('drizzle-orm');
|
|
4
|
-
const ott_zod = require('./bank.
|
|
4
|
+
const ott_zod = require('./bank.DiJmJkDt.cjs');
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
6
|
require('./bank.9Yw4KHyl.cjs');
|
|
7
7
|
require('date-fns');
|