php - Not able to get Transaction Details in Adaptive Payment in paymet -


i using parallel adaptive payment. got php coding following link of paypal developer` website.

https://www.paypal-labs.com/integrationwizard/adaptive/main.php

and used ipn listener follows ,

 <?php  // step 1: read post data  // reading posted data directly $_post causes serialization  // issues array data in post // reading raw post data input stream instead.  $raw_post_data = file_get_contents('php://input');      curl_close($ch); $raw_post_array = explode('&', $raw_post_data); $from="manikandan.a@quadrantsystems.com";     $to="manikandan.vkpr@gmail.com";     $subject="curl_exec".$raw_post_data;     $headers = "mime-version: 1.0\r\n";     $headers .= "content-type: text/html; charset=iso-8859-1\r\n";     $headers .= 'from:'.$from."\r\n";     @mail($to,$subject,print_r($raw_post_array),$headers); $mypost = array(); foreach ($raw_post_array $keyval) {   $keyval = explode ('=', $keyval);   if (count($keyval) == 2)      $mypost[$keyval[0]] = urldecode($keyval[1]); } // read post paypal system , add 'cmd' $req = 'cmd=_notify-validate'; if(function_exists('get_magic_quotes_gpc')) {    $get_magic_quotes_exists = true; }  foreach ($mypost $key => $value) {            if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {          $value = urlencode(stripslashes($value));     } else {         $value = urlencode($value);    }    $req .= "&$key=$value"; }   // step 2: post ipn data paypal validate  $ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr'); curl_setopt($ch, curlopt_http_version, curl_http_version_1_1); 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_forbid_reuse, 1); curl_setopt($ch, curlopt_httpheader, array('connection: close'));  // in wamp environments not come bundled root authority certificates, // please download 'cacert.pem' "http://curl.haxx.se/docs/caextract.html" , set directory path  // of certificate shown below. // curl_setopt($ch, curlopt_cainfo, dirname(__file__) . '/cacert.pem'); if( !($res = curl_exec($ch)) ) {     // error_log("got " . curl_error($ch) . " when processing ipn data");     $from="manikandan.a@quadrantsystems.com";     $to="manikandan.vkpr@gmail.com";     $subject="curl_exec".curl_error($ch);     $headers = "mime-version: 1.0\r\n";     $headers .= "content-type: text/html; charset=iso-8859-1\r\n";     $headers .= 'from:'.$from."\r\n";     @mail($to,$subject,$message,$headers);     curl_close($ch);     exit; } curl_close($ch);   // step 3: inspect ipn validation result , act accordingly  if (strcmp ($res, "verified") == 0) {     // check whether payment_status completed     // check txn_id has not been processed     // check receiver_email primary paypal email     // check payment_amount/payment_currency correct     // process payment      // assign posted variables local variables     $item_name = $_post['item_name'];     $item_number = $_post['item_number'];     $payment_status = $_post['payment_status'];     $payment_amount = $_post['mc_gross'];     $payment_currency = $_post['mc_currency'];     $txn_id = $_post['txn_id'];     $receiver_email = $_post['receiver_email'];     $payer_email = $_post['payer_email'];        $from="manikandan.a@quadrantsystems.com";      $to="manikandan.vkpr@gmail.com";      $subject='success'.$txn_id."paysts".$payment_status."currency".$payment_currency."email".$payer_email;      $headers = "mime-version: 1.0\r\n";                $headers .= "content-type: text/html; charset=iso-8859-1\r\n";                $headers .= 'from:'.$from."\r\n";                if(@mail($to,$subject,$message,$headers));  } else if (strcmp ($res, "invalid") == 0) {      $from="manikandan.a@quadrantsystems.com";      $to="manikandan.vkpr@gmail.com";      $subject='invalid'.$item_name;      $headers = "mime-version: 1.0\r\n";                $headers .= "content-type: text/html; charset=iso-8859-1\r\n";                $headers .= 'from:'.$from."\r\n";                @mail($to,$subject,$message,$headers);     // log manual investigation  }  ?>  

the first , second mail has executed , mail have been receive, the $_post values empty.ie

 $item_name = $_post['item_name'];     $item_number = $_post['item_number'];     $payment_status = $_post['payment_status'];     $payment_amount = $_post['mc_gross'];     $payment_currency = $_post['mc_currency'];     $txn_id = $_post['txn_id'];     $receiver_email = $_post['receiver_email'];     $payer_email = $_post['payer_email']; 

after verified following mail function executed containing empty values.

most not seeing post values coming , getting populated script correctly because of how come back, , not getting parsed correctly. when working adaptive payments, ipn post's come in different format regular payments.

transaction[0].id_for_sender_txn=...&transaction[0].receiver=paypal_tester_12987336_biz@paypal.com&transaction[0].is_primary_receiver=false&transaction[0].id=...&transaction[0].status=completed&transaction[0].status_for_sender_txn=completed&transaction[0].amount=cad+10.00

you need make sure parsing data correctly.


Comments