About Lesson
In this section, we are going to create a Rest API using Express server with MongoDB connection and create necessary models and routes in order to handle CRUD operations. We’ll provide the security using JWT and authenticate and authorize users. And also you’ll see how easy to get payment using Stripe API
const router = require("express").Router(); const stripe = require("stripe")(process.env.STRIPE_KEY); router.post("/payment", (req, res) => { stripe.charges.create( { source: req.body.tokenId, amount: req.body.amount, currency: "usd", }, (stripeErr, stripeRes) => { if (stripeErr) { res.status(500).json(stripeErr); } else { res.status(200).json(stripeRes); } } ); }); module.exports = router;