How to integrate SSLCommerz Payment Gateway in Laravel 7/8

maxresdefault

Integrating payment gateways has always been a headache. Also after you have taken any Best Website Design Services in Bangladesh or any Best Ecommerce Website Development Service in Bangladesh, when it comes to selling you must need a payment gateway to make every payment smooth. Well if you don’t have a website yet then Code Ecstasy is providing the best web design service in Bangladesh and also other web solutions. Today we will learn about SSLCommerz Payment Gateway in Laravel

What is SSLCommerz

SSLcommerz is a Bangladeshi payment gateway system by which you may receive payment from customers through any gateway including bKash, Rocket, Nagad, Banks, Cards etc. Visit their site SSLCommerz to know more.

Integration with Laravel

Integrating SSLCommerz with laravel may be a confusing to many peoples but trust me it’s easy. Today here I will show you how you can integrate SSLCommerz with any laravel application using their api in both Hosted and PopUp.

Okay sometimes reading blogs can be difficult so you may see the step by step video tutorial and enjoy the video well not like a netflix show I know but yet it’s quite simple.

Step 1

Install a fresh Laravel installation

composer create-project laravel/laravel example-app

Step 2

Then we fill up the .env credentials with database credentials and migrate using the command –

php artisan migrate

Then run the server using the command –

php artisan serve

Step 3

Then download the file SSLCommerz API and extract it

Step 4

Copy the Library folder from app directory and paste it to your laravel application in directory in app folder.

Step 5

Then you have to copy the sslcommerz.php file from their config folder to your config folder

Step 6

Then copy SslCommerzPaymentController.php from /app/Http/Controllers folder and paste to your /app/Http/Controllers/ directory accordingly

Step 7

Then copy this part of code to your routes/web.php from their api

image

Step 8

After that go to the directory app/Http/MiddleWare and go to VerifyCsrfToken.php and add this code

protected $except = [
    '/pay-via-ajax', '/success','/cancel','/fail','/ipn'
];

Step 9

In the same way copy two of the views from their folder to yours

Step 10

Create sandbox account from sslcommerz from this link and then add to your env file like this

image 1
Sandbox means a test server. After this system works with this process you will change the store ID and store Password as they provide.

Step 11

Restart your server and create an order table by running

php artisan make:model Order -m

Step 12

Create the order table like the image below and also do add the fillable fields

image 2
image 3

Congratulations

Congratulations you’re done integrating SSLCommerz with Laravel. Go to http://127.0.0.1:8000/example1 and see the system running. A much detail and understanding video is given above. Some extra features is also shown.

Leave a Comment

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