0

我使用此代码来处理贝宝支付数据传输 (PDT):

            $pp_hostname = "www.sandbox.paypal.com"; // Change to www.sandbox.paypal.com to test against sandbox
            // read the post from PayPal system and add 'cmd'
            $req = 'cmd=_notify-synch';

            $tx_token = $_GET['tx'];
            $auth_token = "my_token";
            $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){
                echo "HTTP ERROR";
            }else{ ...

我确实将 $pp_hostname 更改为 sandbox.paypal.com 而不仅仅是 paypal.com,它会输出 HTTP ERROR,因为 $res 是空的。

为什么?

4

0 回答 0