![]() |
VOOZH | about |
Integrating Stripe in Node allows one to make and manage online payments. Stripe provides developer-friendly API to set up the payment gateway to handle secure transactions.
Payment gateways help the user to make their payments. There are many payment gateways available in the market like Razorpay, Google Pay, etc but the most popular among them is the Stripe payment gateway. Stripe is the premier option for online credit card processing and it is also the most popular premium payment gateway.
To integrate Stripe Payment Gateway in Node we will install the Stripe package as a project dependency. Then, we set up environment variables for authentication, and API endpoints for processing payments, and handled the transactions.
Use this command to create a node project in the same folder
npm initYou can visit the link Install stripe module. You can install this package by using this command.
npm install stripeAfter installing stripe module, you can check your stripe version in command prompt using the command.
npm version stripenpm install ejs express body-parserYou need to include stripe module in your file by using these lines.
const stripe = require('stripe')('Your_Secret_Key');To get your secret key, simply go to Stripe Official Website and create an account, then you can get your secret key as well as the publishable key.
Steps to run the program
Run index.js file using below command
node index.jsOpen browser and type this URL
http://localhost:3000/Then you will see the Payment Gateway form as shown below
Then click on 'Pay with Card' button and then you will see the stripe payment form as shown below👁 Stripe payment form
Fill this form with correct credit card details and click on 'Pay' button and then if no errors occur, then the following message will be displayed👁 Success Message
Now go to your stripe dashboard and you can see the current payment details as shown below👁 Stripe Dashboard
So this is how you can integrate Stripe payment gateway in node.js. There are other payment gateways available in the market like Razorpay, Google Pay, etc.