Skip to content

Commit 54be8af

Browse files
committed
Update
1 parent ee1c20b commit 54be8af

File tree

9 files changed

+2820
-2822
lines changed

9 files changed

+2820
-2822
lines changed

assets/css/style.css

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
body {
66
margin: 0;
77
display: flex;
8-
background-image: url('../images/circle.svg');
8+
background-image: url('./../images/circle.svg');
99
background-repeat: no-repeat;
1010
background-size: 100vw;
1111
}
@@ -130,15 +130,15 @@ body {
130130

131131
#prize-2,
132132
#prize-3{
133-
padding: 40px;
133+
padding: 60px;
134134
}
135135

136136
#prize_title{
137137
font-weight: 500;
138138
font-size: 30px;
139139
color: #03045E;
140140
text-align: center;
141-
padding: 10px;
141+
padding: 20px;
142142
/* margin: 30px; */
143143
}
144144

@@ -632,7 +632,10 @@ body {
632632
#prize-1,
633633
#prize-2,
634634
#prize-3{
635-
padding: 30px;
635+
display: flex;
636+
}
637+
#prize-1{
638+
justify-content: flex-start;
636639
}
637640
#session_head{
638641
font-size: 55px;

assets/js/razorpay.js

+134-83
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,154 @@
1-
document.getElementById("button_text").onclick = function (e) {
2-
var url = "https://api.linux-diary.wcewlug.org/api/payment/order"
3-
var params = {
4-
amount: 100,
5-
currency: "INR",
6-
receipt: "linuxDiary3.0",
7-
payment_capture: '1'
8-
};
9-
10-
var xmlHttp = new XMLHttpRequest();
11-
12-
xmlHttp.onreadystatechange = function (res) {
13-
if (xmlHttp.readyState === 4) {
14-
res = JSON.parse(xmlHttp.responseText);
15-
document.getElementById("rzp-text").value = res.sub.id;
16-
alert(res.sub.id);
17-
rzpClick(e);
1+
var referral = "";
2+
document.getElementById("button_text").onclick = function(e) {
3+
4+
var name = document.getElementById('firstName').value;
5+
referral = document.getElementById('referral').value;
6+
var email = document.getElementById('email').value;
7+
var college = document.getElementById('collegeName').value;
8+
var transaction = document.getElementById('transactionId').value;
9+
10+
if(name == undefined || name == "") {
11+
alert("Please Enter Your Name !!!");
12+
return;
13+
}
14+
15+
if(email == undefined || email == "") {
16+
alert("Please Enter Your Email !!!");
17+
return;
18+
}
19+
20+
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
21+
22+
if(!filter.test(email))
23+
{
24+
alert("You have entered an invalid email address !!!")
25+
return;
26+
}
27+
28+
if(college == undefined || college == "") {
29+
alert("Please Enter Your College Name !!!");
30+
return;
31+
}
32+
33+
if(transaction == undefined || transaction == "") {
34+
alert("Please Enter Your Transaction ID !!!");
35+
return;
36+
}
37+
38+
var url2 = "http://localhost:3000/api/payment/findUser"
39+
var params2 = {
40+
email: email
41+
};
42+
var xmlHttp2 = new XMLHttpRequest();
43+
var flag = true;
44+
xmlHttp2.onreadystatechange = function(res) {
45+
if (xmlHttp2.readyState === 4) {
46+
res = JSON.parse(xmlHttp2.responseText);
47+
if(res.status === "failed") {
48+
alert("Email Already Registered !!!");
49+
flag = false;
50+
return;
51+
}
52+
}
53+
}
54+
xmlHttp2.open("POST", url2, true);
55+
xmlHttp2.setRequestHeader("Content-type", "application/json");
56+
xmlHttp2.send(JSON.stringify(params2));
57+
58+
var url3 = "http://localhost:3000/api/payment/findUser2"
59+
var params3 = {
60+
transaction: transaction
61+
};
62+
var xmlHttp3 = new XMLHttpRequest();
63+
var flag = true;
64+
xmlHttp3.onreadystatechange = function(res) {
65+
if (xmlHttp2.readyState === 4) {
66+
67+
if(flag === false) return;
68+
69+
res = JSON.parse(xmlHttp3.responseText);
70+
if(res.status === "failed") {
71+
alert("Transaction ID Already Registered !!!");
72+
flag = false;
73+
return;
74+
}
75+
register(e);
76+
}
1877
}
78+
xmlHttp3.open("POST", url3, true);
79+
xmlHttp3.setRequestHeader("Content-type", "application/json");
80+
xmlHttp3.send(JSON.stringify(params3));
81+
1982
}
20-
xmlHttp.open("POST", url, true);
21-
xmlHttp.setRequestHeader("Content-type", "application/json");
22-
xmlHttp.send(JSON.stringify(params));
23-
}
24-
25-
function rzpClick(e) {
26-
var options = {
27-
"key": "rzp_live_7Qavb1VhFIUu1u",
28-
"currency": "INR",
29-
"name": "LinuxDiary 3.0",
30-
"description": "WLUG Linux Diary 3.0 Registration",
31-
"order_id": document.getElementById("rzp-text").value,
32-
"handler": function (response) {
33-
document.getElementById('order-pay-id').value = response.razorpay_payment_id;
34-
document.getElementById('order-id').value = response.razorpay_order_id;
35-
document.getElementById('order-sig').value = response.razorpay_signature;
36-
verifyClick();
37-
},
38-
"theme": {
39-
"color": "#0EB9F2"
83+
84+
85+
var count = 0;
86+
function incrementReferral(e) {
87+
88+
if(referral != undefined && referral != "") {
89+
var url2 = "http://localhost:3000/api/payment/incrementReferral"
90+
var params2 = {
91+
referralCode: referral
92+
};
93+
var xmlHttp2 = new XMLHttpRequest();
94+
var flag = true;
95+
xmlHttp2.onreadystatechange = function(res) {
96+
if (xmlHttp2.readyState === 4) {
97+
res = JSON.parse(xmlHttp2.responseText);
98+
}
4099
}
41-
};
42-
var rzp1 = new Razorpay(options);
43-
rzp1.open();
44-
e.preventDefault();
45-
}
100+
xmlHttp2.open("POST", url2, true);
101+
xmlHttp2.setRequestHeader("Content-type", "application/json");
102+
xmlHttp2.send(JSON.stringify(params2));
103+
}
104+
}
46105

47-
function register(e) {
106+
function register(e) {
48107

49-
const name = document.getElementById("firstName").value;
108+
if(count >= 1) return;
109+
count++;
50110

51-
const username = document.getElementById("userName").value;
111+
const name = document.getElementById("firstName").value;
52112

53-
const referralCode = document.getElementById("referralCode").value;
113+
const email = document.getElementById("email").value;
54114

55-
const email = document.getElementById("email").value;
115+
const college = document.getElementById("collegeName").value;
56116

57-
const college = document.getElementById("collegeName").value;
117+
const transaction = document.getElementById("transactionId").value;
58118

59-
var url = 'https://api.linux-diary.wcewlug.org/api/payment/register';
119+
var url = 'http://localhost:3000/api/payment/register';
60120

61-
var params = {
62-
name: name,
63-
username: username,
64-
referralCode: referralCode,
65-
email: email,
66-
college: college
67-
}
121+
var params = {
122+
name: name,
123+
email: email,
124+
college: college,
125+
transaction: transaction
126+
}
68127

69-
try {
70-
var xmlHttp = new XMLHttpRequest();
71-
xmlHttp.onreadystatechange = function (res) {
128+
try {
129+
var xmlHttp = new XMLHttpRequest();
130+
xmlHttp.onreadystatechange = function(res) {
72131
if (xmlHttp.readyState === 4) {
73-
alert("Registration Successful !!! Kindly Check Your Mail For Payment Confirmation !!!");
132+
res = JSON.parse(xmlHttp.responseText);
133+
if(res.error === "true" || res.emailSent === "false") {
134+
if(res.error === "true") alert("User Registration Failed !!!");
135+
else alert("Invalid Email ID !!!");
136+
return;
137+
}
138+
incrementReferral(e);
139+
alert("Registration Successful !!! Kindly Check Your Mail For Payment Confirmation !!!");
140+
var obj = document.getElementById('successBox');
141+
var newContent = "<div style='display: flex; justify-content: center;'><p style='color: white;'>Registration Successfull !!!</p></div></br></br></br></br><p style='color: white;'> Your Referral Code : <strong>" + res.referralCode + "</strong></p>" + "<br/></br></br><p style='color: white;'>Confirmation Mail has been sent to you, Thanks For Registration !!!</p></br></br><p style='color: white;'>In case if you have any queries or doubts, feel free to contact us.</p></br></br></br></br><p style='color: white;'>Regards,</br>Walchand Linux User's Group</p>";
142+
obj.innerHTML = newContent;
74143
}
75144
}
76145
xmlHttp.open("POST", url, true); // false for synchronous request
77146
xmlHttp.setRequestHeader("Content-type", "application/json");
78147
xmlHttp.send(JSON.stringify(params));
79-
} catch (e) {
80-
alert(e.message);
81-
console.log(e.message);
82-
}
83-
148+
} catch(e) {
149+
alert(e.message);
150+
console.log(e.message);
151+
}
84152

85-
}
86153

87-
function verifyClick(e) {
88-
var url = 'https://api.linux-diary.wcewlug.org/api/payment/verify';
89-
var params = {
90-
razorpay_order_id: document.getElementById('order-id').value,
91-
razorpay_payment_id: document.getElementById('order-pay-id').value,
92-
razorpay_signature: document.getElementById('order-sig').value
93-
};
94-
var xmlHttp = new XMLHttpRequest();
95-
xmlHttp.onreadystatechange = function (res) {
96-
if (xmlHttp.readyState === 4) {
97-
register(e);
98-
}
99-
}
100-
xmlHttp.open("POST", url, true); // false for synchronous request
101-
xmlHttp.setRequestHeader("Content-type", "application/json");
102-
xmlHttp.send(JSON.stringify(params));
103-
}
154+
}

backend/.gitignore

-2
This file was deleted.

0 commit comments

Comments
 (0)