-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpayment.js
159 lines (140 loc) · 4.87 KB
/
payment.js
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
let button1 = document.getElementById("btn1");
let button2 = document.getElementById("btn2");
let changecolor1 = () => {
button1.style.backgroundColor = "#4fb4f3";
button2.style.backgroundColor = "#91cbee";
};
let changecolor2 = () => {
button2.style.backgroundColor = "#4fb4f3";
button1.style.backgroundColor = "#91cbee";
};
let form = document.querySelector("#pay_page");
let payment = JSON.parse(localStorage.getItem("payment")) || [];
form.addEventListener("submit", (event) => {
event.preventDefault();
let data = {
first_name: document.querySelector("#first_name").value,
last_name: document.querySelector("#last_name").value,
email: document.querySelector("#email").value,
company: document.querySelector("#company").value,
address: document.querySelector("#address").value,
city: document.querySelector("#city").value,
zip: document.querySelector("#zip").value,
state: document.querySelector("#state").value,
atm1: document.querySelector("#atm1").value,
atm2: document.querySelector("#atm2").value,
atm_no: document.querySelector("#atm_no").value,
month: document.querySelector("#month").value,
year: document.querySelector("#year").value,
cvv: document.querySelector("#cvv").value,
};
if (
data.first_name.length === 0 ||
data.last_name.length === 0 ||
data.email.length === 0 ||
data.company.length === 0 ||
data.address.length === 0 ||
data.city.length === 0 ||
data.zip.length === 0 ||
data.state.length === 0 ||
data.atm1.length === 0 ||
data.atm2.length === 0 ||
data.atm_no.length === 0 ||
data.month.length === 0 ||
data.year.length === 0 ||
data.cvv.length === 0
) {
alert("Fields cannot be empty");
} else {
if (
data.first_name.value === data.atm1.value &&
data.last_name.value === data.atm2.value
) {
if (data.atm_no.length === 16) {
console.log("yes");
payment.push(data);
localStorage.setItem("payment", JSON.stringify(payment));
alert(`Your OTP is ${Math.floor(Math.random(3 * 14) + 1)}`);
window.location.href = "otp.html";
} else {
alert("please enter 16-digit valid card number");
}
} else {
alert("name on form should be equal to name on card");
}
}
});
let changeprice2 = (event) => {
event.preventDefault();
document.getElementById("pro").innerHTML = null;
document.getElementById("rate").innerHTML = null;
document.getElementById("rate2").innerHTML = null;
document.getElementById("pro").innerText = "Pro Annually";
document.getElementById("rate").innerText = "$114";
document.getElementById("rate2").innerText = "$114";
};
let changeprice3 = (event) => {
event.preventDefault();
document.getElementById("pro").innerHTML = null;
document.getElementById("rate").innerHTML = null;
document.getElementById("rate2").innerHTML = null;
document.getElementById("pro").innerText = "Pro Monthly";
document.getElementById("rate").innerText = "$14";
document.getElementById("rate2").innerText = "$14";
};
let show_coupon = (event) => {
event.preventDefault();
let text = document.getElementById("text");
text.innerHTML = null;
let div = document.createElement("div");
let label = document.createElement("label");
label.innerText = "DISCOUNT COUPON/REFERAL CODE";
let div1 = document.createElement("div");
div1.setAttribute("class", "newdiv");
let input = document.createElement("input");
input.type = "text";
input.setAttribute("id", "promocode");
let button = document.createElement("button");
button.innerText = "Apply";
button.setAttribute("id", "apply");
div1.append(input, button);
div.append(label, div1);
text.append(div);
};
// let x = document.getElementById("rate").innerText;
// let y = document.getElementById("rate2").innerText;
// let promocode=document.querySelector('#promocode');
// document.querySelector('#apply').addEventListener("click",function(){
// if(promocode.value=="masai30"){
// y = (+y * 0.7).toFixed(2); }
// else{
// y.innerText= +y;
// alert("Invalid Code")
// }
let userinfoas = JSON.parse(localStorage.getItem("userDetails"));
// setTimeout(() => {
let mainaccordin = document.getElementsByClassName("conBoxes");
for (i = 0; i < mainaccordin.length; i++) {
mainaccordin[i].addEventListener("click", function () {
this.classList.toggle("active");
// this.style.color ="blue"|| "black"
});
}
// }, 2000);
if (userinfoas === null) {
window.location.href = "../signup.html";
} else {
let nameprofile = document.getElementById("name-profile");
nameprofile.innerText = userinfoas["fullname"];
}
let profile = () => {
window.location.href = "../profile.html";
};
let profileSignout = () => {
localStorage.removeItem("userDetails");
window.location.href = "../signup.html";
};
let submit = (e) => {
e.preventDefault();
alert("Plan activated successfully");
};