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.
Install a fresh Laravel installation
composer create-project laravel/laravel example-app
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
Then download the file SSLCommerz API and extract it
Copy the Library folder from app directory and paste it to your laravel application in directory in app folder.
Then you have to copy the sslcommerz.php file from their config folder to your config folder
SslCommerzPaymentController.php from /app/Http/Controllers folder and paste to your /app/Http/Controllers/ directory accordingly
Then copy this part of code to your routes/web.php from their api
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' ];
In the same way copy two of the views from their folder to yours
Create sandbox account from sslcommerz from this link and then add to your env file like this
Restart your server and create an order table by running
php artisan make:model Order -m
Create the order table like the image below and also do add the fillable fields
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.