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 Stripe payment gateway. Stripe is the premier option for online credit card processing and it is also the most popular premium payment gateway.
- It’s easy to get started and easy to use.
- It is widely used and popular module for processing payments.
- User friendly services and highly sercured.
Installation of stripe module:
- You can visit the link Install stripe module. You can install this package by using this command.
npm install stripe
- After installing stripe module, you can check your stripe version in command prompt using the command.
npm version stripe
- After that, you can just create a folder and add a file for example index.js, To run this file you need to run the following command.
- Requiring module: You need to include stripe module in your file by using these lines.
var stripe = require('stripe')('Your_Secret_Key');
To get your secret key, simply go to Stripe Offical Website and create an account, then you can get your secret key as well as publishable key.
Steps to run the program:
- The project structure will look like this:
The “Home.ejs” is kept in the views folder.
- Make sure you have ‘view engine’ like I have used “ejs” and also install express, body-parser, and stripe using the following commands:
npm install ejs npm install express npm install body-parser npm install stripe
- Run index.js file using below command:
- Open browser and type this URL:
- 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:
Fill this form with correct credit card details and click on ‘Pay’ button and then if no errors occurs, then following message will be displayed:
- Now go to your stripe dashboard and you can see the current payment details as shown below:
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.