使用Paypal tutorial中的论坛来测试IPN监听器,当我点击提交时,会打开一个新标签,并显示:
Error: Cannot find module 'paypal-ipn' at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17) at Object.Npm.require (/Users/mazinalmaskari/Desktop/code/.meteor/local/build/programs/server/boot.js:150:18)
at Object.Meteor.npmRequire (packages/npm-container/index.js:2:1) at [object Object].route.action (server/routing.js:6:30) at boundNext (packages/iron_middleware-stack/lib/middleware_stack.js:251:1) at runWithEnvironment (packages/meteor/dynamics_nodejs.js:110:1)
我不确定问题的确切位置,当我点击提交时,我会在ngrok中获得500 Internal Server Error
。
这是我位于服务器的IPN侦听器
Router.map(function () {
this.route('ipn', {
path: '/ipn',
where: 'server',
action: function() {
var ipn = Meteor.npmRequire("paypal-ipn");
var wrappedVerify = Async.wrap(ipn, "verify");
var request = this.request;
var verified;
if (request.method !== 'POST') {
this.next();
} else {
try {
verified = wrappedVerify(request.body, {"allow_sandbox" : true});
} catch (error) {
//do something with error
}
if (verified === "VERIFIED") {
var payment = request.body;
//do something with payment
Router.go('/upload');
}
this.next();
}
}
});
});
这是我使用的表格(来自Paypal教程):
<form target="_new" method="post" action="https://ba13954b.ngrok.io/ipn">
<input type="hidden" name="SomePayPalVar" value="SomeValue1"/>
<input type="hidden" name="SomeOtherPPVar" value="SomeValue2"/>
<input type="submit"/>
知道可能导致此问题的原因是什么?
答案 0 :(得分:1)
检查模块,如错误消息所示。但... 试试这样:
var ipn = Meteor.npmRequire('paypal-ipn');