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

@@ -147,11 +147,12 @@ app.use((req, res, next) => {
if (req.session) {
delete req.session.error;
delete req.session.message;
}
}
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