Skip to content

Commit

Permalink
Updated data integrity verification feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Hibar3 authored May 21, 2018
1 parent 78f6448 commit a8aa446
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions Seamless_Integration/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//*******SEAMLESS INTEGRATION*******//

var express = require('express');
var bodyParser = require('body-parser');
var app = express();
Expand All @@ -12,14 +11,14 @@ var md5 = require('md5');

app.use(bodyParser.json());

/*
The codes below are used to call static items if you are using css and images.
This will allow you to access your css and images when you execute this codes in localhost
Alternately you can create public a folder/director '/public' to and put all our files there
*/
app.use('/css', express.static(path.join(__dirname, 'css')));
app.use('/images', express.static(path.join(__dirname, 'images')));


var merchant_id = "";//Insert merchant id here
var orderid = ""; // Order ID should be random generated by merchant function
var vkey = "**************"; //Replace ********** with your MOLPay verification_Key

var enviroment = "sandbox"; //sandbox or production
var URL;

Expand Down Expand Up @@ -63,6 +62,13 @@ var error_code;
var error_desc;
var channel;

var merchant_id = "";//Insert merchant id here
var orderid = ""; // Order ID should be random generated by merchant function
var vkey = "*************"; //Replace ********** with your MOLPay verification_Key
var secret_key = "***********";//Replace ********** with your MOLPay Private Secret_Key
var key0;
var key1;

// The '/' below reads from the main directory where your project is at. Just make sure your codes are in the same folder or directory
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));// Opens your main html file
Expand Down Expand Up @@ -146,6 +152,23 @@ function MolPayObj(req,res){
error_desc,
channel
};

/***********************************************************
* To verify the data integrity sending by MOLPay
************************************************************/
//md5 encryption
key0 = md5( tranID+orderid+status+domain+amount+currency );
key1 = md5( paydate+domain+key0+appcode+secret_key );

//control statement for verification
if(skey != key1){
status = -1; // Invalid transaction
console.log('Invalid');
// failure action. Write your script here .....
}else{
console.log('Approved');
//Write your script here .....
}

console.log(response);
res.end(JSON.stringify(response));//convert the response into JSON format and print it to '/returnurl'
Expand Down

0 comments on commit a8aa446

Please sign in to comment.