import express from 'express'; import cors from 'cors'; import Stripe from 'stripe'; import dotenv from 'dotenv'; dotenv.config(); const app = express(); const stripe = new Stripe(process.env.STRIPE_SECRET_KEY); app.use(cors()); app.use(express.json()); app.post('/create-payment-intent', async (req, res) => { try { const paymentIntent = await stripe.paymentIntents.create({ amount: 999, // €9.99 currency: 'eur', automatic_payment_methods: { enabled: true, }, }); res.send({ clientSecret: paymentIntent.client_secret, }); } catch (e) { res.status(400).send({ error: { message: e.message, } }); } }); const PORT = process.env.PORT || 4242; app.listen(PORT, () => console.log(`Node server listening on port ${PORT}!`));