-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpayment.html
312 lines (230 loc) · 9.89 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<!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">
<title>Payment page</title>
<link id="favicon" rel="icon" href="./images/faviconRebrand.ico" type="image.png" sizes="16x16" />
<link rel="stylesheet" href="./styles/payment.css">
</head>
<body>
<!--navbar selction-->
<div id="navbar">
<img id="navimg" src="https://www.1mg.com/images/tata_1mg_logo.svg">
<div id="an1n">
<div>My Cart</div>
<div>Upload Prescription
</div>
<div>Order Summary</div>
<div>Payment
<hr id="downbar"></hr>
</div>
</div>
<p id="an2n">Need Help?</p>
</div>
<!--body box-->
<div id="body_box">
<!--payment card-->
<div id="payment_outer_box" >
<div id="slide_box" style="background-color: #fff3e3;">
<div class="pay_box" id="wlt_box1" >
<div id="imbx1">
<img src="https://cdn-icons-png.flaticon.com/128/869/869118.png">
</div>
<h4>WALLETS</h4>
</div>
<div class="pay_box" id="wlt_box2">
<div id="imbx2">
<img src="https://static.wixstatic.com/media/e56168_4f3aa738d8c64f5b95d9765969b034e4~mv2.png/v1/crop/x_0,y_64,w_512,h_406/fill/w_473,h_487,al_c,lg_1,q_85,enc_auto/UPI%20Logo.png">
</div>
<h4>UPI</h4>
</div>
<div class="pay_box" id="wlt_box3">
<div id="imbx3">
<img src="https://png.pngitem.com/pimgs/s/13-130380_credit-card-icon-card-icon-hd-png-download.png">
</div>
<h4>CARDS</h4>
</div>
<div class="pay_box" id="wlt_box4">
<div id="imbx4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTg54rkM_QREuN50NTgo90gqXjvE5dHO7cYew&usqp=CAU">
</div>
<h4>NET BANKING</h4>
</div>
<div class="pay_box" id="wlt_box5">
<div id="imbx5">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSN2A6R88jgANu6Qo85aEQevGoNtDUxQEOyUw&usqp=CAU">
</div>
<h4>PAY ON DELIVERY</h4>
</div>
</div>
<!--payment mode-->
<div id="payment_mode">
</div>
</div>
<!--payment statement-->
<div id="statement_div">
<div id="statement_para">
<div style="display: flex;">
<img id="statement_img" src="https://res.cloudinary.com/du8msdgbj/image/upload/v1609235175/rwfhtgwtk8zmnbwdvfme.png">
<h5 style="margin-left: 3%">Pay with Mobikwik and get up to ₹500 cashback on allopathy medicines. Get assured cashback of</h5>
</div>
<hr style="width: 95%;">
<h4 style="margin-left: 40%;color:green">SHOW ALL PAYMENT OFFERS</h4>
</div>
<div id="total_price_box">
<div class="price_tags" id="ch1">Item total(MRP)</div>
<div class="price_tags" id="ch2">Care Plan</div>
<hr style="width: 95%;">
<!-- <div class="price_tags" id="ch21"> 1mg care plane for 3 months</div> -->
<div class="price_tags" id="ch3">shipping free</div>
<div class="price_tags" id="ch4">packing and handing charge</div>
<hr style="width: 95%;">
<div class="price_tags" id="ch5">to be paid</div>
<div id="payment_recall">PLACE ORDER</div>
</div>
</div>
</div>
</body>
</html>
<script type="module">
import {payment1,paymnet_upi,payment_card,cod_payment} from "./components/payment.js"
var random_val1=Math.floor(Math.random() *100)
var random_val2=Math.floor(Math.random() *100)
document.getElementById('wlt_box1').addEventListener('click',wlt_bx1)
function wlt_bx1(){
document.getElementById('payment_mode').innerHTML=null
document.getElementById('payment_mode').innerHTML=payment1()
}
wlt_bx1()
document.getElementById('wlt_box2').addEventListener('click',upi_box)
function upi_box(){
document.getElementById('payment_mode').innerHTML=null
document.getElementById('payment_mode').innerHTML=paymnet_upi()
var paymentdata = /^[\w.-]+@[\w.-]+$/
document.querySelector("#verify_upi").addEventListener("click", checkpayment)
function checkpayment(){
event.preventDefault()
var upi_data={
upi_id:document.getElementById('upi_payment').value ,
}
localStorage.setItem("upidata",JSON.stringify(upi_data))
var cardinfo = JSON.parse(localStorage.getItem("upidata"));
var chk = paymentdata.test(cardinfo.upi_id);
if(chk != undefined || chk !=null){
alert("payment successful")
let product_id=`PXUT6879${random_val1}TY2${random_val2}`
localStorage.setItem("product_id",JSON.stringify(product_id))
localStorage.setItem("orStatus",JSON.stringify("true"))
}
else{
alert("upi number is not valid")
}
}
}
// card number impot
document.getElementById('wlt_box3').addEventListener('click',card_box)
function card_box(){
document.getElementById('payment_mode').innerHTML=null
document.getElementById('payment_mode').innerHTML=payment_card()
var paymentdata=[
{card:123412349867,exmonth:"04",exyear:28,cvv:123},
{card:123412348765,exmonth:"05",exyear:28,cvv:222},
{card:123412343456,exmonth:"06",exyear:23,cvv:143},
{card:123412347896,exmonth:"02",exyear:24,cvv:333},
{card:123412347886,exmonth:"06",exyear:24,cvv:456},
{card:123412345862,exmonth:"07",exyear:28,cvv:574},
{card:123412347878,exmonth:"03",exyear:26,cvv:142},
{card:123677341234,exmonth:"07",exyear:23,cvv:567},
]
document.querySelector("#card_payment").addEventListener("click",checkpayment)
function checkpayment(){
event.preventDefault()
console.log("anish")
var carddata={
cardnam:document.getElementById('card_num').value ,
cardmn:document.getElementById('expiry_num').value,
cardyer:document.getElementById('expiry_num_yy').value,
cardcvv:document.getElementById('cvv_num').value
}
localStorage.setItem("carddata",JSON.stringify(carddata))
var cardinfo = JSON.parse(localStorage.getItem("carddata"))
var chk = paymentdata.find(c => c.card == cardinfo.cardnam && c.exmonth == cardinfo.cardmn && c.exyear == cardinfo.cardyer && c.cvv == cardinfo.cardcvv);
if(chk != undefined || chk !=null){
alert("payment successful")
let product_id=`PXUT6879${random_val1}TY2${random_val2}`
localStorage.setItem("product_id",JSON.stringify(product_id))
localStorage.setItem("orStatus",JSON.stringify("true"))
}
else{
alert("card data is not valid")
}
}
}
//cod impot
document.getElementById('wlt_box5').addEventListener('click',cod_box)
function cod_box(){
document.getElementById('payment_mode').innerHTML=null
document.getElementById('payment_mode').innerHTML=cod_payment()
}
// document.getElementById('payment_recall').addEventListener("click",recall)
// function recall(){
// alert('select the payment option')
// }
let carePlan = JSON.parse(localStorage.getItem('carPlan'))
let cPlanValue = 0;
if(carePlan = "true") {
cPlanValue = 165;
}
let paymentData = JSON.parse(localStorage.getItem('payment_details'))
var total_amount= paymentData.total_price
var p1=document.createElement("p")
p1.innerText=`₹${total_amount}`
p1.style.color="green"
p1.style.fontSize="18px"
p1.style.marginTop="-0%"
document.getElementById('ch1').append(p1)
var p1=document.createElement("p")
p1.innerText=`₹${cPlanValue}`
p1.style.color="green"
p1.style.fontSize="18px"
p1.style.marginTop="-0%"
document.getElementById('ch2').append(p1)
var p1=document.createElement("p")
p1.innerText=`₹275`
p1.style.color="green"
p1.style.fontSize="18px"
p1.style.marginTop="-0%"
// document.getElementById('ch21').append(p1)
var p1=document.createElement("p")
p1.innerText=`₹0`
p1.style.color="green"
p1.style.marginTop="-0%"
document.getElementById('ch3').append(p1)
var p1=document.createElement("p")
p1.innerText=`₹19`
p1.style.fontSize="18px"
p1.style.color="green"
p1.style.marginTop="-0%"
document.getElementById('ch4').append(p1)
var full_amount=total_amount+ cPlanValue + 19
var p1=document.createElement("p")
p1.innerText=`₹${full_amount}`
p1.style.fontSize="18px"
p1.style.color="orange"
p1.style.marginTop="-0%"
document.getElementById('ch5').append(p1)
document.getElementById("payment_recall").addEventListener("click", nextpage)
let orderedProd = JSON.parse(localStorage.getItem("toCart"))
console.log(orderedProd)
function nextpage() {
let status = JSON.parse(localStorage.getItem("orStatus"))
if(status == "true") {
localStorage.setItem("orProd",JSON.stringify(orderedProd))
localStorage.setItem("toCart",JSON.stringify(""))
localStorage.setItem("orStatus",JSON.stringify("false"))
window.location.href = "Myorder.html"
}
}
</script>