Secure TPV transactions ready!

parent 01e0de89
Showing with 3 additions and 7 deletions
......@@ -118,8 +118,6 @@ module.exports = {
notify: function(req, res) {
var params = req.allParams();
console.log("params: " + JSON.stringify(params));
if (!params.Ds_Signature || !params.Ds_MerchantParameters)
return res.badRequest();
......@@ -127,12 +125,9 @@ module.exports = {
var postParams = params.Ds_MerchantParameters;
var decodedParams = decodeMerchantParams(postParams);
console.log("Posted merchant params:" + JSON.stringify(decodedParams));
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 signatureBase64 = signMerchantParams(postParams, key);
console.log("postSignature: " + postSignature + "\nsignatureBase64: " + signatureBase64);
if (postSignature != signatureBase64) {
......@@ -141,7 +136,7 @@ module.exports = {
signatureBase64 = signatureBase64.replace(/\+/gi, "-"); // Change any plus (+) characters to dashes (-)
signatureBase64 = signatureBase64.replace(/\//gi, "_"); // Change any slashes (/) characters to underscores (_)
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");
}
}
......@@ -174,7 +169,8 @@ module.exports = {
License.activate(license.number, parseInt(ownParams.id_stu), function(err, license) {
if (err)
return res.badRequest(err);
return res.badRequest(err);
sails.log.debug("New license sold! " + license.number);
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