Last active
August 28, 2016 17:45
-
-
Save moorthi07/7a481299d4299ff1d2223161ad816df9 to your computer and use it in GitHub Desktop.
deployd mastercard api call inside validate event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.demandIn = function() { | |
var self = this; | |
self.port = process.env.PORT || 5500; | |
self.serverIp = process.env.serverIP; | |
console.log(self.serverIp); | |
if (typeof self.serverIp === "undefined" ) { | |
console.log("hhhhh....") | |
self.serverIp = "127.0.0.1"; | |
} | |
var Simplify = require("simplify-commerce"), | |
client = Simplify.getClient({ | |
//modified keys | |
publicKey: 'sbpb_Nzc2ZTU3MTctNjYxNtNTVjYWZhN2ZmNDk4', | |
privateKey: 'Uos34pHcq2UPE3nqEde6/D0DJHTxsGfng/F5YFFQL0ODSXAOkNtXTToq' | |
}); | |
// var express = require('express'); | |
// var app = express(); | |
// app.get('/', function(req,res){ | |
// res.send('Hello there, please us appropriate API') | |
// }); | |
// client.cusotmer.create({ | |
// email : req.body['email'], | |
// name : req.body['FullName'], | |
// card : { | |
// expMonth :req.body['expMonth'], | |
// expYear : req.body['expYear'], | |
// cvc : req.body['cardCVC'], | |
// number : req.body['cardNumber'] | |
// }, | |
// } | |
// app.post('/authorizeCard', function(req, res) { | |
client.cusotmer.create({ | |
email : "pv@svc.com", | |
name : "MoorthiPV", | |
card : { | |
expMonth :'4', | |
expYear : '17', | |
cvc : '334', | |
number : '1234567899990017' | |
}, | |
}, function(errData, data) { | |
if (errData) { | |
res.json({ | |
isSuccessful: false, | |
message: errData.data.error.message | |
}); | |
} else { | |
console.log(data['card']['customer']['id']); | |
res.json({ | |
isSuccessful: true, | |
customerToken: data['card']['customer']['id'] | |
}); | |
} | |
}); | |
// }); | |
// app.post('/doPayment', function(req, res) { | |
// client.payment.create({ | |
// customer : req.body['customerToken'], | |
// amount : req.body['amountInCents'], | |
// currency: "USD", | |
// description: req.body['paymentFor']}); | |
// }, function(errData, data) { | |
// if (errData) { | |
// res.json({ | |
// isSuccessful: false, | |
// message: errData.data.error.message | |
// }); | |
// } else { | |
// console.log(data['card']['customer']['id']); | |
// res.json({ | |
// isSuccessful: true, | |
// transactionID: data['id'], | |
// authCode: data['authCode'] | |
// }); | |
// } | |
// }); | |
/* | |
var apiRoutes = express.Router(); | |
apiRoutes.post('/addCard', function(req, res, next) { | |
simplify.addCard(req, function(err) { | |
if (err) { return next(err); } | |
}); | |
}); | |
apiRoutes.post('/pay', function()) | |
app.post('/newpayment') | |
*/ | |
// self.start = function() { | |
// app.listen(self.port, self.serverIp, function() { | |
// console.log('%s: Node server started on %s:%d ...', | |
// Date(Date.now()), self.serverIp, self.port); | |
// }); | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment