PHPackages                             miladrahimi/php-mellat-bank - 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. miladrahimi/php-mellat-bank

ActiveLibrary[Payment Processing](/categories/payments)

miladrahimi/php-mellat-bank
===========================

Iranian Mellat Bank Gateway for PHP Projects

v1.1.4(8y ago)12422MITPHPPHP &gt;=5.4.0

Since Aug 10Pushed 6y ago1 watchersCompare

[ Source](https://github.com/miladrahimi/php-mellat-bank)[ Packagist](https://packagist.org/packages/miladrahimi/php-mellat-bank)[ Docs](http://miladrahimi.github.io)[ RSS](/packages/miladrahimi-php-mellat-bank/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)DependenciesVersions (7)Used By (0)

Php-Mellat-Bank
===============

[](#php-mellat-bank)

Iranian Mellat Bank Gateway for PHP Projects

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

[](#installation)

```
composer require miladrahimi/php-mellat-bank

```

### Lifecycle

[](#lifecycle)

The process of an online payment with Mellat bank gateway consists of following steps:

- Request for a new payment
- Redirect user to the bank gateway page
- Verify payment on callback page

Getting Started
---------------

[](#getting-started)

To use the package for your payments you must instantiate the `Gateway` class and provide its configuration.

```
use MiladRahimi\PhpMellatBank\Gateway;

$config = [
    'terminalId' => '...',
    'userName' => '...',
    'userPassword' => '...',
    'callBackUrl' => 'https://example.com/payment/callback',
];

$gateway = new Gateway($config);

```

Request Payment
---------------

[](#request-payment)

As mentioned above, a the first step you must request for a new payment. It can be done this way:

```
$refId = $gateway->requestPayment($amountInRial, 'Some optional description...');

```

This method would throws `GatewayException` if it could not call the bank server api, `MellatException`if the bank response is something other than 0 (success).

`MellatException` holds the bank response in its message.

If there was no error it would returns the `RefId`.

Redirect to Gateway
-------------------

[](#redirect-to-gateway)

Now that you have gotten the `RefId` you can lead user to the bank gateway.

To do this you should display an html form like this:

```

```

The `$bankGatewayUrl` is an url that bank provides for you but you can get it from a `Gateway` instance this way:

```
$gateway->url()

```

Verify Payment
--------------

[](#verify-payment)

User completes the payment in bank gateway then bank redirects him to the callback you have provided in the configuration, it also sends some parameters to the callback with `POST` method.

Your callback url must verify the payment.

```
use MiladRahimi\PhpMellatBank\Gateway;

$gateway = new Gateway($config);

$refId = $gateway->checkPayment();

if($refId != false) {
    $bankResult = $gateway->verifyPayment();
}

```

`checkPayment()` method would return `$refId` or `false` if there were any error.

`verifyPayment()` method would return the bank response as an instance of `BankResult` class, it throws `InvalidResponseException` if the request is not valid (might not from the bank), `GatewayException` if it cannot call the bank server api, `MellatException` if the bank response is something other than 0 (success).

Exceptions
----------

[](#exceptions)

- `GatewayException`: It'd be thrown when there were a problem on calling bank server APIs.
- `MellatException`: It'd be thrown when bank `ResCode` is not `0` (success). It holds the real response in its message.
- `InvalidResponseException`: It'd be thrown in verification level (callback url) when the parameters are not valid. This problem usually occurs when someone/something other than bank calls your callback url.

License
-------

[](#license)

PhpMellatBank is created by [Milad Rahimi](http://miladrahimi.com)and released under the [MIT License](http://opensource.org/licenses/mit-license.php).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

6

Last Release

3194d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/921274b8bb29236d8f94f6c83100a5f751f6394c4c49741e1b92bfbccac0911b?d=identicon)[miladrahimi](/maintainers/miladrahimi)

---

Top Contributors

[![miladrahimi](https://avatars.githubusercontent.com/u/6689295?v=4)](https://github.com/miladrahimi "miladrahimi (20 commits)")

---

Tags

bankgatewaygateway-apiiranianmellat-bankphpgatewayBankiranonline-paymentmellat

### Embed Badge

![Health badge](/badges/miladrahimi-php-mellat-bank/health.svg)

```
[![Health](https://phpackages.com/badges/miladrahimi-php-mellat-bank/health.svg)](https://phpackages.com/packages/miladrahimi-php-mellat-bank)
```

###  Alternatives

[larabook/gateway

A Laravel package for connecting to all Iraninan payment gateways

24553.7k](/packages/larabook-gateway)[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)
