Paypal IPN回调已在沙盒环境中停止工作

Paypal IPN回调已在沙盒环境中停止工作,paypal,callback,sandbox,paypal-ipn,Paypal,Callback,Sandbox,Paypal Ipn,我对paypal IPN回调有问题。Paypal的IPN回调在沙盒环境中停止工作 在过去的几周里,我一直在测试我客户的网站,它一直正常工作——支付了款项,并向网站发送了一个回拨IPN,确认了付款,并更新了网站的数据库 我没有改变代码中的任何内容,代码突然停止工作。付款仍然进行并保存在贝宝帐户中,但IPN总是在重试。。。它不完整 下面是正在使用的代码: <?php // STEP 1: read POST data // Reading POSTed data directly from

我对paypal IPN回调有问题。Paypal的IPN回调在沙盒环境中停止工作

在过去的几周里,我一直在测试我客户的网站,它一直正常工作——支付了款项,并向网站发送了一个回拨IPN,确认了付款,并更新了网站的数据库

我没有改变代码中的任何内容,代码突然停止工作。付款仍然进行并保存在贝宝帐户中,但IPN总是在重试。。。它不完整

下面是正在使用的代码:

<?php

// STEP 1: read POST data

// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream. 
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
} 
foreach ($myPost as $key => $value) { 
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { 
$value = urlencode(stripslashes($value)); 
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}

// STEP 2: POST IPN data back to PayPal to validate

$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));

// In wamp-like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from [link removed] and set 
// the directory path of the certificate as shown below:
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);

……

?>

我已经向PayPal提交了三个帮助请求,但仍然没有得到答复。

cURL请求会向PayPal发回HTTP帖子,以验证IPN消息。如果在这一步停止,这意味着您确实收到了来自PayPal的IPN帖子,但您在连接回PayPal时遇到了问题

当处理IPN数据时,
//错误日志(“get”.curl\u error($ch)。”是什么意思包含

要解决此问题,请测试从服务器到以下地址的HTTPS连接:

例如,您可以直接从服务器上运行cURL(假设您具有SSH访问权限)

curl-vhttps://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-验证

这将返回类似于以下内容的内容:

