Paypal IPN返回HTTP/1.1 200 OK [英] Paypal IPN returning HTTP/1.1 200 OK

查看:112
本文介绍了Paypal IPN返回HTTP/1.1 200 OK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试使用Web Payments标准和HTML变量将网站集成到Paypal.

I am testing integrating a website to Paypal, using Web Payments standard and HTML Variables.

我已经编写了一个简单的PHP脚本来处理IPN通知.

I have written a simple PHP script to handle the IPN notifications.

根据 Paypal文档,一旦您将收到的数据ping回Paypal,Paypal服务器就会以简单的"已验证"或"无效"响应.

According to the Paypal documentation, the Paypal server responds with a simple 'VERIFIED' or 'INVALID' response, once you ping the received data back to Paypal.

在我的处理程序中,我正在对这两个关键字进行区分大小写的字符串比较,如果找不到这些已知关键字中的任何一个,则将其视为错误.

In my handler, I am doing a case sensitive string comparison for those two keywords, if either one of these known keywords is not found, then it is treated as an error.

<?php
  $fp = fsockopen ($socket_url, 80, $errno, $errstr, 10);

  if (!$fp){
     // SOCKET ERROR
     return false;
  }
  else {
         fputs ($fp, $header . $req);
         $is_ok = false;

         while (!feof($fp)) {
             $res = fgets ($fp, 1024);

             if (strcmp("VERIFIED",$this->ipn_response)==0) {
                //do something ...
             }
             // if the IPN POST was 'INVALID'
             else if (strcmp ($res, "INVALID") == 0) {
                 fclose ($fp);
                 return false;
             }
             else {
                echo "Unknown response from Paypal: $res";
                fclose ($fp);
                return false;
            }
         }

         fclose ($fp);
         return true;
   }
?>

我的错误消息表明我从Paypal收到"HTTP/1.1 200 OK"响应.

My error message shows that I am receiving an 'HTTP/1.1 200 OK' response from Paypal.

贝宝(Paypal)的未知回复: 'HTTP/1.1 200 OK'

Unknown response from Paypal: 'HTTP/1.1 200 OK'

PayPal API是否已更改,或者我做错了什么?

Has the PayPal API changed, or am I doing something wrong?

推荐答案

PayPal的响应位于HTTP响应的正文中.您需要先处理HTTP标头,然后才能到达正文.或者,也可以继续读取行,直到找到空白行,然后下一行将成为正文.

PayPal's response is in the body of the HTTP response. You need to process the HTTP headers before you can get at the body. Or, alternately, just keep reading lines until you find a blank line, and the next line will be the body.

这篇关于Paypal IPN返回HTTP/1.1 200 OK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