-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpayment.js
More file actions
55 lines (51 loc) · 1.66 KB
/
payment.js
File metadata and controls
55 lines (51 loc) · 1.66 KB
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
let ADD = JSON.parse(localStorage.getItem("address"));
document.querySelector("#addnew").innerText = ADD;
let account = [];
let obj = {
card: 1224364860728496,
valid: "12/27",
cvv: 377,
};
account.push(obj);
localStorage.setItem("ACCOUNT", JSON.stringify(account));
document.querySelector("#PAY").addEventListener("click", function () {
let CARD = document.querySelector("#input1").value;
let VALID = document.querySelector("#valiD").value;
let CVV = document.querySelector("#cVV").value;
let acc = JSON.parse(localStorage.getItem("ACCOUNT"));
if (acc[0].card == CARD && acc[0].valid == VALID && acc[0].cvv == CVV) {
alert("otp sent successfully");
window.location.replace("otp.html");
} else {
alert("Invalid card detail");
}
});
document.querySelector("#bt").addEventListener("click", function () {
window.location.replace("address.html");
});
document.querySelector("#app").addEventListener("click", function () {
let sum = 0;
let sal = 0;
let INP = document.querySelector("#VAl").value;
if (INP == "big123") {
let final = 0;
let arr = JSON.parse(localStorage.getItem("TOTAL"));
for (let i = 0; i < arr.length; i++) {
final += arr[i];
}
sum = final - 0.2 * final;
sal = 0.2 * final;
document.querySelector("#BR").innerText = sum;
document.querySelector("#TR").innerText = sal.toFixed(2);
alert("Hurray..!! 20% discount applicable.");
} else {
alert("Worng Code");
}
});
let final = 0;
let arr = JSON.parse(localStorage.getItem("TOTAL"));
for (let i = 0; i < arr.length; i++) {
final += arr[i];
}
document.querySelector("#PR").innerText = final;
document.querySelector("#BR").innerText = final;