@7365admin1/core 3.32.2-staging.53 → 3.32.2-staging.55
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 +45 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -12
- 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
|
@@ -8813,7 +8813,35 @@ function useUserRepo() {
|
|
|
8813
8813
|
siteCategory: { $first: "$siteInfo.category" }
|
|
8814
8814
|
}
|
|
8815
8815
|
},
|
|
8816
|
-
{ $project: { siteInfo: 0 } }
|
|
8816
|
+
{ $project: { siteInfo: 0 } },
|
|
8817
|
+
{
|
|
8818
|
+
$lookup: {
|
|
8819
|
+
from: "site.people",
|
|
8820
|
+
localField: "_id",
|
|
8821
|
+
foreignField: "user",
|
|
8822
|
+
pipeline: [
|
|
8823
|
+
{
|
|
8824
|
+
$project: {
|
|
8825
|
+
_id: 0,
|
|
8826
|
+
plateNumber: 1
|
|
8827
|
+
}
|
|
8828
|
+
}
|
|
8829
|
+
],
|
|
8830
|
+
as: "person"
|
|
8831
|
+
}
|
|
8832
|
+
},
|
|
8833
|
+
{
|
|
8834
|
+
$addFields: {
|
|
8835
|
+
plateNumber: {
|
|
8836
|
+
$first: "$person.plateNumber"
|
|
8837
|
+
}
|
|
8838
|
+
}
|
|
8839
|
+
},
|
|
8840
|
+
{
|
|
8841
|
+
$project: {
|
|
8842
|
+
person: 0
|
|
8843
|
+
}
|
|
8844
|
+
}
|
|
8817
8845
|
]).toArray();
|
|
8818
8846
|
const data = results.length > 0 ? results[0] : null;
|
|
8819
8847
|
if (!data) {
|
|
@@ -65323,20 +65351,21 @@ var useRedDotPaymentRepo = () => {
|
|
|
65323
65351
|
session?.endSession();
|
|
65324
65352
|
}
|
|
65325
65353
|
}
|
|
65326
|
-
async function updateStatus(
|
|
65327
|
-
|
|
65328
|
-
|
|
65329
|
-
|
|
65330
|
-
throw new import_node_server_utils224.BadRequestError("Invalid payment ID format.");
|
|
65354
|
+
async function updateStatus(referenceNumber, status, session) {
|
|
65355
|
+
const reference = typeof referenceNumber === "string" ? referenceNumber.trim() : "";
|
|
65356
|
+
if (!reference) {
|
|
65357
|
+
throw new import_node_server_utils224.BadRequestError("Reference number is required.");
|
|
65331
65358
|
}
|
|
65332
65359
|
try {
|
|
65333
65360
|
const res = await paymentCollection().updateOne(
|
|
65334
|
-
{
|
|
65361
|
+
{ referenceNumber: reference, status: "pending" },
|
|
65335
65362
|
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
65336
65363
|
{ session }
|
|
65337
65364
|
);
|
|
65338
65365
|
if (res.matchedCount === 0) {
|
|
65339
|
-
throw new import_node_server_utils224.NotFoundError(
|
|
65366
|
+
throw new import_node_server_utils224.NotFoundError(
|
|
65367
|
+
"Payment not found or is no longer pending."
|
|
65368
|
+
);
|
|
65340
65369
|
}
|
|
65341
65370
|
return res;
|
|
65342
65371
|
} catch (error) {
|
|
@@ -65505,7 +65534,11 @@ var useRedDotPaymentSvc = () => {
|
|
|
65505
65534
|
var import_joi127 = __toESM(require("joi"));
|
|
65506
65535
|
var import_node_server_utils226 = require("@7365admin1/node-server-utils");
|
|
65507
65536
|
function useRedDotPaymentController() {
|
|
65508
|
-
const {
|
|
65537
|
+
const {
|
|
65538
|
+
createPayment: _createPayment,
|
|
65539
|
+
updateStatus: _updateStatus,
|
|
65540
|
+
getPaymentByReference: _getPaymentByReference
|
|
65541
|
+
} = useRedDotPaymentRepo();
|
|
65509
65542
|
const redirectPaymentTransaction = async (req, res) => {
|
|
65510
65543
|
try {
|
|
65511
65544
|
const data = req.body;
|
|
@@ -65579,11 +65612,11 @@ function useRedDotPaymentController() {
|
|
|
65579
65612
|
}
|
|
65580
65613
|
async function updateStatus(req, res, next) {
|
|
65581
65614
|
const schema2 = import_joi127.default.object({
|
|
65582
|
-
|
|
65615
|
+
referenceNumber: import_joi127.default.string().required(),
|
|
65583
65616
|
status: import_joi127.default.string().valid(...Object.values(BillingPaymentStatus)).required()
|
|
65584
65617
|
});
|
|
65585
65618
|
const { error, value } = schema2.validate({
|
|
65586
|
-
|
|
65619
|
+
referenceNumber: req.params.id,
|
|
65587
65620
|
status: req.body.status
|
|
65588
65621
|
});
|
|
65589
65622
|
if (error) {
|
|
@@ -65592,7 +65625,7 @@ function useRedDotPaymentController() {
|
|
|
65592
65625
|
return;
|
|
65593
65626
|
}
|
|
65594
65627
|
try {
|
|
65595
|
-
const data = await _updateStatus(value.
|
|
65628
|
+
const data = await _updateStatus(value.referenceNumber, value.status);
|
|
65596
65629
|
res.status(200).json({ message: "success", data });
|
|
65597
65630
|
return;
|
|
65598
65631
|
} catch (error2) {
|