PHPackages                             jooyeshgar/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. jooyeshgar/moadian

ActiveLibrary[API Development](/categories/api)

jooyeshgar/moadian
==================

Laravel package for interacting with the Moadian API of intamedia.ir

V3.0.0(1mo ago)376.3k↑107.1%15[14 issues](https://github.com/Jooyeshgar/moadian/issues)[1 PRs](https://github.com/Jooyeshgar/moadian/pulls)GPL-3.0PHPPHP ^7.4|^8.0

Since May 3Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/Jooyeshgar/moadian)[ Packagist](https://packagist.org/packages/jooyeshgar/moadian)[ Docs](https://github.com/Jooyeshgar/moadian)[ RSS](/packages/jooyeshgar-moadian/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (14)Versions (20)Used By (0)

Laravel Moadian API Driver (API Only)
=====================================

[](#laravel-moadian-api-driver-api-only)

This Laravel package provides a convenient way to interact with the API of the "Moadian system" (سامانه مودیان) offered by intamedia.ir. With this package, you can easily make requests to the Moadian API and handle the responses in your Laravel application.

**Important Notice:** This package provides access to the Moadian system API and is not intended for direct user interaction. It's designed for developers integrating Moadian functionality into their applications.

For a user-friendly accounting software experience, we recommend checking out our FreeAmin project (under **development**):

- Link:

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

[](#requirements)

This package requires Laravel 8 or higher. It has been tested with Laravel 8 and PHP 7.4, as well as with Laravel 10 and PHP 8.1.

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

[](#installation)

To install this package, simply run the following command:

```
composer require jooyeshgar/moadian
```

Usage
-----

[](#usage)

To use this package, you will need to obtain a username, private key and certificate from intamedia.ir. Once you have your credentials, you can configure the package in your Laravel application's `.env` file:

```
MOADIAN_USERNAME=your-username-here
MOADIAN_PRIVATE_KEY_PATH=/path/to/private.pem
MOADIAN_CERTIFICATE_PATH=/path/to/certificate.crt

```

The default location to store the private key is: storage\_path('app/keys/private.pem');
The default location to store the certificate is: storage\_path('app/keys/certificate.crt');

You can then use the `Moadian` facade to interact with the Moadian API. Here are some examples:

```
use Jooyeshgar\Moadian\Facades\Moadian;

// Get server info
$info = Moadian::getServerInfo();

// Get fiscal info
$fiscalInfo = Moadian::getFiscalInfo();

// Get economic code information
$info = Moadian::getEconomicCodeInformation('10840096498');

// Inquiry by reference numbers
$info = Moadian::inquiryByReferenceNumbers('a45aa663-6888-4025-a89d-86fc789672a0');
```

### Send Invoice

[](#send-invoice)

To send an invoice to Moadian, you can use the sendInvoice() method provided by the plugin. Here's an example of how to use it:

```
use Jooyeshgar\Moadian\Invoice as MoadianInvoice;
use Jooyeshgar\Moadian\InvoiceHeader;
use Jooyeshgar\Moadian\InvoiceItem;
use Jooyeshgar\Moadian\Payment;

public function sendInvoice($invoiceId = '') {
    $invoiceId = intval($invoiceId);
    $invoice = Invoice::find($invoiceId);

    if (!$invoice) {
        throw new Exception('Invoice not found');
    }

    $timestamp = Carbon::parse($invoice->date)->timestamp * 1000;

    $header = new InvoiceHeader(env('MOADIAN_USERNAME'));
    $header->setTaxID(Carbon::parse($invoice->date), $invoice->number);
    $header->indati2m = $timestamp;
    $header->indatim = $timestamp;
    $header->inty = 1; //invoice type
    $header->inno = $invoiceId;
    $header->irtaxid = null; // invoice reference tax ID
    $header->inp = $invoice->inp; //invoice pattern
    $header->ins = 1;
    $header->tins = env('TAXID');
    $header->tob = 2;
    $header->bid = $invoice->nationalnum;
    $header->tinb = $invoice->nationalnum;
    $header->bpc = $invoice->postal;

    $amount   = $invoice->items->sum('amount');
    $discount = $invoice->items->sum('discount');
    $vat      = $invoice->items->sum('vat');
    $header->tprdis = $amount;
    $header->tdis = $discount;
    $header->tadis = $amount - $discount;
    $header->tvam = $vat;
    $header->todam = 0;
    $header->tbill = $amount - $discount + $vat;
    $header->setm = $invoice->setm;
    $header->cap = $amount - $discount + $vat;

    $moadianInvoice = new MoadianInvoice($header);

    foreach ($invoice->items as $item) {
        $body = new InvoiceItem();
        $body->sstid = $item->seals->sstid;
        $body->sstt = $item->desc;
        $body->am = '1';
        $body->mu = 1627;
        $body->fee = $item->amount;
        $body->prdis = $item->amount;
        $body->dis = $item->discount;
        $body->adis = $item->amount - $item->discount;
        $body->vra = 9;
        $body->vam = $item->vat; // or directly calculate here like floor($body->adis * $body->vra / 100)
        $body->tsstam = $item->amount - $item->discount + $item->vat;
        $moadianInvoice->addItem($body);
    }

    foreach ($invoice->cashes as $cashe) {
        if ($cashe->active == 1) {
            $payment = new Payment();
            $payment->trn = $cashe->code;
            $payment->pdt = Carbon::parse($cashe->date)->timestamp * 1000;
            $moadianInvoice->addPayment($payment);
        }
    }

    $info = Moadian::sendInvoice($moadianInvoice);
    $info = $info->getBody();
    $info = $info['result'][0];

    $invoice->taxID           = $header->taxid;
    $invoice->uid             = $info['uid'] ?? '';
    $invoice->referenceNumber = $info['referenceNumber'] ?? '';
    $invoice->taxResult       = 'send';

    $invoice->save();
}
```

Note that you need to have a valid Moadian account and credentials to use this plugin.

There are other types of invoices (Cancellation, corrective, Sales return) that you can send with this package. For more information about different types of invoices and how to send them, please refer to the official document.

Useful Links
------------

[](#useful-links)

- [The regulation of store terminals](https://www.intamedia.ir/The-regulation-of-store-terminals)
- [Guide to extract public key from digital signature](https://www.intamedia.ir/The-regulation-of-store-terminals/ID/15879/%D8%B1%D8%A7%D9%87%D9%86%D9%85%D8%A7%DB%8C-%D8%A7%D8%B3%D8%AA%D8%AE%D8%B1%D8%A7%D8%AC-%DA%A9%D9%84%DB%8C%D8%AF-%D8%B9%D9%85%D9%88%D9%85%DB%8C-%D8%A7%D8%B2-%D8%A7%D9%85%D8%B6%D8%A7%DB%8C-%D8%AF%DB%8C%D8%AC%DB%8C%D8%AA%D8%A7%D9%84%D9%85%D9%87%D8%B1%D8%B3%D8%A7%D8%B2%D9%85%D8%A7%D9%86%DB%8C-%D9%88-%D8%A8%D8%A7%D8%B1%DA%AF%D8%B0%D8%A7%D8%B1%DB%8C-%D8%A2%D9%86-%D8%AF%D8%B1-%DA%A9%D8%A7%D8%B1%D9%BE%D9%88%D8%B4%D9%87-%D8%B3%D8%A7%D9%85%D8%A7%D9%86%D9%87-%D9%85%D9%88%D8%AF%DB%8C%D8%A7%D9%86)

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

[](#contributing)

If you find a bug or would like to contribute to this package, please feel free to [submit an issue](https://github.com/Jooyeshgar/moadian/issues) or [create a pull request](https://github.com/Jooyeshgar/moadian/pulls).

License
-------

[](#license)

This package is open source software licensed under the [GPL-3.0 license](https://opensource.org/licenses/GPL-3.0).

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity37

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~254 days

Total

15

Last Release

33d ago

Major Versions

v0.6 → v1.02023-05-21

V1.1.2 → v2.0.0-beta2023-10-18

v2.0.1 → V3.0.02026-06-01

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9395832?v=4)[Hadi](/maintainers/hadi60)[@hadi60](https://github.com/hadi60)

---

Top Contributors

[![hbhossein](https://avatars.githubusercontent.com/u/52930093?v=4)](https://github.com/hbhossein "hbhossein (41 commits)")[![hadi60](https://avatars.githubusercontent.com/u/9395832?v=4)](https://github.com/hadi60 "hadi60 (32 commits)")[![mr-mr7](https://avatars.githubusercontent.com/u/38888744?v=4)](https://github.com/mr-mr7 "mr-mr7 (10 commits)")[![amizayi](https://avatars.githubusercontent.com/u/68772394?v=4)](https://github.com/amizayi "amizayi (1 commits)")[![hosseinjarrahi](https://avatars.githubusercontent.com/u/37629053?v=4)](https://github.com/hosseinjarrahi "hosseinjarrahi (1 commits)")

---

Tags

laravelmoadianintamedia

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

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

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k108.5M886](/packages/laravel-socialite)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[civicrm/civicrm-core

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

751291.4k43](/packages/civicrm-civicrm-core)[tempest/framework

The PHP framework that gets out of your way.

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

PHPackages © 2026

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