PHPackages                             noorani-mm/laravel-saman-payment-gateway - 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. noorani-mm/laravel-saman-payment-gateway

ActiveLibrary[Payment Processing](/categories/payments)

noorani-mm/laravel-saman-payment-gateway
========================================

Laravel package for Saman (SEP) payment gateway

v1.1.1(4mo ago)212MITPHPPHP ^8.1

Since Dec 22Pushed 4mo agoCompare

[ Source](https://github.com/Noorani-MM/laravel-saman-payment-gateway)[ Packagist](https://packagist.org/packages/noorani-mm/laravel-saman-payment-gateway)[ RSS](/packages/noorani-mm-laravel-saman-payment-gateway/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

Laravel Saman Payment Gateway
=============================

[](#laravel-saman-payment-gateway)

Laravel package for integrating **Saman (SEP / Shaparak)** payment gateway.

This package provides a clean, DTO-based, and IDE-friendly API for:

- Creating payment tokens
- Redirecting users to the payment page
- Verifying transactions via callback

---

Features
--------

[](#features)

- ✅ Laravel 10 &amp; 11 compatible
- ✅ DTO-based request &amp; response models
- ✅ Facade support with full IDE autocomplete
- ✅ Configurable via config file &amp; `.env`
- ✅ No external dependencies beyond Laravel components
- ✅ Clean service-based architecture

---

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

[](#installation)

Install the package via Composer:

```
composer require noorani-mm/laravel-saman-payment-gateway
```

---

Publish Configuration
---------------------

[](#publish-configuration)

Publish the config file:

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

This will create:

```
config/saman-gateway.php

```

---

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

[](#configuration)

Set the following values in your `.env` file:

```
SAMAN_TERMINAL_ID=XXXXXXXX
SAMAN_REDIRECT_URL=https://your-site.com/payment/callback
SAMAN_TIMEOUT=30
```

Example `config/saman-gateway.php`:

```
return [
    'TerminalId'   => env('SAMAN_TERMINAL_ID'),
    'RedirectURL' => env('SAMAN_REDIRECT_URL'),
    'Timeout'     => env('SAMAN_TIMEOUT', 30),
];
```

---

Usage
-----

[](#usage)

### Import Facade

[](#import-facade)

```
use NooraniMm\SamanGateway\Facades\Saman;
```

---

1️⃣ Create Payment Token
------------------------

[](#1️⃣-create-payment-token)

Create a payment token using a DTO:

```
use NooraniMm\SamanGateway\DTO\Requests\CreatePaymentTokenRequestDTO;

$dto = new CreatePaymentTokenRequestDTO(
    Amount: 100000,
    ResNum: 'ORDER-123'
);

$response = Saman::createPaymentToken($dto);
```

---

2️⃣ Redirect User to Payment Page
---------------------------------

[](#2️⃣-redirect-user-to-payment-page)

### Auto redirect (HTML form auto-submit)

[](#auto-redirect-html-form-auto-submit)

```
Saman::redirectToPayment($response);
```

### Manual handling (JS / frontend rendering)

[](#manual-handling-js--frontend-rendering)

```
$data = Saman::redirectToPayment($response, false);

/*
$data = [
    'token'  => '...',
    'url'    => 'https://sep.shaparak.ir/OnlinePG/OnlinePG',
    'method' => 'post',
];
*/
```

---

3️⃣ Verify Payment (Callback)
-----------------------------

[](#3️⃣-verify-payment-callback)

In your callback controller:

```
use Illuminate\Http\Request;
use NooraniMm\SamanGateway\Facades\Saman;

public function callback(Request $request)
{
    $result = Saman::verify($request);

    if ($result->isSuccessful()) {
        // Payment successful
    } else {
        // Payment failed
    }
}
```

The callback data is mapped into a `PaymentCallbackResponseDTO`.

---

DTO Architecture
----------------

[](#dto-architecture)

### Requests

[](#requests)

```
DTO/Requests/
├── CreatePaymentTokenRequestDTO

```

### Responses

[](#responses)

```
DTO/Responses/
├── CreatePaymentTokenResponseDTO
├── PaymentCallbackResponseDTO

```

Each DTO explicitly defines:

- Required fields
- Optional fields
- Exact data types
- IDE-friendly documentation

---

Facade Methods (IDE Autocomplete)
---------------------------------

[](#facade-methods-ide-autocomplete)

The `Saman` facade exposes the following methods:

```
Saman::createPaymentToken(CreatePaymentTokenRequestDTO $DTO);

Saman::redirectToPayment(
    CreatePaymentTokenResponseDTO $DTO,
    bool $autoRedirect = true
);

Saman::verify(Request $request);
```

All methods are documented via `@method` annotations for full IDE support.

---

Architecture Overview
---------------------

[](#architecture-overview)

```
Facade (Saman)
      ↓
Service (SamanPaymentGateway)
      ↓
DTOs (Request / Response)
      ↓
Saman (SEP) API

```

- Facade: simple static API
- Service: core business logic
- DTOs: explicit data contracts
- Config: environment-driven

---

Error Handling
--------------

[](#error-handling)

- Network or HTTP errors throw `Exception`
- Gateway errors are returned inside response DTOs
- Verification failure is determined via gateway response codes

---

Requirements
------------

[](#requirements)

- PHP ^8.1
- Laravel 10 or 11

---

License
-------

[](#license)

MIT License © Mohammad Mahdi Noorani

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance76

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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 ~3 days

Total

4

Last Release

132d ago

### Community

Maintainers

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

---

Top Contributors

[![Noorani-MM](https://avatars.githubusercontent.com/u/74505328?v=4)](https://github.com/Noorani-MM "Noorani-MM (10 commits)")

### Embed Badge

![Health badge](/badges/noorani-mm-laravel-saman-payment-gateway/health.svg)

```
[![Health](https://phpackages.com/badges/noorani-mm-laravel-saman-payment-gateway/health.svg)](https://phpackages.com/packages/noorani-mm-laravel-saman-payment-gateway)
```

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)[asciisd/knet

Knet package is provides an expressive, fluent interface to KNet's payment services.

141.1k](/packages/asciisd-knet)

PHPackages © 2026

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