PHPackages                             xeronce/shadhinpay - 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. xeronce/shadhinpay

ActiveLibrary[Payment Processing](/categories/payments)

xeronce/shadhinpay
==================

Receive Payments with new era gateway tool

v1.0.0(1mo ago)07MITPHPPHP &gt;=7.4

Since Jul 9Pushed 1mo agoCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

ShadhinPay Payment Gateway Laravel Package
==========================================

[](#shadhinpay-payment-gateway-laravel-package)

An elegant, easy-to-use Laravel integration for ShadhinPay. Fully compatible with Laravel 8, 9, 10, and 11, and PHP 7.4 through 8.x.

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

[](#installation)

Install the package via Composer:

```
composer require xeronce/shadhinpay
```

### Local Development / Testing

[](#local-development--testing)

If you are developing or testing this package locally before publishing, add the package to your host Laravel project's `composer.json` using a path repository:

```
"repositories": [
    {
        "type": "path",
        "url": "path/to/shadhinpay-laravel",
        "options": {
            "symlink": true
        }
    }
],
```

Then run:

```
composer require xeronce/shadhinpay:@dev
```

### Zero Configuration

[](#zero-configuration)

Laravel's Package Auto-Discovery will automatically register the service provider and `Shadhinpay` Facade.

If you wish to publish the configuration file, run:

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

---

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

[](#configuration)

Add the following environment variables to your `.env` file:

```
SHADHINPAY_CLIENT_ID=your_client_id
SHADHINPAY_BUSINESS_ID=your_business_id
SHADHINPAY_API_KEY=your_x_api_key_access_key
SHADHINPAY_SIGNING_SECRET=your_webhook_signing_secret_optional
SHADHINPAY_BASE_URL=https://request.shadhinpay.com
```

---

Usage
-----

[](#usage)

### 1. Create a Payment

[](#1-create-a-payment)

To initiate a payment and redirect the customer to ShadhinPay's checkout:

```
use Xeronce\Shadhinpay\Facades\Shadhinpay;

$response = Shadhinpay::pay([
    'amount'        => 500.00,
    'currency'      => 'BDT',
    'merchantTxnId' => 'TXN-' . time(),
    'callbackUrl'   => route('payment.callback'),
    'customerPhone' => '01700000000',
    'customerEmail' => 'customer@example.com',
    'description'   => 'Buying Premium Plan',
]);

if (isset($response['data']['paymentUrl'])) {
    return redirect($response['data']['paymentUrl']);
}

// Handle error
return back()->with('error', $response['message'] ?? 'Payment failed to initialize');
```

### 2. Verify a Payment

[](#2-verify-a-payment)

To verify the payment status using the `paymentId` returned from the checkout callback:

```
use Xeronce\Shadhinpay\Facades\Shadhinpay;

$paymentId = $request->query('paymentId');
$response = Shadhinpay::verify($paymentId);

if (isset($response['data']['status']) && $response['data']['status'] === 'COMPLETED') {
    // Payment is successful
}
```

### 3. Refund a Payment

[](#3-refund-a-payment)

To request a refund for an existing payment:

```
use Xeronce\Shadhinpay\Facades\Shadhinpay;

$response = Shadhinpay::refund($paymentId, [
    'amount' => 500.00,
    'reason' => 'Customer requested cancelation',
    'merchantRef' => 'REF-' . time()
]);
```

---

Webhooks
--------

[](#webhooks)

ShadhinPay automatically dispatches webhooks to notify your application of payment status changes.

The package exposes a POST endpoint at: `/shadhinpay/webhook`

Important

Since webhook requests are sent from ShadhinPay's servers, you **must exempt** the webhook route from CSRF protection.

**For Laravel 8, 9, and 10:**Add the route to `$except` in `app/Http/Middleware/VerifyCsrfToken.php`:

```
protected $except = [
    'shadhinpay/webhook',
];
```

**For Laravel 11+:**Add the route to the middleware configuration in `bootstrap/app.php`:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: [
        'shadhinpay/webhook',
    ]);
})
```

### Webhook Event Listener

[](#webhook-event-listener)

When a webhook is received, the package verifies the webhook signature (if `SHADHINPAY_SIGNING_SECRET` is defined in `.env`) and fires a `WebhookReceived` event.

You can listen to this event in your `EventServiceProvider`:

```
use Xeronce\Shadhinpay\Events\WebhookReceived;
use App\Listeners\HandleShadhinpayWebhook;

protected $listen = [
    WebhookReceived::class => [
        HandleShadhinpayWebhook::class,
    ],
];
```

And in your listener class `HandleShadhinpayWebhook.php`:

```
namespace App\Listeners;

use Xeronce\Shadhinpay\Events\WebhookReceived;

class HandleShadhinpayWebhook
{
    public function handle(WebhookReceived $event)
    {
        $payload = $event->payload;
        $eventType = $payload['eventType'] ?? ''; // e.g. PAYMENT.COMPLETED

        if ($eventType === 'PAYMENT.COMPLETED') {
            $paymentData = $payload['data'];
            $paymentId = $paymentData['paymentId'];
            $merchantTxnId = $paymentData['merchantTxnId'];

            // Update your database order status
        }
    }
}
```

Security
--------

[](#security)

If `SHADHINPAY_SIGNING_SECRET` is set, all incoming webhooks are validated using HMAC-SHA256 replay-safe protection to prevent request spoofing.

License
-------

[](#license)

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

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance92

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

40d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cbeab9df5783d946f7c627ac52d0835e600c6fe5d3d706f3f5de28b57d60872b?d=identicon)[xeronce](/maintainers/xeronce)

---

Top Contributors

[![hellotazim](https://avatars.githubusercontent.com/u/148036464?v=4)](https://github.com/hellotazim "hellotazim (1 commits)")

### Embed Badge

![Health badge](/badges/xeronce-shadhinpay/health.svg)

```
[![Health](https://phpackages.com/badges/xeronce-shadhinpay/health.svg)](https://phpackages.com/packages/xeronce-shadhinpay)
```

###  Alternatives

[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3827.1k](/packages/linkxtr-laravel-qrcode)

PHPackages © 2026

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