smronju / laravel-sslcommerz
Laravel SSLCommerz is a super easy package to integrate SSLCommerz on Laravel websites.
Fund package maintenance!
Requires
- php: ^8.2||^8.3||^8.4
- illuminate/contracts: ^12.0||^13.0
- illuminate/http: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1||^9.0
- orchestra/testbench: ^10.0.0||^11.0.0
- pestphp/pest: ^3.0||^4.0
- pestphp/pest-plugin-arch: ^3.0||^4.0
- pestphp/pest-plugin-laravel: ^3.0||^4.0
README
Laravel SSLCommerz
Integrate SSLCommerz into your Laravel application in minutes. This package provides a clean, fluent API to handle payments, validations, and refunds with zero hassle.
๐ Quick Start in 3 Steps
1. Install via Composer
composer require smronju/laravel-sslcommerz
2. Configure Your Environment
Add your credentials to your .env file:
SSLCOMMERZ_STORE_ID=your_id SSLCOMMERZ_STORE_PASSWORD=your_password SSLCOMMERZ_STORE_CURRENCY=BDT # Optional (default: BDT) SSLCOMMERZ_SANDBOX=true # Set false for production (default: true)
โจ How to get sandbox credentials
SSLCommerz credentials are required to use this package. You can get sandbox credentials by following these steps:
-
Create Sandbox Account: Visit the https://developer.sslcommerz.com/registration/ page to create an account.
-
Obtain Credentials: After registration, you will receive your Store ID and Store Password via email or from the SSLCommerz dashboard.
-
Set Up in .env: Copy these credentials and paste them into your
.envfile as shown in the Configuration step.
Important
Sandbox credentials are for testing purposes only. You should replace them with your live credentials and change SANDBOX=false before deploying to production.
3. Initialize & Publish (Optional)
This will publish the configuration file to config/sslcommerz.php:
php artisan laravel-sslcommerz:install
๐ก Simple Usage
๐ณ Initiate a Payment
The package uses a fluent interface to prepare and trigger the payment.
use Smronju\Sslcommerz\Facades\Sslcommerz; $response = Sslcommerz::setOrder($amount, $invoiceId, $productName) ->setCustomer($name, $email, $phone) ->makePayment(); if ($response->success()) { return redirect($response->gatewayPageURL()); }
โ Validate Payment
Simply pass the request data and expected transaction details.
$isValid = Sslcommerz::validatePayment($request->all(), $transactionId, $amount); if ($isValid) { // Save to database, update status, etc. }
๐ Advanced Features
Handling Callbacks
Define your routes in routes/web.php:
Route::post('/sslcommerz/success', [SslcommerzController::class, 'success'])->name('sslcommerz.success'); Route::post('/sslcommerz/failure', [SslcommerzController::class, 'failure'])->name('sslcommerz.failure');
Refunds & Status Checks
// Request a refund $refund = Sslcommerz::refundPayment($bankTranId, $amount, "Customer requested refund"); // Check refund status $status = Sslcommerz::checkRefundStatus($refundRefId);
๐ฅ Features at a Glance
- โ PHP 8.2+ & Laravel 12-13 support.
- ๐ Fluent API: Ready-to-use methods for customer info, shipping info, etc.
- ๐ Secure: In-built hash verification and data validation.
- ๐ฆ Zero Config: Works out of the box with sensible defaults.
- ๐งช Sandbox Ready: Easy toggle between sandbox and live environments.
๐ Documentation
For detailed guides on dynamic parameters, IPN handling, and advanced configurations, visit the Documentation Wiki.
Credits
License
The MIT License (MIT). Please see License File for more information.
