php - Paypal IPN and wordpress failure -


i have website accepting paypal ipn's paypal. site wordpress website, on shared enviroment, have customized. using ipn simulator fails on webservice listener ipn succeeds base url. why can not receive success on webservice , log data?

using browser , hitting below webservice write logfile. using ipn simulator never writes logfile. ssl access logs never receive post ipn http does. access log @ bottom

hitting

https://example.example.org/wp-content/plugins/myplugin/controllers/payments/ipn

fails ipn simulator."ipn not sent, , handshake not verified. please review information."

hitting https://example.example.org/

succeeds in hitting ipn sent , handshake verified.

 core::error("in ipn function");             // step 1: read post data             // reading posted data directly $_post causes serialization issues array data in post.             // instead, read raw post data input stream.             $raw_post_data = file_get_contents('php://input');             $raw_post_array = explode('&', $raw_post_data);             $mypost = array();             foreach ($raw_post_array $keyval) {               $keyval = explode ('=', $keyval);               if (count($keyval) == 2)                 $mypost[$keyval[0]] = urldecode($keyval[1]);             }             core::error("ipn");             core::error(json_encode($mypost));             core::error(json_encode($_get));             core::error(json_encode($_post));             // read ipn message sent paypal , prepend 'cmd=_notify-validate'             $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";             }              $path = "/home1/xx/";             $cert = "ff67367c5cd4de4ae18bcce1d70fdabd7c866135.pem";               $sandboxurl = "https://www.sandbox.paypal.com/cgi-bin/webscr";             $prurl = "https://www.paypal.com/cgi-bin/webscr";             // step 2: post ipn data paypal validate             $ch = curl_init($sandboxurl);             //curl_setopt($ch, curlopt_cainfo, $path . $cert);             curl_setopt($ch, curlopt_http_version, curl_http_version_1_1);             curl_setopt($ch, curlopt_post, 1);             curl_setopt($ch, curlopt_sslversion, 6);             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-like 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, '/home1/xxx/cacert.pem');             $res = curl_exec($ch);             if ( !$res ) {               core::error(curl_error($ch));               // error_log("got " . curl_error($ch) . " when processing ipn data");               curl_close($ch);               exit;             }             core::error("resposne");             core::error($res);              curl_close($ch);              // inspect ipn validation result , act accordingly             if (strcmp ($res, "verified") == 0) {                     core::error("verified ");                     // ipn verified, process                      // ipn verified, process it:                     // 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 notification                     // 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'];                     // ipn message values depend upon type of notification sent.                     // loop through &_post array , print nv pairs screen:                     foreach($_post $key => $value) {                             $data =  $key . " = " . $value . "<br>";                             core::error($data);                     }              } else if (strcmp ($res, "invalid") == 0) {                     // ipn invalid, log manual investigation                     core::error("invalid ");             }      header("http/1.1 200 ok");      die(); 

https log after ipn spammed

 ip - - [14/jun/2016:19:29:05 -0500] "post /wp-admin/admin-ajax.php http/1.1" 200 47 "https://wordpress.example.org/wp-admin/admin.php?page=example%2fexample.php" "mozilla/5.0 (macintosh; intel mac os x 10_10_5) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.84 safari/537.36" ip - - [14/jun/2016:19:30:07 -0500] "post /wp-admin/admin-ajax.php http/1.1" 200 47 "https://wordpress.example.org/wp-admin/admin.php?page=example%2fexample.php" "mozilla/5.0 (macintosh; intel mac os x 10_10_5) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.84 safari/537.36" ip - - [14/jun/2016:19:31:07 -0500] "post /wp-admin/admin-ajax.php http/1.1" 200 47 "https://wordpress.example.org/wp-admin/admin.php?page=example%2fexample.php" "mozilla/5.0 (macintosh; intel mac os x 10_10_5) applewebkit/537.36 (khtml, gecko) chrome/51.0.2704.84 safari/537.36" 

nonhttps log after ipn spammed

ip - - [14/jun/2016:17:35:13 -0500] "post /wp-content/plugins/example/controllers/payments/ipn http/1.1" 406 275 "-" "-" ip - - [14/jun/2016:17:37:10 -0500] "post /wp-content/plugins/example/controllers/payments/ipn http/1.1" 406 275 "-" "-" ip - - [14/jun/2016:17:39:04 -0500] "post /wp-content/plugins/example/controllers/payments/ipn http/1.1" 406 275 "-" "-" ip - - [14/jun/2016:17:58:28 -0500] "post /wp-content/plugins/example/controllers/payments/ipn http/1.1" 406 275 "-" "-" ip - - [14/jun/2016:17:58:35 -0500] "post /wp-content/plugins/example/controllers/payments/ipn http/1.1" 406 275 "-" "-" 

edit if replace script this , place in root directory of site work. move script anywhere under root dir not work.

edit2 using script or not ipn succeeds on index of site. dont understand why succeed here

the answer development need send ipn requests ipn simulator @ sandbox.paypal.com instead of developer.paypal.com.

you must login sandbox.paypal.com something-facilitator@example.com creds created in developer.paypal.com.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -