SSL COMMERZ payment gateway with Express JS

Md. Jidanul Hakim Jitu
2 min readApr 22, 2021

--

SSL Commerz payment gateway is one of the best payment gateway system in Bangladesh. It’s now so popular that most of the developers prefer to use it as their only payment gateway on their websites.

I am not expertise in web development. So, please forgive me if I have any mistake. But somehow, I tried to make a backend controller for the SSL-Commerz payment gateway with Express JS (Node).

Let’s do it together 👌✌

Payment Model (to save in Database [here I have used MongoDB])

To save the user data in the database you have to first make a model. These are the object properties that you will see after having a successful payment in your cluster’s database.

You can make a model like that or in your own way. It depends on what data you want to save. Let’s see the model

Payment Controller

Okay! First things first…Set controllers for your payment gateway. There will be about 6–7 controllers. They are for
1. Payment Initiation

2. Payment Session

3. Payment Notification (IPN controller to get the payment related issues from the customer from SSL Commerz)

4. Successful Payment

5. Complete Payment

6. Failed Payment

7. Cancel Payment

Let’s see the code (I have used the ‘Users’ model in the controller to find out the data of the user who is making the payment. You can make it in your way.)

Payment Router

The payment routers are for using the controller in the exact route.

Let’s see the code

--

--

Md. Jidanul Hakim Jitu

I am a goal-oriented problem solver with energy for web development, who might want to join a group of similar engineers.