PHPackages                             anovob/laravel-nagad-api - 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. anovob/laravel-nagad-api

ActiveLibrary[Payment Processing](/categories/payments)

anovob/laravel-nagad-api
========================

Nagad Payment Gateway for Laravel (Bangladesh)

0981PHP

Since Dec 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/anovob/laravel-nagad-api)[ Packagist](https://packagist.org/packages/anovob/laravel-nagad-api)[ RSS](/packages/anovob-laravel-nagad-api/feed)WikiDiscussions master Synced 2d 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](https://nagad.com.bd) is one of the 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)
    - [Setting up your configuration](#setting-up-your-configuration)
- [Usage](#usage)
- [License](#license)

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

[](#installation)

You can install the package via composer:

```
composer require anovob/laravel-nagad-api
```

### Setting up your configuration

[](#setting-up-your-configuration)

Extract the nagad config files:

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

- This will publish and config file in `config_path()` of your application. Eg. `config/nagad.php`
- Configure the configurations for 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 PGW. To do this: go to `config/app.php` and set `'timezone' => 'Asia/Dhaka'`

Usage
-----

[](#usage)

NagadPGW uses three stages of payment process, and two of theme are simultaneous. To get started, first you have to setup a callback route (`GET`) for the Nagad Callback and name the route in the nagad config file.

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

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

env setup
=========

[](#env-setup)

```
NAGAD_METHOD=sandbox
NAGAD_MERHCANT_ID=683002007104225
NAGAD_MERHCANT_PHONE=01817535192
NAGAD_KEY_PUBLIC=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjBH1pFNSSRKPuMcNxmU5jZ1x8K9LPFM4XSu11m7uCfLUSE4SEjL30w3ockFvwAcuJffCUwtSpbjr34cSTD7EFG1Jqk9Gg0fQCKvPaU54jjMJoP2toR9fGmQV7y9fz31UVxSk97AqWZZLJBT2lmv76AgpVV0k0xtb/0VIv8pd/j6TIz9SFfsTQOugHkhyRzzhvZisiKzOAAWNX8RMpG+iqQi4p9W9VrmmiCfFDmLFnMrwhncnMsvlXB8QSJCq2irrx3HG0SJJCbS5+atz+E1iqO8QaPJ05snxv82Mf4NlZ4gZK0Pq/VvJ20lSkR+0nk+s/v3BgIyle78wjZP1vWLU4wIDAQAB
NAGAD_KEY_PRIVATE=MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCJakyLqojWTDAVUdNJLvuXhROV+LXymqnukBrmiWwTYnJYm9r5cKHj1hYQRhU5eiy6NmFVJqJtwpxyyDSCWSoSmIQMoO2KjYyB5cDajRF45v1GmSeyiIn0hl55qM8ohJGjXQVPfXiqEB5c5REJ8Toy83gzGE3ApmLipoegnwMkewsTNDbe5xZdxN1qfKiRiCL720FtQfIwPDp9ZqbG2OQbdyZUB8I08irKJ0x/psM4SjXasglHBK5G1DX7BmwcB/PRbC0cHYy3pXDmLI8pZl1NehLzbav0Y4fP4MdnpQnfzZJdpaGVE0oI15lq+KZ0tbllNcS+/4MSwW+afvOw9bazAgMBAAECggEAIkenUsw3GKam9BqWh9I1p0Xmbeo+kYftznqai1pK4McVWW9//+wOJsU4edTR5KXK1KVOQKzDpnf/CU9SchYGPd9YScI3n/HR1HHZW2wHqM6O7na0hYA0UhDXLqhjDWuM3W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+K8EBSQcwLsrI7QL7fvQ==
NAGAD_CALLBACK_URL=nagad.callback
```

To Start payment, in your NagadController:

```
    use NagadAPI\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

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity27

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://avatars.githubusercontent.com/u/5115489?v=4)[A S M Saief](/maintainers/anovob)[@anovob](https://github.com/anovob)

---

Top Contributors

[![anovob](https://avatars.githubusercontent.com/u/5115489?v=4)](https://github.com/anovob "anovob (9 commits)")

### Embed Badge

![Health badge](/badges/anovob-laravel-nagad-api/health.svg)

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

###  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)
