Secure TPV transactions ready!

parent 01e0de89
Showing with 2 additions and 6 deletions
...@@ -118,8 +118,6 @@ module.exports = { ...@@ -118,8 +118,6 @@ module.exports = {
notify: function(req, res) { notify: function(req, res) {
var params = req.allParams(); var params = req.allParams();
console.log("params: " + JSON.stringify(params));
if (!params.Ds_Signature || !params.Ds_MerchantParameters) if (!params.Ds_Signature || !params.Ds_MerchantParameters)
return res.badRequest(); return res.badRequest();
...@@ -127,12 +125,9 @@ module.exports = { ...@@ -127,12 +125,9 @@ module.exports = {
var postParams = params.Ds_MerchantParameters; var postParams = params.Ds_MerchantParameters;
var decodedParams = decodeMerchantParams(postParams); var decodedParams = decodeMerchantParams(postParams);
console.log("Posted merchant params:" + JSON.stringify(decodedParams));
var ownParams = decodeMerchantParams(decodedParams.Ds_MerchantData); var ownParams = decodeMerchantParams(decodedParams.Ds_MerchantData);
console.log("Posted own merchant params:" + JSON.stringify(ownParams));
var key = cipherMerchantKey(decodedParams.Ds_Order, sails.config.pictogram.tpv.key); var key = cipherMerchantKey(decodedParams.Ds_Order, sails.config.pictogram.tpv.key);
var signatureBase64 = signMerchantParams(postParams, key); var signatureBase64 = signMerchantParams(postParams, key);
console.log("postSignature: " + postSignature + "\nsignatureBase64: " + signatureBase64);
if (postSignature != signatureBase64) { if (postSignature != signatureBase64) {
...@@ -141,7 +136,7 @@ module.exports = { ...@@ -141,7 +136,7 @@ module.exports = {
signatureBase64 = signatureBase64.replace(/\+/gi, "-"); // Change any plus (+) characters to dashes (-) signatureBase64 = signatureBase64.replace(/\+/gi, "-"); // Change any plus (+) characters to dashes (-)
signatureBase64 = signatureBase64.replace(/\//gi, "_"); // Change any slashes (/) characters to underscores (_) signatureBase64 = signatureBase64.replace(/\//gi, "_"); // Change any slashes (/) characters to underscores (_)
if (postSignature != signatureBase64) { if (postSignature != signatureBase64) {
console.log("tpv/notify: Signature verification on TPV operation failed"); sails.log.debug("tpv/notify: Signature verification on TPV operation failed");
return res.badRequest("Invalid signature"); return res.badRequest("Invalid signature");
} }
} }
...@@ -175,6 +170,7 @@ module.exports = { ...@@ -175,6 +170,7 @@ module.exports = {
License.activate(license.number, parseInt(ownParams.id_stu), function(err, license) { License.activate(license.number, parseInt(ownParams.id_stu), function(err, license) {
if (err) if (err)
return res.badRequest(err); return res.badRequest(err);
sails.log.debug("New license sold! " + license.number);
return res.ok(license); return res.ok(license);
}); });
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment