Something went wrong. Try again.
An E-Commerce Website built using Node.js, Express, Express Generator, MongoDB, and HandleBars Template Engine. Scope - Single Admin/Vendor…
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109<section> <div class="container">
<form action="" id="checkout-form">
<div class="float-left col-md-6 mt-5"> <h2 class="text-center mt-5 mb-4">Enter Delivery Details</h2>
<label for="">Address</label> <input id="address" type="text" name="address" class="form-control">
<label for="">PIN Code</label> <input id="pincode" type="text" name="pincode" class="form-control">
<label for="">Mobile Number</label> <input id="mobile" type="text" name="mobile" class="form-control">
<input type="text" name="userId" value="{{user._id}}" hidden> </div>
<div style="border: 1px solid; padding: 35px 35px; margin: 80px 10px;" class="checkout col-md-5 float-right"> <h4>Total Amount : ₹ {{total}}</h4> <hr> <h5>Payment Method</h5>
<div class="payment my-4"> <input type="radio" id="cod" name="payment-method" value="COD" checked> <label for="cod">COD</label><br> <input type="radio" id="online" name="payment-method" value="ONLINE"> <label for="online">Online Payment</label><br> </div>
<button type="submit" style="width: 100%;" class="btn btn-primary py-2 text-centered">Submit</button> </div>
</form>
</div></section>
<script> $("#checkout-form").submit((e) => { e.preventDefault() $.ajax({ url: '/place-order', method: 'POST', data: $('#checkout-form').serialize(), success: (response) => {
console.log(response) if (response.COD_success) { location.href = '/order-complete' } else { razorPayPayment(response) }
} }) })
function razorPayPayment(order) { var options = { "key": "rzp_test_FdLHOIWpFAHRd2", // Enter the Key ID generated from the Dashboard "amount": order.amount, // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise "currency": "INR", "name": "Shopping Cart", "description": "Shopping Cart Online Test Transaction", "image": "https://arjunkrishna.in/images/profile-pic.jpg", "order_id": order.id, //This is a sample Order ID. Pass the `id` obtained in the response of Step 1 "handler": function (response) { // alert(response.razorpay_payment_id); // alert(response.razorpay_order_id); // alert(response.razorpay_signature)
verifyPayment(response, order) }, "prefill": { "name": "Gaurav Kumar", "email": "gaurav.kumar@example.com", "contact": "9999999999" }, "notes": { "address": "Razorpay Corporate Office" }, "theme": { "color": "#528FF0" } }; var rzp1 = new Razorpay(options); rzp1.open(); }
function verifyPayment(payment, order) { $.ajax({ url: '/verify-payment', data: { payment, order }, method: 'POST', success: (response) => { if (response.status) { location.href = '/order-complete' } else { alert("Payment Failed") } } }) }</script>