PHPackages                             siddiquinoor/nagad-in-laravel - 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. [Payment Processing](/categories/payments)
4. /
5. siddiquinoor/nagad-in-laravel

ActiveLibrary[Payment Processing](/categories/payments)

siddiquinoor/nagad-in-laravel
=============================

Nagad Payment Gateway for Laravel

013PHP

Since Mar 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/siddiquinoor/nagad-in-laravel)[ Packagist](https://packagist.org/packages/siddiquinoor/nagad-in-laravel)[ RSS](/packages/siddiquinoor-nagad-in-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Nagad (Bangladesh) payment gateway for Laravel 6.x+, 7.x+, 8.x+
===============================================================

[](#nagad-bangladesh-payment-gateway-for-laravel-6x-7x-8x)

Nagad is one of the Mobile Financial Services in Bangladesh. This package is built for Nagad Payment Gateway for Laravel 6.x, 7.x and 8.x+

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Configuration](#configuration)
- [Usage](#usage)
- [License](#license)

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

[](#installation)

Install the package via composer:

```
composer require siddiquinoor/nagad-in-laravel:dev-master
```

### Configuration

[](#configuration)

Add config file in your `config` directory:

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

- This will publish and config file in `config_path()` of your application. e.g `config/nagad.php`
- Configure the Nagad merchant account. Use `sandbox = true` for development stage.
- Be sure to set the **timezone** of you application to `Asia/Dhaka` in order to work with Nagad Payment Gate Way. To do this: go to `config/app.php` and set `'timezone' => 'Asia/Dhaka'`

Usage
-----

[](#usage)

Set Nagad call back to our route

```
    // in routes/web.php
    Route::get('/nagad/callback', 'NagadController@callback')->name('nagad.callback');
```

Name the route in the nagad config file.

```
    //in config/nagad.php
    'callback' => 'nagad.callback' // or use env variable to store

```

env setup
=========

[](#env-setup)

```
NAGAD_METHOD=sandbox
NAGAD_MERHCANT_ID=YOUR_MERCHANTID
NAGAD_MERHCANT_PHONE=YOUR_PHONE_NUMBER
NAGAD_KEY_PUBLIC=YOUR_PUBLIC_KEY
NAGAD_KEY_PRIVATE=YOUR_PRIVATE_KEY
NAGAD_CALLBACK_URL=nagad.callback
```

To Start payment, in your NagadController:

```
    use NagadLaravel\Nagad;
    use Illuminate\Http\Request;

    public function createPayment()
    {
        /**
         * Method 1: Quickest
         * This will automatically redirect you to the Nagad PG Page
         * */

        return Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->checkout()
            ->redirect();

        /**
         * Method 2: Manual Redirection
         * This will return only the redirect URL and manually redirect to the url
         * */

        $url = Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->checkout()
            ->getRedirectUrl();

        return ['url' => $url];

        /**
         * Method 3: Advanced
         * You set additional params which will be return at the callback
         * */

        return Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->setAddionalInfo(['pid' => 9, 'myName' => 'DG'])
            ->checkout()
            ->redirect();

        /**
         * Method 4: Advanced Custom Callabck
         * You can set/override callback url while creating payment
         * */

        return Nagad::setOrderID('ORDERID123')
            ->setAmount('540')
            ->setAddionalInfo(['pid' => 9, 'myName' => 'DG'])
            ->setCallbackUrl("https://manual-callback.url/callback")
            ->checkout()
            ->redirect();
    }

	//To receive the callback response use this method:

    /**
     * This is the routed callback method
     * which receives a GET request.
     *
     * */

    public function callback(Request $request)
    {
        $verified = Nagad::callback($request)->verify();
        if($verified->success()) {

            // Get Additional Data
            dd($verified->getAdditionalData());

            // Get Full Response
            dd($verified->getVerifiedResponse());
        } else {
            dd($verified->getErrors());
        }
    }
```

To receive error response use this in App/Exceptions/Handler.php:

```
public function render($request, Exception $exception)
{
    if($exception instanceof NagadException) {
    //return custom error page when custom exception is thrown
    return response()->view('errors.nagad', compact('exception'));
    }

    return parent::render($request, $exception);
}
```

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

[](#available-methods)

### For Checking-out

[](#for-checking-out)

- `setOrderID(string $orderID)` : `$orderID` to be any unique AlphaNumeric String
- `setAmount(string $amount)` : `$amount` to be any valid currency numeric String
- `setAddionalInfo(array $array)` : `$array` to be any array to be returned at callback
- `setCallbackUrl(string $url)` : `$url` to be any url string to be overidden the defualt callback url set in config
- `checkout()` : to initiate checkout process.
- `redirect()` : to direct redirect to the NagadPG Web Page.
- `getRedirectUrl()` : instead of redirecting, getting the redirect url manually.

### For Callback

[](#for-callback)

- `callback($request)` : `$request` to be `Illuminate\Http\Request` instance
- `verify()` : to verify the response.
- `success()` : to check if transaction is succeed.
- `getErrors()` : to get the error and errorCode if fails transactions | returns `array[]`
- `getVerifiedResponse()` : to get the full verified response | returns `array[]`
- `getAdditionalData(bool $object)` : to get the additional info passed during checkout. `$object` is to set return object or array.

License
-------

[](#license)

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

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8492cc9ec0be272dfb77e9d65997b554b83047bbc67de5a6725aa60cce0b7da0?d=identicon)[siddiquinoor](/maintainers/siddiquinoor)

---

Top Contributors

[![siddiquinoor](https://avatars.githubusercontent.com/u/5842552?v=4)](https://github.com/siddiquinoor "siddiquinoor (2 commits)")

### Embed Badge

![Health badge](/badges/siddiquinoor-nagad-in-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/siddiquinoor-nagad-in-laravel/health.svg)](https://phpackages.com/packages/siddiquinoor-nagad-in-laravel)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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