$ curl -v https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate
* About to connect() to www.sandbox.paypal.com port 443 (#0)
*   Trying 173.0.82.77...
* connected
* Connected to www.sandbox.paypal.com (173.0.82.77) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /usr/ssl/certs/ca-bundle.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
*        subject: 1.3.6.1.4.1.311.60.2.1.3=US; 1.3.6.1.4.1.311.60.2.1.2=Delaware; businessCategory=Private Organization; serialNumber=3014267; C=US; postalCode=95131-2021; ST=California; L=San Jose; street=2211 N 1st St; O=PayPal, Inc.; OU=PayPal Production; CN=www.sandbox.paypal.com
*        start date: 2011-09-01 00:00:00 GMT
*        expire date: 2013-09-30 23:59:59 GMT
*        common name: www.sandbox.paypal.com (matched)
*        issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of use at https://www.verisign.com/rpa (c)06; CN=VeriSign Class 3 Extended Validation SSL CA
*        SSL certificate verify ok.
> GET /cgi-bin/webscr?cmd=_notify-validate HTTP/1.1
> User-Agent: curl/7.28.1
> Host: www.sandbox.paypal.com
> Accept: */*
>
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Date: Wed, 14 Aug 2013 20:15:53 GMT
< Server: Apache
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: xxxxx    
< X-Cnection: close
< Set-Cookie: xxxx domain=.paypal.com; path=/; Secure; HttpOnly
< Set-Cookie: Apache=10.72.128.11.1376511353229960; path=/; expires=Fri, 07-Aug-43 20:15:53 GMT
< Vary: Accept-Encoding
< Strict-Transport-Security: max-age=14400
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host www.sandbox.paypal.com left intact
**INVALID* Closing connection #0**
* SSLv3, TLS alert, Client hello (1):
$curl-vhttps://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-证实
*即将连接()到www.sandbox.paypal.com端口443(#0)
*正在尝试173.0.82.77。。。
*连接的
*已连接到www.sandbox.paypal.com(173.0.82.77)端口443(#0)
*已成功设置证书验证位置:
*CAfile:/usr/ssl/certs/ca-bundle.crt
卡帕斯:没有
*SSLv3,TLS握手,客户端hello(1):
*SSLv3,TLS握手,服务器hello(2):
*SSLv3,TLS握手,证书(11):
*SSLv3,TLS握手,服务器完成(14):
*SSLv3、TLS握手、客户端密钥交换(16):
*SSLv3,TLS更改密码,客户端你好(1):
*SSLv3,TLS握手,完成(20):
*SSLv3,TLS更改密码,客户端你好(1):
*SSLv3,TLS握手,完成(20):
*使用AES256-SHA的SSL连接
*服务器证书:
*主题:1.3.6.1.4.1.311.60.2.1.3=美国;1.3.6.1.4.1.311.60.2.1.2=特拉华州;businessCategory=私人组织;序号=3014267;C=美国;postalCode=95131-2021;ST=加利福尼亚州;L=圣何塞;第1街北2211号;O=贝宝公司。;OU=贝宝生产;CN=www.sandbox.paypal.com
*开始日期:2011-09-01 00:00:00 GMT
*过期日期:2013-09-30 23:59:59 GMT
*通用名称:www.sandbox.paypal.com(匹配)
*发行人:C=美国;O=VeriSign公司。;OU=VeriSign信任网络;OU=使用条款https://www.verisign.com/rpa (c) 06;CN=VeriSign Class 3扩展验证SSL CA
*SSL证书验证正常。
>GET/cgi-bin/webscr?cmd=\u notify-validate HTTP/1.1
>用户代理:curl/7.28.1
>主持人:www.sandbox.paypal.com
>接受:*/*
>
*HTTP 1.1或更高版本,支持持久连接和流水线

如果收到超时或SSL握手错误,则需要单独进行调查

请参阅此文档,它可能有助于Hello Danish,感谢您的回复。我已经准备好测试这个脚本了。这是我第一次尝试。然后我改成了下面的脚本:这个脚本工作得很好,但突然它停止了工作。ThanxI已经进行了测试,似乎问题与卷曲有关。IPN应该是这样工作的:1-paypal发送带有事务变量的回调2-从接收文件中,这些变量再次发送到paypal,以进行确认3-paypal验证接收到的信息4-paypal响应“已验证”或“无效”在我的回调文件中,接收到的VAR被正确解析并发送回paypal。如果我复制url并直接在浏览器中提交,我会得到“已验证”的响应。但通过Curl提交时,会出现错误(无法连接到主机)。有什么想法吗?午饭后,神奇的是,它又在沙箱里工作了。。。但当我把它送到现场时,它又停止了工作。IPN没有到达我的回调文件(我猜),并给出了一个HTTP错误(406)。有什么线索吗?除了Curl中的链接,我还需要配置什么吗?谢谢罗伯特,谢谢你的回答。它又开始工作了。我昨天(现场)支付的款项尚未支付,但今天已经确认。我又测试了2个,他们自动确认(IPN)。这些奇怪的事情有什么解释吗:-7月26日-IPN停止工作-沙箱。-8月14日-IPN再次发挥作用-沙盒。-8月14日-IPN停止工作-实时模式(406错误)。-8月15日-IPN再次工作-现场模式。我的角色没有任何变化。以下是提交给贝宝的所有门票:#130810-000033、#130804-000067、#130731-000377、#130726-000079。从我这边看,没有,我看不到任何解释。您可能已经有好几天无法连接到IPN验证端点,但我无法确定原因(我们没有将IP地址列入黑名单)。Thanx Robert。我想我永远也不会知道,但重要的是现在一切正常:)再次感谢你的帮助。
$ curl -v https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate
* About to connect() to www.sandbox.paypal.com port 443 (#0)
*   Trying 173.0.82.77...
* connected
* Connected to www.sandbox.paypal.com (173.0.82.77) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /usr/ssl/certs/ca-bundle.crt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
*        subject: 1.3.6.1.4.1.311.60.2.1.3=US; 1.3.6.1.4.1.311.60.2.1.2=Delaware; businessCategory=Private Organization; serialNumber=3014267; C=US; postalCode=95131-2021; ST=California; L=San Jose; street=2211 N 1st St; O=PayPal, Inc.; OU=PayPal Production; CN=www.sandbox.paypal.com
*        start date: 2011-09-01 00:00:00 GMT
*        expire date: 2013-09-30 23:59:59 GMT
*        common name: www.sandbox.paypal.com (matched)
*        issuer: C=US; O=VeriSign, Inc.; OU=VeriSign Trust Network; OU=Terms of use at https://www.verisign.com/rpa (c)06; CN=VeriSign Class 3 Extended Validation SSL CA
*        SSL certificate verify ok.
> GET /cgi-bin/webscr?cmd=_notify-validate HTTP/1.1
> User-Agent: curl/7.28.1
> Host: www.sandbox.paypal.com
> Accept: */*
>
* HTTP 1.1 or later with persistent connection, pipelining supported
< HTTP/1.1 200 OK
< Date: Wed, 14 Aug 2013 20:15:53 GMT
< Server: Apache
< X-Frame-Options: SAMEORIGIN
< Set-Cookie: xxxxx    
< X-Cnection: close
< Set-Cookie: xxxx domain=.paypal.com; path=/; Secure; HttpOnly
< Set-Cookie: Apache=10.72.128.11.1376511353229960; path=/; expires=Fri, 07-Aug-43 20:15:53 GMT
< Vary: Accept-Encoding
< Strict-Transport-Security: max-age=14400
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
* Connection #0 to host www.sandbox.paypal.com left intact
**INVALID* Closing connection #0**
* SSLv3, TLS alert, Client hello (1):