PageRenderTime 49ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/process_booking.php

https://bitbucket.org/isaacoheneayisi/book2wheelmainproject
PHP | 271 lines | 228 code | 36 blank | 7 comment | 6 complexity | 0e6160c2074d922752df6b7ea9acf3f2 MD5 | raw file
  1. <?php
  2. ob_start();
  3. include('search_header.php');
  4. include('includes/allFunctions.php');
  5. session_start();
  6. //include('includes/config.php');
  7. $page_title ="bikedetails";
  8. //Set useful variables for paypal form
  9. // $paypalURL = 'https://www.sandbox.paypal.com/cgi-bin/webscr'; //Test PayPal API URL
  10. $paypalURL = 'https://www.paypal.com/cgi-bin/webscr'; //Test PayPal API URL
  11. //$paypalID = 'ayiscoo@yahoo.com'; //Business Email
  12. $paypalID = 'fur@book2wheel.com'; //Business Email
  13. //$paypalID = 'fur-facilitator@book2wheel.com'; //Business Email
  14. if (empty($_SESSION['total'])){
  15. header('Location: index.php',true,301);
  16. exit;
  17. }
  18. ?>
  19. <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  20. <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  21. <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  22. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
  23. <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
  24. <hr>
  25. <link rel="stylesheet" href="css/payment.css" />
  26. <div class="container" style="margin-top: 70px; background-color: #EDF0F2">
  27. <main class="page payment-page">
  28. <section class="payment-form dark">
  29. <div class="container">
  30. <div class="block-heading">
  31. <h2>Payment</h2>
  32. <p>You will pay 20% of the total priced proposed by the owner and pay the rest to him on pickup</p>
  33. </div>
  34. <form action="<?php echo $paypalURL; ?>" method="post">
  35. <div class="products">
  36. <h3 class="title">Your Booking</h3>
  37. <div class="item">
  38. <span class="price"><?php
  39. if ($_SESSION['num_days'] ==0){
  40. echo 1;
  41. }else {
  42. echo $_SESSION['num_days'];
  43. }
  44. ?></span>
  45. <p class="item-name">Number of Days</p>
  46. <!-- <p class="item-description">Lorem ipsum dolor sit amet</p> -->
  47. </div>
  48. <div class="item">
  49. <span class="price"><?php echo $_SESSION['total']; ?></span>
  50. <p class="item-name">Price for Days Chosen</p>
  51. <!-- <p class="item-description">i: </p> -->
  52. </div>
  53. <div class="item">
  54. <span class="price"> From : <?php echo $_SESSION['begin_book_date'] ." "."to"." ".$_SESSION['end_book_date'] ?> </span>
  55. <p class="item-name">Choosen Dates</p>
  56. <!-- <p class="item-description">i: </p> -->
  57. </div>
  58. <div class="item">
  59. <span class="price"><img src="user_profile/bikes/<?php echo $_SESSION['image_url']; ?>" width="200px" height="70px"></span>
  60. <p class="item-name">Chosen Bike</p>
  61. <!-- <p class="item-description">Lorem ipsum dolor sit amet</p> -->
  62. </div><br /> <br />
  63. <div class="item">
  64. <span class="price"><?php echo $_SESSION['total']; ?></span>
  65. <p class="item-name">Price for <?php echo $_SESSION['num_days'] ?> </p>
  66. <!-- <p class="item-description">i: </p> -->
  67. </div>
  68. <br />
  69. <?php
  70. $twenty_per = (20/100)* $_SESSION['total'];
  71. $_SESSION['total_per'] = $twenty_per ;
  72. ?>
  73. <div class="total">20% of the Total<span class="price">PHP <?php echo $twenty_per; ?></span></div>
  74. </div>
  75. <!-- Identify your business so that you can collect the payments. -->
  76. <input type="hidden" name="business" value="<?php echo $paypalID; ?>">
  77. <!-- Specify a Buy Now button. -->
  78. <input type="hidden" name="cmd" value="_xclick">
  79. <!-- Specify details about the item that buyers will purchase. -->
  80. <input type="hidden" name="item_name" value="MotoBike Booking">
  81. <input type="hidden" name="item_number" value="<?php echo $_SESSION['num_days']; ?>">
  82. <input type="hidden" name="amount" value="<?php echo $twenty_per; ?>">
  83. <input type="hidden" name="currency_code" value="PHP">
  84. <input type='hidden' name='notify_url' value='https://book2wheel.com/asia/pay_success.php'>
  85. <!-- Specify URLs -->
  86. <!-- <input type='hidden' name='cancel_return' value='http://localhost/book2wheel/pay_cancel.php'>
  87. <input type='hidden' name='return' value='http://localhost/book2wheel/pay_success.php'> -->
  88. <input type='hidden' name='cancel_return' value='https://book2wheel.com/asia/pay_cancel.php'>
  89. <input type='hidden' name='return' value='https://book2wheel.com/asia/pay_success.php'>
  90. <input type="hidden" name="notify_url" value="https://book2wheel.com/asia/ipn.php" />
  91. <!-- <input type='hidden' name='notify_url' value='http://www.codexworld.com/ipn.php'> -->
  92. <!-- Display the payment button. -->
  93. <!-- <input type="image" name="submit" border="0"
  94. src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
  95. <img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" > -->
  96. <!-- <div class="card-details">
  97. <h3 class="title">Credit Card Details</h3>
  98. <div class="row">
  99. <div class="form-group col-sm-7">
  100. <label for="card-holder">Card Holder</label>
  101. <input id="card-holder" type="text" class="form-control" placeholder="Card Holder" aria-label="Card Holder" aria-describedby="basic-addon1">
  102. </div>
  103. <div class="form-group col-sm-5">
  104. <label for="">Expiration Date</label>
  105. <div class="input-group expiration-date">
  106. <input type="text" class="form-control" placeholder="MM" aria-label="MM" aria-describedby="basic-addon1">
  107. <span class="date-separator">/</span>
  108. <input type="text" class="form-control" placeholder="YY" aria-label="YY" aria-describedby="basic-addon1">
  109. </div>
  110. </div>
  111. <div class="form-group col-sm-8">
  112. <label for="card-number">Card Number</label>
  113. <input id="card-number" type="text" class="form-control" placeholder="Card Number" aria-label="Card Holder" aria-describedby="basic-addon1">
  114. </div>
  115. <div class="form-group col-sm-4">
  116. <label for="cvc">CVC</label>
  117. <input id="cvc" type="text" class="form-control" placeholder="CVC" aria-label="Card Holder" aria-describedby="basic-addon1">
  118. </div>
  119. <div class="form-group col-sm-12">
  120. <button type="button" class="btn btn-primary btn-block">Proceed</button>
  121. </div>
  122. </div>
  123. </div> -->
  124. <div class="form-group col-sm-12">
  125. <input type="submit" class="btn btn-primary btn-block" value="Proceed with Paypal" width="126px" height="33px"></a></button><br />
  126. <p><input type="radio" name='visa' id="visa" value='P' id="visa"/> Pay with Visa<img width="50px" height="50px" src="img/visa.jpg" ><img width="50px" height="50px" src="img/mastercard.jpg"> </p>
  127. </div>
  128. </form>
  129. <div id="pay_master">
  130. <form role="form" id="visa_payment" method="post" >
  131. <input type="hidden" name="opera" value="visa_master">
  132. <div class="products">
  133. <p><input type="radio" name='paypal' value='paypal' id="paypal"/> Hide </p>
  134. <div class="card-details">
  135. <h3 class="title">Billing Information <a href="#" width="126px" height="33px"><img src="img/visa.jpg" >
  136. <img src="img/mastercard.jpg"> </a>
  137. </h3>
  138. <div class="row">
  139. <div class="form-group col-sm-12">
  140. <label for="card-holder">Billing Adsress</label>
  141. <input id="card-holder" type="text" class="form-control" id="billing_address" name="billing_address" placeholder="Billing Adsress" aria-label="billing address" aria-describedby="basic-addon1">
  142. </div>
  143. <div class="form-group col-sm-12">
  144. <label for="card-holder">Billing City</label>
  145. <input id="card-holder" type="text" d="billing_city" name="billing_city" class="form-control" placeholder="Billing City" aria-label="Card Holder" aria-describedby="basic-addon1">
  146. </div>
  147. <div class="form-group col-sm-12">
  148. <label for="card-holder">Billing Country</label>
  149. <input id="card-holder" type="text" id="billing_country" name="billing_country" class="form-control" placeholder="Billing Country" aria-label="Card Holder" aria-describedby="basic-addon1">
  150. </div>
  151. <div class="form-group col-sm-12">
  152. <label for="card-holder">Billing Postal Code</label>
  153. <input id="card-holder" type="text" id="billing_postcode" name="billing_postcode" class="form-control" placeholder="Postal Code" aria-label="Card Holder" aria-describedby="basic-addon1">
  154. </div>
  155. <div class="form-group col-sm-12">
  156. <label for="card-number">Email</label>
  157. <input id="card-number" type="email" id="email" name="email" class="form-control" placeholder="Email" aria-label="Card Holder" aria-describedby="basic-addon1">
  158. </div>
  159. <?php
  160. $euro_charge = convertCurrency($twenty_per, "PHP", "EUR");
  161. ?>
  162. <div class="form-group col-sm-12">
  163. <label for="card-number" style="font-size: 20px">PHP <?php echo $twenty_per ?> = <?php echo $euro_charge ?> EUR </label>
  164. <input id="card-number" type="hidden" id="amount" name="amount" class="form-control" value="<?php echo $euro_charge; ?>" aria-label="Card Holder" aria-describedby="basic-addon1">
  165. </div>
  166. <div class="form-group col-sm-12">
  167. <input type="submit" class="btn btn-primary btn-block" value="Proceed EUR <?php echo $euro_charge; ?>" />
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </form>
  173. </div>
  174. </div>
  175. </section>
  176. </main>
  177. </div>
  178. <!-- <script src="https://www.paypalobjects.com/api/checkout.js"></script> -->
  179. <!-- <script>
  180. paypal.Button.render({
  181. env: 'sandbox',
  182. client: {
  183. sandbox: 'demo_sandbox_client_id'
  184. },
  185. payment: function (data, actions) {
  186. return actions.payment.create({
  187. transactions: [{
  188. amount: {
  189. total: '0.01',
  190. currency: 'USD'
  191. }
  192. }]
  193. });
  194. },
  195. onAuthorize: function (data, actions) {
  196. return actions.payment.execute()
  197. .then(function () {
  198. window.alert('Thank you for your purchase!');
  199. });
  200. }
  201. }, '#paypal-button');
  202. </script> -->
  203. <?php
  204. function convertCurrency($amount, $from, $to){
  205. $conv_id = "{$from}_{$to}";
  206. $string = file_get_contents("https://free.currencyconverterapi.com/api/v3/convert?q=$conv_id&compact=ultra");
  207. $json_a = json_decode($string, true);
  208. return $amount * round($json_a[$conv_id], 4);
  209. }
  210. ?>
  211. <?php include ('search_footer.php'); ?>
  212. <script type="text/javascript" src="js/script.js"></script>
  213. <script type="text/javascript">
  214. $('#pay_master').hide();
  215. </script>
  216. <script type="text/javascript">
  217. $(function() {
  218. $('input[type="radio"]').change(function() {
  219. var rad = $(this);
  220. //('input[type="radio"]').addClass('none');
  221. if (rad.is(':checked'))
  222. $('#pay_master').show();
  223. $("#visa").attr("checked", false);
  224. $("#paypal").attr("checked", false);
  225. });
  226. $('#paypal').change(function() {
  227. var rad = $(this);
  228. //('input[type="radio"]').addClass('none');
  229. if (rad.is(':checked'))
  230. $("#visa").attr("checked", false);
  231. $("#paypal").attr("checked", false);
  232. $('#pay_master').hide();
  233. });
  234. });
  235. </script>