Download the PHP package nosh/omnitax without Composer

On this page you can find all versions of the php package nosh/omnitax. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package omnitax

OmniTax

A Laravel package for real‑time fiscal (digital) invoicing with Pakistan's tax system — built for FBR, and extensible to every provincial authority and beyond.

nosh/omnitax lets any restaurant, café, or retail business issue government‑compliant invoices — the kind that carry an official fiscal invoice number and a QR code — directly from their own system. You build one plain invoice; the package reports it to the correct tax authority in real time, gets back the official invoice number, and hands you a print‑ready QR code and logo for the customer's receipt.

What's included today, and what's coming: OmniTax is made first and foremost for Pakistan's FBR and tax system. Right now it ships complete FBR (federal / PRAL), SRB (Sindh) and PRA (Punjab) integrations — SRB and PRA in both cloud and offline modes. KPRA (KP) and BRA (Balochistan) are on the roadmap (§2), and because the package is authority‑driven, adding each one (and, by design, tax systems in other countries later) is a new driver, not a rewrite of your billing code.

It is authority‑driven and multi‑tenant: one installation can serve many businesses, each connected to its own tax authority with its own credentials.


Table of contents

  1. What this package does
  2. Supported authorities & roadmap
  3. Requirements
  4. How it works
  5. Installation
  6. Configuration
  7. Before you can go live: registering with your authority
  8. Quick start — your first invoice
  9. The canonical invoice
  10. Reading the response
  11. Printing the receipt: QR code & logo
  12. Reporting a sale: real time, with a queued fallback (recommended)
  13. Multi‑tenant: one install, many restaurants
  14. Reference data (provinces, units, HS codes…)
  15. Sandbox testing & scenarios
  16. Events
  17. Artisan commands
  18. Error handling
  19. Going to production — checklist
  20. Extending: add a new authority (future‑global)
  21. FAQ
  22. Support & license

1. What this package does

In Pakistan, tax‑registered restaurants and businesses must report each sale to their tax authority and print an official fiscal invoice — one bearing a government‑issued invoice number and a QR code — for the customer. Different authorities run different systems:

This package hides all of that behind one clean API. You describe a sale once, in a neutral format, and the package:

  1. Picks the right authority driver for that business.
  2. Translates your invoice into that authority's exact payload.
  3. Validates it (dry run) and/or submits it in real time.
  4. Returns the official fiscal invoice number and the data for the QR code.
  5. Stores the invoice, its status, and the authority's response for your records.
  6. Retries safely on failure, and never double‑reports the same sale.

You never touch a government API directly, and you never rewrite your billing code when you expand to a new province or country.


2. Supported authorities & roadmap

Authority Region Applies to Status
FBR (Federal, via PRAL) Islamabad / ICT + goods Services (ICT), goods ✅ Available
SRB — Sindh Revenue Board Sindh Restaurant / services ✅ Available (cloud + offline)
PRA — Punjab Revenue Authority Punjab Restaurant / services ✅ Available (cloud + offline)
KPRA — KP Revenue Authority Khyber Pakhtunkhwa Restaurant / services ✅ Available (cloud + offline)
BRA — Balochistan Revenue Authority Balochistan Restaurant / services 🗓️ Planned
International (ZATCA, MyInvois, …) Global Any 🧭 By design — see §20

The public API in this document is identical for every authority. Enabling a new one is a configuration change, not a rewrite of your billing code.

2a. SRB (Sindh Revenue Board) — cloud & offline

SRB reports each sale to the SRB POS system and prints an SRB Invoice Number plus a QR code that encodes the SRB verification URL. SRB offers two integration modes, and this package supports both from the same code — you build the same canonical invoice and only the deployment's mode differs:

Mode For How it connects Credentials
cloud Your online / website deployment Calls the SRB gateway directly: POST https://pos.srb.gos.pk/ePOSGateway/v1/SalesInvoiceService.api Sends posUser / posPass (issued by SRB) in the request body
offline Your desktop app Calls the SRB POS Connector running on the same machine: POST http://localhost:8282/pos/SalesInvoiceServices None in the request — the Connector holds them

Pick the mode per deployment (FISCAL_SRB_MODE=cloud|offline, or the mode column per tenant). Everything else is shared.

