php - PayPal IPN Stuck at Payment Verify -
i have been working time on this, , have yet find solution. attempting paypal ipn work, have yet successful @ doing so. first, having trouble connecting ssl, went without now. after that, seemed getting other issue. went ahead , added debug, , have found getting stuck @ verify check. know going on.
below paypal ipn, , below that, button code.
<?php include("inc/database.php"); $debug = true; $header = ''; $req = "cmd=_notify-validate"; foreach($_post $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } $header .= "post /cgi-bin/webscr http/1.1\r\n"; $header .= "content-type: application/x-www-form-urlencoded\r\n"; $header .= "host: www.sandbox.paypal.com\r\n"; // www.sandbox.paypal.com test site $header .= "content-length: " . strlen($req) . "\r\n\r\n"; if ($debug) { $ourfilename = "pdebug.txt"; $ourfilehandle = fopen($ourfilename, 'w') or die("can't open file"); fwrite($ourfilehandle, $req); fclose($ourfilehandle); } $fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30); if(!$fp) { // http error; $message .= "\n http error. \n"; } else { if ($debug) { $ourfilename = "debug/debug2_connected.txt"; $ourfilehandle = fopen($ourfilename, 'w') or die("can't open file"); fclose($ourfilehandle); } fputs($fp, $header . $req); while(!feof($fp)) { $res = fgets($fp, 1024); if ($debug) { $ourfilename = "debug/debug3_fgets.txt"; $ourfilehandle = fopen($ourfilename, 'w') or die("can't open file"); fwrite($ourfilehandle, $res); fclose($ourfilehandle); } if(strcmp($res, "verified") == 0) { if ($debug) { $ourfilename = "debug/debug4_verified.txt"; $ourfilehandle = fopen($ourfilename, 'w') or die("can't open file"); fclose($ourfilehandle); } $ids = explode("|", $_post['custom']); $item_name = $_post["item_name"]; $item_number = $_post["item_number"]; $item_username = $ids[0]; $item_packageid = $ids[1]; $item_email = $ids[2]; $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"]; $prices = array(4, 4, 4); if(($payment_status == "completed") && ($receiver_email == "bking-facilitator@inbox.com") && ($payment_amount == $prices[$item_packageid - 1]) && ($payment_currency == "usd") && (checktxnid($txn_id) == 0)) { addpaypalpayment($item_name, $item_number, $item_username, $item_packageid, $item_email, $payment_status, $payment_amount, $payment_currency, $txn_id, $receiver_email, $payer_email); serviceadd($item_username, $item_number, $item_packageid); setserviceactive($item_packageid); sendemailwithusername("carwash", "paypal ipn", "success!"); } else { $mail_to = getuseremail($item_username); $mail_subject = "purchase unsuccessful"; $mail_body = "something went wrong recent order. \n\nthe transaction id number :$txn_id \n\npayment status is: $payment_status \n\npayment amount is: $payment_amount \n\nif believe error on our part, please submit ticket , you."; mail($mail_to, $mail_subject, $mail_body); sendemailwithusername("carwash", "paypal ipn", "failure!!"); } } else if(!strcmp($res, "invalid")) { $mail_to = "bking@inbox.com"; $mail_subject = "paypal - invalid ipn"; $mail_body = "we had invalid response. \n\nthe transaction id number $txn_id \n\n username = $item_username"; mail($mail_to, $mail_subject, $mail_body); sendemailwithusername("carwash", "paypal ipn", "failure!!!!!!!!"); } } fclose($fp); } ?>
button code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="<?php echo $ppemail; ?>"> <input type="hidden" name="item_name" value="<?php echo $pname; ?>"> <input type="hidden" name="item_number" value="<?php echo $id; ?>"> <input type="hidden" name="amount" value="<?php echo $prices[$id - 1] . ".00"; ?>"> <input type="hidden" name="quantity" value="1"> <input type="hidden" name="no_shipping" value="1"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="currency_code" value="usd"> <input type="hidden" name="lc" value="us"> <input type="hidden" name="bn" value="pp-buynowbf"> <input type="image" src="https://www.paypal.com/en_us/i/btn/x-click-but23.gif" border="0" name="submit" alt="make payments paypal - it's fast, free , secure!"> <img alt="" border="0" src="https://www.paypal.com/en_gb/i/scr/pixel.gif" width="1" height="1"> <!-- <div style="padding-top:100px; padding-right: 40%; padding-left: 40%;"> <center><input type="submit" name="submit" class="btn" value="checkout paypal"></center> </div> --> <input type="hidden" name="return" value="http://bvpn.biz/success.php?id=<?php echo $id; ?>&met=<?php echo $met; ?>"> <input type="hidden" name="cancel_return" value="http://bvpn.biz/success.php?id=<?php echo $id; ?>&met=<?php echo $met; ?>&do=2"> <input type="hidden" name="rm" value="2"> <input type="hidden" name="notify_url" value="http://bvpn.biz/ipn.php"/> <input type="hidden" name="custom" value="<?php echo $_session['username'].'|'.$pid.'|'.getuseremail($_session["username"]); ?>"> </form>
any supply great!
try if(strcmp(trim($res), "verified") == 0)...
according post here paypal sending verified response followed \r\n
when http1.1 header used. trim($res)
solved problem me.
Comments
Post a Comment