PHPackages                             marslankhalid/fbr-ims-laravel - 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. marslankhalid/fbr-ims-laravel

ActiveLibrary[Payment Processing](/categories/payments)

marslankhalid/fbr-ims-laravel
=============================

A Laravel client for Pakistan FBR IMS invoice web services.

0.1(yesterday)00MITPHP ^8.1

Since Jul 19Compare

[ Source](https://github.com/marslankhalid/fbr-ims-laravel)[ Packagist](https://packagist.org/packages/marslankhalid/fbr-ims-laravel)[ RSS](/packages/marslankhalid-fbr-ims-laravel/feed)WikiDiscussions Synced today

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

FBR IMS Laravel
===============

[](#fbr-ims-laravel)

[![Tests](https://github.com/marslankhalid/fbr-ims-laravel/actions/workflows/tests.yml/badge.svg)](https://github.com/marslankhalid/fbr-ims-laravel/actions/workflows/tests.yml)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE.md)

A small Laravel package for posting invoices to Pakistan FBR's IMS invoice web service. It supports environment-specific endpoints and credentials, typed invoice objects, gateway-fault parsing, and the documented IMS success response.

> This community package is not affiliated with or endorsed by FBR. Confirm endpoint, authentication, payload, and tax requirements with FBR before production use.

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

[](#requirements)

- PHP 8.1+
- Laravel 9–12

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

[](#installation)

```
composer require marslankhalid/fbr-ims-laravel
php artisan vendor:publish --tag=fbr-ims-config
```

Configure `.env`:

```
FBR_IMS_ENVIRONMENT=sandbox
FBR_SANDBOX_URL=https://esp.fbr.gov.pk:8244/FBR/v1/api/Live/PostData
FBR_IMS_SANDBOX_TOKEN=
FBR_IMS_SANDBOX_POS_ID=

FBR_PRODUCTION_URL=https://gw.fbr.gov.pk/imsp/v1/api/Live/PostData
FBR_IMS_PRODUCTION_TOKEN=
FBR_IMS_PRODUCTION_POS_ID=
```

Usage with arrays
-----------------

[](#usage-with-arrays)

```
use MarslanKhalid\FbrIms\Contracts\Client;

$response = app(Client::class)->post([
    'InvoiceNumber' => '',
    'POSID' => 110014,
    'USIN' => 'USIN0',
    'DateTime' => '2026-07-20 12:00:00',
    'BuyerName' => 'Buyer Name',
    'BuyerPhoneNumber' => '03001234567',
    'TotalBillAmount' => 117,
    'TotalQuantity' => 1,
    'TotalSaleValue' => 100,
    'TotalTaxCharged' => 17,
    'Discount' => 0,
    'FurtherTax' => 0,
    'PaymentMode' => 1,
    'RefUSIN' => null,
    'InvoiceType' => 1,
    'Items' => [[
        'ItemCode' => 'IT_1011',
        'ItemName' => 'Test Item',
        'PCTCode' => '11001010',
        'Quantity' => 1,
        'TaxRate' => 17,
        'SaleValue' => 100,
        'Discount' => 0,
        'TaxCharged' => 17,
        'FurtherTax' => 0,
        'TotalAmount' => 117,
        'InvoiceType' => 1,
        'RefUSIN' => null,
    ]],
]);

if ($response->successful()) {
    $invoiceNumber = $response->invoiceNumber;
} else {
    report("FBR error {$response->code}: {$response->message} {$response->description}");
}
```

Typed invoice objects
---------------------

[](#typed-invoice-objects)

```
use MarslanKhalid\FbrIms\Data\Invoice;
use MarslanKhalid\FbrIms\Data\InvoiceItem;
use MarslanKhalid\FbrIms\Facades\FbrIms;

$item = new InvoiceItem(
    itemCode: 'IT_1011',
    itemName: 'Test Item',
    pctCode: '11001010',
    quantity: 1,
    taxRate: 17,
    saleValue: 100,
    discount: 0,
    taxCharged: 17,
    totalAmount: 117,
);

$invoice = new Invoice(
    posId: 110014,
    usin: 'USIN0',
    dateTime: now(),
    totalBillAmount: 117,
    totalQuantity: 1,
    totalSaleValue: 100,
    totalTaxCharged: 17,
    items: [$item],
);

$response = FbrIms::post($invoice);
```

Responses
---------

[](#responses)

Successful IMS responses such as the following are normalized:

```
{"InvoiceNumber":"192757FGNA32386557","Code":"100","Response":"Invoice received successfully"}
```

Gateway faults are preserved, including WSO2 code `900908` (`Resource forbidden`). Use `$response->body` and `$response->rawBody` for audit logging.

Security and idempotency
------------------------

[](#security-and-idempotency)

- Keep tokens in environment variables; never commit them.
- Use a unique `USIN` for each business invoice.
- Persist the request and complete response before retrying.
- If FBR returns code `100`, store the returned invoice number and do not repost the invoice.
- A transport timeout is ambiguous: reconcile with FBR before retrying.

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

License
-------

[](#license)

MIT

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

[](#contributing)

Contributions are welcome. Read [CONTRIBUTING.md](CONTRIBUTING.md) for the development workflow and [CODE\_OF\_CONDUCT.md](CODE_OF_CONDUCT.md) before opening an issue or pull request.

Security vulnerabilities should be reported privately as described in [SECURITY.md](SECURITY.md), not through public issues.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16500135?v=4)[Muhammad Arslan Khalid](/maintainers/marslankhalid)[@marslankhalid](https://github.com/marslankhalid)

---

Tags

laravelinvoiceIMSpakistanfbr

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/marslankhalid-fbr-ims-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/marslankhalid-fbr-ims-laravel/health.svg)](https://phpackages.com/packages/marslankhalid-fbr-ims-laravel)
```

###  Alternatives

[laravel/socialite

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

5.7k108.5M922](/packages/laravel-socialite)[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.5k21.5M663](/packages/laravel-boost)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M176](/packages/spatie-laravel-health)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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