我试图在我的node.js应用程序中实现Paypal验证,我使用的是快速框架。
这是我的密码:
app.post('/paypal', function(req,res){
console.log("IN PAYPAL !! req.body : "+req.body);
var ipn = require('paypal-ipn');
ipn.verify(req.body, function callback(err, msg) {
if (err) {
console.log("Error:"+err);
} else {
//Do stuff with original params here
console.log("req.body.payment_status :"+req.body.payment_status+" msg: "+msg);
res.end();
if (req.body.payment_status == 'Completed') {
//Payment has been confirmed as completed
}
}
});
});为此,我使用了paypal-ipn。
当我试图从Paypal Sandbox发送IPN消息时,我收到了这条消息
IPN传输失败。无法连接到指定的URL。请验证URL,然后再试一次。
但是当我在curl的帮助下尝试一个来自终端的示例消息时,我在我的服务器应用程序上得到了请求,它正在显示日志。
在贝宝!!req.body :对象对象req.body.payment_status :Pending :验证后/paypal 200 572 msg
发布于 2012-11-30 07:00:24
这样啊,原来是这么回事。我没有监听服务器中的端口443 (https)。
var https = require('https'),
fs = require('fs');
var httpsOptions = {
key: fs.readFileSync('path/to/private/key'),
cert: fs.readFileSync('path/to/certs')
}
http.createServer(app).listen(app.get('port'), function() {
console.log("server listening on port " + app.get('port'));
});
https.createServer(httpsOptions, app).listen(443,function () {
console.log("server listening on port " + 443);
});Paypal将IPN消息发送到https端口443 (我认为)。不管怎么说我有..。
https://stackoverflow.com/questions/13621906
复制相似问题