Skip to content

Commit

Permalink
Merge pull request #80 from ArchanRD/payment-gateway
Browse files Browse the repository at this point in the history
Fixed Payment gateway - Razorpay
  • Loading branch information
Vimall03 authored Oct 11, 2024
2 parents 3fbb11d + 1a2c3db commit 43647ac
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
$order=$_SESSION['Order'];
$amount=$_SESSION['amount'];
$userId= $_SESSION['user_id'];

$rid = $_SESSION['rest_id'];

$oid = mt_rand(10000, 99999);
$_SESSION['orderid'] = str_pad($oid, 5, '0', STR_PAD_LEFT);
Expand Down
2 changes: 1 addition & 1 deletion menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ function convertCartToArray(cart) {
<td id="" class="text-center"><b id="totalPrice"></b></td>
</tbody>
</table>
<div id="addVal"></div><form action="/homemade/menu.php" method="post">
<div id="addVal"></div><form action="/alimento/menu.php" method="post">
<input hidden value="<?php echo $id ?>" name="restaurant_id"/>
<a href="checkout.php"> <button id="checkoutBtn" class="btn btn-primary checkOutBtn" style="display:none">CHECKOUT</button></a>
</form>
Expand Down
26 changes: 24 additions & 2 deletions pay.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,29 @@

<script type="text/javascript">
$(document).ready(function() {

$('.razorpay-payment-button').click();
let options = {
// Razorpay options
key: "<?php echo $data['key']?>", // Your Razorpay Key
amount: "<?php echo $data['amount']?>", // Amount is in currency subunits
currency: "INR",
name: "<?php echo $data['name']?>",
description: "<?php echo $data['description']?>",
image: "<?php echo $data['image']?>",
order_id: "<?php echo $data['order_id']?>",
handler: function (response){
window.location.href = "/alimento/verify.php?razorpay_payment_id=" + response.razorpay_payment_id;
},
prefill: {
name: "<?php echo $data['prefill']['name']?>",
email: "<?php echo $data['prefill']['email']?>",
contact: "<?php echo $data['prefill']['contact']?>"
},
notes: {
shopping_order_id: "<?php echo $_SESSION['orderid'] ?>"
}
};

let razorpay = new Razorpay(options);
razorpay.open();
});
</script>
8 changes: 4 additions & 4 deletions verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
$phone=$_SESSION['Billing_phone'];
$name=$_SESSION['name'];


$sql = "INSERT INTO `orders` ( `order_id`, `r_id`, `user_id`, `amount`, `address`, `phone`, `payment`, `order_status`, `rating`, `name`)
VALUES ('$orderId', '$restId', '$userId', '$amount', '$address', '$phone', '$tranStatus', 'Accecpted', '0', '$name');";
// Added $order in the query as it is set to 'NOT NULL' and no DEFAULT value is provided. Later it is updated in below forEach loop.
$sql = "INSERT INTO `orders` ( `order_id`, `r_id`, `user_id`, `order`, `amount`, `address`, `phone`, `payment`, `order_status`, `rating`, `name`)
VALUES ('$orderId', '$restId', '$userId', '$order', '$amount', '$address', '$phone', '$tranStatus', 'Accecpted', '0', '$name');";
$result = mysqli_query($conn, $sql);

foreach ($order as $item) {
Expand All @@ -63,7 +63,7 @@
}

if ($result) {
header("location: Track_order.php");
header("location: track_order.php");
}
}

Expand Down

0 comments on commit 43647ac

Please sign in to comment.