afzalsabbir / sslaracommerz
A package for SSLCommerz Payment Gateway. Inspired by https://github.com/sslcommerz/SSLCommerz-Laravel
Installs: 69
Dependents: 0
Suggesters: 0
Security: 0
Stars: 22
Watchers: 6
Forks: 4
pkg:composer/afzalsabbir/sslaracommerz
Requires
- php: ^7.1.3|^8.0
- guzzlehttp/guzzle: ^6.3|^7.0
- laravel/framework: ^6.0|^7.0|^8.0|^9.0
Requires (Dev)
- fzaninotto/faker: ^1.9@dev
- illuminate/support: 5.8.*|^6.0|^7.0|^8.0|^9.0
- mockery/mockery: ^1.0@dev
- phpunit/phpunit: ^4.8|^5.7|^6.0|^7.5|^8.5|^9.5
- symfony/thanks: ^1.0
This package is auto-updated.
Last update: 2025-10-08 21:36:17 UTC
README
A package for SSLCommerz Payment Gateway
Inspired by SSLCommerz
SSLCommerz Payment gateway library for Laravel framework. Official documentation is here.
Tags: Payment Gateway, SSLCommerz, IPN, Laravel, SSLaraCommerz
Requires: Laravel >= 5.6 and MySQL
License: MIT License
Install
composer require afzalsabbir/sslaracommerz
Migration
php artisan migrate
Instructions
Vendor Publish - Required
# Public Assets php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="public-assets"
Public Assets: To integrate popup checkout, use the below script before the end of body tag.
-
For Sandbox
<script> (function (window, document) { var loader = function () { var script = document.createElement("script"), tag = document.getElementsByTagName("script")[0]; script.src = "https://sandbox.sslcommerz.com/embed.min.js?" + Math.random().toString(36).substring(7); tag.parentNode.insertBefore(script, tag); }; window.addEventListener ? window.addEventListener("load", loader, false) : window.attachEvent("onload", loader); })(window, document); </script>
or, Publish the Public Assets and use the below
sandboxscript<script src="/assets/js/sandbox.js"></script>
-
For Live
<script> (function (window, document) { var loader = function () { var script = document.createElement("script"), tag = document.getElementsByTagName("script")[0]; script.src = "https://seamless-epay.sslcommerz.com/embed.min.js?" + Math.random().toString(36).substring(7); tag.parentNode.insertBefore(script, tag); }; window.addEventListener ? window.addEventListener("load", loader, false) : window.attachEvent("onload", loader); })(window, document); </script>
or, Publish the Public Assets and use the below
livescript<script src="/assets/js/live.js"></script>
# Routes and Controller php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="routes-controller"
Routes and Controller: To customize the routes and controller, use the below command.
- Add
$this->loadRoutesFrom(base_path('routes/sslcommerz.php'));inapp/Providers/RouteServiceProvider.phpnamespace App\Providers; // ... class RouteServiceProvider extends ServiceProvider { // ... public function boot() { // ... $this->loadRoutesFrom(base_path('routes/sslcommerz.php')); } // ... }
Vendor Publish - Optional
# Config php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="config" # Views ## Namespace: sslaracommerz php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="views" # Migrations php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="migrations"
Note: If you later encounter issues with session destroying after redirect, you can set
'same_site' => null,in yourconfig/session.phpfile.
-
Step 1: Add
STORE_IDandSTORE_PASSWORDvalues on your project's.envfile. You can register for a store at https://developer.sslcommerz.com/registration/ -
Step 2: Add the below routes into the
$exceptsarray ofVerifyCsrfTokenmiddleware.protected $except = [ '/pay-via-ajax', '/success','/cancel','/fail','/ipn' ];
Now, let's go to the main integration part.
-
Step 3: Use the below button where you want to show the "Pay Now" button:
<button class="your-button-class" id="sslczPayBtn" token="if you have any token validation" postdata="your javascript arrays or objects which requires in backend" order="If you already have the transaction generated for current order" endpoint="/pay-via-ajax"> Pay Now </button>
-
Step 4: For EasyCheckout (Popup) integration, you can update the
checkout_ajax.phpor use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration. -
Step 5: For Hosted Checkout integration, you can update the
checkout_hosted.phpor use a different file according to your need. We have provided a basic sample page from where you can kickstart the payment gateway integration. -
Step 6: For redirecting action from SSLCommerz Payment gateway, we have also provided sample
success.php,cancel.php,fail.phpfiles. You can update those files according to your need.
Original Documentation
For more clear concept read: SSLCommerz README.md
Testing
Run the tests with:
vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email afzalbd1@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.