简体   繁体   English

贝宝IPN侦听器响应

[英]PayPal IPN listener response

After fully testing in PayPal's sandbox and getting the process to work perfectly. 在贝宝(PayPal)的沙盒中进行全面测试并使其正常运行之后。 I've taken it live and it's not working. 我已经将其启用,但无法正常工作。

I'm receiving the POST data from PayPal via the notify_url. 我正在通过notify_url从PayPal接收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.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

(using this code to get the response) (使用此代码获取响应)

$res = stream_get_contents($fp, 1024);

The response I'm getting back is: 我得到的答复是:

HTTP/1.1 200 OK
Date: Fri, 11 May 2012 20:51:28 GMT
X-Frame-Options: SAMEORIGIN
Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG=SdeBuKBN39mjr3w791CHr_MlSkoBdDmbxpQOjT_WOicyD_Sg6BYZm8koiEv2-5XBUkCjpXQwFqIxIQgIyo3e7arO8015CVw96dpne2CNjbgc1CvpDlqXn72IBWq%7cW7uYn6Za7ljG4iLtLVcyFoPk8gZD7sr_S8WjwZrZWD8UXzE7KAH3bll9TVik3wbdCFlrZG%7csxrZZHSH5SWBGfrKsIU6Dz-K43j4h37efIkWFcVJVER0ncRxNJ0wANN1Dp3pZpV2PLxC1m%7c1336769488; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Mon, 09-May-2022 20:51:28 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navlns=0.0; expires=Thu, 06-May-2032 20:51:28 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: Apache=10.73.8.50.1336769488653443; path=/; expires=Sun, 04-May-42 20:51:28 GMT
Vary: Accept-Encoding
Strict-Transport-Security: max-age=14400
Connection: close
Content-Type: text/html; charset=UTF-8
Set-Cookie: TSe9a623=bb3c8ce40a7f3f6d1c018255c9

What I'm not getting is the INVALID or VERIFIED response in this. 我没有得到的是这个中的INVALID或VERIFIED响应。 This is the entire output from PayPal. 这是PayPal的全部输出。 In the sandbox, I was getting VERIFIED in the last line, and no Set-Cookie. 在沙盒中,我在最后一行得到了VERIFIED,并且没有Set-Cookie。

It seems weird that I'm not receiving an INVALID or VERIFIED response. 我没有收到INVALID或VERIFIED响应似乎很奇怪。

Any suggestions would be appreciated. 任何建议,将不胜感激。

Did you write the request to the socket using fwrite/fputs? 您是否使用fwrite / fputs将请求写入套接字? Also, judging by the length of that response, you may need to read more than 1024 bytes from the stream. 同样,从响应的长度来看,您可能需要从流中读取1024个以上的字节。 That's getting awfully close. 那已经非常接近了。

You may want to read the response in a loop: 您可能需要循环读取响应:

$resp = '';
while (!feof($fp)) {
    $resp .= stream_get_contents($fp, 1024);
}

Then you can separate the headers from the body using: 然后,您可以使用以下方法将标题与正文分开:

list($headers, $response) = explode("\r\n\r\n", 2);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM