PHP - Paypal IPN integration issue -
there paypal button on page. there 2 custom fields paypal button. getting ipn response on ipn.php page. have got code paypal site.
when testing using sandbox, payment deduced buyer business relationship , deposited merchant account. info not inserted database table mentioned @ lastly of below code. have tried send both variable values in single variable named "custom" still no luck. please review code , allow me know wrong doing. please help me struggling lastly 2 days.
$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]); } $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"; } $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')); if( !($res = curl_exec($ch)) ) { // error_log("got " . curl_error($ch) . " when processing ipn data"); curl_close($ch); exit; } curl_close($ch); if (strcmp ($res, "verified") == 0) { $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']; $custom_memname = $_post['custom_memname']; // 1st custom variable $custom_mempass = $_post['custom_mempass']; // 2nd custom variable $str_query_insert="insert t_fmember(memberid,password) values('" .$custom_memname."','".$custom_mempass."')"; executequery($str_query_insert); }
i added code on ipn.php page , used ipn simulator didn't response yet.
$post_data_string = serialize($_post); mail('mymail@yahoo.com', 'paypal ipn', $post_data_string);
please help farther if possible. give thanks you
you need utilize paypal sandbox ipn simulator @ http://developer.paypal.com in order test ipn notifications in sandbox mode.
php paypal paypal-ipn
No comments:
Post a Comment