-
Notifications
You must be signed in to change notification settings - Fork 0
/
payment.html
89 lines (85 loc) · 3.16 KB
/
payment.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style2.css">
<title>FoodZap</title>
</head>
<body>
<h1>Welcome to FoodZap Payment</h1>
<div>
<h2>Enter Plan Amount:</h2><input type="text" id= order-amt /><br/></br>
<h3><button id="rzp-button1">Pay</button></h3></div>
</div>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
var orderId;
const con='00';
$(document).ready(function () {
var settings = {
"url": "/create/orderId",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"amount": "399"
}),
};
//creates new orderId everytime
$.ajax(settings).done(function (response) {
orderId = response.orderId;
console.log(orderId);
$("button").show();
});
});
document.getElementById('rzp-button1').onclick = function (e) {
var options = {
"key": "rzp_test_DNDVwNw519IZIQ", // Enter the Key ID generated from the Dashboard
"amount": parent.document.getElementById('order-amt').value+"00", // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise
"currency": "INR",
"name": "FoodZap Corporation",
"description": "Razorpay",
"image": "https://i.ibb.co/Q97CrWZ/logo1.jpg",
"order_id": orderId, //This is a sample Order ID. Pass the `id` obtained in the previous step
"handler": function (response) {
alert(response.razorpay_payment_id);
alert(response.razorpay_order_id);
alert(response.razorpay_signature)
var settings = {
"url": "/api/payment/verify",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({ response }),
}
$.ajax(settings).done(function (response) {
alert(JSON.stringify(response));
});
},
"theme": {
"color": "#9a3c73"
}
};
var rzp1 = new Razorpay(options);
rzp1.on('payment.failed', function (response) {
alert(response.error.code);
alert(response.error.description);
alert(response.error.source);
alert(response.error.step);
alert(response.error.reason);
alert(response.error.metadata.order_id);
alert(response.error.metadata.payment_id);
});
rzp1.open();
e.preventDefault();
}
</script>
</body>
</html>