PHPackages                             navid045/mellatbank - 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. navid045/mellatbank

ActiveLibrary[Payment Processing](/categories/payments)

navid045/mellatbank
===================

Iranian Mellat Bank Gateway for PHP Projects

v1.1.5(7y ago)21.5kMITPHPPHP &gt;=5.4.0

Since Aug 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/naviloper/mellatbank)[ Packagist](https://packagist.org/packages/navid045/mellatbank)[ Docs](https://github.com/navid045/phpmellatbank)[ RSS](/packages/navid045-mellatbank/feed)WikiDiscussions master Synced today

READMEChangelog (1)DependenciesVersions (9)Used By (0)

PhpMellatBank
=============

[](#phpmellatbank)

Iranian Mellat Bank Gateway for PHP Projects

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

[](#installation)

```
composer require navid045/mellatbank
```

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

MellatBank is created by [Milad Rahimi](http://miladrahimi.com) and changed by [Navid Hosseini](https://github.com/navid045)and released under the [MIT License](http://opensource.org/licenses/mit-license.php).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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 ~53 days

Recently: every ~79 days

Total

7

Last Release

2876d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ba2604c529766e2bafae5f2eedfbea5baa162c66e2e3ce57e0df93bcb7c00b2?d=identicon)[naviloper](/maintainers/naviloper)

---

Top Contributors

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

---

Tags

gatewayBankiranonline-paymentmellatMallat Bank

### Embed Badge

![Health badge](/badges/navid045-mellatbank/health.svg)

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

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