PHPackages                             kiankamgar/php-moadian - 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. [API Development](/categories/api)
4. /
5. kiankamgar/php-moadian

ActiveLibrary[API Development](/categories/api)

kiankamgar/php-moadian
======================

This PHP SDK provides seamless integration with the tp.tax.gov.ir API, also known as Karpoosheh or Moadian. The tp.tax.gov.ir platform offers a range of tax-related functionalities, and this SDK simplifies the process of incorporating those features into your PHP applications.

v1.0.1(2y ago)6331MITPHPPHP ^8.0

Since Apr 15Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kiankamgar/php-moadian)[ Packagist](https://packagist.org/packages/kiankamgar/php-moadian)[ RSS](/packages/kiankamgar-php-moadian/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

PHP Moadian
===========

[](#php-moadian)

[![Total Downloads](https://camo.githubusercontent.com/7796c143c7e03e3f1f378bd85d4760c769cbdf090afb96dfe70b35ede9989799/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b69616e6b616d6761722f7068702d6d6f616469616e)](https://packagist.org/packages/kiankamgar/php-moadian)[![Latest Stable Version](https://camo.githubusercontent.com/d7f3b11d2b201fbb263f56677170386e8b52c66dbc6b07553ff9034363c710eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69616e6b616d6761722f7068702d6d6f616469616e)](https://packagist.org/packages/kiankamgar/php-moadian)[![License](https://camo.githubusercontent.com/acc219e384f4db30a03f2f594edd7a4a1d21aae3c8426e74b3c626cffad916b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6b69616e6b616d6761722f7068702d6d6f616469616e)](https://packagist.org/packages/kiankamgar/php-moadian)

PHP SDK for tp.tax.gov.ir API (Karpoosheh/Moadian)

This PHP SDK provides a convenient way to interact with the tp.tax.gov.ir API, also known as Karpoosheh or Moadian. By integrating this SDK into your PHP applications, you can seamlessly access and utilize the functionalities offered by the tp.tax.gov.ir APIs.

Features
--------

[](#features)

- **Easy Integration**: Simplifies the process of integrating tp.tax.gov.ir API into your PHP projects.
- **Comprehensive Functionality**: Access a wide range of functionalities offered by the tp.tax.gov.ir platform.
- **Robust and Secure**: Built with attention to security and reliability, ensuring safe interactions with the API.

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- Composer for installation

### Composer Dependencies

[](#composer-dependencies)

```
{
   "require": {
      "php": "^8.0",
      "guzzlehttp/guzzle": "^7.5",
      "ext-json": "*",
      "ext-openssl": "*",
      "ext-ctype": "*",
      "phpseclib/phpseclib": "~3.0"
   }
}
```

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

[](#getting-started)

1. Get memory id (fiscal id), private key and certificate files from tp.tax.gov.ir.
2. Install the SDK via Composer:

    ```
    composer require kiankamgar/php-moadian
    ```
3. Start utilizing the various methods provided by the SDK to interact with the API.

Usage
-----

[](#usage)

Require composer autoload file:

```
require_once __DIR__ . '/vendor/autoload.php';
```

Create an instance from Moadian class:

```
use KianKamgar\MoadianPhp\Moadian;

$moadian = new Moadian(
        $privateKeyFilePath,
        $certificateFilePath,
        $memoryId,
        $economicalCode
    );
```

Now you can use these APIs:

### Get fiscal information

[](#get-fiscal-information)

```
$fiscalInformation = $moadian->getFiscalInformation();

$economicCode = $fiscalInformation->getEconomicCode();
$fiscalStatus = $fiscalInformation->getFiscalStatus();
$nameTrade = $fiscalInformation->getNameTrade();
$nationalId = $fiscalInformation->getNationalId();
```

### Get tax payer

[](#get-tax-payer)

```
$taxPayer = $moadian->getTaxPayer();

$nameTrade = $taxPayer->getNameTrade();
$nationalId = $taxPayer->getNationalId();
$taxpayerStatus = $taxPayer->getTaxpayerStatus();
```

### Send invoice

[](#send-invoice)

#### Create invoice

[](#create-invoice)

Each invoice contains header, body array and payment array (payment array is optional). You can create invoice with Invoice helper:

```
use KianKamgar\MoadianPhp\Invoice;

$invoice = new Invoice();
$invoice->header($moadian->getMemoryId())
        ->setInty(1)
        ->setInp(1)
        ->setIns(1)
        ->setTins("14003778990")
        ->setTob(2)
        ->setBid("10100302746")
        ->setTinb("10100302746")
        ->setTprdis(20_000)
        ->setTdis(500)
        ->setTadis(19_500)
        ->setTvam(1_755)
        ->setTodam(0)
        ->setTbill(21_255)
        ->setSetm(2);

$invoice->body()
        ->setSstid("2710000138624")
        ->setSstt("title")
        ->setMu("164")
        ->setAm(2)
        ->setFee(10_000)
        ->setPrdis(20_000)
        ->setDis(500)
        ->setAdis(19_500)
        ->setVra(9)
        ->setVam(1_755)
        ->setTsstam(21255)
        ->build();

$invoice->body()
        ->setSstid("2710000138624")
        ->setSstt("another title")
        ->setMu("164")
        ->setAm(2)
        ->setFee(10_000)
        ->setPrdis(20_000)
        ->setDis(500)
        ->setAdis(19_500)
        ->setVra(9)
        ->setVam(1_755)
        ->setTsstam(21255)
        ->build();

$invoice->payment()
        ->setPcn('pcn')
        ->setPv(10)
        ->build();
```

#### Send invoices

[](#send-invoices)

Now that you have created your invoice objects you can send your invoices with two options:

1. If you just want to send invoices and do not need inquiry, you can do this:

```
$response = $moadian->sendInvoices(
        $invoice1,
        $invoice2,
        $invoice3,
        ...
    );

$timestamp = $response->getTimestamp();
$result = $response->getResult();
```

2. If you want to send invoices and get the inquiry for each as well, you can do this:

***NOTE:*** keep in mind that you need to wait at least 10 seconds to be able to inquiry an invoice, therefor in this case your request will take at least 10 seconds

```
$response = $moadian->sendInvoicesWithResponse(
        $invoice1,
        $invoice2,
        $invoice3,
        ...
    );

$result = $response->getResult();
```

### Inquiry sent invoices

[](#inquiry-sent-invoices)

1. By reference id(s)

```
$inquiry = $moadian->getInquiryByReferenceIds(['referenceId1', 'referenceId2']);

$result = $inquiry->getResult();
```

You can pass start and end as well to filter results (both are optional):

```
$start = new DateTime();
$end = (new DateTime())->modify('+1 day');

$inquiry = $moadian->getInquiryByReferenceIds(
  ['referenceId1', 'referenceId2'],
  $start,
  $end
);

$result = $inquiry->getResult();
```

2. By uid

```
$inquiry = $moadian->getInquiryByUid(['uid1', 'uid2']);

$result = $inquiry->getResult();
```

You can pass start and end as well to filter results (both are optional):

```
$start = new DateTime();
$end = (new DateTime())->modify('+1 day');

$inquiry = $moadian->getInquiryByUid(
  ['uid1', 'uid2'],
  $start,
  $end
);

$result = $inquiry->getResult();
```

3. By Time

```
// inquiry sent invoices in the past 24 hours
$inquiry = $moadian->getInquiryByTime();

$result = $inquiry->getResult();
```

Also, you can pass optional parameters:

```
use KianKamgar\MoadianPhp\Enums\InvoiceStatus;

$start = new DateTime();
$end = (new DateTime())->modify('+1 day');
$inquiry = $moadian->getInquiryByTime(
  $pageNumber, // default = 1
  $pageSize, // default = 10
  InvoiceStatus::SUCCESS,
  $start,
  $end
);

$result = $inquiry->getResult();
```

Contributing
------------

[](#contributing)

Contributions, bug reports, and feature requests are welcome! Please feel free to open issues or submit pull requests.

License
-------

[](#license)

This SDK is open-source and licensed under the MIT License. See the [LICENSE](https://github.com/kiankamgar/php-moadian/blob/main/LICENSE) file for more details.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

Total

2

Last Release

798d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/43221882?v=4)[Kian Kamgar](/maintainers/kiankamgar)[@kiankamgar](https://github.com/kiankamgar)

---

Top Contributors

[![kiankamgar](https://avatars.githubusercontent.com/u/43221882?v=4)](https://github.com/kiankamgar "kiankamgar (26 commits)")

---

Tags

composerfinancekarpooshehmoadianphpsdksdk-phptax

### Embed Badge

![Health badge](/badges/kiankamgar-php-moadian/health.svg)

```
[![Health](https://phpackages.com/badges/kiankamgar-php-moadian/health.svg)](https://phpackages.com/packages/kiankamgar-php-moadian)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k41](/packages/civicrm-civicrm-core)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M567](/packages/shopware-core)[soneso/stellar-php-sdk

Stellar PHP SDK for the Stellar Network

4154.3k4](/packages/soneso-stellar-php-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)[aimeos/prisma

A powerful PHP package for integrating media related Large Language Models (LLMs) into your applications

1943.1k5](/packages/aimeos-prisma)

PHPackages © 2026

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