PayPal IPN模拟器工作正常,但IPN无法响应沙箱付款

时间:2018-03-06 21:53:37

标签: php paypal paypal-sandbox paypal-ipn

如果我从这里发送IPN https://developer.paypal.com/developer/ipnSimulator/,它可以正常工作。

如果我使用PayPal沙盒帐户和PayPal标准按钮直接从我的网站付款,则IPN监听器不会选择任何内容。这是我网站上的PayPal按钮(请注意,它确实链接到PayPal的沙箱并正确指定了notify_url):

                <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
                    <input type="hidden" name="cmd" value="_xclick">
                    <input type="hidden" name="no_shipping" value="1">
                    <input type="hidden" name="no_note" value="1">
                    <input type="hidden" name="currency_code" value="USD">
                    <input type="hidden" name="button_subtype" value="services">

                    <input type="hidden" name="business" value="payments@www.com">
                    <input type="hidden" name="item_number" value="21-2360-4" id="itemNumber">
                    <input type="hidden" name="item_name" value="Listing Fee">
                    <input type="hidden" name="return" value="https://www.com/Market">
                    <input type="hidden" name="cancel_return" value="https://www.com/Seller">
                    <input type="hidden" name="amount" value="10" id="amount">

                    <input type="hidden" name="notify_url" value="https://www.com/IPN">
                    <p><button type="submit" id="sellButton">Pay fee and list</button></p>
                </form>

这是我的IPN监听器代码,适用于从PayPal IPN模拟器页面制作的IPN,但不适用于使用上述表单制作的沙箱付款(请注意,它也在收听PayPal的沙箱):

if($_SERVER['REQUEST_METHOD'] != 'POST'){
    exit();
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));
$response = curl_exec($ch);
curl_close($ch);

if($response == "VERIFIED"){
     // Successful purchase code.
}

非常感谢任何关于它为什么不接收IPN的线索。

1 个答案:

答案 0 :(得分:1)

修改后的信息 登录收件人Paypal帐户并设置IPN

步骤 个人资料 - &gt;个人资料和设置 - &gt;我的销售工具 - &gt;即时付款通知 - &gt;更新

点击&#34;选择IPN设置&#34;

设置&#34;通知网址&#34;你所拥有的领域&#34; notify_url&#34;在HTML表单中。

选择&#34;接收IPN消息&#34;

保存

注意:如果您检查IPN历史记录,它可能会显示为已排队。这似乎是一个沙盒故障或者它可能处理许多请求并且排长队。您可以尝试使用较小的价值(例如1美元)进行实时付款。 见这里:Paypal IPN Status - Queued

现在无关紧要--- 这应该是一个评论,但我没有批准发表评论。 你有<button name="submit">Purchase with PayPal</button> 那应该是<button type="submit">Purchase with PayPal</button> 请在<form></form>代码中提供完整的Paypal html代码。

相关问题