@7365admin1/core 3.32.2-staging.32 → 3.32.2-staging.33
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/index.d.ts +3 -1
- package/dist/index.js +70 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +296 -239
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6873,6 +6873,7 @@ declare function useRedDotPaymentController(): {
|
|
|
6873
6873
|
redirectPaymentTransaction: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6874
6874
|
enquirePaymentTransaction: (req: Request, res: Response) => Promise<Response<any, Record<string, any>>>;
|
|
6875
6875
|
createPayment: (req: Request, res: Response, next: NextFunction) => Promise<Response<any, Record<string, any>> | undefined>;
|
|
6876
|
+
updateStatus: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6876
6877
|
};
|
|
6877
6878
|
|
|
6878
6879
|
interface IDirectPayment extends IBaseModel {
|
|
@@ -6933,11 +6934,12 @@ type TBillingPayments = {
|
|
|
6933
6934
|
|
|
6934
6935
|
declare const useRedDotPaymentRepo: () => {
|
|
6935
6936
|
paySingleUnitBill: (refId: string, payload: Partial<TUnitBilling>) => Promise<mongodb.WithId<bson.Document> | null>;
|
|
6936
|
-
createPayment: (type: string, payload: Partial<TBillingPayments>, session?: ClientSession) => Promise<
|
|
6937
|
+
createPayment: (type: string, payload: Partial<TBillingPayments>, session?: ClientSession) => Promise<string | undefined>;
|
|
6937
6938
|
payMultipleUnitBill: (refId: string[], payload: Partial<TUnitBilling>) => Promise<{
|
|
6938
6939
|
message: string;
|
|
6939
6940
|
remainingBalance: number;
|
|
6940
6941
|
}>;
|
|
6942
|
+
updateStatus: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
6941
6943
|
};
|
|
6942
6944
|
|
|
6943
6945
|
declare enum VerificationType {
|
package/dist/index.js
CHANGED
|
@@ -536,13 +536,13 @@ var require_logger = __commonJS({
|
|
|
536
536
|
"use strict";
|
|
537
537
|
exports.__esModule = true;
|
|
538
538
|
var _utils = require_utils();
|
|
539
|
-
var
|
|
539
|
+
var logger203 = {
|
|
540
540
|
methodMap: ["debug", "info", "warn", "error"],
|
|
541
541
|
level: "info",
|
|
542
542
|
// Maps a given level value to the `methodMap` indexes above.
|
|
543
543
|
lookupLevel: function lookupLevel(level) {
|
|
544
544
|
if (typeof level === "string") {
|
|
545
|
-
var levelMap = _utils.indexOf(
|
|
545
|
+
var levelMap = _utils.indexOf(logger203.methodMap, level.toLowerCase());
|
|
546
546
|
if (levelMap >= 0) {
|
|
547
547
|
level = levelMap;
|
|
548
548
|
} else {
|
|
@@ -553,9 +553,9 @@ var require_logger = __commonJS({
|
|
|
553
553
|
},
|
|
554
554
|
// Can be overridden in the host environment
|
|
555
555
|
log: function log(level) {
|
|
556
|
-
level =
|
|
557
|
-
if (typeof console !== "undefined" &&
|
|
558
|
-
var method =
|
|
556
|
+
level = logger203.lookupLevel(level);
|
|
557
|
+
if (typeof console !== "undefined" && logger203.lookupLevel(logger203.level) <= level) {
|
|
558
|
+
var method = logger203.methodMap[level];
|
|
559
559
|
if (!console[method]) {
|
|
560
560
|
method = "log";
|
|
561
561
|
}
|
|
@@ -566,7 +566,7 @@ var require_logger = __commonJS({
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
};
|
|
569
|
-
exports["default"] =
|
|
569
|
+
exports["default"] = logger203;
|
|
570
570
|
module2.exports = exports["default"];
|
|
571
571
|
}
|
|
572
572
|
});
|
|
@@ -64621,6 +64621,13 @@ var import_mongodb134 = require("mongodb");
|
|
|
64621
64621
|
var import_node_server_utils223 = require("@7365admin1/node-server-utils");
|
|
64622
64622
|
var import_mongodb133 = require("mongodb");
|
|
64623
64623
|
var import_joi126 = __toESM(require("joi"));
|
|
64624
|
+
var BillingPaymentStatus = /* @__PURE__ */ ((BillingPaymentStatus2) => {
|
|
64625
|
+
BillingPaymentStatus2["PENDING"] = "pending";
|
|
64626
|
+
BillingPaymentStatus2["SUCCESS"] = "success";
|
|
64627
|
+
BillingPaymentStatus2["FAILED"] = "failed";
|
|
64628
|
+
BillingPaymentStatus2["PARTIAL"] = "partial";
|
|
64629
|
+
return BillingPaymentStatus2;
|
|
64630
|
+
})(BillingPaymentStatus || {});
|
|
64624
64631
|
var schemaBillingItems = import_joi126.default.object({
|
|
64625
64632
|
_id: import_joi126.default.string().hex().optional(),
|
|
64626
64633
|
name: import_joi126.default.string().optional().allow(null, "")
|
|
@@ -64734,8 +64741,8 @@ var useRedDotPaymentRepo = () => {
|
|
|
64734
64741
|
if (type == "single") {
|
|
64735
64742
|
try {
|
|
64736
64743
|
payload = MBillingItems(payload);
|
|
64737
|
-
|
|
64738
|
-
return
|
|
64744
|
+
await paymentCollection().insertOne(payload, { session });
|
|
64745
|
+
return payload.referenceNumber;
|
|
64739
64746
|
} catch (error) {
|
|
64740
64747
|
import_node_server_utils224.logger.log({
|
|
64741
64748
|
level: "error",
|
|
@@ -64764,7 +64771,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
64764
64771
|
{ $set: { referenceNumber } },
|
|
64765
64772
|
{ session }
|
|
64766
64773
|
);
|
|
64767
|
-
return
|
|
64774
|
+
return referenceNumber;
|
|
64768
64775
|
} catch (error) {
|
|
64769
64776
|
import_node_server_utils224.logger.log({
|
|
64770
64777
|
level: "error",
|
|
@@ -64944,6 +64951,29 @@ var useRedDotPaymentRepo = () => {
|
|
|
64944
64951
|
session?.endSession();
|
|
64945
64952
|
}
|
|
64946
64953
|
}
|
|
64954
|
+
async function updateStatus(_id, status, session) {
|
|
64955
|
+
try {
|
|
64956
|
+
_id = new import_mongodb134.ObjectId(_id);
|
|
64957
|
+
} catch {
|
|
64958
|
+
throw new import_node_server_utils224.BadRequestError("Invalid payment ID format.");
|
|
64959
|
+
}
|
|
64960
|
+
try {
|
|
64961
|
+
const res = await paymentCollection().updateOne(
|
|
64962
|
+
{ _id },
|
|
64963
|
+
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
64964
|
+
{ session }
|
|
64965
|
+
);
|
|
64966
|
+
if (res.matchedCount === 0) {
|
|
64967
|
+
throw new import_node_server_utils224.NotFoundError("Payment not found.");
|
|
64968
|
+
}
|
|
64969
|
+
return res;
|
|
64970
|
+
} catch (error) {
|
|
64971
|
+
if (error instanceof import_node_server_utils224.AppError) {
|
|
64972
|
+
throw error;
|
|
64973
|
+
}
|
|
64974
|
+
throw new import_node_server_utils224.InternalServerError("Failed to update payment status.");
|
|
64975
|
+
}
|
|
64976
|
+
}
|
|
64947
64977
|
function formatDateString(today) {
|
|
64948
64978
|
today = typeof today === "string" ? new Date(today) : today;
|
|
64949
64979
|
let month = today.getMonth() + 1;
|
|
@@ -64952,7 +64982,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
64952
64982
|
const formattedDate = `${month.toString().padStart(2, "0")}${day.toString().padStart(2, "0")}${year}`;
|
|
64953
64983
|
return formattedDate;
|
|
64954
64984
|
}
|
|
64955
|
-
return { paySingleUnitBill, createPayment, payMultipleUnitBill };
|
|
64985
|
+
return { paySingleUnitBill, createPayment, payMultipleUnitBill, updateStatus };
|
|
64956
64986
|
};
|
|
64957
64987
|
|
|
64958
64988
|
// src/services/reddot-payment.service.ts
|
|
@@ -65096,7 +65126,7 @@ var useRedDotPaymentSvc = () => {
|
|
|
65096
65126
|
var import_joi127 = __toESM(require("joi"));
|
|
65097
65127
|
var import_node_server_utils226 = require("@7365admin1/node-server-utils");
|
|
65098
65128
|
function useRedDotPaymentController() {
|
|
65099
|
-
const { createPayment: _createPayment } = useRedDotPaymentRepo();
|
|
65129
|
+
const { createPayment: _createPayment, updateStatus: _updateStatus } = useRedDotPaymentRepo();
|
|
65100
65130
|
const redirectPaymentTransaction = async (req, res) => {
|
|
65101
65131
|
try {
|
|
65102
65132
|
const data = req.body;
|
|
@@ -65160,17 +65190,43 @@ function useRedDotPaymentController() {
|
|
|
65160
65190
|
try {
|
|
65161
65191
|
const payment = await _createPayment(type, value);
|
|
65162
65192
|
res.status(201).json({
|
|
65163
|
-
message: "
|
|
65193
|
+
message: "success",
|
|
65164
65194
|
data: payment
|
|
65165
65195
|
});
|
|
65166
65196
|
} catch (error) {
|
|
65167
|
-
|
|
65197
|
+
const status = error?.statusCode ?? 500;
|
|
65198
|
+
res.status(status).json({ message: "failed" });
|
|
65199
|
+
}
|
|
65200
|
+
}
|
|
65201
|
+
async function updateStatus(req, res, next) {
|
|
65202
|
+
const schema2 = import_joi127.default.object({
|
|
65203
|
+
_id: import_joi127.default.string().hex().length(24).required(),
|
|
65204
|
+
status: import_joi127.default.string().valid(...Object.values(BillingPaymentStatus)).required()
|
|
65205
|
+
});
|
|
65206
|
+
const { error, value } = schema2.validate({
|
|
65207
|
+
_id: req.params.id,
|
|
65208
|
+
status: req.body.status
|
|
65209
|
+
});
|
|
65210
|
+
if (error) {
|
|
65211
|
+
import_node_server_utils226.logger.log({ level: "error", message: error.message });
|
|
65212
|
+
next(new import_node_server_utils226.BadRequestError(error.message));
|
|
65213
|
+
return;
|
|
65214
|
+
}
|
|
65215
|
+
try {
|
|
65216
|
+
const data = await _updateStatus(value._id, value.status);
|
|
65217
|
+
res.status(200).json({ message: "success", data });
|
|
65218
|
+
return;
|
|
65219
|
+
} catch (error2) {
|
|
65220
|
+
import_node_server_utils226.logger.log({ level: "error", message: error2.message });
|
|
65221
|
+
next(error2);
|
|
65222
|
+
return;
|
|
65168
65223
|
}
|
|
65169
65224
|
}
|
|
65170
65225
|
return {
|
|
65171
65226
|
redirectPaymentTransaction,
|
|
65172
65227
|
enquirePaymentTransaction,
|
|
65173
|
-
createPayment
|
|
65228
|
+
createPayment,
|
|
65229
|
+
updateStatus
|
|
65174
65230
|
};
|
|
65175
65231
|
}
|
|
65176
65232
|
|