Guest User

Untitled

a guest
Nov 7th, 2017
680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. <form style="text-align:center;" id="paypalform" action="https://www.paypal.com/cgi-bin/webscr" method="POST">
  2. <input type='hidden' name='cmd' value='_xclick'>
  3. <input type='hidden' name='business' value='payment@xxx.com'>
  4. <input type='hidden' name='item_name' value='201001114262121'>
  5. <input type='hidden' name='amount' id="amount" value='1.00'>
  6. <input type='hidden' name='currency_code' value='CAD'>
  7. <input type='hidden' name='return' value='http://www.xxx.com/paypal_process.php'>
  8. <input type='hidden' name='invoice' value='82'>
  9. <input type='hidden' name='charset' value='utf-8'>
  10. <input type='hidden' name='no_shipping' value='1'>
  11. <input type='hidden' name='no_note' value=''>
  12. <input type='hidden' name='notify_url' value='http://www.xxx.com/return.php'>
  13. <input type='hidden' name='rm' value='82'>
  14. <input type='hidden' name='cancel_return' value='http://www.xxx.com/index.html'>
  15. </form>
  16.  
  17. <?php
  18. if(isset($_POST['submit']))
  19. {
  20. function do_post_request($url, $data, $optional_headers = null)
  21. {
  22. $params = array('http' => array(
  23. 'method' => 'POST',
  24. 'content' => $data
  25. ));
  26. if($optional_headers != null)
  27. {
  28. $params['http']['header'] = $optional_headers;
  29. }
  30. $ctx = stream_context_create($params);
  31. $fp = @fopen($url, 'rb', false, $ctx);
  32. if (!$fp)
  33. {
  34. throw new Exception("Problem with $url, $php_errormsg");
  35. }
  36. $response='';
  37. while (!feof($fp))
  38. {
  39. $response = $response.fgets($fp);
  40. }
  41. if ($response === false)
  42. {
  43. throw new Exception("Problem reading data from $url, $php_errormsg");
  44. }
  45.  
  46. fclose($fp);
  47. return $response;
  48. }
  49. $host = 'http://mydomain.com';
  50. $url = 'http://mydomain.com/formHandler.php';
  51. $username = 'admin';
  52. $password = '123456';
  53. $data = array ('action' => 'login','lgname' => $username, 'lgpassword' => $password, 'format' => 'txt');
  54. $data = http_build_query($data);
  55. $reply = do_post_request($url, $data);
  56. echo "**********Response*********<pre>";
  57. echo var_dump($reply);
  58. #header('location:'.$host);
  59. #exit;
  60.  
  61. } else {
  62. echo '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'"><input type="text" name="uname" /><br><input type="password" name="password" /><input type="submit" name="submit"></form>';
  63. }
  64.  
  65. ?>
  66.  
  67. <?
  68. echo "<script type="text/javascript">
  69. window.onload=function(){
  70. document.forms['paypalform'].submit();
  71. }
  72. </script>";
  73. ?>
  74.  
  75. $paypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
  76. $paypalID = 'xyz-merchant@gmail.com';
  77. $form = "<form id='paypal' action='". $paypalURL."' method='post'>";
  78. $form .='<input type="hidden" name="business" value="'. $paypalID.'">';
  79. $form .='<input type="hidden" name="cmd" value="_xclick">';
  80. $itemDetail = "Detail goes here";
  81. $orderId = 4444;
  82. $totalAmountWithFee = 55;
  83. $form .='<input type="hidden" name="item_name" value=" '.$itemDetail.'">
  84. <input type="hidden" name="item_number" value="'.$orderId.'">
  85. <input type="hidden" name="amount" value="'.$totalAmountWithFee.'">
  86. <input type="hidden" name="currency_code" value="USD">';
  87.  
  88. $form .="<input type='hidden' name='cancel_return' value='http://localhost/public/cancel.php'> <input type='hidden' name='return' value='http://localhost/success.php'>";
  89. $form.="<script type="text/javascript"> document.forms['paypal'].submit();</script>";
  90. echo $form;
Add Comment
Please, Sign In to add comment