[英]Paypal : trouble with ipn response
I am uable to get the VERIFIED answer from paypal using the IPN I'm receiving the POST data from PayPal via the notify_url. 我可以使用IPN从贝宝获得经过验证的答案,我是通过notify_url从贝宝接收到POST数据的。 I then send it back to PayPal with cmd=_notify-validate infront of the data. 然后,我使用数据前面的cmd = _notify-validate将其发送回PayPal。
Using PayPals documented code, I'm using this to send the message to PayPal 使用贝宝(PayPal)记录的代码,我正在使用该代码将消息发送到贝宝(PayPal)
$header = "POST /cgi-bin/webscr HTTP/1.1\r\n"; // HTTP POST request
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
$header.= "Host: www.sandbox.paypal.com\r\n";
$header.= "Content-Length: " . strlen($req) . "\r\n";
$header.= "Connection: Close\r\n\r\n";
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
Then I use this 然后我用这个
if (!$fp) {
// HTTP ERROR;
} else {
var_dump(fputs($fp, $header . $req));
while (!feof($fp)) {
$res = stream_get_contents($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
//Transaction verified
}
}
}
In fact I have two $res (due to the while loop). 实际上,我有两个$ res(由于while循环)。 The first does not seems to be of interest and the second is 第一个似乎没有兴趣,第二个是
55 GMT
Connection: close
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dslingshot%26TIME%3D1273590100; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Set-Cookie: Apache=10.72.128.11.1416751435364358; path=/; expires=Tue, 15-Nov-44 14:03:55 GMT
Vary: Accept-Encoding
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
8
VERIFIED
0
It seems that the first part is a header and the second part (8 VERIFIED 0) is the real response but why do I have this 0 and 8 ? 似乎第一部分是标题,第二部分(8 VERIFIED 0)是真正的响应,但是为什么我有这个0和8? Usually people use 人们通常使用
if (strcmp ($res, "VERIFIED") == 0) {
To check that the $res is VERIFIED... So can I consider that the response is 'VERIFIED', using something like 要检查$ res是否已验证...所以我可以认为响应是'VERIFIED',使用类似
if(strstr($res,'VERIFIED')) {
Some help please ?!? 请帮忙吗?!?
Thanks 谢谢
I had the exact same issue, and was able to solve it the same way. 我遇到了完全相同的问题,并且能够以相同的方式解决它。 If I use the sample code from PayPal I get no response at all. 如果我使用贝宝(PayPal)的示例代码,则完全没有响应。
But I have come across something that works using cURL here: https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php . 但是我在这里遇到了使用cURL可以工作的东西: https : //github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php 。
I needed to install cURL using these instructions: curl_init() function not working 我需要使用以下说明安装cURL: curl_init()函数不起作用
And also download and use the cacert.pem found in the script comments. 并下载并使用脚本注释中的cacert.pem。
I am still not certain why stream_get_contents() is returning the headers. 我仍然不确定为什么stream_get_contents()返回标头。 If you have figured it out, can you update this? 如果知道了,可以更新吗?
I have the same issue than you. 我和你有同样的问题。 And I use strstr($res,'VERIFIED') to check if notification is verified. 然后我使用strstr($ res,'VERIFIED')来检查通知是否经过验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.