PHPackages                             softscholar/laravel-payments - 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. softscholar/laravel-payments

ActiveLibrary[Payment Processing](/categories/payments)

softscholar/laravel-payments
============================

Payment gateway service by SoftScholar

v1.0.2(1y ago)3846MITPHPPHP ^8.0CI passing

Since Oct 7Pushed 1y agoCompare

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

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

Laravel Payments by SoftScholar
===============================

[](#laravel-payments-by-softscholar)

**Laravel Payments** is a service package for integrating payment gateways into your Laravel application, developed by [SoftScholar](https://softscholar.com). This package currently supports the Nagad Payment Gateway, with plans to add support for more gateways in the future.

> **Note:** This package uses Nagad API version 4.0.1.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
    - [Configuration Options](#configuration-options)
    - [Setting Environment Variables](#setting-environment-variables)
- [Usage](#usage)
- [Supported Payment Gateways](#supported-payment-gateways)
- [License](#license)
- [Contributing](#contributing)

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

[](#installation)

To install the package, run the following command in your Laravel project directory:

```
composer require softscholar/laravel-payments
```

Configuration
-------------

[](#configuration)

After installing the package, you need to publish the configuration file to set up credentials for the payment gateways. Run the following command to publish the configuration file:

```
php artisan vendor:publish --provider="Softscholar\Payment\PaymentServiceProvider"
```

This will create a configuration file named `spayment.php` in the `config` directory of your Laravel project. You can customize this file to configure credentials and settings for the Nagad Payment Gateway or any other gateways that will be supported in the future.

### Configuration Options

[](#configuration-options)

The configuration file will look something like this:

```
return [
    'mode' => env('PAYMENT_GATEWAY_MODE', 'sandbox'),
    'gateways' => [
        'nagad' => [
            'mode' => env('NAGAD_MODE', 'sandbox'),
            'merchant_id' => env('NAGAD_MERCHANT_ID', 'your-merchant-id'),
            'merchant_public_key' => env('NAGAD_PG_PUBLIC_KEY', 'your-merchant-public-key'),
            'merchant_private_key' => env('NAGAD_MERCHANT_PRIVATE_KEY', 'merchant-private-key'),
            'merchant_number' => env('NAGAD_MERCHANT_NUMBER', 'your-merchant-number'),
            'tokenization' => env('NAGAD_TOKENIZATION', false),
            'ssl_verify' => env('NAGAD_SSL_VERIFY', false), // on production set it to true
            'merchant_hex' => env('NAGAD_MERCHANT_HEX', 'your-merchant-hex'),
            'merchant_iv' => env('NAGAD_MERCHANT_IV', 'your-merchant-iv'),
        ],
    ],
    ...
];
```

### Setting Environment Variables

[](#setting-environment-variables)

To use the Nagad Payment Gateway, add the necessary environment variables to your `.env` file:

```
NAGAD_MODE=sandbox
NAGAD_MERCHANT_ID=your-merchant-id
NAGAD_MERCHANT_SECRET=your-merchant-secret
NAGAD_PG_PUBLIC_KEY=your-public-key
NAGAD_MERCHANT_PRIVATE_KEY=your-private-key
NAGAD_MERCHANT_NUMBER=your-merchant-number
NAGAD_CALLBACK_URL=your-callback-url
NAGAD_SSL_VERIFY=false
NAGAD_MERCHANT_HEX=your-merchant-hex
NAGAD_MERCHANT_IV=your-merchant-iv
```

Replace your-merchant-id, your-merchant-secret, your-public-key, your-private-key, and your-callback-url with the actual credentials provided by Nagad.

After setting these variables, the package will be ready to use with the Nagad gateway. Additional gateways can be configured similarly in the future as they are added to the package.

Usage
-----

[](#usage)

To use the Laravel Payments package, you can create a new instance of the `Payment` class and call the `purchase` method to initiate a payment. Here is an example of how you can use the package to make a payment using the Nagad gateway:

```
use Softscholar\Payment\Services\Gateways\Nagad\Nagad;

        $merchantCallbackURL = route('gateways.nagad.callback');

        $checkoutData =  [
            'callback_url' => $merchantCallbackURL,
            'order_id' => $product->id . 'Ord' . time(),
            'customer_id' => $customerId, // must be greater than 4 digits
            'additional_info' => [
                'additionalFieldNameBN' => 'পণ্যের নাম',
                'additionalFieldNameEN' => 'Product Name',
                'additionalFieldValue' => $product->name,
            ],
            'amount' => $product->price,
        ];

    // create an instance of Nagad
    $nagad = new Nagad(
            $YourMerchantId,
            $YourMerchantPgKey,
            $YourMerchantPrivateKey,
            $YourMerchantHex,
            $YourMerchantIv,
            $YourMerchantNumber
        );

    /**
     * checkout method takes two parameters
        * 1. checkoutData
        * 2. checkoutType (optional) - default is 'regular'
        * Types: 'regular', 'authorize', 'tokenized'
        * For tokenized checkout, you will need to authorize the payment first by passing 'authorize' as the second parameter
        * After authorizing the payment, you will get a account details, store the thoose details and use them to tokenize the payment
        * once you have token then call the checkout method with 'tokenized' as the second parameter
     */

    // initiate the payment and get the redirect URL
     $redirectUrl = $nagad->checkout($checkoutData); // for regular checkout

    // for tokenization you will need to authorize the payment first
    // with zero(0) amount
    $checkoutData['amount'] = 0;
    $redirectUrl = $nagad->checkout($checkoutData, 'authorize');

    // store the account details and use them to tokenize the payment
    // once you have token then call the checkout method with 'tokenized' as the second parameter
    $redirectUrl = $nagad->checkout($checkoutData, 'tokenized');
```

The `purchase` method will return a redirect URL that you can use to redirect the user to the Nagad payment page. The user will be able to complete the payment on the Nagad website, and once the payment is completed, the user will be redirected back to the callback URL specified in the checkout data.

Callback data example

```
'merchant' => 'your-merchant-id',
'order_id' => 'order-id',
'payment_ref_id' => 'payment-ref-id',
'status' => 'payment-status',
'status_code' => 'payment-status-code',
'message' => 'payment-message',
'payment_dt' => 'payment-date-time'
```

More detailed documentation will be added in the future as more gateways are added to the package. You can also check the [Nagad API Documentation](https://nagad.com.bd) for more information on how to use the Nagad Payment Gateway.

You can get the example application of: [Laravel Payments Example](https://github.com/softscholar/laravel-payments-app) You can check the example application to see how to use the package.

Supported Payment Gateways
--------------------------

[](#supported-payment-gateways)

The Laravel Payments package currently supports the following payment gateways:

- Nagad
- More gateways will be added in the future

License
-------

[](#license)

The Laravel Payments package is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT).

Contributing
------------

[](#contributing)

Open source contributions are welcome! If you would like to contribute to the package, please fork the repository and submit a pull request with your changes.

If you have any questions or need help with the package, please feel free to contact us at [SoftScholar](https://softscholar.com) or email to [Email](mailto:atiq@softscholar.com).

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance49

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~105 days

Total

3

Last Release

371d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/288cb3a8610dddc98a87c03eac7cf3c146dfec62a46a237953f4db654be1ab7c?d=identicon)[softscholar](/maintainers/softscholar)

---

Top Contributors

[![atiq-ur](https://avatars.githubusercontent.com/u/57439878?v=4)](https://github.com/atiq-ur "atiq-ur (17 commits)")

---

Tags

hectoberfesthectoberfest2024laravelnagadpaymentslaravelpaymentgatewaytokenizationnagadsoftscholar

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/softscholar-laravel-payments/health.svg)

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

###  Alternatives

[evryn/laravel-toman

A simple stable Laravel package to handle popular payment gateways in Iran including ZarinPal and IDPay.

1079.9k](/packages/evryn-laravel-toman)[dena-a/iran-payment

a Laravel package to handle Internet Payment Gateways for Iran Banking System

312.4k1](/packages/dena-a-iran-payment)[parsisolution/gateway

A Laravel package for connecting to all Iraninan payment gateways

231.7k](/packages/parsisolution-gateway)

PHPackages © 2026

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