在本地测试 Paypal IPN

Testing Paypal IPN locally

基于Paypal tutorial,这是他们提供的用于测试 IPN 的表格:

<form target="_new" method="post" action="https://www.YourDomain.com/Path/YourIPNHandler.php">
  <input type="hidden" name="SomePayPalVar" value="SomeValue1"/>
  <input type="hidden" name="SomeOtherPPVar" value="SomeValue2"/>

  <!-- code for other variables to be tested ... -->

  <input type="submit"/>
</form>

我在 server/routing.js 中获得了我的 IPN 侦听器代码并使用了 Iron 路由器并指定了到 /ipn 的路径。这是它的代码

Router.map(function () {
    this.route('ipn', {
        path: '/ipn',
        where: 'server',

所以我现在的问题是,我应该在表格中输入什么 URL 而不是“https://www.YourDomain.com/Path/YourIPNHandler.php” URL?因为正在我的本地机器上测试它 "localhost:3000"

我有同样问题的朋友。解决方案非常简单。 Paypal 不允许在您的本地计算机上进行测试:Paypal 说:很抱歉,IPN 不允许 URL 端口号。 您的 "www.YourDomain.com" 必须有一台服务器。在我的开发测试案例中,我下载了一个名为 NGROK 的 "tunnel" 应用程序,它为您提供了一个测试域。您可以从 here 获取它。 然后只需打开 ngrok 控制台并编写命令就足够了:

> ngrok http -host-header=localhost 3000

之后执行您的网络应用程序。启动 ngrok 后,只需在网络浏览器中打开 http://localhost:4040 即可查看 ngrok 提供的域。 当您在浏览器中转到 localhost:4040 时,ngrok 会向您显示 http 和 http 域,就像它们在示例中显示的那样。

http://92832de0.ngrok.io 
https://92832de0.ngrok.io

现在只需将 "www.YourDomain.com" 替换为这个 ngrok URL。

希望对您有所帮助。问候!