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
composer require afzalsabbir/sslaracommerz
php artisan migrate
# Public Assets
php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="public-assets"
-
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
sandbox
script<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
live
script<script src="/assets/js/live.js"></script>
# Routes and Controller
php artisan vendor:publish --provider="AfzalSabbir\SSLaraCommerz\SSLaraCommerzServiceProvider" --tag="routes-controller"
- Add
$this->loadRoutesFrom(base_path('routes/sslcommerz.php'));
inapp/Providers/RouteServiceProvider.php
namespace App\Providers; // ... class RouteServiceProvider extends ServiceProvider { // ... public function boot() { // ... $this->loadRoutesFrom(base_path('routes/sslcommerz.php')); } // ... }
# 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.php
file.
-
Step 1: Add
STORE_ID
andSTORE_PASSWORD
values on your project's.env
file. You can register for a store at https://developer.sslcommerz.com/registration/ -
Step 2: Add the below routes into the
$excepts
array ofVerifyCsrfToken
middleware.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.php
or 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.php
or 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.php
files. You can update those files according to your need.
For more clear concept read: SSLCommerz README.md
Run the tests with:
vendor/bin/phpunit
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email afzalbd1@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.