PHPackages                             dizatech/pasargad\_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/pasargad\_ipg

ActiveLibrary[Payment Processing](/categories/payments)

dizatech/pasargad\_ipg
======================

v1.0.0(1y ago)124311GPL-3.0-or-laterPHP

Since Dec 22Pushed 1y ago1 watchersCompare

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

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

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

[](#payment-cycle)

For a payment transaction we have to request a purchase via webservice. If our request is successful the IPG will return a url which we should use while redirecting customer to payment page. Customer will be redirected back to our desired URL(redirect address) from payment page via a GET request carrying data which may be used to check and verify customer's transaction using web service.

### Instantiating an IPG object

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

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

- username: your payment gateway username
- password: your payment gateway password
- terminal\_number: your payment gateway terminal number

#### Code sample:

[](#code-sample)

```
$args = [
    'username'          => '123',
    'password'          => '456',
    'terminal_number'   => '789',
]; //Replace arguments with your gateway actual values
$ipg = new Dizatech\PasargadIpg\PasargadIpg($args);
```

### Purchase Request

[](#purchase-request)

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

#### Arguments:

[](#arguments)

- amount: payment amount in Rials
- invoice\_number: unique invoice number
- invoice\_date: invoice date in desired format
- redirect\_address: URL to which customer may be redirected after payment

#### Returns:

[](#returns)

An object with the following properties:

- status: `success` or `error`
- url id: in case of a successful request contains the a url id which may be used for further tracking the purchase request
- payment url: in case of a successful request contains a payment url to which we should redirect our customer

#### Code sample:

[](#code-sample-1)

```
$purchase = $ipg->purchase(
    amount: 20000,
    invoice_number: 1,
    invoice_date: '2024-06-29 10:20:30',
    redirect_address: 'http://myaddress.com/verify'
); //Replace arguments with your gateway actual values
if ($purchase->status == 'success') {
    header("Location: {$purchase->payment_url}");
    exit;
}
```

Payment check and verification
------------------------------

[](#payment-check-and-verification)

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

- status: status of customer payment
- invoiceId: the invoice number sent to IPG in purchase phase; we can use this invoice id for acquiring original invoice from our database
- referenceNumber: reference number which may be used for further tracking the payment
- trackId: tracking id which may be used for further tracking the payment

If `status` equals `sucecss` it may considered as a successful payment claim which should be inquired and verified. Anything other than `success` means the payment has failed; thus, there will be no need for any further action. It should be noted that successful payments have to verified. otherwise they will be returned to customer's bank account.

### Inquiry

[](#inquiry)

Successful payment data should be inquired before we could verify them. Inquiry can be accomplished by calling `inquiry` method.

#### Arguments:

[](#arguments-1)

- invoice\_number: invoice number used in purchase phase for which the user has been sent to payment gateway

#### Returns:

[](#returns-1)

- status: inquiry request status which should be success; otherwise it means that our request has totally failed; thus we don't have any data related to the payment.
- payment\_status: payment status which may be `success`, `confirmed` or `refunded`. `success` as payment status means the payment has been successful and we can move on and verify the payment. `confirmed` means the payment has already been verified and also confirmed (can't be refunded and will be transferred to the merchant's bank account). `refunded` payments are successful payments but has been returned to the payer's bank account either because of deliberate refunding or failure in verification.
- transaction\_id: transaction id which may be used for further tracking the payment
- reference\_number: reference number which may be used for further tracking the payment
- amount: the actual paid amount which should match the original invoice amount
- pan: the customer's PAN number
- url\_id: url id which may be used to retrieve original invoice from our database, verifying or further tracking the payment

#### Code Sample:

[](#code-sample-2)

```
$inquiry = $ipg->inquiry(invoice_number: 1);
//Replace arguments with your gateway actual values
```

### Verify

[](#verify)

If the inquiry result is `success` and payment result is also `success` we have to verify the transaction via `verify` method.

#### Arguments:

[](#arguments-2)

- invoice\_number: invoice number used in purchase phase for which the user has been sent to payment gateway
- url\_id: url id returned from inquiry phase

#### Returns:

[](#returns-2)

- status: verify request status which may be `success` or `error`
- reference\_number: reference number which may be used for further tracking the payment
- amount: the actual paid amount which should match the original invoice amount
- pan: the customer's PAN number

#### Code Sample:

[](#code-sample-3)

```
//Replace arguments with your gateway actual values
$inquiry = $ipg->inquiry(invoice_number: 1);
if ($inquiry->status == 'success' && $inquiry->payment_status == 'success') {
    $verification_result = $ipg->verify(
        invoice_number: 1,
        url_id: '2.................004497985'
    );
    if ($verification_result->status == 'success') {
        echo $inquiry->transaction_id . "";
        echo $verification_result->reference_number . "";
        echo $verification_result->pan . "";
        echo $inquiry->url_id;
        die();
    } else {
        die('Failed');
    }
} elseif ($inquiry->status == 'success' && $inquiry->payment_status == 'refunded') {
    die('Refunded');
}
```

Refund
------

[](#refund)

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

#### Arguments:

[](#arguments-3)

- invoice\_number: invoice number used in purchase phase for which the user has been sent to payment gateway
- url\_id: url id returned from inquiry or purchase phase

#### Returns:

[](#returns-3)

- status: refund request status which may be `success` or `error`
- error\_message: in case of `error` it may contain an error message

#### Code Sample:

[](#code-sample-4)

```
$refund = $ipg->refund(
    invoice_number: 1,
    url_id: '2.................004497985'
); //Replace arguments with your gateway actual values
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

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

Recently: every ~322 days

Total

6

Last Release

672d ago

Major Versions

v0.1.4 → v1.0.02024-07-05

### 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 (6 commits)")

### Embed Badge

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

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

###  Alternatives

[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M8](/packages/chargebee-chargebee-php)[imdhemy/google-play-billing

Google Play Billing

491.3M5](/packages/imdhemy-google-play-billing)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42337.5k4](/packages/bitpay-sdk)[buckaroo/sdk

Buckaroo payment SDK

12189.1k8](/packages/buckaroo-sdk)[contica/facturador-electronico-cr

Un facturador de código libre para integrar facturación electrónica en Costa Rica a un proyecto PHP

2128.8k](/packages/contica-facturador-electronico-cr)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)

PHPackages © 2026

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