phpcurlpaypalpaypal-pdt

Connect to paypal dose'nt work


I try to check payment usind pdt this is my code:

$pp_hostname = "www.paypal.com"; 
$req = 'cmd=_notify-synch';
$tx_token = $_GET['tx'];
$req .= "&tx=$tx_token&at=$asimon";
$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);
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 'Error';
}

And I always get Error;
I make a payment but the connection dont work what is the problem?


Solution

  • Your server probably doesn't doesn't have the new certificate chain for PayPal. Test this, and if it works, update your certificates:

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    

    Remove this also:

    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: $pp_hostname"));
    

    curl already sends that header