Comparing version 1.0.12 to 1.0.13
@@ -10,4 +10,4 @@ var DocumentScheme = function () { | ||
"trade_date": 0, | ||
"total_amount_net": 300, | ||
"total_amount_gross": 300, | ||
"total_amount_net": 0, | ||
"total_amount_gross": 0, | ||
"seller_data": { | ||
@@ -14,0 +14,0 @@ "company": { |
43
index.js
@@ -59,2 +59,4 @@ var SoapService = require("./SoapService.js"), DocumentScheme = require("./DocumentScheme.js"); | ||
var taskTracker = {}; | ||
// ERRORS | ||
@@ -81,2 +83,6 @@ var errs = { | ||
description: "Data.user.userName must be a string with minimum 4 characters length." | ||
}, | ||
ERR_INVALID_TASKID: { | ||
err: "ERR_INVALID_TASKID", | ||
description: "Invalid taskId sent." | ||
} | ||
@@ -178,2 +184,3 @@ }; | ||
var requestDeliveryData = "NOT_NEEDED"; | ||
// Wczytanie produktów. | ||
@@ -183,3 +190,2 @@ for (var i = 0; i < paymentData.itemsId.length; i++) { | ||
var item = this.Product(itemId); | ||
document.sales_document_data.total_amount_net += item.amount_net * item.quantity; | ||
@@ -207,4 +213,5 @@ document.sales_document_data.total_amount_gross += item.amount_gross * item.quantity; | ||
var wui = self.App24(document.sales_document_data.items, document.sales_document_data.delivery_option); | ||
var data = { | ||
WUI: self.App24(document.sales_document_data.items, document.sales_document_data.delivery_option), | ||
WUI: wui, | ||
params: { | ||
@@ -227,15 +234,27 @@ type: "NORMAL", | ||
SoapService.call["requestPaymentInitiation"](data, function(requestResponse){ | ||
console.log(requestResponse); | ||
SoapService.call["requestPaymentInitiation"](data, function(requestResponse) { | ||
res.json(requestResponse); | ||
if (requestResponse.requestStatus === "SUCCESS") { | ||
taskTracker[requestResponse.taskId] = wui; | ||
var interval = setInterval(function(){ | ||
SoapService.call["getTaskStatus"]({ | ||
taskId: requestResponse.taskId | ||
WUI: wui, | ||
params: { | ||
taskId: requestResponse.taskId | ||
} | ||
}, function(taskResponse){ | ||
console.log(taskResponse); | ||
if (taskResponse.requestStatus !== "SUCCESS") { | ||
console.log(taskResponse); | ||
setInterval(function(){ | ||
delete taskTracker[requestResponse.taskId]; | ||
}, 30000); | ||
return clearInterval(interval); | ||
}; | ||
if (taskResponse.status.split("_")[0] === "FINISHED" || taskResponse.progressPercent === 100) { | ||
clearInterval(interval); | ||
setInterval(function(){ | ||
delete taskTracker[requestResponse.taskId]; | ||
}, 30000); | ||
} | ||
@@ -254,4 +273,14 @@ | ||
paymentStatus: function (taskId, cb) { | ||
if (typeof taskId !== "string") { | ||
return cb(errs.ERR_INVALID_TASKID); | ||
} | ||
var self = this; | ||
var wui = taskTracker[taskId]; | ||
SoapService.call["getTaskStatus"]({ | ||
taskId: taskId | ||
WUI: wui, | ||
params: { | ||
taskId: taskId | ||
} | ||
}, function (taskResponse) { | ||
@@ -258,0 +287,0 @@ if (cb) { |
{ | ||
"name": "billon", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15478
505