nets-service-sdk 1.1.17 → 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 +28 -14
  2. package/package.json +5 -3
package/dist/index.js CHANGED
@@ -68,9 +68,10 @@ var require_winston = __commonJS({
68
68
  const parts = callingModule.filename.split(path.sep);
69
69
  return path.join(parts[parts.length - 1], parts.pop());
70
70
  };
71
- var myFormat = printf(
72
- ({ level, message, label: label2, timestamp: timestamp2 }) => `${timestamp2} [${label2}] ${level}: ${message}`
73
- );
71
+ var myFormat = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
72
+ const versionPrefix = global.appVersion ? `[v${global.appVersion}] ` : "";
73
+ return `${timestamp2} [${label2}] ${versionPrefix}${level}: ${message}`;
74
+ });
74
75
  var logger = (module3) => createLogger({
75
76
  format: combine(label({ label: getLabel(module3) }), timestamp(), myFormat),
76
77
  transports: [
@@ -198,6 +199,9 @@ var require_sendMessage = __commonJS({
198
199
  module2.exports.sendMessage = (room = "clientRoom", tag, msg) => {
199
200
  if (typeof msg === "object" && msg !== null) {
200
201
  msg.sdkVersion = sdkVersion;
202
+ if (global.appVersion) {
203
+ msg.appVersion = global.appVersion;
204
+ }
201
205
  }
202
206
  logger.log({
203
207
  level: "info",
@@ -498,13 +502,19 @@ var require_parser = __commonJS({
498
502
  const data = { ...obj };
499
503
  const keys = Object.keys(data);
500
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
+ }
501
511
  keys.forEach((key) => {
502
512
  if (key == "01") {
503
513
  translatedJson["approvalCode"] = obj[key];
504
514
  }
505
515
  if (key == "02") {
506
516
  const statusResponse = statusCheck(obj[key]);
507
- if (statusResponse) {
517
+ if (statusResponse && !translatedJson.status) {
508
518
  translatedJson.status = statusResponse.status;
509
519
  translatedJson.description = statusResponse.detail;
510
520
  translatedJson.category = statusResponse.category;
@@ -512,12 +522,6 @@ var require_parser = __commonJS({
512
522
  translatedJson["balance"] = statusResponse.balance;
513
523
  }
514
524
  }
515
- const ecnnError = CheckECNERROR(obj["ECN"]);
516
- if (ecnnError) {
517
- translatedJson.status = ecnnError.status;
518
- translatedJson.description = ecnnError.detail;
519
- translatedJson.category = ecnnError.category;
520
- }
521
525
  translatedJson["responsetext"] = obj[key];
522
526
  }
523
527
  if (key == "03") {
@@ -598,7 +602,7 @@ var require_parser = __commonJS({
598
602
  if (key == "HC") {
599
603
  translatedJson["hostResponseCode"] = obj[key];
600
604
  const mapped = getResponseFromCode(obj[key]);
601
- if (mapped) {
605
+ if (mapped && !translatedJson.status) {
602
606
  translatedJson.status = mapped.status;
603
607
  translatedJson.description = mapped.detail;
604
608
  translatedJson.category = mapped.category;
@@ -644,6 +648,11 @@ var require_parser = __commonJS({
644
648
  translatedJson["receiptTextFormat"] = obj[key];
645
649
  }
646
650
  });
651
+ if (!translatedJson.status) {
652
+ translatedJson.status = "UNKNOWN";
653
+ translatedJson.description = "NO_RESPONSE_CODE";
654
+ translatedJson.category = "RETRY";
655
+ }
647
656
  logger.log({ level: "info", message: "jsonProcessor translated terminal response into JSON format." });
648
657
  return { translated: translatedJson, raw: obj };
649
658
  };
@@ -676,6 +685,9 @@ var require_parser = __commonJS({
676
685
  if (data?.indexOf("DECLINED") > -1) {
677
686
  return { status: "DECLINED", detail: "Transaction Declined", category: "HARD_FAIL" };
678
687
  }
688
+ if (data?.indexOf("CANCELLED") > -1) {
689
+ return { status: "USER_CANCELLED", detail: "USER_CANCELLED", category: "HARD_FAIL" };
690
+ }
679
691
  if (data?.indexOf("CARD NOT SUPPORTED") > -1) {
680
692
  return { status: "CARD_NOT_SUPPORTED", detail: "Card not supported", category: "HARD_FAIL" };
681
693
  }
@@ -1288,7 +1300,7 @@ var require_package = __commonJS({
1288
1300
  "package.json"(exports2, module2) {
1289
1301
  module2.exports = {
1290
1302
  name: "nets-service-sdk",
1291
- version: "1.1.17",
1303
+ version: "1.1.19",
1292
1304
  description: "Utility functions for Nets Service",
1293
1305
  source: "src/index.js",
1294
1306
  main: "dist/index.js",
@@ -1297,7 +1309,7 @@ var require_package = __commonJS({
1297
1309
  scripts: {
1298
1310
  build: "esbuild src/index.js --bundle --platform=node --packages=external --outfile=dist/index.js",
1299
1311
  watch: "microbundle watch",
1300
- test: 'echo "Error: no test specified" && exit 1'
1312
+ test: "jest"
1301
1313
  },
1302
1314
  keywords: [
1303
1315
  "nets",
@@ -1323,10 +1335,12 @@ var require_package = __commonJS({
1323
1335
  request: "^2.88.2",
1324
1336
  serialport: "^10.5.0",
1325
1337
  "socket.io-client": "^4.7.2",
1326
- winston: "^3.8.2"
1338
+ winston: "^3.8.2",
1339
+ "winston-daily-rotate-file": "^5.0.0"
1327
1340
  },
1328
1341
  devDependencies: {
1329
1342
  esbuild: "^0.27.0",
1343
+ jest: "^30.3.0",
1330
1344
  microbundle: "^0.15.1"
1331
1345
  }
1332
1346
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nets-service-sdk",
3
- "version": "1.1.17",
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
  }