Paypal Sandbox IPN网址不会被执行的可能原因是什么?

时间:2013-09-02 12:19:29

标签: php paypal paypal-sandbox paypal-ipn

我正在尝试使用沙盒实现PayPal付款,但我似乎无法理解为什么它无法调用/覆盖/执行我的IPN网址。

我一直在论坛上阅读一个尝试过的解决方案,但似乎没有什么可以帮助我解决我的问题。

我得到了这个简单的表单代码:

<form action=" https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" name="form2" id="form2">
    <input name="first_name" required="" size="40" type="text">
    <input name="last_name" required="" size="40" type="text">
    <input name="email" size="40" type="email">
    <input name="item_name" size="40" type="text" value="Test Item">
    <input name="amount" type="hidden" value="0.01">
    <input name="cmd" type="hidden" value="_xclick">
    <input name="business" type="hidden" value="test-seller8@test.co.uk">
    <input name="notify_url" type="hidden" value="http://myurl.com/ipn.php">
    <input name="return" type="hidden" value="http://myurl.com/result.php">
    <input name="currency_code" type="hidden" value="GBP">
    <input name="no_shipping" type="hidden" value="1">
    <input type="submit" value="Pay now!">
</form>

我认为我的表格没问题,我可以使用paypal付款并使用沙盒个人帐户类型付款,它会提供一个链接重定向到我的返回页面,在我点击它的时候,它会转到正确的页面。

问题是我的IPN脚本没有被执行。这是我的IPN中的代码。

if(strcmp($_REQUEST['payment_status'],'Completed') == 0)
{
    $fd = fopen(dirname(__FILE__).'/results/payment-result.txt', 'wb');

    //dump request to file
    fwrite($fd, "### $_REQUEST = ### \n");
    fwrite($fd, print_r($_REQUEST, true));  
}
else 
{
    echo 'No direct access';    
}

我尝试删除if语句来检查付款状态是否已完成,只是为了检查脚本是否执行但是没有,它甚至没有创建.txt文件。我还尝试通过直接访问它来检查我的IPN代码中是否有错误,但似乎没问题,它会创建文件并记录请求变量。

我也尝试过使用IPN模拟器,但每当我发送它时,它只会像永远一样加载,然后给出错误:

IPN Delivery Failed:I/O error: Connection timed out; nested exception is java.net.ConnectException: Connection timed out

这对我来说没有意义。

现在我很困惑我错过了哪一部分或导致我的IPN正在执行的问题。

1 个答案:

答案 0 :(得分:0)

您应确保在PayPal设置中启用了IPN:

  • 登录您的PayPal帐户,然后转到个人资料→个人资料&amp;设置→销售首选项→即时付款通知首选项:(或click here直接转到该页面,确保您在点击链接之前登录了您的PayPal帐户)
  • 点击PayPal网站上的打开IPN。
  • 然后系统会提示您输入通知网址,该网址应为任意网址 - 无论如何它只会被您的notify_url参数替换
  • 保存设置

如果您已经完成此操作,那么您需要确保您的通知网址可以通过外部网站访问,使用类似https://www.hidemyass.com/proxy的内容来检查您的网站是否可用。

检查您的PayPal帐户上的IPN history,您就会看到IPN发送到的确切网址和状态。