SRB specifics the driver handles for you (per SRB's official POS API guides):

As with FBR, set FISCAL_TRANSPORT=mock to build and test the whole SRB flow — both modes — with no POS ID and no network.

2b. PRA (Punjab Revenue Authority) — cloud & offline

PRA (via PRAL) fiscalises each sale through its Software Fiscal Device / IMS and returns a PRA Invoice Number plus a QR that encodes PRA's verification URL. Like SRB, PRA offers two integration modes, and the package supports both from the same code — same canonical invoice, only the deployment's mode differs:

Mode For How it connects Auth
cloud Your online / website deployment Posts straight to PRAL: POST https://ims.pral.com.pk/ims/{sandbox\|production}/api/Live/PostData Authorization: Bearer <token> (+ TLS 1.2, and the server's IP must be whitelisted by PRA)
offline Your desktop app Posts to PRA's locally-installed Software Fiscal Device (IMS component): POST http://localhost:8524/api/IMSFiscal/GetInvoiceNumberByModel — the component then syncs to PRA on its own None — the installed component holds the POS credentials

Pick the mode per deployment (FISCAL_PRA_MODE=cloud|offline, or the mode column per tenant).

PRA specifics the driver handles (per PRAL's "Software Fiscal Device" spec v1.2):

As always, FISCAL_TRANSPORT=mock runs the whole PRA flow — both modes — with no token, no IP whitelisting and no network.

2c. KPRA (KP Revenue Authority) — cloud & offline

KPRA fiscalises each sale through its RIMS (Restaurant Invoice Monitoring System) and returns a KPRA transaction ID plus a QR that encodes KPRA's verification URL. Like SRB and PRA, KPRA offers two integration modes, and the package supports both from the same code — same canonical invoice, only the deployment's mode differs:

Mode For How it connects Auth
cloud Your online / website deployment Posts each sale to KPRA's live API: POST https://kpra.gov.pk/api/rims-integration ntn + pos_id + key in the body (HTTPS required)
offline Your desktop app Posts to the locally-installed KPRA RIMS utility: POST http://localhost:3000/api/invoice — the utility queues while offline and syncs to KPRA when the connection returns Same ntn + pos_id + key in the body

Pick the mode per deployment (FISCAL_KPRA_MODE=cloud|offline, or the mode column per tenant).

KPRA specifics the driver handles (per KPRA's RIMS API docs + OpenAPI spec):

As always, FISCAL_TRANSPORT=mock runs the whole KPRA flow — both modes, plus credit notes — with no POS ID and no network.


3. Requirements


4. How it works

The invoice you build is authority‑neutral. The driver is the only thing that knows the specific field names, URLs, and rules of a given authority — so your code stays the same everywhere.


5. Installation

Install via Composer:

Publish the configuration file:

Publish and run the migrations (they create the invoice, line‑item, credential, and reference‑data tables):

That's it — the package is wired into Laravel.


6. Configuration

6a. Single business (simplest)

If your app serves one restaurant, put its details in .env:

6b. The config file

config/omnitax.php exposes everything, with one block per authority:

You typically only ever set a token. Everything else has sensible defaults.


7. Before you can go live: registering with your authority

Fiscal invoicing is a regulated service — you need an account and a security token from your authority before real submissions work:

  1. Register your business on your authority's digital‑invoicing portal (for FBR this is the IRIS / PRAL Digital Invoicing portal).
  2. Request a Digital Invoicing security token. For FBR this token is valid for 5 years and is sent in the Authorization: Bearer … header of every request. You renew it when it expires.
  3. Put the token in .env (FISCAL_TOKEN=…) or, for multi‑tenant, in the credentials table (§13).
  4. Start in sandbox (FISCAL_SANDBOX=true) and run the built‑in scenarios (§15). When you're satisfied, flip to production.

You do not need a token to build and test your integration. The package ships a full mocked mode — set FISCAL_TRANSPORT=mock (see §6) and every submit()/validate() returns spec‑shaped responses with no token and no network, so you can develop the whole flow first. Set FISCAL_TRANSPORT=http and drop in the real token when it arrives — no code changes.


8. Quick start — your first invoice

Here's a complete restaurant dine‑in bill: one table, two line items, reported and printed. (Notice a restaurant sale is a service — saleType: "Services".)

Validate first (optional but recommended) — a dry run that checks the invoice without committing it:

Choosing the authority explicitly (otherwise the default/tenant authority is used):


9. The canonical invoice

You always build the same neutral structure; the driver maps it to the authority's exact field names.

Invoice (header):

Field Meaning Notes
type Sale Invoice or Debit Note
date Date of issuance
seller Your registered identity NTN/CNIC, name, province, address — usually from config
buyer The customer Optional for walk‑ins (walkInCustomer())
buyerRegistrationType Registered / Unregistered Set automatically by the builder
invoiceRefNo Original invoice ref Required only for debit notes
items[] The lines See below

Line item:

Field Meaning
description The dish / product / service
quantity How many
unitPrice / valueExcludingTax Value before tax
taxRate e.g. "16%"
taxAmount Computed for you if you don't pass it
saleType "Services" for restaurants; other types for goods
hsCode Product/service code (required by FBR for goods)
uom Unit of measure
plus furtherTax, extraTax, discount, fedPayable, sroScheduleNo, sroItemSerialNo — all optional

The builder computes totals and fills authority‑specific defaults so you don't have to remember every field for every authority.


10. Reading the response

Every submit() / validate() returns a FiscalResponse:

A rejection tells you exactly which line and why (e.g. itemSNo 1 → "0046 – Provide rate."), so you can fix and resubmit.


11. Printing the receipt: QR code & logo

Authorities require two marks on the printed invoice: the official QR code and the digital‑invoicing logo.

The package renders the QR to the official spec automatically (Version 2.0, 25×25, 1.0″×1.0″ for FBR). Drop $qr->dataUri() and the logo into your receipt template and you're compliant.


12. Reporting a sale: real time, with a queued fallback (recommended)

At a till you want the fiscal number on the receipt you are printing, but you can never let a slow government server hold up a payment. report() does both: it tries the authority inline for at most a few seconds, and if that cannot finish it queues the sale and returns immediately.

Outcome Record status Queued?
Accepted inside the time limit valid — fiscal_number, qr_payload set no
Authority unreachable, timed out, or 5xx pending — last_error says why yes (after your DB transaction commits)
Rejected (bad data, credentials, 4xx) failed — last_error has the authority's reason no — the same payload would be refused again

Configure it in config/omnitax.php (or .env):

You can also force either behaviour per call: report($invoice, realtime: false), or cap any call yourself with OmniTax::timeout(2.5)->submit($invoice).

Idempotent: report() on a sale that is already accepted returns its record without calling the authority, so a retried request or a reprint can never report a sale twice. Always give each sale its own number with ->number() — it is what makes the idempotency key unique (two identical sales on one day are still two sales).

reference is your own key for the sale. Look the fiscal documents up later with FiscalInvoice::forReference("bill:42")->get() (the sale and any credit notes). Each record also keeps attempts and last_error for operators, and scopes pending(), failed() and reported().

12a. Submitting in the background only

The lower-level building blocks report() uses, if you want to queue without any inline attempt and drive the record yourself:

Run a worker for the dedicated queue:

Idempotency: each invoice carries a stable key, so a retry (or a double‑click at the till) never reports the same sale twice. The job backs off and retries up to FISCAL_RETRY_ATTEMPTS when the authority is unreachable or returns 5xx (the record stays pending); a rejection marks it failed and is not retried. Anything still pending after that is picked up by fiscal:submit-pending.

12b. Refunds: credit notes

A refund is a new document that references the original sale — never a resubmission of it:

Authority Credit note
PRA ✅ InvoiceType 3 with RefUSIN
SRB ✅ invoiceType 2 (sales return)
FBR Digital Invoicing ❌ no credit note — a credit note sent to FBR is rejected locally with a clear message, never sent as an ordinary sale

12c. "Test connection" and feature checks

For a settings page:

OmniTax::for($branch)->isConfigured() is a cheap "are credentials saved at all?" for gating UI, and supports(Feature::CREDIT_NOTE | Feature::OFFLINE_MODE | Feature::REMOTE_VALIDATION) tells you what an authority can do before you try.

12d. Network behaviour


13. Multi‑tenant: one install, many restaurants

If your platform hosts many restaurants, each has its own authority, token, and seller identity. Switch the credentials driver to database:

Store each restaurant's connection (tokens are encrypted at rest):

Then scope every call to that restaurant — the package loads the right authority, token, and seller for you:

This is the "enable it per restaurant" model: a business that hasn't opted in simply has no FiscalCredential, and fiscal invoicing stays dormant for them. Turning it on is one row.

You can also resolve credentials from your own store with a closure (e.g. if they live in another service):

13a. Where each merchant enters their credentials

The package owns storage, encryption, and lookup of credentials — it does not ship a screen for typing them in. That UI is yours to build, because it belongs in your app next to the rest of a merchant's account settings. The division of labour is:

Concern Owned by
A settings form where a merchant enters their token + business details Your app (you build one small page)
Encrypting the token, storing the row, resolving it at submit time The package

So a production rollout is just: build a "Fiscal Invoicing Settings" page in your app with these fields, and on save write one FiscalCredential row:

Key it on the merchant's stable tenant id (in Nosh, the Auth tenant UUID) — the same id you later pass to OmniTax::for($tenantId). A merchant who hasn't filled the form yet has no row, so fiscal invoicing stays dormant for them until they onboard. No secret ever goes in .env or config in this model — only in the encrypted fiscal_credentials table (or your own store, via the closure above).


14. Reference data (provinces, units, HS codes…)

Authorities publish lookup lists (province codes, units of measure, HS codes, tax rates, SRO items). The package fetches, caches, and exposes them:

Keep them fresh with a scheduled sync (cached 30 days by default):


15. Sandbox testing & scenarios

Before going live you validate against your authority's sandbox using official test scenarios. For FBR these are SN001–SN028. The one that matters for a restaurant is:

In sandbox the package automatically attaches the required scenarioId; in production it's omitted.


16. Events

Hook into the lifecycle without touching the package:

Event Fires when
InvoiceSubmitting just before a call to the authority
InvoiceAccepted the authority accepted the invoice
InvoiceRejected the authority rejected it (with errors)
CredentialsMissing a tenant tried to submit with no fiscal credentials

17. Artisan commands


18. Error handling

Common authority error codes (surfaced verbatim):

Code Meaning
0001 Seller not registered for sales tax
0002 Invalid buyer registration / NTN
0005 Invalid date format
0046 Missing rate
0052 Invalid HS code
0401 Unauthorized seller access
0402 Unauthorized buyer access

HTTP: 200 OK · 401 Unauthorized (bad/expired token) · 500 authority‑side error (retried automatically).


19. Going to production — checklist


20. Extending: add a new authority (future‑global)

Every authority is just a driver implementing one interface:

To add one (a new province, or a new country such as KSA ZATCA or Malaysia MyInvois):

  1. Create a driver that maps the canonical invoice to that authority's payload and parses its response into a FiscalResponse.
  2. Register it and add a config block with its endpoints.
  3. Done — every calling application uses it through the exact same API (OmniTax::authority('zatca')->submit($invoice)).

Because the invoice your app builds is authority‑neutral, going international never changes your billing code — only a driver is added. This is the seam that makes the package global‑ready from day one.


21. FAQ

Do I need a token to start building? No. Develop and test the whole flow in sandbox/mock mode, then drop the real token in when it arrives.

My restaurant is in Punjab — do I use FBR? No. Dine‑in is a provincial service → use PRA. Set FISCAL_AUTHORITY=pra (or the tenant's authority). FBR is for ICT/Islamabad and goods.

Can one platform serve restaurants in different provinces? Yes — that's the multi‑tenant model (§13). Each restaurant's FiscalCredential points at its own authority.

Will this work outside Pakistan later? Yes by design — a new country is a new driver (§20); your integration code doesn't change.

What happens if the government API is down mid‑service? Invoices queue as pending, retry with backoff, and are never double‑reported. Billing at the till isn't blocked.


22. Support & license

For integration help, sandbox onboarding, or enabling a new authority, contact the Nosh team.


All versions of omnitax with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
illuminate/support Version ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/database Version ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/bus Version ^10.0 || ^11.0 || ^12.0 || ^13.0
illuminate/queue Version ^10.0 || ^11.0 || ^12.0 || ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nosh/omnitax contains the following files

Loading the files please wait ...