php - PayPal IPN Sandbox Script -


i have paypal ipn script i'm testing in sandbox. have inserted mail function everywhere possible know whats going on, , "invalid response" paypal, when using ipn tool @ the paypal developer site...

here script, * character represents censorship of confidential information:

<?php mysql_connect('localhost', '************', '******************'); mysql_select_db('*************'); $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 .= "content-length: " . strlen($req) . "\r\n\r\n"; $fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); $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']; if (!$fp) { } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "verified") == 0) { if ($payment_status != 'completed') {     mail('**********************', 'error', 'paypal ipn error: payment status invalid');     exit(); } if ($reciever_email != '***********************') {     mail('***********************', 'error', 'paypal ipn error: reciever email invalid');     exit(); } if ($payment_currency != 'usd') {     mail('***********************', 'error', 'paypal ipn error: currency invalid');     exit(); } mail('***********************', 'paypal transaction complete', 'paypal transaction complete! $' . $payment_amount); } else if (strcmp ($res, "invalid") == 0) { mail('***********************', 'error', 'paypal ipn error: response invalid'); exit(); } } fclose ($fp); } ?> 

the odd thing is, if replace ssl://www.sandbox.paypal.com ssl://www.paypal.com, script seems work fine. assistance here appreciated!

have capture post receiving , captured sending , compared 2 make sure being sent correctly , is. take @ ipn trouble shooting steps posted here. may resolve issue well.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -