For any technical support, please email at integration@sslcommerz.com
Laravel v5.6 or later
GPLv2 or later
-
Step 1: Download and extract the library files.
-
Step 2: Copy the
Library
folder and put it in the laravel project'sapp/
directory. If needed, then runcomposer dump -o
. -
Step 3: Copy the
config/sslcommerz.php
file into your project'sconfig/
folder. -
Step 4: Copy and put 3 key-value pairs from
env_example
to your.env
file.
For development purposes, you can obtain sandbox 'Store ID' and 'Store Password' by registering at https://developer.sslcommerz.com/registration/
- Step 5: Add exceptions for
VerifyCsrfToken
middleware accordingly (this is for our example code, use your actual routes).
protected $except = [
'/success',
'/cancel',
'/fail',
'/ipn',
'/pay-via-ajax', // only required to run example codes. Please see bellow.
];
- Optional: We have also provided some example codes which can help you understand the process. Developer's discretion is needed. Following steps are not mandatory.
Copy
SslCommerzPaymentController
into your project'sControllers
folder.
Copy defined routes from
routes/web.php
into your project's route file.
Copy views from
resources/views/*.blade.php
.
-
We provide a simple solution to show sslcommerz gateway page inside popup. To integrate it, You need to have a
<button>
with following properties -- id="sslczPayBtn"
- endpoint=[your ajax route]
- postdata= [you need to populate a js object with required form fields]
<button id="sslczPayBtn"
token="if you have any token validation"
postdata=""
order="If you already have the transaction generated for current order"
endpoint="/pay-via-ajax"> Pay Now
</button>
- Populate postdata obj as required -
<script>
var obj = {};
obj.cus_name = $('#customer_name').val();
obj.cus_phone = $('#mobile').val();
obj.cus_email = $('#email').val();
obj.cus_addr1 = $('#address').val();
obj.amount = $('#total_amount').val();
$('#sslczPayBtn').prop('postdata', obj);
</script>
- Add following script -
<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>
<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>
- Session is destroyed after redirecting to success/cancel/fail URL
This is a general Laravel issue, unrelated to SSLCommerz. You can try setting 'same_site' => 'none' in your
config/session.php
file.
- I am getting an error saying "Store Credential Error Or Store is Deactive"
You have incorrect (or missing) configuration values in .env file. Check step 4.
- I am not getting IPN in localhost / development machine.
You can't. IPN requires a publicly accessible webserver.
Md. Rakibul Islam
Prabal Mallick