Я пытался это решить уже некоторое время. У меня есть страница заказа, где клиент должен ввести информацию, такую как имя, адрес и т. Д., А также еще несколько уникальных полей. Я создал IPN с Paypal, и клиент перенаправляется на указанную мной страницу. Но данные не совпадают с этим. Надеюсь, что я задаю свой вопрос правильно, чтобы я не закрылся. Вот HTML в кнопку отправки Paypal, которая перенаправляется на их страницу.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="NT2YC6LP7SWBE"> <input type="image" src="http://img.ruphp.com/php/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <input type="hidden" name="child_name" id="child_name" value ="<? echo $child_name; ?>" maxlength="20"/> <input type="hidden" name="age" id="age" value ="<? echo $age; ?>" maxlength="4"/> <input type="hidden" name="hometown" id="hometown" value ="<? echo $hometown; ?>" maxlength="32"/> <input type="hidden" name="boy_girl" id="boy_girl" value ="<? echo $boy_girl; ?>" maxlength="4"/> <input type="hidden" name="first_name" id="first_name" value ="<? echo $first_name; ?>" maxlength="32"/> <input type="hidden" name="last_name" id="last_name" value ="<? echo $last_name; ?>" maxlength="32"/> <input type="hidden" name="email" id="email" value ="<? echo $email; ?>" maxlength="64"/> <input type="hidden" name="address1" id="address1" value ="<? echo $address1; ?>" maxlength="64"/> <input type="hidden" name="address2" id="address2" value ="<? echo $address2; ?>" maxlength="32"/> <input type="hidden" name="city" id="city" value ="<? echo $city; ?>" maxlength="32"/> <input type="hidden" name="state" id="state" value ="<? echo $state; ?>" maxlength="20"/> <input type="hidden" name="zip" id="zip" value ="<? echo $zip; ?>" maxlength="10"/> <input type="hidden" name="country" id="country" value ="<? echo $country; ?>" maxlength="32"/> <input type="hidden" name="payment_type" id="payment_type" value ="paypal" maxlength="6"/> <input type="hidden" name="paid" id="paid" value ="yes" maxlength="3"/> <input type="hidden" name="mailed" id="mailed" value ="no" maxlength="3"/> <img alt="" border="0" src="http://img.ruphp.com/php/pixel.gif" width="1" height="1"> </form>
Мне было указано, что некоторые из переменных не являются «переменными Paypal», и я могу исправить это позже, но ни одна из моих данных не вернулась к указанной странице после посещения Paypal, даже переменные, поддерживаемые Paypal, такие как " город." Вот PHP, который у меня есть на странице, на которую они перенаправляются.
$raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $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 as $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.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) { $child_name = htmlentities($_POST['child_name']); $age = $_POST['age']; $hometown = $_POST['hometown']; $boy_girl = $_POST['boy_girl']; $email = $_POST['email']; $first_name = htmlentities($_POST['first_name']); $last_name = htmlentities($_POST['last_name']); $address1 = htmlentities($_POST['address1']); $address2 = htmlentities($_POST['address2']); $city = htmlentities($_POST['city']); $state = $_POST['state']; $zip = htmlentities($_POST['zip']); $country = htmlentities($_POST['country']); $payment_type = $_POST['payment_type']; $paid = $_POST['paid']; $mailed = $_POST['mailed']; } else if (strcmp ($res, "INVALID") == 0) { } $query = "INSERT INTO customer_list ( number, child_name, age, hometown, boy_girl, first_name, last_name, email, address1, address2, city, state, zip, country, payment_type, paid, mailed) VALUES ('', '".mysql_real_escape_string($child_name)."', '".mysql_real_escape_string($age)."', '".mysql_real_escape_string($hometown)."', '".mysql_real_escape_string($boy_girl)."', '".mysql_real_escape_string($first_name)."', '".mysql_real_escape_string($last_name)."', '".mysql_real_escape_string($email)."', '".mysql_real_escape_string($address1)."', '".mysql_real_escape_string($address2)."', '".mysql_real_escape_string($city)."', '".mysql_real_escape_string($state)."', '".mysql_real_escape_string($zip)."', '".mysql_real_escape_string($country)."', '".mysql_real_escape_string($payment_type)."', '".mysql_real_escape_string($paid)."', '".mysql_real_escape_string($mailed)."')"; if ($query_run = mysql_query($query)) { $subject = "Thank You for Your Order"; $message = "Thank you for placing your order with My-Letter-From-Santa-Claus.com. \n\nYou can expect to receive your personalized letter soon. Please make note of your customer number. Your customer number is: ".mysql_insert_id().". \n\nPlease send all inquiries to : info@my-letter-from-santa-claus.com"; $from = "info@my-letter-from-santa-claus.com"; $headers = "From:" . $from; mail($email, $subject, $message, $headers); echo 'Thank you for your order.'; echo 'Letter For '.$child_name; } else { echo mysql_error(); }
по$raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $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 as $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.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) { $child_name = htmlentities($_POST['child_name']); $age = $_POST['age']; $hometown = $_POST['hometown']; $boy_girl = $_POST['boy_girl']; $email = $_POST['email']; $first_name = htmlentities($_POST['first_name']); $last_name = htmlentities($_POST['last_name']); $address1 = htmlentities($_POST['address1']); $address2 = htmlentities($_POST['address2']); $city = htmlentities($_POST['city']); $state = $_POST['state']; $zip = htmlentities($_POST['zip']); $country = htmlentities($_POST['country']); $payment_type = $_POST['payment_type']; $paid = $_POST['paid']; $mailed = $_POST['mailed']; } else if (strcmp ($res, "INVALID") == 0) { } $query = "INSERT INTO customer_list ( number, child_name, age, hometown, boy_girl, first_name, last_name, email, address1, address2, city, state, zip, country, payment_type, paid, mailed) VALUES ('', '".mysql_real_escape_string($child_name)."', '".mysql_real_escape_string($age)."', '".mysql_real_escape_string($hometown)."', '".mysql_real_escape_string($boy_girl)."', '".mysql_real_escape_string($first_name)."', '".mysql_real_escape_string($last_name)."', '".mysql_real_escape_string($email)."', '".mysql_real_escape_string($address1)."', '".mysql_real_escape_string($address2)."', '".mysql_real_escape_string($city)."', '".mysql_real_escape_string($state)."', '".mysql_real_escape_string($zip)."', '".mysql_real_escape_string($country)."', '".mysql_real_escape_string($payment_type)."', '".mysql_real_escape_string($paid)."', '".mysql_real_escape_string($mailed)."')"; if ($query_run = mysql_query($query)) { $subject = "Thank You for Your Order"; $message = "Thank you for placing your order with My-Letter-From-Santa-Claus.com. \n\nYou can expect to receive your personalized letter soon. Please make note of your customer number. Your customer number is: ".mysql_insert_id().". \n\nPlease send all inquiries to : info@my-letter-from-santa-claus.com"; $from = "info@my-letter-from-santa-claus.com"; $headers = "From:" . $from; mail($email, $subject, $message, $headers); echo 'Thank you for your order.'; echo 'Letter For '.$child_name; } else { echo mysql_error(); }
-$raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $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 as $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.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) { $child_name = htmlentities($_POST['child_name']); $age = $_POST['age']; $hometown = $_POST['hometown']; $boy_girl = $_POST['boy_girl']; $email = $_POST['email']; $first_name = htmlentities($_POST['first_name']); $last_name = htmlentities($_POST['last_name']); $address1 = htmlentities($_POST['address1']); $address2 = htmlentities($_POST['address2']); $city = htmlentities($_POST['city']); $state = $_POST['state']; $zip = htmlentities($_POST['zip']); $country = htmlentities($_POST['country']); $payment_type = $_POST['payment_type']; $paid = $_POST['paid']; $mailed = $_POST['mailed']; } else if (strcmp ($res, "INVALID") == 0) { } $query = "INSERT INTO customer_list ( number, child_name, age, hometown, boy_girl, first_name, last_name, email, address1, address2, city, state, zip, country, payment_type, paid, mailed) VALUES ('', '".mysql_real_escape_string($child_name)."', '".mysql_real_escape_string($age)."', '".mysql_real_escape_string($hometown)."', '".mysql_real_escape_string($boy_girl)."', '".mysql_real_escape_string($first_name)."', '".mysql_real_escape_string($last_name)."', '".mysql_real_escape_string($email)."', '".mysql_real_escape_string($address1)."', '".mysql_real_escape_string($address2)."', '".mysql_real_escape_string($city)."', '".mysql_real_escape_string($state)."', '".mysql_real_escape_string($zip)."', '".mysql_real_escape_string($country)."', '".mysql_real_escape_string($payment_type)."', '".mysql_real_escape_string($paid)."', '".mysql_real_escape_string($mailed)."')"; if ($query_run = mysql_query($query)) { $subject = "Thank You for Your Order"; $message = "Thank you for placing your order with My-Letter-From-Santa-Claus.com. \n\nYou can expect to receive your personalized letter soon. Please make note of your customer number. Your customer number is: ".mysql_insert_id().". \n\nPlease send all inquiries to : info@my-letter-from-santa-claus.com"; $from = "info@my-letter-from-santa-claus.com"; $headers = "From:" . $from; mail($email, $subject, $message, $headers); echo 'Thank you for your order.'; echo 'Letter For '.$child_name; } else { echo mysql_error(); }
по$raw_post_data = file_get_contents('php://input'); $raw_post_array = explode('&', $raw_post_data); $myPost = array(); foreach ($raw_post_array as $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 as $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.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) { $child_name = htmlentities($_POST['child_name']); $age = $_POST['age']; $hometown = $_POST['hometown']; $boy_girl = $_POST['boy_girl']; $email = $_POST['email']; $first_name = htmlentities($_POST['first_name']); $last_name = htmlentities($_POST['last_name']); $address1 = htmlentities($_POST['address1']); $address2 = htmlentities($_POST['address2']); $city = htmlentities($_POST['city']); $state = $_POST['state']; $zip = htmlentities($_POST['zip']); $country = htmlentities($_POST['country']); $payment_type = $_POST['payment_type']; $paid = $_POST['paid']; $mailed = $_POST['mailed']; } else if (strcmp ($res, "INVALID") == 0) { } $query = "INSERT INTO customer_list ( number, child_name, age, hometown, boy_girl, first_name, last_name, email, address1, address2, city, state, zip, country, payment_type, paid, mailed) VALUES ('', '".mysql_real_escape_string($child_name)."', '".mysql_real_escape_string($age)."', '".mysql_real_escape_string($hometown)."', '".mysql_real_escape_string($boy_girl)."', '".mysql_real_escape_string($first_name)."', '".mysql_real_escape_string($last_name)."', '".mysql_real_escape_string($email)."', '".mysql_real_escape_string($address1)."', '".mysql_real_escape_string($address2)."', '".mysql_real_escape_string($city)."', '".mysql_real_escape_string($state)."', '".mysql_real_escape_string($zip)."', '".mysql_real_escape_string($country)."', '".mysql_real_escape_string($payment_type)."', '".mysql_real_escape_string($paid)."', '".mysql_real_escape_string($mailed)."')"; if ($query_run = mysql_query($query)) { $subject = "Thank You for Your Order"; $message = "Thank you for placing your order with My-Letter-From-Santa-Claus.com. \n\nYou can expect to receive your personalized letter soon. Please make note of your customer number. Your customer number is: ".mysql_insert_id().". \n\nPlease send all inquiries to : info@my-letter-from-santa-claus.com"; $from = "info@my-letter-from-santa-claus.com"; $headers = "From:" . $from; mail($email, $subject, $message, $headers); echo 'Thank you for your order.'; echo 'Letter For '.$child_name; } else { echo mysql_error(); }
Я скопировал большую часть этого непосредственно из x.com, за исключением того, что я, конечно, перешел на мои собственные переменные. В базу данных ничего не публикуется, но это не проблема, поскольку я даже не могу повторить данные. В базу данных вводится пара вещей, но это не данные с моей страницы заказа – это имя и фамилия, которые вводятся в качестве информации о кредитной карте в Paypal, а для параметра payment_type указано «instan» (I maxed it на 6 символов), но, как вы можете видеть из скрытого поля ввода в HTML, я хотел бы опубликовать значение «paypal». Как это исправить?