ssl - PayPal PDT SSL 连接在我的插件域上挂起

标签 ssl paypal connection paypal-pdt

在我的 PayPal autoReturn 页面上,使用已知可用的 PHP 脚本来处理支付数据传输,无论我做什么,我都会不断收到此错误消息:"Warning: fgets(): SSL: Connection reset by peer...*(在这一行:'$line = fgets($fp, 1024);'* "

在我问我的问题之前,我只想说我已经尝试了这里和我被建议阅读的任何其他论坛或文章中建议的所有内容,例如将 HTTP 1.0 更改为 HTTP 1.1,使用 $res=stream_get_contents($fp, 1024) 而不是 while 循环 使用 $line = fgets($fp, 1024) 等。我的问题仍然存在。

这就是我认为可能存在的问题(我希望有人能告诉我我是否在正确的轨道上):我的 PDT 自动返回页面在一个附加站点上,我在想当无法识别共享 SSL(对于我在共享服务器上的主域)时,PayPal 挂断。因此,我要求我的虚拟主机专门为我的附加域安装 SSL。

附加域 SSL 问题会不会是我收到警告消息的原因?同样,该消息是:"Warning: fgets(): SSL: Connection reset by peer...*(在行中:'$line = fgets($fp, 1024);'* "

这是我的代码:

 //look if the parameter 'tx' is set in the GET request and that it  does not have a null or empty value
if(isset($_GET['tx']) && ($_GET['tx'])!=null && ($_GET['tx'])!= "") {
    $tx = $_GET['tx'];

    verifyWithPayPal($tx);
}
else {
    exitCode();
}

function verifyWithPayPal($tx) {
    $req = 'cmd=_notify-synch';
    $tx_token = $tx;
    $auth_token = "MY SANDBOX AUTH_TOKEN HERE";
    $req .= "&tx=$tx_token&at=$auth_token";

    // post back to PayPal system to validate
    $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";

    // url for paypal sandbox
    //$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno,   $errstr, 30);    

    // url for payal
    // $fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
    // If possible, securely post back to paypal using HTTPS
    // Your PHP server will need to be SSL enabled.

     $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);

    if (!$fp) {
        exitCode();
    } else {
        fputs($fp, $header . $req);        
        // read the body data
        $res = '';
        $headerdone = false;

         while (!feof($fp)) {
            $line = fgets($fp, 1024);
        // $res=stream_get_contents($fp, 1024);
            if (strcmp($line, "\r\n") == 0) {
                // read the header
                $headerdone = true;
            }
            else if ($headerdone) {
                // header has been read. now read the contents
                $res .= $line;
            }
         }

        // parse the data
        $lines = explode("\n", $res);

        $response = array();

        if (strcmp ($lines[0], "SUCCESS") == 0) {

            for ($i=1; $i<count($lines);$i++){
                list($key,$val) = explode("=", $lines[$i]);
                $response[urldecode($key)] = urldecode($val);
            }

            $itemName = $response["item_name"];
            $amount = $response["payment_gross"];
            $myEmail = $response["receiver_email"];
            $userEmailPaypalId = $response["payer_email"];
            $paymentStatus = $response["payment_status"];
            $paypalTxId = $response["txn_id"];
            $currency = $response["mc_currency"];

            // check the payment_status is Completed
            if($paymentStatus!="Completed") {
                payment_complete();
                emailer($userEmailPayPalID);

            } else {
                payment_incomplete($paymentStatus);
            }

            /*
            // check that txn_id has not been previously processed
            checkIfTransactionHasAlreadyBeenProcessed($paypalTxId);
            // check that receiver_email is your Primary PayPal email
            checkThatPaymentIsReceivedAtYourEmailAddress($myEmail);
            // check that payment_amount/payment_currency are correct
            checkPaymentAmountAndCurrency($amount, $currency);
            // process the order
            processOrder();
            } else {
            exitCode();
            */
        }
    }
        fclose ($fp);
}

最佳答案

我注意到您正在连接到 www.sandbox.paypal.com。我相信您想连接到 api.sandbox.paypal.com

关于ssl - PayPal PDT SSL 连接在我的插件域上挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28302928/

相关文章:

php - 用于登录的覆盖窗口中的 SSL

Android 在没有弃用方法的情况下向服务器发送 https post 请求

transactions - IPN 返回不同的交易 ID

mongodb - 如何连接到在 Docker 容器中运行的 MongoDB?

python - _ssl.sslwrap 函数参数的类型强制

ssl - 如果所有子域都指向网站根目录,是否需要通配符 SSL 证书

php - symfony2 payum paypal express 简单结账

ruby-on-rails - 检索买家结算结束时间

tcp - 我是使用 1 个端口进行 1000 个连接,还是使用 1000 个端口,每个端口有 1 个连接?

mysql - 有没有办法在不同主机上测试您的 MYSQL 数据库速度?