-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptbuy.js
More file actions
56 lines (46 loc) · 1.6 KB
/
scriptbuy.js
File metadata and controls
56 lines (46 loc) · 1.6 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
56
// server.js
const express = require('express');
const bodyParser = require('body-parser');
const stripe = require('stripe')('your-secret-key-here');
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.post('/charge', async (req, res) => {
const token = req.body.stripeToken;
const amount = req.body.amount;
try {
let { status } = await stripe.charges.create({
amount: amount,
currency: 'usd',
description: 'Token Purchase',
source: token
});
res.json({ status });
} catch (err) {
res.status(500).end();
}
});
app.listen(3000, () => {
console.log('Server running on port 3000');
});
document.addEventListener('DOMContentLoaded', () => {
const menuToggle = document.getElementById('menu-toggle');
const dots = document.getElementById('dots');
const dropdown = document.getElementById('dropdown');
const sidebar = document.getElementById('sidebar');
const closeBtn = document.getElementById('close-btn');
menuToggle.addEventListener('click', () => {
sidebar.classList.toggle('open');
});
closeBtn.addEventListener('click', () => {
sidebar.classList.remove('open');
});
dots.addEventListener('click', () => {
dropdown.classList.toggle('show');
});
document.addEventListener('click', (event) => {
if (!dots.contains(event.target) && !dropdown.contains(event.target)) {
dropdown.classList.remove('show');
}
});
});