rdrobertson15@yahoo.com Posted October 26, 2011 Share Posted October 26, 2011 thanks in advance I am using Yahoo webhost with PHP 5.3.6. The application is returning from a Paypal Sandbox transaction. I have the settings on my sandbox correct. I am trying to get the transaction info. i put in some debugging lines so now I get this at the top of the webpage: "CURL_INIT Resource id #3 Response: STATUS: " i perform a $_GET on the calling page and I do get that info displayed. i try to print what is returned from the function below and get nothing Notice the Response and STATUS: have NO info This is code(thanks Torleif Berger who's currently not available) from another page that does the call after Paypal returns to it: <?php include 'process_pdt.function.php'; $payment_data = isset($_GET['tx']) ? process_pdt($_GET['tx']) : FALSE; $current_url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']; ?> ----------------------------------------- The process_pdt code follows <?php <?php include 'token'; /** * Processes a PDT transaction id. * * @author Torleif Berger * @link http://www.geekality.net/?p=1210 * @copyright © 2011 www.geekality.net * @return The payment data if $tx was valid; otherwise FALSE. */ function process_pdt($tx) { // Init cURL $request = curl_init(); printf("CURL_INIT %s\n",$request); // Set request options curl_setopt_array($request, array ( CURLOPT_URL => 'https://www.sandbox.paypal.com/cgi-bin/webscr', CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => http_build_query(array ( 'cmd' => '_notify-synch', 'tx' => $tx, 'at' => $my_token, )), CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HEADER => FALSE, CURLOPT_SSL_VERIFYPEER => TRUE, CURLOPT_CAINFO => 'cacert.pem', )); // Execute request and get response and status code $response = curl_exec($request); printf("Response: %s\n", $response); $status = curl_getinfo($request, CURLINFO_HTTP_CODE); printf("STATUS: \n",$status ); // Close connection curl_close($request); // Validate response if($status == 200 AND strpos($response, 'SUCCESS') === 0) { // Remove SUCCESS part (7 characters long) $response = "SUCCESS"; /* $response = substr($response, 7); // Urldecode it $response = urldecode($response); // Turn it into associative array preg_match_all('/^([^=\r\n]++)=(.*+)/m', $response, $m, PREG_PATTERN_ORDER); $response = array_combine($m[1], $m[2]); // Fix character encoding if needed if(isset($response['charset']) AND strtoupper($response['charset']) !== 'UTF-8') { foreach($response as $key => $value) { $value = mb_convert_encoding($value, 'UTF-8', $response['charset']); } $response['charset_original'] = $response['charset']; $response['charset'] = 'UTF-8'; } // Sort on keys ksort($response); */ // Done! return $response; } $response = "FAIL"; return FALSE; } Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 26, 2011 Share Posted October 26, 2011 Are you using IPN(instant payment notification)? If so is it enabled in your merchant tools? Quote Link to comment Share on other sites More sharing options...
rdrobertson15@yahoo.com Posted October 26, 2011 Author Share Posted October 26, 2011 no I'm not. Using PDT. Don't really need IPN for this app. Just need to get the info from a class registration payment from paypal. the curl_init seems to work. it's the $response = curl_exec($request); and $status = curl_getinfo($request, CURLINFO_HTTP_CODE); that don't appear to be working. Is there a timing issue? I got the code from someone else but it's missing something. thanks Quote Link to comment Share on other sites More sharing options...
rdrobertson15@yahoo.com Posted October 26, 2011 Author Share Posted October 26, 2011 problem solved. for testing i don’t want certificates so set ” CURLOPT_SSL_VERIFYPEER => FALSE, ” this got me a response. thx again Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.