@7365admin1/core 3.32.2-staging.53 → 3.32.2-staging.54
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 +1 -1
- package/dist/index.js +16 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -6980,7 +6980,7 @@ declare const useRedDotPaymentRepo: () => {
|
|
|
6980
6980
|
message: string;
|
|
6981
6981
|
remainingBalance: number;
|
|
6982
6982
|
}>;
|
|
6983
|
-
updateStatus: (
|
|
6983
|
+
updateStatus: (referenceNumber: string, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
6984
6984
|
};
|
|
6985
6985
|
|
|
6986
6986
|
declare enum VerificationType {
|
package/dist/index.js
CHANGED
|
@@ -65323,20 +65323,21 @@ var useRedDotPaymentRepo = () => {
|
|
|
65323
65323
|
session?.endSession();
|
|
65324
65324
|
}
|
|
65325
65325
|
}
|
|
65326
|
-
async function updateStatus(
|
|
65327
|
-
|
|
65328
|
-
|
|
65329
|
-
|
|
65330
|
-
throw new import_node_server_utils224.BadRequestError("Invalid payment ID format.");
|
|
65326
|
+
async function updateStatus(referenceNumber, status, session) {
|
|
65327
|
+
const reference = typeof referenceNumber === "string" ? referenceNumber.trim() : "";
|
|
65328
|
+
if (!reference) {
|
|
65329
|
+
throw new import_node_server_utils224.BadRequestError("Reference number is required.");
|
|
65331
65330
|
}
|
|
65332
65331
|
try {
|
|
65333
65332
|
const res = await paymentCollection().updateOne(
|
|
65334
|
-
{
|
|
65333
|
+
{ referenceNumber: reference, status: "pending" },
|
|
65335
65334
|
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
65336
65335
|
{ session }
|
|
65337
65336
|
);
|
|
65338
65337
|
if (res.matchedCount === 0) {
|
|
65339
|
-
throw new import_node_server_utils224.NotFoundError(
|
|
65338
|
+
throw new import_node_server_utils224.NotFoundError(
|
|
65339
|
+
"Payment not found or is no longer pending."
|
|
65340
|
+
);
|
|
65340
65341
|
}
|
|
65341
65342
|
return res;
|
|
65342
65343
|
} catch (error) {
|
|
@@ -65505,7 +65506,11 @@ var useRedDotPaymentSvc = () => {
|
|
|
65505
65506
|
var import_joi127 = __toESM(require("joi"));
|
|
65506
65507
|
var import_node_server_utils226 = require("@7365admin1/node-server-utils");
|
|
65507
65508
|
function useRedDotPaymentController() {
|
|
65508
|
-
const {
|
|
65509
|
+
const {
|
|
65510
|
+
createPayment: _createPayment,
|
|
65511
|
+
updateStatus: _updateStatus,
|
|
65512
|
+
getPaymentByReference: _getPaymentByReference
|
|
65513
|
+
} = useRedDotPaymentRepo();
|
|
65509
65514
|
const redirectPaymentTransaction = async (req, res) => {
|
|
65510
65515
|
try {
|
|
65511
65516
|
const data = req.body;
|
|
@@ -65579,11 +65584,11 @@ function useRedDotPaymentController() {
|
|
|
65579
65584
|
}
|
|
65580
65585
|
async function updateStatus(req, res, next) {
|
|
65581
65586
|
const schema2 = import_joi127.default.object({
|
|
65582
|
-
|
|
65587
|
+
referenceNumber: import_joi127.default.string().required(),
|
|
65583
65588
|
status: import_joi127.default.string().valid(...Object.values(BillingPaymentStatus)).required()
|
|
65584
65589
|
});
|
|
65585
65590
|
const { error, value } = schema2.validate({
|
|
65586
|
-
|
|
65591
|
+
referenceNumber: req.params.id,
|
|
65587
65592
|
status: req.body.status
|
|
65588
65593
|
});
|
|
65589
65594
|
if (error) {
|
|
@@ -65592,7 +65597,7 @@ function useRedDotPaymentController() {
|
|
|
65592
65597
|
return;
|
|
65593
65598
|
}
|
|
65594
65599
|
try {
|
|
65595
|
-
const data = await _updateStatus(value.
|
|
65600
|
+
const data = await _updateStatus(value.referenceNumber, value.status);
|
|
65596
65601
|
res.status(200).json({ message: "success", data });
|
|
65597
65602
|
return;
|
|
65598
65603
|
} catch (error2) {
|