Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
1,284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. //VIEW (WHERE I PUT PAYPAL BUTTON)
  2.  
  3. <?php include "functions/view_functions.php";?>
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <link href="https://fonts.googleapis.com/css?family=Sintony" rel="stylesheet">
  8. <link rel='stylesheet' href='css/style.css'/>
  9. <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
  10. <meta name="My New Car" content="Best Site or App to Buy a Car in Vancouver">
  11. <meta http-equiv="content-type" content="text/html;charset=UTF-8">
  12. <meta name=viewport content="width=device-width, initial-scale=1">
  13. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  14. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  15. <title>View my car - detail</title>
  16. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  17. <!--Including PayPal API-->
  18. <script src="https://www.paypalobjects.com/api/checkout.js"></script>
  19. </head>
  20. <body>
  21.  
  22. <article class="view-bg view-bg-location flex flex-middle flex-center" role="banner">
  23. <section class="main" id="home">
  24. <nav role="navigation">
  25. <ul class="list">
  26. <li><a href="index.php" class="active">Home</a></li>
  27. <li><a href="index.php#search">Search</a></li>
  28. <li><a href="index.php#available">Available Cars</a></li>
  29. <li><a href="admin/">Admin Sign In</a></li>
  30. <li><a href="subscriber/">Suscriber Sign In</a></li>
  31. <li><a href="index.php#contact">Contact</a></li>
  32. </ul>
  33. </nav>
  34. </section>
  35. </article>
  36. <section>
  37. <div class="container" align= "center" id="search">
  38. <h2 class= "textSearch">View my car detail:</h2>
  39.  
  40. <!--
  41. marianacaldassouza-facilitator@hotmail.com
  42. AQUXEBTvax8Qpu-CULisSvgtgsrKEsuTMdqWDd_lXR9Jd4GMzUlqhzVua2eZ-BheBfnON7A-Lm0IWyAH
  43.  
  44. Production:EOu3H8f4enqyxYbHOs2FVSFKQmzzUoM0hzx-bKECxC4lTxMoUp3DEMaBg1HBg3VUj5uJaXA0zVt_Ml5u
  45.  
  46. -->
  47.  
  48. <div id="paypal-button-container"></div>
  49.  
  50. <?php
  51. ShowSpecificCar();
  52. ?>
  53. </div>
  54. <div class="footer" id="contact">
  55. <p class="bottom"><a href="index.php"><- Return to main page</a></p>
  56. </div>
  57. </section>
  58. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  59. <script>
  60. $("document").ready(function() {
  61. $(function() {
  62. $(window).scroll(function () {
  63. if ($(this).scrollTop() > 50) {
  64. $("nav").addClass('changeColor')
  65. $('.list').addClass('center')
  66. }
  67. if ($(this).scrollTop() < 50) {
  68. $('nav').removeClass('changeColor')
  69. $('.list').removeClass('center')
  70. }
  71. });
  72. });
  73. });
  74. </script>
  75. </body>
  76. </html>
  77.  
  78.  
  79. //VIEW FUNCTIONS (WHERE I HAVE THE PAYPAL CODE. NOTE YOU NEED TO CREATE A PAYPAL ACCOUNT AND AN APP:
  80. https://developer.paypal.com/developer/applications/create
  81.  
  82. <?php include "connection_db.php";
  83.  
  84. function ShowSpecificCar(){
  85. //We put variables from other places, like $connection, inside a function by using global
  86. global $connection;
  87. //This id comes from a link in the function ShowAllCars in index_functions
  88. $id = $_GET['id'];
  89.  
  90. $query = "SELECT * FROM cars WHERE vin=".$id;
  91. //We use the mysqli built functions to stablish a connection (db.php) and perform the queries in our database.
  92. $result = mysqli_query($connection, $query);
  93. if(!$result){
  94. die("Query failed." . mysqli_error());
  95. }
  96.  
  97. $rowcount=mysqli_num_rows($result);
  98.  
  99. if ($rowcount==0){
  100. echo "<hr/><h2>No car was found!</h2>";
  101. }else{
  102. echo '<table class="table">';
  103. echo "<tr>";
  104. while($row = mysqli_fetch_assoc($result)){
  105. ?>
  106. <script>
  107. paypal.Button.render({
  108.  
  109. env: 'sandbox', // sandbox | production
  110.  
  111. // PayPal Client IDs - replace with your own
  112. // Create a PayPal app: https://developer.paypal.com/developer/applications/create
  113. client: {
  114. sandbox: 'AZDxjDScFpQtjWTOUtWKbyN_bDt4OgqaF4eYXlewfBP4-8aqX3PiV8e1GWU6liB2CUXlkA59kJXE7M6R',
  115. production: 'EOu3H8f4enqyxYbHOs2FVSFKQmzzUoM0hzx-bKECxC4lTxMoUp3DEMaBg1HBg3VUj5uJaXA0zVt_Ml5u'
  116. },
  117.  
  118. // Show the buyer a 'Pay Now' button in the checkout flow
  119. commit: true,
  120.  
  121. // payment() is called when the button is clicked
  122. payment: function(data, actions) {
  123.  
  124. // Make a call to the REST api to create the payment
  125. return actions.payment.create({
  126. payment: {
  127. transactions: [
  128. {
  129. amount: { total: '<?php echo number_format($row['price'], 2, '.','');?>', currency: 'USD' }
  130. }
  131. ]
  132. }
  133. });
  134. },
  135.  
  136. // onAuthorize() is called when the buyer approves the payment
  137. onAuthorize: function(data, actions) {
  138.  
  139. // Make a call to the REST api to execute the payment
  140. return actions.payment.execute().then(function() {
  141. window.alert('Payment Complete!');
  142. });
  143. }
  144.  
  145. }, '#paypal-button-container');
  146.  
  147. </script>
  148. <?php
  149. echo "<td>";
  150. echo "<table>";
  151. echo "<tr>";
  152. echo "<td>";
  153. echo '<img width="350" height="200" src="data:image/jpg;base64,'.base64_encode( $row['picture1'] ).'"/>';
  154. echo '<img width="350" height="200" src="data:image/jpg;base64,'.base64_encode( $row['picture2'] ).'"/>';
  155. echo '<img width="350" height="200" src="data:image/jpg;base64,'.base64_encode( $row['picture3'] ).'"/>';
  156. echo "</td>";
  157. echo "</tr>";
  158. echo "<tr>";
  159. echo "<td>Make: ";
  160. echo $row['make'];
  161. echo "</td>";
  162. echo "</tr>";
  163. echo "<tr>";
  164. echo "<td>Model: ";
  165. echo $row['model'];
  166. echo "</td>";
  167. echo "</tr>";
  168. echo "<tr>";
  169. echo "<td>Year: ";
  170. echo $row['year'];
  171. echo "</td>";
  172. echo "</tr>";
  173. echo "<tr>";
  174. echo "<td>Color: ";
  175. echo $row['color'];
  176. echo "</td>";
  177. echo "</tr>";
  178. echo "<tr>";
  179. echo "<td>Mileage: ";
  180. echo $row['mileage'];
  181. echo "</td>";
  182. echo "</tr>";
  183. echo "<tr>";
  184. echo "<td>Accidents: ";
  185. echo $row['accidents'];
  186. echo "</td>";
  187. echo "</tr>";
  188. echo "<tr>";
  189. echo "<td>Total Damage: ";
  190. echo "$". number_format($row['totalDamage'], 2, '.','');
  191. echo "</td>";
  192. echo "</tr>";
  193. echo "<tr>";
  194. echo "<td>Price: ";
  195. echo "$". number_format($row['price'], 2, '.','');
  196. echo "</td>";
  197. echo "</tr>";
  198. echo "<tr>";
  199. echo "<td>Special features: <br/>";
  200. $specialFeatures = $row['specialFeatures'];
  201. if(strpos($specialFeatures, 'A' ) !== false ) echo 'AWD<br/>';
  202. if(strpos($specialFeatures, '4' ) !== false ) echo '4WD<br/>';
  203. if(strpos($specialFeatures, 'P' ) !== false ) echo 'Power steering<br/>';
  204. if(strpos($specialFeatures, 'N' ) !== false ) echo 'Navigation<br/>';
  205. if(strpos($specialFeatures, 'S' ) !== false ) echo 'ABS break<br/>';
  206. if(strpos($specialFeatures, 'R' ) !== false ) echo 'Panoramic sunroof<br/>';
  207. if(strpos($specialFeatures, 'T' ) !== false ) echo 'Automatic Transmission<br/>';
  208. if(strpos($specialFeatures, 'W' ) !== false ) echo 'Winch<br/>';
  209. echo "</td>";
  210. echo "</tr>";
  211. echo "</table>";
  212. echo "</td>";
  213. }
  214. echo "</tr>";
  215. echo "</table>";
  216. }
  217. }
  218.  
  219.  
  220. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement