【问题标题】:PayPal Integration HTTP ErrorPayPal 集成 HTTP 错误
【发布时间】:2015-05-03 19:46:54
【问题描述】:

我的网站上集成了 PayPal。我的网站上有一个表格,可以将客户带到 PayPal 以完成付款,然后将其返回到我的网站。然后,我的网站向 PayPal 发送一个请求,其中包含 PDT 的交易令牌,以便我可以运行一些检查,然后将他们购买的产品自动记入我的客户的账户。

系统使用PHP和cURL来发送处理这一切。

当我使用时:"www.sandbox.paypal.com/cgi-bin/webscr"

除了沙盒凭据,一切正常,一切正常。

一旦我将其全部更改为"www.paypal.com/cgi-bin/webscr"

它不起作用,我的代码告诉我请求失败。 我的代码:

$pp_hostname = "www.paypal.com";

        // read the post from PayPal system and add 'cmd'
        $req = 'cmd=_notify-synch';

        $tx_token = $_GET['tx'];
        $auth_token = "#######-hashed_out_here-########";
        $req .= "&tx=$tx_token&at=$auth_token";

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "https://$pp_hostname/cgi-bin/webscr");
        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);
        //set cacert.pem verisign certificate path in curl using 'CURLOPT_CAINFO' field here,
        //if your server does not bundled with default verisign certificates.
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
        $res = curl_exec($ch);
        curl_close($ch);
        if(!$res){
                $this->twig->error("Request failed.");
        }else{
            $lines = explode("\n", $res);
            $keyarray = array();
            if (strcmp ($lines[0], "SUCCESS") == 0) {
                for ($i='1'; $i<count($lines);$i++){
                    $test = explode("=", $lines[$i]);
                    if(empty($test[1])){
                        $keyarray[urldecode($test[0])] = '';
                    }else{
                        $keyarray[urldecode($test[0])] = urldecode($test[1]);
                    }
                }
                //give product
            } else if (strcmp ($lines[0], "FAIL") == 0) {
                $this->twig->error('Transaction failed!');
            }
        }

不知道为什么我会遇到问题,所以我不知道如何解决。 我的 PayPal 账户设置为企业,开启了 PDT 和 IPN 以及自动退货

我似乎收到了 HTTP 错误,但我不能说,如果我记录 curl_error,它只会说“”,如果我记录 curl_errno,我会得到 0。

【问题讨论】:

    标签: php curl paypal


    【解决方案1】:

    我设法解决了这个问题。这是由于我的服务器没有安装 ssl 证书,一旦我安装了它就可以正常工作。

    【讨论】:

      猜你喜欢
      • 2012-06-09
      • 2016-11-16
      • 2018-12-25
      • 2011-09-25
      • 1970-01-01
      • 2013-09-21
      • 2021-02-01
      • 2016-07-21
      • 2019-02-21
      相关资源
      最近更新 更多