PHPackages                             nimah79/f3-zarinpal - 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. nimah79/f3-zarinpal

ActiveLibrary[Payment Processing](/categories/payments)

nimah79/f3-zarinpal
===================

Zarinpal Plugin for PHP Fat-Free Framework

v1.0.1(6y ago)06GPL-3.0PHPPHP &gt;=5.4.0

Since Aug 12Pushed 6y agoCompare

[ Source](https://github.com/nimah79/f3-zarinpal)[ Packagist](https://packagist.org/packages/nimah79/f3-zarinpal)[ Docs](https://github.com/nimah79/f3-zarinpal)[ RSS](/packages/nimah79-f3-zarinpal/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)DependenciesVersions (3)Used By (0)

F3 Zarinpal
===========

[](#f3-zarinpal)

This is a Zarinpal plugin for the [PHP Fat-Free Framework](https://github.com/bcosca/fatfree).

Features
--------

[](#features)

- Easy to use API
- Full API Methods
- Full Documented

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

[](#installation)

### Using [Composer](https://getcomposer.org)

[](#using-composer)

```
composer require nimah79/f3-zarinpal

```

Config sample
-------------

[](#config-sample)

Add these lines to your F3 config:

```
[ZARINPAL]
merchant_id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

```

Quick Start
-----------

[](#quick-start)

#### Request Authority (and redirecting user)

[](#request-authority-and-redirecting-user)

```
$zarinpal = new Zarinpal();

$zarinpal->setAmount(5500);
$zarinpal->setDescription('Purchasing test product');
$zarinpal->setCallbackURL('http://example.com/pay/verify');

$result = $zarinpal->request();
if ($result->ok) {
    $zarinpal->redirect();
} else {
    echo 'Error: ' . $result->message;
}
```

#### Verifying transaction

[](#verifying-transaction)

```
$zarinpal = new Zarinpal();

$zarinpal->setAmount(5500);

$result = $zarinpal->verify();
if ($result->ok) {
    echo 'Successful transaction!';
}
```

More!
-----

[](#more)

### Set uesr information

[](#set-uesr-information)

You can pass user information to Zarinpal. This is recommended to have more control on your transactions:

```
$zarinpal->setEmail('foo@bar.com');
$zarinpal->setMobile('09123456789');
```

### Using Sandbox

[](#using-sandbox)

You can use sandbox mode when you want to do some test transactions with custom result (succeeded or failed):

```
$zarinpal->enableSandbox();
```

### Using Zaringate

[](#using-zaringate)

By default, users will redirect to Zarinpal Webgate page, but you can transfer your users to payment gateway directly. Notice that you need to activate necessary service for using Zaringate (call Zarinpal supports):

```
$zarinpal->enableZaringate();
```

### Shared payoff

[](#shared-payoff)

> This method is suitable for those sellers whose benefit from entered price must be distributed in a special way. For example, you own a website that presents ceremony services and you have some contributions with several contractors. In this way you would keep some money and settle the rest of it to the contractors' account.

```
// 4500 Tomans from the main transaction is sent
// to ZP.125732 with this Description: Testing profit
$zarinpal->addSharedPay('ZP.125732', 4500,  'Testing profit');
```

You can also add multiple items for shared payoff:

```
$zarinpal->addSharedPay('ZP.125732', 4500, 'Testing profit');
$zarinpal->addSharedPay('ZP.133476.2', 1200, 'More testing profit');
$zarinpal->addSharedPay('ZP.197825.1', 6700, 'More than more testing profit');
```

### Long time authority

[](#long-time-authority)

By default, an authority will expire at 15 minutes after generating, but you can set your custom lifetime for your generated authority by using `expireIn()` method (between 1800 to 3888000 seconds). You should use it before `request()`:

```
// Will expire after 7200 seconds (2 hours)
$zarinpal->expireIn(7200);
```

Notice that you need to activate necessary service for using thins method (call Zarinpal supports).

### Get redirect URL

[](#get-redirect-url)

Sometimes, you need to have gateway URL instead of redirecting:

```
$zarinpal->getRedirectURL();
```

Pay attention to use this method after `$zarinpal->request()`. Look at to this example:

```
$result = $zarinpal->request();
if ($result->ok) {
    // It will return something like:
    // https://www.zarinpal.com/pg/StartPay/xxxxx/
    $zarinpal->getRedirectURL();
}
```

### Get generated authority

[](#get-generated-authority)

Normally you don't need this method, but it's possible to get pure generated authority. It also need to run after `request()`:

```
$result = $zarinpal->request();
if ($result->ok) {
    $zarinpal->getAuthority();
}
```

### Refresh Authority

[](#refresh-authority)

If you want to refresh your authority lifetime, use `refreshAuthority()`. It does the same thing that `expireIn()` does. but `refreshAuthority()` can be used when you generated an authority in past and `expireIn()` will help you to set your authority life span before generating:

```
// This will refresh your authority (xxxxxxxxxx) for 3600 seconds (1 hour)
$zarinpal->refreshAuthority("xxxxxxxxxx", 3600);
```

### Get list of unverified transactions

[](#get-list-of-unverified-transactions)

This method return a list of transactions that you didn't `verify()` them, so it sound that all transactions on this list should be uncompleted:

```
$result  =  $zarinpal->getUnverified();
if ($result->ok) {
    // Contains an array of arrays
    print_r($result->body->Authorities);
} else {
    echo $result->message;
}
```

Response
--------

[](#response)

All responses from the API will return a `Response` object. This object contains these datas:

```
{
  "ok": true|false,
  "message": string,
  "status": int,
  "body": {
    ...
  }
}

```

You can check if the request was successful or not using `ok`, get returned status in `status` and get translated status message in `message`. Also, you can access to api result in `body`.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity54

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

Total

2

Last Release

2466d ago

### Community

Maintainers

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

---

Top Contributors

[![nimah79](https://avatars.githubusercontent.com/u/20343056?v=4)](https://github.com/nimah79 "nimah79 (10 commits)")

---

Tags

paymentgatewayzarinpalF3fatfree

### Embed Badge

![Health badge](/badges/nimah79-f3-zarinpal/health.svg)

```
[![Health](https://phpackages.com/badges/nimah79-f3-zarinpal/health.svg)](https://phpackages.com/packages/nimah79-f3-zarinpal)
```

###  Alternatives

[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)[dena-a/iran-payment

a Laravel package to handle Internet Payment Gateways for Iran Banking System

312.4k1](/packages/dena-a-iran-payment)[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)
