@riocrypto/common-server 1.0.2670 → 1.0.2672

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.
@@ -28,7 +28,17 @@ const getBulkPaymentFromReference = (reference, mongoose) => __awaiter(void 0, v
28
28
  ],
29
29
  },
30
30
  });
31
- // Reference format: 2 chars from random portion (8-9) + last 6 chars of ID
31
+ // First try exact match on stored reference field (most reliable)
32
+ const exactMatch = bulkPayments.find((bp) => { var _a; return ((_a = bp.reference) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === referenceText; });
33
+ if (exactMatch) {
34
+ return exactMatch;
35
+ }
36
+ // Bulk payment references must contain "bp" prefix to avoid false positives
37
+ // with order references that don't have this prefix
38
+ if (!referenceText.includes("bp")) {
39
+ throw new Error("Bulk payment not found");
40
+ }
41
+ // Match by ID pattern: 2 chars from random portion (8-9) + last 6 chars
32
42
  const bulkPayment = bulkPayments.find((bulkPayment) => {
33
43
  const bulkPaymentId = bulkPayment.id.toString().toLowerCase();
34
44
  const randomPrefix = bulkPaymentId.slice(8, 10);
@@ -47,14 +47,13 @@ const getOrderFromReference = (reference, mongoose) => __awaiter(void 0, void 0,
47
47
  break;
48
48
  }
49
49
  // Check each order ID against the reference
50
- // Reference format: 2 chars from random portion (8-9) + last 6 chars of order ID
50
+ // Reference format: 2 chars from random portion (8-9) + last 6 chars
51
51
  for (const order of orders) {
52
52
  const orderId = order._id.toString().toLowerCase();
53
53
  const randomPrefix = orderId.slice(8, 10);
54
54
  const last6 = orderId.slice(-6);
55
55
  const reference8Chars = randomPrefix + last6;
56
56
  if (referenceText.includes(reference8Chars)) {
57
- // Found a match, now fetch the full order document
58
57
  foundOrder = yield Order.findById(order._id);
59
58
  break;
60
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2670",
3
+ "version": "1.0.2672",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",