Updating user controller

We will create a new, or update an existing, Stripe Customer when the user places an order after entering their credit card details. To implement this, we will update the user controllers with a stripeCustomer method that will be called before the order is created when our server receives a request to the create order API (discussed in the Creating new order section).

In the stripeCustomer controller method, we will need to use the stripe npm module:

npm install stripe --save

After installing the stripe module, it needs to be imported into the user controller file and the stripe instance initialized with the application's Stripe secret key.

mern-marketplace/server/controllers/user.controller.js:

import stripe from ...

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.