When a seller updates an order by processing the product ordered in their shop, the application will create a charge on behalf of the seller on the Customer's credit card for the cost of the product ordered. To implement this, we will update the user.controller.js file, with a createCharge controller method that will use Stripe's create a charge API, and need the seller's Stripe account ID along with the buyer's Stripe Customer ID.
mern-marketplace/server/controllers/user.controller.js:
const createCharge = (req, res, next) => { if(!req.profile.stripe_seller){ return res.status('400').json({ error: "Please connect your Stripe account" }) } myStripe.tokens.create({ customer: req.order.payment_id, ...