php - Paypal PDT script not working using cURL -
i can't seem paypal pdt script working. paypal hits return url i'm presented blank screen , nothing happens. can see incorrect? here's code:
$tx = $_get['tx']; $id = $_get['cm']; $amount = $_get['amt']; $currency = $_get['cc']; $identity = '###########################################'; // init curl $ch = curl_init(); // set request options $url = 'https:www.paypal.com/cgi-bin/webscr'; $fields = array( 'cmd' => '_notify-synch', 'tx' => $tx, 'at' => $identity, ); curl_setopt($ch,curlopt_url, $url); curl_setopt($ch,curlopt_post, count($fields)); curl_setopt($ch,curlopt_postfields, $fields_string); curl_setopt($ch,curlopt_returntransfer, true); curl_setopt($ch,curlopt_header, false); // execute request , response , status code $response = curl_exec($ch); $status = curl_getinfo($ch, curlinfo_http_code); // close connection curl_close($ch); if($status == 200 , strpos($response, 'success') === 0) { wp_redirect(home_url('/account')); exit; } else { wp_redirect(home_url()); exit; }
the url string shows necessary information being returned (transaction id etc) correct don't know if it's being used failing wordpress redirects or if it's failing @ point beforehand.
coreyrs,
using code able to pdt work few changes:
$url = 'https:www.paypal.com/cgi-bin/webscr';
to
$url = 'https://www.paypal.com/cgi-bin/webscr';
and
curl_setopt($ch,curlopt_postfields, $fields_string);
to
curl_setopt($ch,curlopt_postfields, http_build_query($fields));
also, make sure if testing sandbox use url https://www.sandbox.paypal.com/cgi-bin/webscr instead.
Comments
Post a Comment