Advertisement
Daniel3996

item.php

Dec 12th, 2023 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.84 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.  
  7. <meta http-equiv="refresh" content="15">
  8. <link href='https://fonts.googleapis.com/css?family=Alkatra' rel='stylesheet'>
  9. <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  10. <title>Checkout</title>
  11.  
  12. <style>
  13. /* Global styles */
  14. * {
  15. margin: 0;
  16. padding: 0;
  17. box-sizing: border-box;
  18. }
  19.  
  20. body {
  21. font-family: 'Alkatra', sans-serif;
  22. background-color: #f2f2f2;
  23. }
  24.  
  25. h1, h2, p {
  26. margin: 10px;
  27. text-align: center;
  28. }
  29.  
  30. img {
  31. display: block;
  32. margin: 10px auto;
  33. width: 160px;
  34. height: auto;
  35. }
  36.  
  37. button {
  38. display: block;
  39. margin: 10px auto;
  40. padding: 10px;
  41. border: none;
  42. border-radius: 5px;
  43. background-color: rgb(175, 129, 76);
  44. color: white;
  45. font-weight: bold;
  46. cursor: pointer;
  47. }
  48.  
  49. a {
  50. text-decoration: none;
  51. color: white;
  52. }
  53.  
  54. a:hover {
  55. color: #f2f2f2;
  56. }
  57.  
  58. /* Header styles */
  59. header {
  60. background-color: #af844c;
  61. text-align: center;
  62. padding: 20px;
  63. color: white;
  64. }
  65.  
  66. /* Form styles */
  67. form {
  68. max-width: 500px;
  69. margin: 20px auto;
  70. padding: 20px;
  71. border: 1px solid #ccc;
  72. border-radius: 5px;
  73. background-color: #fff;
  74. }
  75. /* Add some basic styling for the buttons */
  76. .quantity-btn {
  77. cursor: pointer;
  78. font-size: 16px;
  79. padding: 5px 10px;
  80. margin: 0 5px;
  81. }
  82. </style>
  83. </head>
  84. <body>
  85. <?php
  86. $item = $_GET['item'];
  87. $price = $_GET['price'];
  88. ?>
  89. <header>
  90. <h1>Items</h1>
  91. </header>
  92. <form>
  93. <h2><?php echo $item; ?></h2>
  94. <p>Price: <strong id="item-price"><?php echo $price; ?></strong></p>
  95.  
  96. <!-- Plus and minus buttons for quantity -->
  97. <button type="button" class="quantity-btn" onclick="updateQuantity('minus', '<?php echo $item; ?>', '<?php echo $price; ?>')">-</button>
  98. <!-- Make the quantity field read-only -->
  99. <input type="text" id="quantity" name="quantity" value="1" readonly>
  100. <button type="button" class="quantity-btn" onclick="updateQuantity('plus', '<?php echo $item; ?>', '<?php echo $price; ?>')">+</button>
  101.  
  102. <!-- Display total price -->
  103. <p>Total Price: Rs:<strong id="total-price"><?php echo number_format($price, 2); ?></strong></p>
  104.  
  105. <!-- Add hidden input fields for item and price -->
  106. <input type="hidden" name="item" value="<?php echo $item; ?>">
  107. <input type="hidden" name="price" value="<?php echo $price; ?>">
  108.  
  109. <!-- Styled hyperlink with data attributes -->
  110. <button type="submit">
  111. <a href="javascript:void(0)" class="btn btn-sm btn-primary float-right buy_now"
  112. data-amount="<?php echo $price * 100; ?>" data-id="<?php echo $item; ?>">
  113. Order Now
  114. </a>
  115. </button>
  116. <!-- Original "Cancel and Return back" button -->
  117. <button><a href="index.html">Cancel and Return back</a></button>
  118. </form>
  119.  
  120. <!-- Razorpay scripts -->
  121. <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
  122. <script>
  123. // Script for Razorpay integration
  124. $('body').on('click', '.buy_now', function(e){
  125. var totalAmount = $(this).attr("data-amount");
  126. var product_id = $(this).attr("data-id");
  127. var options = {
  128. "key": "rzp_test//",
  129. "amount": totalAmount,
  130. "name": "Tutsmake",
  131. "description": "Payment",
  132. "image": "//www.tutsmake.com/wp-content/uploads/2018/12/cropped-favicon-1024-1-180x180.png",
  133. "handler": function (response){
  134. $.ajax({
  135. url: 'http://stripe_payment_gateway.dvl.to/checkout.php',
  136. type: 'post',
  137. dataType: 'json',
  138. data: {
  139. razorpay_payment_id: response.razorpay_payment_id,
  140. totalAmount: totalAmount,
  141. product_id: product_id,
  142. },
  143. success: function (msg) {
  144. window.location.href = 'http://stripe_payment_gateway.dvl.to/success.php';
  145. }
  146. });
  147. },
  148. "theme": {
  149. "color": "#528FF0"
  150. }
  151. };
  152. var rzp1 = new Razorpay(options);
  153. rzp1.open();
  154. e.preventDefault();
  155. });
  156. </script>
  157.  
  158. <!-- Function to update quantity and total price -->
  159. <script>
  160. function updateQuantity(action, item, price) {
  161. var quantityInput = document.querySelector('input[name="quantity"]');
  162. var quantity = parseInt(quantityInput.value);
  163.  
  164. if (action === 'plus') {
  165. quantity += 1;
  166. } else if (action === 'minus' && quantity > 1) {
  167. quantity -= 1;
  168. }
  169.  
  170. quantityInput.value = quantity;
  171.  
  172. var itemPrice = parseFloat(price);
  173. var totalPrice = quantity * itemPrice;
  174.  
  175. document.getElementById('total-price').textContent = totalPrice.toFixed(2);
  176. }
  177. </script>
  178.  
  179. </body>
  180. </html>
  181.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement