@7365admin1/core 3.32.2-staging.52 → 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 CHANGED
@@ -6980,7 +6980,7 @@ declare const useRedDotPaymentRepo: () => {
6980
6980
  message: string;
6981
6981
  remainingBalance: number;
6982
6982
  }>;
6983
- updateStatus: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
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
@@ -64947,6 +64947,7 @@ var BillingPaymentStatus = /* @__PURE__ */ ((BillingPaymentStatus2) => {
64947
64947
  BillingPaymentStatus2["SUCCESS"] = "success";
64948
64948
  BillingPaymentStatus2["FAILED"] = "failed";
64949
64949
  BillingPaymentStatus2["PARTIAL"] = "partial";
64950
+ BillingPaymentStatus2["CANCELLED"] = "cancelled";
64950
64951
  return BillingPaymentStatus2;
64951
64952
  })(BillingPaymentStatus || {});
64952
64953
  var schemaBillingItems = import_joi126.default.object({
@@ -65322,20 +65323,21 @@ var useRedDotPaymentRepo = () => {
65322
65323
  session?.endSession();
65323
65324
  }
65324
65325
  }
65325
- async function updateStatus(_id, status, session) {
65326
- try {
65327
- _id = new import_mongodb135.ObjectId(_id);
65328
- } catch {
65329
- 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.");
65330
65330
  }
65331
65331
  try {
65332
65332
  const res = await paymentCollection().updateOne(
65333
- { _id },
65333
+ { referenceNumber: reference, status: "pending" },
65334
65334
  { $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
65335
65335
  { session }
65336
65336
  );
65337
65337
  if (res.matchedCount === 0) {
65338
- throw new import_node_server_utils224.NotFoundError("Payment not found.");
65338
+ throw new import_node_server_utils224.NotFoundError(
65339
+ "Payment not found or is no longer pending."
65340
+ );
65339
65341
  }
65340
65342
  return res;
65341
65343
  } catch (error) {
@@ -65504,7 +65506,11 @@ var useRedDotPaymentSvc = () => {
65504
65506
  var import_joi127 = __toESM(require("joi"));
65505
65507
  var import_node_server_utils226 = require("@7365admin1/node-server-utils");
65506
65508
  function useRedDotPaymentController() {
65507
- const { createPayment: _createPayment, updateStatus: _updateStatus, getPaymentByReference: _getPaymentByReference } = useRedDotPaymentRepo();
65509
+ const {
65510
+ createPayment: _createPayment,
65511
+ updateStatus: _updateStatus,
65512
+ getPaymentByReference: _getPaymentByReference
65513
+ } = useRedDotPaymentRepo();
65508
65514
  const redirectPaymentTransaction = async (req, res) => {
65509
65515
  try {
65510
65516
  const data = req.body;
@@ -65578,11 +65584,11 @@ function useRedDotPaymentController() {
65578
65584
  }
65579
65585
  async function updateStatus(req, res, next) {
65580
65586
  const schema2 = import_joi127.default.object({
65581
- _id: import_joi127.default.string().hex().length(24).required(),
65587
+ referenceNumber: import_joi127.default.string().required(),
65582
65588
  status: import_joi127.default.string().valid(...Object.values(BillingPaymentStatus)).required()
65583
65589
  });
65584
65590
  const { error, value } = schema2.validate({
65585
- _id: req.params.id,
65591
+ referenceNumber: req.params.id,
65586
65592
  status: req.body.status
65587
65593
  });
65588
65594
  if (error) {
@@ -65591,7 +65597,7 @@ function useRedDotPaymentController() {
65591
65597
  return;
65592
65598
  }
65593
65599
  try {
65594
- const data = await _updateStatus(value._id, value.status);
65600
+ const data = await _updateStatus(value.referenceNumber, value.status);
65595
65601
  res.status(200).json({ message: "success", data });
65596
65602
  return;
65597
65603
  } catch (error2) {
@@ -65615,6 +65621,7 @@ function useRedDotPaymentController() {
65615
65621
  return;
65616
65622
  } catch (error2) {
65617
65623
  next(error2);
65624
+ return;
65618
65625
  }
65619
65626
  }
65620
65627
  return {