PHPackages                             hiqdev/php-billing - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hiqdev/php-billing

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hiqdev/php-billing
==================

PHP Billing Library

6618.6k11[1 issues](https://github.com/hiqdev/php-billing/issues)[3 PRs](https://github.com/hiqdev/php-billing/pulls)1PHPCI passing

Since May 17Pushed 6d ago5 watchersCompare

[ Source](https://github.com/hiqdev/php-billing)[ Packagist](https://packagist.org/packages/hiqdev/php-billing)[ RSS](/packages/hiqdev-php-billing/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (21)Used By (1)

PHP Billing Library
===================

[](#php-billing-library)

[![Latest Stable Version](https://camo.githubusercontent.com/1f2bec3516a9c28316721f833d01fb96a30b9164aecd208be3178dcd719876bf/68747470733a2f2f706f7365722e707567782e6f72672f6869716465762f7068702d62696c6c696e672f762f737461626c65)](https://packagist.org/packages/hiqdev/php-billing)[![Total Downloads](https://camo.githubusercontent.com/97573673e7152bbb10be71b0d6b28dbb60366b7927c1954e3d355d9193d5612f/68747470733a2f2f706f7365722e707567782e6f72672f6869716465762f7068702d62696c6c696e672f646f776e6c6f616473)](https://packagist.org/packages/hiqdev/php-billing)[![codecov](https://camo.githubusercontent.com/d6496dd5c751b7166038fddbc8cbb1df3c4fcc6b21d3de8d41b98619735f6ab8/68747470733a2f2f636f6465636f762e696f2f67682f6869716465762f7068702d62696c6c696e672f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/hiqdev/php-billing)[![phpunit-tests](https://github.com/hiqdev/php-billing/actions/workflows/phpunit-tests.yml/badge.svg)](https://github.com/hiqdev/php-billing/actions/workflows/phpunit-tests.yml/badge.svg)[![behat-tests](https://github.com/hiqdev/php-billing/actions/workflows/behat-tests.yml/badge.svg)](https://github.com/hiqdev/php-billing/actions/workflows/behat-tests.yml/badge.svg)[![psalm](https://github.com/hiqdev/php-billing/actions/workflows/psalm-analysis.yml/badge.svg)](https://github.com/hiqdev/php-billing/actions/workflows/psalm-analysis.yml/badge.svg)[![phpcs](https://github.com/hiqdev/php-billing/actions/workflows/phpcs.yml/badge.svg)](https://github.com/hiqdev/php-billing/actions/workflows/phpcs.yml/badge.svg)

A pure domain library for billing and invoicing. No framework dependency — drop it into any PHP 8.3+ project.

It models the full billing pipeline: customers subscribe to resources under pricing plans, metered activities are recorded as actions, the calculator matches actions to prices to produce charges, and the aggregator groups charges into bills.

Supports one-time, metered, and recurring charging with multiple pricing strategies (fixed per-unit, percentage-based, tiered/progressive, discrete lookup), a formula DSL for smart discounts and installments, and a reseller hierarchy.

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

[](#installation)

```
composer require hiqdev/php-billing
```

How It Works
------------

[](#how-it-works)

```
Customer → Plan → Price
                    ↓
Sale → Action → Calculator → Charge → Aggregator → Bill

```

1. A **Customer** subscribes to a **Target** (resource) under a **Plan** via a **Sale**
2. Metered activity is recorded as an **Action** (type, target, quantity, time)
3. **Calculator** matches each Action against Prices in the Plan → produces **Charges**
4. **Aggregator** groups Charges into **Bills** (invoice line items)
5. **Billing** orchestrates steps 3–4 and optionally persists the result

Core Entities
-------------

[](#core-entities)

EntityRole**Action**A customer's metered activity of a certain Type at a certain Target**Sale**Subscription binding a Customer to a Target under a Plan**Plan**A tariff containing a set of Prices**Price**A billing rule — SinglePrice, EnumPrice, RatePrice, or ProgressivePrice**Charge**Result of matching an Action to a Price**Bill**Aggregation of Charges into an invoice line item**Calculator**Orchestrates the billing pipeline**Aggregator**Groups Charges into Bills by unique key**Billing**Top-level entry point: calculate + aggregate + persist[![Model UML](https://camo.githubusercontent.com/e72f56f239669b2a458f21225db293a8080ce99502c91f9cc26afc12aff4f1ce/687474703a2f2f7777772e706c616e74756d6c2e636f6d2f706c616e74756d6c2f70726f78793f63616368653d6e6f267372633d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6869716465762f7068702d62696c6c696e672f6d61737465722f646f63732f6d6f64656c2e70756d6c)](https://camo.githubusercontent.com/e72f56f239669b2a458f21225db293a8080ce99502c91f9cc26afc12aff4f1ce/687474703a2f2f7777772e706c616e74756d6c2e636f6d2f706c616e74756d6c2f70726f78793f63616368653d6e6f267372633d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f6869716465762f7068702d62696c6c696e672f6d61737465722f646f63732f6d6f64656c2e70756d6c)

Documentation
-------------

[](#documentation)

- [Domain Model](docs/domain-model.md) — core entities, state objects, immutability rules, calculator pipeline, orchestration
- [Price Types](docs/price-types.md) — SinglePrice, EnumPrice, RatePrice, ProgressivePrice algorithms
- [Formula DSL and Charge Modifiers](docs/formula-and-modifiers.md) — discount, installment, cap, modifier system, ChargeDerivative
- [Product Subsystem](docs/product-subsystem.md) — tariff type registry, behaviors, invoice representations
- [Codebase Overview](docs/overview.md) — directory map, patterns, and testing

Integration Points
------------------

[](#integration-points)

This library is the billing core — a foundation that needs surrounding infrastructure to become a complete billing system. Typical layers built on top:

- **Storage** — implement `PlanRepositoryInterface`, `SaleRepositoryInterface`, `BillRepositoryInterface`, etc. to connect to your database
- **Action producers** — translate business events (purchases, resource measurements) into `Action` objects
- **Scheduler** — periodic jobs that fetch usage metrics, create Actions, run `Billing::perform()`, and update Bills
- **Plan management UI** — lets managers create Plans, configure Prices, and assign Plans to Customers
- **Read API** — query layer for Bills, Charges, Actions with filtering, ordering, and access control

Many of these layers are use-case specific. This package provides the calculation engine; persistence, scheduling, and UI are your responsibility.

License
-------

[](#license)

This project is released under the terms of the BSD-3-Clause [license](LICENSE). Read more [here](http://choosealicense.com/licenses/bsd-3-clause).

Copyright © 2017-2026, HiQDev ()

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance64

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/790fd24da129907d373559f60c6994f664f06e3f518502c03580cc9f3594615e?d=identicon)[hiqdev](/maintainers/hiqdev)

![](https://www.gravatar.com/avatar/99106256c24a8cb23871b99fa90e48f37f1aa71608c185759b7d2a88683a5918?d=identicon)[hiqsol](/maintainers/hiqsol)

---

Top Contributors

[![hiqsol](https://avatars.githubusercontent.com/u/11820365?v=4)](https://github.com/hiqsol "hiqsol (494 commits)")[![SilverFire](https://avatars.githubusercontent.com/u/4499203?v=4)](https://github.com/SilverFire "SilverFire (179 commits)")[![VadymHrechukha](https://avatars.githubusercontent.com/u/114911409?v=4)](https://github.com/VadymHrechukha "VadymHrechukha (156 commits)")[![bladeroot](https://avatars.githubusercontent.com/u/10207103?v=4)](https://github.com/bladeroot "bladeroot (22 commits)")[![tafid](https://avatars.githubusercontent.com/u/3338188?v=4)](https://github.com/tafid "tafid (21 commits)")[![ValeriyShnurovoy](https://avatars.githubusercontent.com/u/16237008?v=4)](https://github.com/ValeriyShnurovoy "ValeriyShnurovoy (14 commits)")[![strorch](https://avatars.githubusercontent.com/u/23340907?v=4)](https://github.com/strorch "strorch (3 commits)")[![gadezist](https://avatars.githubusercontent.com/u/39760138?v=4)](https://github.com/gadezist "gadezist (2 commits)")[![marclaporte](https://avatars.githubusercontent.com/u/1004261?v=4)](https://github.com/marclaporte "marclaporte (1 commits)")

---

Tags

hacktoberfest

### Embed Badge

![Health badge](/badges/hiqdev-php-billing/health.svg)

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

###  Alternatives

[seyfer/kohana-pagination

Kohana module to manage pagination quick and easy

112.9k](/packages/seyfer-kohana-pagination)

PHPackages © 2026

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