This commit is contained in:
2025-03-04 21:34:18 -05:00
parent 1e2523ece7
commit 792a64fd13
4 changed files with 57 additions and 3 deletions

View File

@@ -152,6 +152,7 @@ app.use((req, res, next) => {
});
//
// In-memory data structures
//
@@ -625,6 +626,13 @@ app.post('/qrcodesu',requireSuperUser,async (req,res) => {
return res.send({ owner:username, qrcode: URL, magiclink:GetMagicLink(username) });
})
app.get("/buy",(req,res) => {
return res.render("buy",{ username:req.session.username, superuser:req.session.superuser, settings:settings, message: "" });
});
app.post("/buy",(req,res) => {
// Stopped here
});
app.get('/settings',requireSuperUser, (req,res) => {
res.render('settings',{ username:req.session.username, superuser:req.session.superuser, settings:settings, message: "" })
@@ -679,7 +687,8 @@ app.post('/update-setting', requireSuperUser, (req, res) => {
settings[req.body.name]=req.body.checked;
console.log("setting got updated to ",settings[req.body.name]);
res.json({ success: true, message: 'Checkbox state updated successfully' });
});
});
app.post('/pay0',requireLogin,(req,res) => {
return res.render("pay",{ username:req.session.username, superuser:req.session.superuser, ticket:req.body.ticket, amount:req.body.amount });
@@ -693,10 +702,10 @@ app.post('/charge', requireLogin, async (req, res) => {
} else try {
// Token or Payment Method ID from the client
const paymentMethodId = req.body.paymentMethodId;
console.log("paymentMethodId: ",paymentMethodId);
// Create a PaymentIntent on the server
const pennies=Math.round(parseFloat(req.body.amount) * 100);
console.log("Pennies=",pennies);
const return_url=base_url+'/mytickets';
const paymentIntent = await stripe.paymentIntents.create({
amount: pennies, // Amount in cents

21
views/buy.ejs Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Buy a Ticket</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<%- include('partials/nav') %>
<div class="content">
<form id="buy" method="post" action="/buy">
Email Address to receive tickets:<br>
<input type="email" name="email"><br>
Number of Tickets:<br>
<input type="number" min="1" max="4" step="1" placeholder="1" name="qty"><br>
Pay how much for each ticket:<br>
<input type="number" min="1.00" max="1000.00" step="0.01" placeholder="50.00" name="amount"><br>
<button id="Submit" type="submit">Pay</button>
</form>
</div>
</body>
</html>

21
views/opencamping.ejs Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Buy a Ticket</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<%- include('partials/nav') %>
<div class="content">
<form id="buy" method="post" action="/buy">
Email Address to receive tickets:
<input type="email" name="email">
Number of Tickets:
<input type="number" min="1" max="4" step="1" placeholder="1" name="qty">
Pay how much for each ticket:
<input type="number" min="1.00" max="1000.00" step="0.01" placeholder="50.00" name="amount">
<button id="Submit" type="submit">Pay</button>
</form>
</div>
</body>
</html>

View File

@@ -1,7 +1,10 @@
<!-- views/partials/nav.ejs -->
<div class="nav">
Falls on Fire<br>
<a href="/buy">Buy Tickets</a><br>
<%if (typeof username!='undefined' && username) {%>
<a href="/mytickets">View My Tickets</a><br>
<%}%>
<%if (typeof superuser!='undefined' && superuser) {%>
<a href="/camps">View Camps (Admin)</a><br>
<a href="/settings">Settings (Admin)</a><br>