nets-service-sdk 1.1.18 → 1.1.19

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.
Files changed (2) hide show
  1. package/dist/index.js +21 -11
  2. package/package.json +5 -3
package/dist/index.js CHANGED
@@ -502,13 +502,19 @@ var require_parser = __commonJS({
502
502
  const data = { ...obj };
503
503
  const keys = Object.keys(data);
504
504
  const translatedJson = {};
505
+ const ecnError = CheckECNERROR(obj["ECN"]);
506
+ if (ecnError) {
507
+ translatedJson.status = ecnError.status;
508
+ translatedJson.description = ecnError.detail;
509
+ translatedJson.category = ecnError.category;
510
+ }
505
511
  keys.forEach((key) => {
506
512
  if (key == "01") {
507
513
  translatedJson["approvalCode"] = obj[key];
508
514
  }
509
515
  if (key == "02") {
510
516
  const statusResponse = statusCheck(obj[key]);
511
- if (statusResponse) {
517
+ if (statusResponse && !translatedJson.status) {
512
518
  translatedJson.status = statusResponse.status;
513
519
  translatedJson.description = statusResponse.detail;
514
520
  translatedJson.category = statusResponse.category;
@@ -516,12 +522,6 @@ var require_parser = __commonJS({
516
522
  translatedJson["balance"] = statusResponse.balance;
517
523
  }
518
524
  }
519
- const ecnnError = CheckECNERROR(obj["ECN"]);
520
- if (ecnnError) {
521
- translatedJson.status = ecnnError.status;
522
- translatedJson.description = ecnnError.detail;
523
- translatedJson.category = ecnnError.category;
524
- }
525
525
  translatedJson["responsetext"] = obj[key];
526
526
  }
527
527
  if (key == "03") {
@@ -602,7 +602,7 @@ var require_parser = __commonJS({
602
602
  if (key == "HC") {
603
603
  translatedJson["hostResponseCode"] = obj[key];
604
604
  const mapped = getResponseFromCode(obj[key]);
605
- if (mapped) {
605
+ if (mapped && !translatedJson.status) {
606
606
  translatedJson.status = mapped.status;
607
607
  translatedJson.description = mapped.detail;
608
608
  translatedJson.category = mapped.category;
@@ -648,6 +648,11 @@ var require_parser = __commonJS({
648
648
  translatedJson["receiptTextFormat"] = obj[key];
649
649
  }
650
650
  });
651
+ if (!translatedJson.status) {
652
+ translatedJson.status = "UNKNOWN";
653
+ translatedJson.description = "NO_RESPONSE_CODE";
654
+ translatedJson.category = "RETRY";
655
+ }
651
656
  logger.log({ level: "info", message: "jsonProcessor translated terminal response into JSON format." });
652
657
  return { translated: translatedJson, raw: obj };
653
658
  };
@@ -680,6 +685,9 @@ var require_parser = __commonJS({
680
685
  if (data?.indexOf("DECLINED") > -1) {
681
686
  return { status: "DECLINED", detail: "Transaction Declined", category: "HARD_FAIL" };
682
687
  }
688
+ if (data?.indexOf("CANCELLED") > -1) {
689
+ return { status: "USER_CANCELLED", detail: "USER_CANCELLED", category: "HARD_FAIL" };
690
+ }
683
691
  if (data?.indexOf("CARD NOT SUPPORTED") > -1) {
684
692
  return { status: "CARD_NOT_SUPPORTED", detail: "Card not supported", category: "HARD_FAIL" };
685
693
  }
@@ -1292,7 +1300,7 @@ var require_package = __commonJS({
1292
1300
  "package.json"(exports2, module2) {
1293
1301
  module2.exports = {
1294
1302
  name: "nets-service-sdk",
1295
- version: "1.1.18",
1303
+ version: "1.1.19",
1296
1304
  description: "Utility functions for Nets Service",
1297
1305
  source: "src/index.js",
1298
1306
  main: "dist/index.js",
@@ -1301,7 +1309,7 @@ var require_package = __commonJS({
1301
1309
  scripts: {
1302
1310
  build: "esbuild src/index.js --bundle --platform=node --packages=external --outfile=dist/index.js",
1303
1311
  watch: "microbundle watch",
1304
- test: 'echo "Error: no test specified" && exit 1'
1312
+ test: "jest"
1305
1313
  },
1306
1314
  keywords: [
1307
1315
  "nets",
@@ -1327,10 +1335,12 @@ var require_package = __commonJS({
1327
1335
  request: "^2.88.2",
1328
1336
  serialport: "^10.5.0",
1329
1337
  "socket.io-client": "^4.7.2",
1330
- winston: "^3.8.2"
1338
+ winston: "^3.8.2",
1339
+ "winston-daily-rotate-file": "^5.0.0"
1331
1340
  },
1332
1341
  devDependencies: {
1333
1342
  esbuild: "^0.27.0",
1343
+ jest: "^30.3.0",
1334
1344
  microbundle: "^0.15.1"
1335
1345
  }
1336
1346
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nets-service-sdk",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "description": "Utility functions for Nets Service",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "build": "esbuild src/index.js --bundle --platform=node --packages=external --outfile=dist/index.js",
11
11
  "watch": "microbundle watch",
12
- "test": "echo \"Error: no test specified\" && exit 1"
12
+ "test": "jest"
13
13
  },
14
14
  "keywords": [
15
15
  "nets",
@@ -35,10 +35,12 @@
35
35
  "request": "^2.88.2",
36
36
  "serialport": "^10.5.0",
37
37
  "socket.io-client": "^4.7.2",
38
- "winston": "^3.8.2"
38
+ "winston": "^3.8.2",
39
+ "winston-daily-rotate-file": "^5.0.0"
39
40
  },
40
41
  "devDependencies": {
41
42
  "esbuild": "^0.27.0",
43
+ "jest": "^30.3.0",
42
44
  "microbundle": "^0.15.1"
43
45
  }
44
46
  }