diff --git a/config/rgProperties.json b/config/rgProperties.json index 43be9b1..d3535b2 100644 --- a/config/rgProperties.json +++ b/config/rgProperties.json @@ -10,7 +10,7 @@ "LIVE_HOST_16": "gateway-16.rocketgate.com", "LIVE_HOST_17": "gateway-17.rocketgate.com", "TEST_HOST": "dev-gateway.rocketgate.com", - "VERSION_NUMBER": "K2.5" + "VERSION_NUMBER": "K2.6" }, "responseSettings": { "VERSION_INDICATOR": "version", diff --git a/lib/utils.js b/lib/utils.js index a291e58..a2325e4 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,18 +1,31 @@ -var xml2json = require('xml2json'), - json2xml = require("json2xml"); +const { XMLParser, XMLBuilder } = require('fast-xml-parser'); -var exports = module.exports = { +const parser = new XMLParser({ + attributeNamePrefix: "", + textNodeName: "$t", + parseTagValue: false, + ignoreDeclaration: true, + ignoreAttributes: false, +}); + +const builder = new XMLBuilder({ + ignoreAttributes: false, + attributeNamePrefix: "$", + textNodeName: "$t", +}); +var exports = module.exports = { toXML: function (params, callback) { try { - callback(null, json2xml({ gatewayRequest: params }, { header: true })); + const xml = builder.build({ '?xml': { '$version': '1.0', '$encoding': 'UTF-8' }, gatewayRequest: params }); + callback(null, xml); } catch (err) { callback(err); } }, fromXML: function (xmlDocument, callback) { try { - callback(null, JSON.parse(xml2json.toJson(xmlDocument)).gatewayResponse); + callback(null, parser.parse(xmlDocument).gatewayResponse); } catch (err) { callback(err); } diff --git a/package.json b/package.json index 1df30a4..fcdbadd 100644 --- a/package.json +++ b/package.json @@ -24,12 +24,11 @@ ], "dependencies": { "async": "2.1.x", + "fast-xml-parser": "5.3.x", "is_js": "0.9.x", - "json2xml": "0.1.x", "moment": "2.15.x", "request": "2.76.x", - "urlencode": "1.1.x", - "xml2json": "0.10.x" + "urlencode": "1.1.x" }, "devDependencies": { "eslint": "^3.17.1",