You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
167 lines
5.2 KiB
167 lines
5.2 KiB
<html>
|
|
<header>
|
|
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
|
|
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
|
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
const paymentStart=(id,amount,isBulk)=>{
|
|
|
|
console.log("payment started" + id);
|
|
console.log("payment isBulk started" + isBulk);
|
|
|
|
|
|
amount = Number(amount);
|
|
|
|
console.log("amount==>" + amount);
|
|
|
|
if (amount === 0) {
|
|
|
|
const freeOrderId = "ord-" + Date.now();
|
|
const freePaymentId = "pay-" + Date.now();
|
|
|
|
Swal.fire({
|
|
title: "Free Entry",
|
|
text: "This category is free of cost. Confirming booking...",
|
|
icon: "info",
|
|
allowOutsideClick: false,
|
|
didOpen: () => Swal.showLoading()
|
|
});
|
|
|
|
updatePaymentInServer(
|
|
freePaymentId,
|
|
freeOrderId,
|
|
id,
|
|
amount,
|
|
isBulk
|
|
);
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
$.ajax({
|
|
url:'/victoriapublichall/bookingapi/create_order',
|
|
data:JSON.stringify({amount:amount,info:'order_request',id:id,isBulk:isBulk}),
|
|
contentType:'application/json',
|
|
type:'POST',
|
|
dataType:'json',
|
|
success:function(response){
|
|
|
|
let amt = response.amount;
|
|
let refid = id;
|
|
console.log("refid")
|
|
console.log("FIRST:==>");
|
|
console.log(response);
|
|
if(response.status=="created"){
|
|
|
|
|
|
let options = {
|
|
/* "key": "[[${keyId}]]", */
|
|
"key": "rzp_test_tDkHFEqWXmuEi8",
|
|
// "key":"rzp_live_ySI5Ns54Y7qOcJ",
|
|
"amount": response.amount, // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise
|
|
"currency": response.currency,
|
|
"name": "Greater Chennai Corporation",
|
|
"description": "Victoria public Hall Booking Transaction",
|
|
"image": "https://upload.wikimedia.org/wikipedia/commons/a/a8/Chennai_Corporation_Emblem.png",
|
|
"order_id": response.id, //This is a sample Order ID. Pass the `id` obtained in the response of Step 1
|
|
"handler": function (response){
|
|
|
|
console.log("second==>\n");
|
|
console.log(response);
|
|
console.log(response.razorpay_payment_id);
|
|
console.log(response.razorpay_order_id);
|
|
console.log(response.razorpay_signature);
|
|
console.log("payment success");
|
|
//alert("congrates !payment successfull")
|
|
updatePaymentInServer(response.razorpay_payment_id,response.razorpay_order_id,refid,amt,isBulk);
|
|
},
|
|
|
|
modal: {
|
|
ondismiss: function () {
|
|
console.log("Razorpay popup closed by user");
|
|
|
|
|
|
const loader = document.getElementById("pageLoader");
|
|
if (loader) {
|
|
loader.style.display = "block";
|
|
}
|
|
|
|
// small delay so loader is visible
|
|
setTimeout(() => {
|
|
// REDIRECT BACK TO BOOKING PAGE
|
|
window.location.replace("/victoriapublichall/register");
|
|
}, 300);
|
|
}
|
|
},
|
|
"prefill": {
|
|
"name": "",
|
|
"email": "",
|
|
"contact": ""
|
|
},
|
|
"notes": {
|
|
"address": "Greater Chennai Corporation."
|
|
},
|
|
"theme": {
|
|
"color": "#3399cc"
|
|
}
|
|
};
|
|
var rzp1 = new Razorpay(options);
|
|
rzp1.on('payment.failed', function (response){
|
|
console.log(response.error.code);
|
|
console.log(response.error.description);
|
|
console.log(response.error.source);
|
|
console.log(response.error.step);
|
|
console.log(response.error.reason);
|
|
console.log(response.error.metadata.order_id);
|
|
console.log(response.error.metadata.payment_id);
|
|
alert("Payment Failed");
|
|
});
|
|
rzp1.open();
|
|
|
|
}
|
|
},
|
|
error:function(error){
|
|
console.log(error);
|
|
alert("error");
|
|
}
|
|
})
|
|
};
|
|
|
|
function updatePaymentInServer(payment_id,order_id,refid,amt,isbulk){
|
|
console.log("amt...",amt);
|
|
let mobile_no = "";
|
|
|
|
if (isbulk === 1 || isbulk === true) {
|
|
|
|
mobile_no = $("#paymentNumber").val()?.trim() ;
|
|
} else {
|
|
mobile_no = $("#contactDisplay").text()?.trim() ;
|
|
}
|
|
|
|
console.log("mobile_no==>", mobile_no);
|
|
|
|
$.ajax({
|
|
url:'/victoriapublichall/bookingapi/Confirm',
|
|
data:JSON.stringify({payment_id:payment_id,order_id:order_id,id:refid,amt:amt,mobile_no: mobile_no,isBulk:isbulk}),
|
|
contentType:'application/json',
|
|
type:'POST',
|
|
dataType:'text',
|
|
success:function(response){
|
|
console.log("update payment in server");
|
|
|
|
console.log("order_id...",order_id);
|
|
window.location.href = "/victoriapublichall/bookingQRCode?orderid=" +order_id;
|
|
|
|
},
|
|
error:function(error){
|
|
swal("Failed`!", "Failed to confirm your booking. If payment was debited, it will be credited back, or you can check with your bank.", "error");
|
|
}
|
|
});
|
|
};
|
|
</script>
|
|
</header>
|
|
</html>
|