PHPackages                             dizatech/saman\_ipg - 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. dizatech/saman\_ipg

ActiveLibrary[Payment Processing](/categories/payments)

dizatech/saman\_ipg
===================

1.0.1(8mo ago)0271GPL-3.0-or-laterPHP

Since Jun 29Pushed 8mo agoCompare

[ Source](https://github.com/dizatech/saman_ipg)[ Packagist](https://packagist.org/packages/dizatech/saman_ipg)[ RSS](/packages/dizatech-saman-ipg/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (3)Used By (1)

Payment Cycle
-------------

[](#payment-cycle)

For a payment transaction we have to request a payment. If our request is successful the IPG will return a token with which we should guide the customer to the payment page via a POST request. Customer will be redirected back to our desired URL(redirect address) from payment page via a POST request carrying data which may be used to check and verify the transaction.

### Instantiating an IPG object

[](#instantiating-an-ipg-object)

for instantiating an IPG object we should call `Dizatech\SamanIpg\SamanIpg` constructor passing it an array of required arguments containing:

- terminal\_id: your payment gateway terminal id

#### Code sample:

[](#code-sample)

```
$args = [
    'terminal_id'   => '123',
]; //Replace arguments with your gateway actual values
$ipg = new Dizatech\SamanIpg\SamanIpg($args);
```

### Payment Request

[](#payment-request)

For a payment transaction we should request a payment from IPG and acquire a token. This may be accomplished by calling `requestPayment` method. If the request is successful we can redirect our customer to the payment page with the acquired token.

#### Arguments:

[](#arguments)

- amount: payment amount in Rials
- order\_id: unique order id
- redirect\_url: URL to which customer may be redirected after payment

#### Returns:

[](#returns)

An object with the following properties:

- status: `success` or `error`
- token: in case of a successful request contains a token with which we can redirect user to the payment page. This token may be used for further tracking the purchase request
- message: in case of an error contains a message describing the error

```
$result = $ipg->requestPayment(
    order_id: 3,
    amount: 13000,
    redirect_url: 'http://myaddress.com/verify'
);
if ($result->status == 'success') {
    echo "

                Send

            window.addEventListener('load', function () {document.getElementById('saman_redirect_form').submit()})";
    exit;
}
```

Payment verification
--------------------

[](#payment-verification)

After payment the customer will be redirected back to the redirect address provided in payment request, via a POST request carrying all necessary data. Data fields sent by IPG are:

- State: a numeric code showing payment status. 0 means successful and 2 indicates a payment which has beeen verified before
- ResNum: the order id passed to IPG in first phase
- RefNum: Tracking number
- RRN: Reference number If `ResCode` equals `0` or `ResCode` equals `2` and POST request contains a RefNum we can continue verifying the payment via calling the ipg `verify` method.

#### Arguments:

[](#arguments-1)

- amount: original payment amount sent to IPG in first phase
- ref\_number: the RefNum returned by IPG

#### Returns:

[](#returns-1)

- status: `success` or `error`
- ref\_no: the RRN returned by IPG
- token: the RefNum returned by IPG. This RefNum (token) can be used later for interacting with the transcation. For example you may need it if you want to reverse the transaction.
- message: in case of an error contains an message describing the error If `ResCode` equals `0` it means the transaction has been successful and verified. `ResCode = 2` means the transaction was successful but has already beeen verified. So in either case the transaction can be regarded as **successful**. Other values for `ResCode` means the transaction has failed.

#### Code Sample:

[](#code-sample-1)

```
//Replace arguments with your gateway actual values
$args = [
    'terminal_id'   => '123',
]; //Replace arguments with your gateway actual values
$ipg = new Dizatech\SamanIpg\SamanIpg($args);

if (0 == $_REQUEST['ResCode'] && isset($_REQUEST['RefNum'])) {
    $result = $ipg->verify(13000, $_REQUEST['RefNum']);
    if ($result->status == 'success') {
        echo "Transaction sucessful! Reference Number: {$result->ref_no}";
    } else {
        echo "Transaction failed with error: {$result->error}";
    }
}
```

Payment Reverse
---------------

[](#payment-reverse)

In case we need to cancel customer's order immediately after payment (maximum 2 hours later) we can simply reverse the payment transaction which may result to full and instant refund to customer's bank account. For reversing transactions we can call `reverse` method.

#### Arguments:

[](#arguments-2)

- ref\_number: the RefNum returned by IPG in case of successful payment verification

#### Returns:

[](#returns-2)

- status: `success` or `error`
- ref\_no: the RRN returned by IPG
- token: the RefNum returned by IPG
- message: in case of an error contains an message describing the error

#### Code Sample:

[](#code-sample-2)

```
//Replace arguments with your gateway actual values
$args = [
    'terminal_id'   => '123',
]; //Replace arguments with your gateway actual values
$ipg = new Dizatech\SamanIpg\SamanIpg($args);
$result = $ipg->reverse('123456789'); //Replace with atcual ref_num of the transaction
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance61

Regular maintenance activity

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 80% 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 ~119 days

Total

2

Last Release

249d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7ca25b6ce9e40a205b65efd8c9fb92865bbf6d4586f11be7ca76be0d4151b808?d=identicon)[omidfarahani](/maintainers/omidfarahani)

---

Top Contributors

[![omidfarahani](https://avatars.githubusercontent.com/u/10830204?v=4)](https://github.com/omidfarahani "omidfarahani (4 commits)")[![saharfalah](https://avatars.githubusercontent.com/u/25864060?v=4)](https://github.com/saharfalah "saharfalah (1 commits)")

### Embed Badge

![Health badge](/badges/dizatech-saman-ipg/health.svg)

```
[![Health](https://phpackages.com/badges/dizatech-saman-ipg/health.svg)](https://phpackages.com/packages/dizatech-saman-ipg)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M507](/packages/pimcore-pimcore)[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M985](/packages/statamic-cms)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)

PHPackages © 2026

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