Confirm a stripe paymentIntent using Node.js

This is the second article where we will confirm a stripe paymentIntent using Node.js. We have integrated the stripe payment gateway in React and created the demo of the checkout form.

So in the previous article, we have created the paymentIntent in React application but now we need to confirm that paymentIntent using the Stripe API in the Node.js. You can use any backend technology to confirm the stripe payment.

Stripe payment gateway integration.

Confirm a stripe paymentIntent using Node.js

  1. Setup server using express
  2. Install stripe dependency
  3. Collect Secret API key
  4. Create REST API to confirm paymentIntent
  5. Output

1. Setup server using express

Here, we will use the express framework in Node.js to create a REST API. Kindly follow the link below if you donā€™t know how to create REST API in Node.js using express framework.

Create REST API in Node.js

Now, letā€™s enable the CORS in the Node app. Follow the steps to Enable CORS in Node.js so we can access the REST API endpoint in the frontend application.

After adding packages, your file should look like the following.

server.js

2. Install stripe dependency

Now, letā€™s install the stripe package in the Node app. Run the following command to install the dependency.

3. Collect Secret API key

We need a Secret API key to confirm paymentIntent. Follow the instructions if you donā€™t know where to get the API key.

4. Create REST API to confirm paymentIntent

Letā€™s create a REST API endpoint to confirm the paymentIntent. We will confirm the PaymentIntent by setting the confirm property to true. We need the payment method id and amount from the API request to confirm the paymentIntent.

server.js

5. Output

Run the Node application by executing the node server.js command and check the following output that is related to the frontend application.

Output - Integrate stripe payment gateway - Clue Mediator
Output – Integrate stripe payment gateway – Clue Mediator

Thatā€™s it for today.
Thank you for reading. Happy Coding..!!

Demo & Source Code

Github Repository
If you found value in this article,
you can support us by buying me a coffee! ā˜•

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *