April 2020
Intermediate to advanced
716 pages
18h 55m
English
For an existing Stripe Customer – in other words, where the current user already has a value stored for the stripe_customer field – we will use the Stripe API to update a Stripe Customer, as follows.
mern-marketplace/server/controllers/user.controller.js:
myStripe.customers.update(req.profile.stripe_customer, { source: req.body.token }, (err, customer) => { if(err){ return res.status(400).send({ error: "Could not update charge details" }) } req.body.order.payment_id = customer.id next() })
Once the Stripe Customer has been successfully updated, we will add the Customer ID to the order being created in the next() call. Though not covered here, the Stripe Customer feature can be used to allow users to ...