Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d7b7bf05
authored
Sep 18, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Secure TPV transactions ready!
parent
01e0de89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
sails/src/api/controllers/TPVController.js
sails/src/api/controllers/TPVController.js
View file @
d7b7bf05
...
...
@@ -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
.
lo
g
(
"tpv/notify: Signature verification on TPV operation failed"
);
sails
.
log
.
debu
g
(
"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
);
});
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment