@riocrypto/common-server 1.0.1758 → 1.0.1759
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.
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.getOrderFromReference = void 0;
|
|
13
13
|
const order_1 = require("../models/order");
|
|
14
|
+
const common_1 = require("@riocrypto/common");
|
|
14
15
|
const getOrderFromReference = (reference, mongoose) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
16
|
// Ensure reference is defined and exactly 6 characters long
|
|
16
17
|
if (!reference || reference.length !== 6) {
|
|
@@ -19,8 +20,9 @@ const getOrderFromReference = (reference, mongoose) => __awaiter(void 0, void 0,
|
|
|
19
20
|
// Convert reference to lowercase to ensure case-insensitive comparison
|
|
20
21
|
const orderIdPart = reference.toLowerCase();
|
|
21
22
|
const Order = (0, order_1.buildOrder)(mongoose);
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
const orders = yield Order.find({
|
|
24
|
+
status: { $in: [common_1.OrderStatus.AwaitingPayment, common_1.OrderStatus.Processing] },
|
|
25
|
+
});
|
|
24
26
|
const order = orders.find((order) => order.id.toString().endsWith(orderIdPart));
|
|
25
27
|
if (!order) {
|
|
26
28
|
throw new Error("Order not found");
|