【发布时间】:2018-08-14 21:18:59
【问题描述】:
如果我从这里https://developer.paypal.com/developer/ipnSimulator/ 发送 IPN,它可以正常工作。
如果我使用 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 的线索将不胜感激。
【问题讨论】:
-
对不起,看错了。
标签: php paypal paypal-sandbox paypal-ipn