April 2020
Intermediate to advanced
716 pages
18h 55m
English
When a seller changes the status of an ordered product to Processing, we will set up a backend API to not only update the order but to also create a charge on the customer's credit card for the price of the product multiplied by the quantity ordered. The route for this API will be declared as follows.
mern-marketplace/server/routes/order.routes.js:
router.route('/api/order/:orderId/charge/:userId/:shopId') .put(authCtrl.requireSignin, shopCtrl.isOwner, userCtrl.createCharge, orderCtrl.update)router.param('orderId', orderCtrl.orderByID)
To retrieve the order associated with the orderId parameter in the route, we will use the orderByID order controller method, which gets the order from the Order collection and ...
Read now
Unlock full access