If the current user does not have a corresponding Stripe Customer, in other words, a value is not stored for the stripe_customer field, we will use the create a Customer API (https://stripe.com/docs/api#create_customer) from Stripe.
mern-marketplace/server/controllers/user.controller.js:
myStripe.customers.create({ email: req.profile.email, source: req.body.token }).then((customer) => { User.update({'_id':req.profile._id}, {'$set': { 'stripe_customer': customer.id }}, (err, order) => { if (err) { return res.status(400).send({ error: errorHandler.getErrorMessage(err) }) } req.body.order.payment_id = customer.id next() })})
If the Stripe Customer is successfully created, we will update the current user's data ...