php - PayPal 沙箱 IPN 不再响应

标签 php paypal paypal-ipn paypal-sandbox

我正在使用 Paypal 沙箱测试我的 PHP 脚本,该脚本适用于 www.paypal.com 但不适用于 www.sandbox.paypal.com。我最近收到一封来自 PayPal 的电子邮件,要求使用 HTTP 1.1 协议(protocol)而不是 1.0,所以我已经这样做了,并且我在标题中使用了指定的 Connection: close,但 IPN URL 挂起。当我尝试使用 www.paypal.com 时,没有挂起。

PayPal 在他们的第二封电子邮件中明确说明了这一点

This is a follow-up to the bulletin we sent on 6 September, 2012. It has come to our attention that some merchants were experiencing issues getting their IPN scripts updated to use HTTP 1.1 because the scripts would get "hung" or take a long time to get a ‘VERIFIED’ response. We are including instructions on how to remedy this issue by adding a "Connection: close" header in the HTTP request.

但这显然行不通。

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: $url\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$header .= "Connection: close\r\n";

有什么想法吗?非常感谢帮助。

最佳答案

你在倒数第二行有\r\n\r\n,它需要放在最后一行......

$header = "POST /cgi-bin/webscr HTTP/1.1\r\n";
$header .= "Host: $url\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n";
$header .= "Host: www.paypal.com\r\n"; 
$header .= "Connection: close\r\n\r\n";

您还需要主机线。

关于php - PayPal 沙箱 IPN 不再响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12977015/

相关文章:

python - PayPal REST 实时问题

paypal - 使用用户的电子邮件地址获取 PayPal 配置文件 ID

ruby-on-rails - 如何按原始顺序获取 POST 参数(使用 Rails)?

IPN 的 PHP 自定义变量

paypal - 使用 PayPal 在 URL 参数中设置收件人 ID 或电子邮件

php - 加扰图像?

php - phpMyAdmin 中的错误 "Could not connect to MySQLserver"

php - 如何将文档根目录更改为脚本的公共(public)目录?

php - 将用户直接转发到 PayPal 上的信用卡处理页面

php - 在 PHP session 中存储对象