📁 File Manager Pro
v10.0.3 | PHP: 8.2.31
Server: LiteSpeed
2026-06-29 15:12:35
📂
/ (Root)
/
home
/
orkouolp
/
node_js
/
orkofarms.com
/
api
📍 /home/orkouolp/node_js/orkofarms.com/api
🔄 Refresh
✏️
Editing: paymentIntent.js
Writable
const stripeAPI = require('../stripe'); function calculateOrderAmount(cartItems) { return cartItems.reduce((total, product) => { return total + product.price * product.quantity; }, 0) * 100; }; async function paymentIntent(req, res) { console.log('POST /create-payment-intent'); const { cartItems, description, receipt_email, shipping } = req.body; let paymentIntent; try { paymentIntent = await stripeAPI.paymentIntents.create({ amount: calculateOrderAmount(cartItems), currency: 'usd', description, payment_method_types: ['card'], receipt_email, shipping, }); res.status(200).json({ clientSecret: paymentIntent.client_secret, id: paymentIntent.id }); } catch(error) { console.log(error); res.status(400).json({ error: 'an error occured, unable to create payment intent'}); } } module.exports = paymentIntent;
💾 Save Changes
❌ Cancel