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 *