Fix orderData method

This commit is contained in:
Vladislav Hristov 2018-07-04 16:30:16 +03:00
parent 044bbba9e3
commit 5d4e9f8309
2 changed files with 3 additions and 12 deletions

View File

@ -78,7 +78,7 @@ module.exports = class Client {
const returnedBusinessCode = res.businessCode();
return {
orderData: xml,
orderData: xml.length ? xml.toString() : xml,
orderId: res.orderId(),
technicalCode: returnedTechnicalCode,

View File

@ -47,7 +47,7 @@ module.exports = (xml, keys) => ({
const decipher = crypto.createDecipheriv('aes-128-cbc', this.transactionKey(), DEFAULT_IV).setAutoPadding(false);
const data = Buffer.from(decipher.update(orderData, 'base64', 'binary') + decipher.final('binary'), 'binary');
return zlib.inflateSync(data).toString();
return zlib.inflateSync(data);
},
transactionKey() {
@ -111,17 +111,8 @@ module.exports = (xml, keys) => ({
return errors.technical[code].meaning;
},
/* returnCode(where = 'header') {
const select = xpath.useNamespaces({ xmlns: 'urn:org:ebics:H004' });
const node = where === 'header'
? select('//xmlns:header/xmlns:mutable/xmlns:ReturnCode', this.doc)
: select('//xmlns:body/xmlns:ReturnCode', this.doc);
return node.length ? node[0].textContent : '';
}, */
bankKeys() {
const orderData = this.orderData();
const orderData = this.orderData().toString();
if (!Object.keys(orderData).length) return {};
const doc = new DOMParser().parseFromString(orderData, 'text/xml');