错误:找不到模块' paypal-ipn'

时间:2016-03-16 17:55:36

标签: meteor paypal paypal-ipn

使用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"/>

知道可能导致此问题的原因是什么?

1 个答案:

答案 0 :(得分:1)

检查模块,如错误消息所示。但... 试试这样:

var ipn = Meteor.npmRequire('paypal-ipn');

基于: https://github.com/meteorhacks/npm