paypal-listener has no effect (IPN) -
i use plugin "quick paypal payments" , set following paypal-listener.php, save in database, when paypemt successful. when there successful payment, there no saving in database. mistake?
<?php include ("wp-config.php"); global $wpdb; //build data post paypal $postback = 'cmd=_notify-validate'; // go through each of posted vars , add them postback variable foreach ($_post $key => $value) { $value = urlencode(stripslashes($value)); $postback .= "&$key=$value"; } // build header string post paypal system validate $header = "post /cgi-bin/webscr http/1.0\r\n"; $header .= "content-type: application/x-www-form-urlencoded\r\n"; $header .= "content-length: " . strlen($postback) . "\r\n\r\n"; // send paypal or sandbox depending on whether you're live or developing // comment out 1 of following lines //$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);//open connection $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); // or use port 443 ssl connection //$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // http error failed connect //error handling or email here } else // if we've connected ok { fputs ($fp, $header . $postback);//post data while (!feof($fp)) { $response = fgets ($fp, 1024); //it's verified if(strcmp($response,"verified") == 0){ // assign posted variables local variables, apply urldecode them @ point well, makes things simpler later $payment_status = $_post['payment_status'];//read payment details , account holder if($payment_status == 'completed') { $unique_id = $_session['unique_id']; $abfrage = "update eigene_angebote set `bezahlt` = 1, `bezahlt_am` = now() `unique_id`='".$unique_id."'"; $result=$wpdb->get_results($abfrage, array_a);** } else if($payment_status == 'denied' || $payment_status == 'failed' || $payment_status == 'refunded' || $payment_status == 'reversed' || $payment_status == 'voided') { } else if($payment_status == 'in-progress' || $payment_status == 'pending' || $payment_status == 'processed') { //do } else if($payment_status == 'canceled_reversal') { //do } } else if (strcmp ($response, "invalid") == 0) { //the paypal response invalid, not verified } } //end of while fclose ($fp); } ?>
i use wordpress-plugin "quick paypal payments" there can set paypal-listener.php . have buisiness paypal account.
Comments
Post a Comment