PHPackages                             dgvai/laravel-sslcommerz - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. dgvai/laravel-sslcommerz

ActiveLibrary

dgvai/laravel-sslcommerz
========================

Laravel package of SSLCommerz

1.0.4(4y ago)2439.2k—5.3%12[2 PRs](https://github.com/dgvai/laravel-sslcommerz/pulls)MITPHP

Since Apr 14Pushed 3y ago3 watchersCompare

[ Source](https://github.com/dgvai/laravel-sslcommerz)[ Packagist](https://packagist.org/packages/dgvai/laravel-sslcommerz)[ RSS](/packages/dgvai-laravel-sslcommerz/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (6)Used By (0)

SSLCommerz Payment Gateway Package for Laravel
==============================================

[](#sslcommerz-payment-gateway-package-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/9cd697a137644b463916664dd3bf2838b3d8c1f0fa1150db44bcab0d69b0f1b6/68747470733a2f2f706f7365722e707567782e6f72672f64677661692f6c61726176656c2d73736c636f6d6d65727a2f762f737461626c65)](https://packagist.org/packages/dgvai/laravel-sslcommerz)[![Total Downloads](https://camo.githubusercontent.com/35aa73f833f271981e8e6863a7499e8484fb47c7d0071c5e43af8d51752abf95/68747470733a2f2f706f7365722e707567782e6f72672f64677661692f6c61726176656c2d73736c636f6d6d65727a2f646f776e6c6f616473)](https://packagist.org/packages/dgvai/laravel-sslcommerz)[![Latest Unstable Version](https://camo.githubusercontent.com/a15e1492e44d9cd92bceb961003d274bd86079684cb9a8fe6f9237159b5cadac/68747470733a2f2f706f7365722e707567782e6f72672f64677661692f6c61726176656c2d73736c636f6d6d65727a2f762f756e737461626c65)](https://packagist.org/packages/dgvai/laravel-sslcommerz)[![License](https://camo.githubusercontent.com/7d2447a8bae03805eeae2c4e22c7058d3e13c708fd9a876902c3388a64f8d375/68747470733a2f2f706f7365722e707567782e6f72672f64677661692f6c61726176656c2d73736c636f6d6d65727a2f6c6963656e7365)](https://packagist.org/packages/dgvai/laravel-sslcommerz)[![Monthly Downloads](https://camo.githubusercontent.com/0800d954745ffcaa72d7a9aa1b1d4635d8dc9c8748705ffa3513d8389e474052/68747470733a2f2f706f7365722e707567782e6f72672f64677661692f6c61726176656c2d73736c636f6d6d65727a2f642f6d6f6e74686c79)](https://packagist.org/packages/dgvai/laravel-sslcommerz)[![Daily Downloads](https://camo.githubusercontent.com/6e2e7ec9defafd6f8700b4308e6d8215dc689c7943c484a3cfda7ab60c822726/68747470733a2f2f706f7365722e707567782e6f72672f64677661692f6c61726176656c2d73736c636f6d6d65727a2f642f6461696c79)](https://packagist.org/packages/dgvai/laravel-sslcommerz)[![composer.lock](https://camo.githubusercontent.com/7a117d2821f1e471b38660dde552e5c46fb903de49e455e853e16ec1cc817f7e/68747470733a2f2f706f7365722e707567782e6f72672f64677661692f6c61726176656c2d73736c636f6d6d65727a2f636f6d706f7365726c6f636b)](https://packagist.org/packages/dgvai/laravel-sslcommerz)

This package is built for [SSLCommerz](https://www.sslcommerz.com) online payment gateway in Bangladesh for Laravel 5.5+, 6.x and 7.x. (not tested for lower versions (&lt; 5.5))

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Publish Configuration](#publish-configuration)
    - [Setup and Configure](#setup-and-configure)
- [Usage](#usage)
    - [Make Payment](#make-payment)
    - [Refund Process](#refund-process)
    - [Transaction Query](#transaction-query)
- [Available Methods](#available-methods)
- [Changelog](#changelog)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
    composer require dgvai/laravel-sslcommerz
```

### Publish Configuration

[](#publish-configuration)

Publish configuration file

```
    php artisan vendor:publish --tag=sslc-config
```

### Setup and configure

[](#setup-and-configure)

Update your app environment (.env)

```
    SSLC_STORE_ID           =   [YOUR SSLCOMMERZ STORE_ID]
    SSLC_STORE_PASSWORD     =   [YOUR SSLCOMMERZ STORE_ID]
    SSLC_STORE_CURRENCY     =   [STORE CURRENCY eg. BDT]
    SSLC_ROUTE_SUCCESS      =   [route name of success_url, eg: payment.success]
    SSLC_ROUTE_FAILURE      =   [eg: payment.failure]
    SSLC_ROUTE_CANCE        =   [eg: payment.cancel]
    SSLC_ROUTE_IPN          =   [eg: payment.ipn]
    SSLC_ALLOW_LOCALHOST    =   [TRUE/FALSE]

```

**NOTE** SSLC\_ROUTE\_\* variables are route name() not url()

Create four `POST` routes for SSLCommerz

```
    Route::post('sslcommerz/success','PaymentController@success')->name('payment.success');
    Route::post('sslcommerz/failure','PaymentController@failure')->name('failure');
    Route::post('sslcommerz/cancel','PaymentController@cancel')->name('cancel');
    Route::post('sslcommerz/ipn','PaymentController@ipn')->name('payment.ipn');
```

**NOTE** These named routes are being used in .env file

Add exception in `app\Http\Middleware\VerifyCsrfToken.php`

```
    protected $except = [
        'sslcommerz/*'
    ];
```

**NOTE** This will be the initial group of those four routes

After done configuraing

```
    php artisan config:cache
```

Usage
-----

[](#usage)

### Make Payment

[](#make-payment)

Now you can call for payment in you controller method:

```
use DGvai\SSLCommerz\SSLCommerz;
use App\Http\Controllers\Controller;

class PaymentController extends Controller
{
    public function order()
    {
        ...
        //  DO YOU ORDER SAVING PROCESS TO DB OR ANYTHING
        ...

        $sslc = new SSLCommerz();
        $sslc->amount(20)
            ->trxid('DEMOTRX123')
            ->product('Demo Product Name')
            ->customer('Customer Name','custemail@email.com');
        return $sslc->make_payment();

        /**
         *
         *  USE:  $sslc->make_payment(true) FOR CHECKOUT INTEGRATION
         *
         * */
    }

    public function success(Request $request)
    {
        $validate = SSLCommerz::validate_payment($request);
        if($validate)
        {
            $bankID = $request->bank_tran_id;   //  KEEP THIS bank_tran_id FOR REFUNDING ISSUE
            ...
            //  Do the rest database saving works
            //  take a look at dd($request->all()) to see what you need
            ...
        }
    }

    public function failure(Request $request)
    {
        ...
        //  do the database works
        //  also same goes for cancel()
        //  for IPN() you can leave it untouched or can follow
        //  official documentation about IPN from SSLCommerz Panel
        ...
    }
}
```

**NOTE** This is the minimalist basic need to perform a payment.

### Refund Process

[](#refund-process)

Also you can call for Refund Request and check Refund State

```
    public function refund($bankID)
    {
        /**
         * SSLCommerz::refund($bank_trans_id, $amount [,$reason])
         */

        $refund = SSLCommerz::refund($bankID,$refund_amount);

        if($refund->status)
        {
            /**
             * States:
             * success : Refund request is initiated successfully
             * failed : Refund request is failed to initiate
             * processing : The refund has been initiated already
            */

            $state  = $refund->refund_state;

            /**
             * RefID will be used for post-refund status checking
            */

            $refID  = $refund->ref_id;

            /**
             *  To get all the outputs
            */

            dd($refund->output);
        }
        else
        {
            return $refund->message;
        }
    }

    public function check_refund_status($refID)
    {
        $refund = SSLCommerz::query_refund($refID);

        if($refund->status)
        {
            /**
             * States:
             * refunded : Refund request has been proceeded successfully
             * processing : Refund request is under processing
             * cancelled : Refund request has been proceeded successfully
            */

            $state  = $refund->refund_state;

            /**
             * RefID will be used for post-refund status checking
            */

            $refID  = $refund->ref_id;

            /**
             *  To get all the outputs
            */

            dd($refund->output);
        }
        else
        {
            return $refund->message;
        }
    }
```

### Transaction Query

[](#transaction-query)

Also you can query for your Transaction based on the Transaction ID you provided.

```
    public function get_transaction_status($trxID)
    {
        $query = SSLCommerz::query_transaction($trxID);

        if($query->status)
        {
            dd($query->output);
        }
        else
        {
            $query->message;
        }
    }
```

Available Methods
-----------------

[](#available-methods)

### required `amount($amount)`

[](#required-amountamount)

Description: Set the amount of payment

Usage: `$sslc->amount(50)`

### required `trxid($trxid = null)`

[](#required-trxidtrxid--null)

Description: Set the Transaction ID. If `null` passed, php `uniqid()` will be used to generate the TrxID

Usage: `$sslc->trxid(mt_rand(10000000,999999999))`

### required `product($name [,$category])`

[](#required-productname-category)

Description: Set the Product Name (required) and Category (optional)

Usage: `$sslc->product($product->name, $product->category)`

### required `customer($name, $email [,$phone, $address, $city, $state, $postal, $country, $fax])`

[](#required-customername-email-phone-address-city-state-postal-country-fax)

Description: Set the Customer Name and Email (required), Phone,Address,City,State,Postal Code, Country, FAX Code (optional)

Usage: `$sslc->customer($user->name, $user->email, $user->phone)`

### optional `setUrl($url_array[])`

[](#optional-seturlurl_array)

Description: To Manually set the success,failure,cancel and ipn URL not using from .env one

Usage: `$sslc->setUrl([route('custome.success'), route('custom.failure'), .. ])`

### optional `setCurrency($currency)`

[](#optional-setcurrencycurrency)

Description: To Manually set the currency not using from .env one

Usage: `$sslc->setCurrency('USD')`

### optional `setBin($bin)`

[](#optional-setbinbin)

Description: You can provide the BIN of card to allow the transaction must be completed by this BIN. You can declare by coma ',' separate of these BIN. Example: 371598,371599,376947,376948,376949

Usage: `$sslc->setBin('371598,371599,376947')`

### optional `enableEMI($installment, $max_installment, bool $restrict_emi_only = false)`

[](#optional-enableemiinstallment-max_installment-bool-restrict_emi_only--false)

Description: This method enables EMI payment.

**installment** = Customer selects from your Site, So no instalment option will be displayed at gateway page

**max\_installment** = Max instalment Option, Here customer will get 3,6, 9 instalment at gateway page

**restrict\_emi\_only** = Value is true/false, if value is true then only EMI transaction is possible, in payment page. No Mobile banking and internet banking channel will not display.

Usage: `$sslc->enableEMI(5,12,false)`

### optional `setShipping($product_number, $name, $address, $city [,$postal, $state, $country])`

[](#optional-setshippingproduct_number-name-address-city-postal-state-country)

Description: This method sets shipping details. Not required usually!

Usage: `$sslc->setShipping(5,'productname','24/7 Beijing Street','Dhaka',1234)`

### optional `setAirlineTicketProfile($flight_type, $hours_till_departure, $pnr, $journey_from_to, $third_party_booking)`

[](#optional-setairlineticketprofileflight_type-hours_till_departure-pnr-journey_from_to-third_party_booking)

Description: This method is Mandatory, if **product\_profile** is *airline-tickets*! Not usually required! See [Official Documentation](https://developer.sslcommerz.com/doc/v4/) for this section.

Usage: `$sslc->setAirlineTicketProfile('bus',3,1,'DHK-RAJ',null)`

### optional `setTravelVerticalProfile($hotel_name, $length_of_stay, $check_in_time, $hotel_city)`

[](#optional-settravelverticalprofilehotel_name-length_of_stay-check_in_time-hotel_city)

Description: This method is Mandatory, if **product\_profile** is *travel-vertical*! Not usually required! See [Official Documentation](https://developer.sslcommerz.com/doc/v4/) for this section.

Usage: `$sslc->setTravelVerticalProfile('Dalas',3,'12:00pm',Rajshahi)`

### optional `setTelecomVerticleProfile($product_type, $topup_number, $country_topup)`

[](#optional-settelecomverticleprofileproduct_type-topup_number-country_topup)

Description: This method is Mandatory, if **product\_profile** is *telecom-vertical*! Not usually required! See [Official Documentation](https://developer.sslcommerz.com/doc/v4/) for this section.

Usage: `$sslc->setTelecomVerticleProfile('Flexiload',0170000000,'BD')`

### optional `setCarts($cart, $product_amount, $vat, $discount_amount, $convenience_fee)`

[](#optional-setcartscart-product_amount-vat-discount_amount-convenience_fee)

Description: This method is not usually used! See [Official Documentation](https://developer.sslcommerz.com/doc/v4/) for this section.

Usage: `$sslc->setCarts($cart_json,5,'3%','20%','500')`

### optional `setExtras($extra1, $extra2, $extra3, $extra4)`

[](#optional-setextrasextra1-extra2-extra3-extra4)

Description: This method is used to pass to the success/failure response as extra parameter, if it is needed. Not mandatory! See [Official Documentation](https://developer.sslcommerz.com/doc/v4/) for this section.

Usage: `$sslc->setExtras($my_token)`

### required `make_payment($checkout = false)`

[](#required-make_paymentcheckout--false)

Description: Make the payment. 1. For hosted mode (default), pass nothing/false. 2. For checkout mode, pass the first param `true`, and it will return JSON

Usage: `$sslc->make_payment()`

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~171 days

Total

5

Last Release

1540d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/53512998?v=4)[Jalal Uddin](/maintainers/dgvai)[@dgvai](https://github.com/dgvai)

---

Top Contributors

[![dgvai](https://avatars.githubusercontent.com/u/53512998?v=4)](https://github.com/dgvai "dgvai (10 commits)")[![sharafat](https://avatars.githubusercontent.com/u/810435?v=4)](https://github.com/sharafat "sharafat (1 commits)")

---

Tags

composer-packagelaravel-packagelaravel-payment-gatewaysslcommerzsslcommerz-payment-gateway

### Embed Badge

![Health badge](/badges/dgvai-laravel-sslcommerz/health.svg)

```
[![Health](https://phpackages.com/badges/dgvai-laravel-sslcommerz/health.svg)](https://phpackages.com/packages/dgvai-laravel-sslcommerz)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
