forms - Send data to PayPal; submit with PHP -


this code:

<form action="" method="post"> <input class="payment_input" type="text" name="name" placeholder="name"> <input class="payment_input" type="text" name="address" placeholder="address"> <input class="payment_input" type="text" name="email" placeholder="e-mail"><br> <input class="payment_input" type="submit" name="submit_paypal" value="go paypal"> </form>  <?php $order_token = md5(uniqid($_post['name'], true));   if (isset($_post["submit_paypal"])) {  $statement = $pdo->prepare("insert customers (name, address, email, order_token) values (:name, :address, :email, :order_token)"); $statement->execute(array(':name' => $_post['name'], ':address' => $_post['address'], ':email' => $_post['email'], ':order_token' => $order_token));  echo " <form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\"> <input type=\"hidden\" name=\"cmd\" value=\"_xclick\"> <input type=\"hidden\" name=\"business\" value=\"test@icloud.com\">  <input type=\"hidden\" name=\"item_name\" value=\"ebook\"> <input type=\"hidden\" name=\"amount\" value=\"10\"> <input type=\"hidden\" name=\"return\" value=\"http://www.example.com/book.php?payment=success&ordertoken=".$order_token."\"> <input type=\"hidden\" name=\"cancel_return\" value=\"http://example.com/book.php?payment=canceled\"> <input type=\"submit\"> </form> "; } ?> 

it woks follows: user gets form insert data (name, address, email). when user submits form 2 things should happen: user data stored im database random order_token. order_token needed identify user data when payment done. (when order_token e.g. "5dcb567fb34805d45d55218995df12f5", paypal return link (if payment successful) "http://www.example.com/book.php?payment=success&ordertoken=5dcb567fb34805d45d55218995df12f5").

but have 2 problems:

  1. how submit paypal form user submits order form on website without need make submit button user have click?

  2. how prevent user can manipulate paypal form? user change amount e.g. 10 1.

i hope has energy me because i'm working on since nights.

with of javascript, paypal form can automatically submitted.

the code:

<script type="text/javascript">     document.myform.submit(); </script> 

to use need add name="myform"to paypal form.

also, not show paypal ipn system, suggest looking make sure set payment gateway properly.

in addition preventing user changing paypal form code, use of ipn stop this. after payment received, paypal contact php script (ipn) , able verify item's name, how paid ect.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -