New to the community? Welcome! Please read our Community Rules and Guidelines
Join the live Q&A with our Community moderator team Wednesdays, 1-2pm PT (4-5pm ET) and Fridays, 4-5pm GMT. Learn more in Community Events
I have been searching for a solution but just don't know what is the cause of the problem. I have seen many postings on similar topics in Google but non has worked for me. My shopping cart was working well a 2 or 3 years ago but today it does not. I am using IPN and PDT because my products are downloadable files.
The original code the worked many years ago was:
$url = 'https://www.paypal.com/cgi-bin/webscr';
$myppaa = array( 'cmd' => '_notify-synch',
'tx' => $txn_id,
'at' => 'ImCO1w................................FAcwKjY9K',
'submit' => 'PDT' );
$dataarray = $myppaa;
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($dataarray),
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if(strpos($result, 'SUCCESS') === 0)
I had no problems with the code above. A few days ago I decided to upgrade my shopping cart and found out that I had to send back the exact $_POST variables. So I modified the code to :-
$ta1 = array( 'cmd' => '_notify-validate');
$myppaa = array_merge($ta1, $_POST);
$dataarray = $myppaa;
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.12011-10-16 20:23:00'));
curl_setopt($curl, CURLOPT_REFERER, $_SERVER['HTTP_HOST']);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $url );
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $dataarray);
$result = curl_exec($curl);
serialize_savefilebare( $result, 'rppbackend.txt'); //saving the returned values into a text file so that I can examine it later
This always returns invalid. The string saved in the file is :
I have tried many changes and sometimes it returns "" instead of "INVALID".
Anyone who knows how I can get it to work?
After lots of experiment I changed to using the PayPal script example shown in their documentation and the curl code shown in some of the stackexchange solutions.
Finally, I have got my shopping cart working with PayPal.
Interesting in that I changed to the PayPal example program and kept getting rejected by sandbox. Then switched over to the live PayPal and tested by 'purchasing' a product that was US$0.01/- and it worked!!! So sandbox was the problem. Of course once I began testing with the live system I manged to fix some bugs in my shopping cart.