1- # PHP Billing
2-
3- ** PHP Billing Library**
1+ # PHP Billing Library
42
53[ ![ Latest Stable Version] ( https://poser.pugx.org/hiqdev/php-billing/v/stable )] ( https://packagist.org/packages/hiqdev/php-billing )
64[ ![ Total Downloads] ( https://poser.pugx.org/hiqdev/php-billing/downloads )] ( https://packagist.org/packages/hiqdev/php-billing )
75![ phpunit-tests] ( https://github.com/hiqdev/php-billing/actions/workflows/phpunit-tests.yml/badge.svg )
86![ behat-tests] ( https://github.com/hiqdev/php-billing/actions/workflows/behat-tests.yml/badge.svg )
9- [ ![ Build Status] ( https://img.shields.io/travis/hiqdev/php-billing.svg )] ( https://travis-ci.org/hiqdev/php-billing )
10- [ ![ Scrutinizer Code Coverage] ( https://img.shields.io/scrutinizer/coverage/g/hiqdev/php-billing.svg )] ( https://scrutinizer-ci.com/g/hiqdev/php-billing/ )
11- [ ![ Scrutinizer Code Quality] ( https://img.shields.io/scrutinizer/g/hiqdev/php-billing.svg )] ( https://scrutinizer-ci.com/g/hiqdev/php-billing/ )
12-
13- Billing library providing:
14-
15- - customers with subscriptions
16- - orders with actions
17- - tariff plans with prices
18- - smart discounts with formulas
19- - bills with charges
20- - calculator and aggregator
21-
22- - one-time, metered and recurring charging
23-
24- Please see [ additional documentation in russian] ( docs/ru.md ) .
25-
26- ## Installation
27-
28- The preferred way to install this library is through [ composer] ( http://getcomposer.org/download/ ) .
297
30- Either run
8+ A pure domain library for billing and invoicing. It models the full billing pipeline:
9+ [ Customer] s subscribe to [ Target] s under [ Plan] s (via [ Sale] s), metered activities
10+ are recorded as [ Action] s, the [ Calculator] matches Actions to [ Price] s within Plans
11+ to produce [ Charge] s, and the [ Aggregator] groups Charges into [ Bill] s.
3112
32- ``` sh
33- php composer.phar require " hiqdev/php-billing "
34- ```
13+ The library supports one-time, metered, and recurring charging with multiple pricing
14+ strategies (fixed per-unit, percentage-based, tiered/progressive, discrete lookup),
15+ a formula DSL for smart discounts and installments, and a reseller hierarchy.
3516
36- or add
17+ No framework dependency — this is a standalone domain model.
3718
38- ``` json
39- "hiqdev/php-billing" : " *"
40- ```
19+ ## Core Entities
4120
42- to the require section of your composer.json.
43-
44- ## Idea
45-
46- In general the billing functions like this:
47-
48- For a given [ order] a [ calculator] finds [ plan] s and then matches
49- applicable [ price] s to [ action] s and calculates [ charge] s.
50- Then [ charge] s can be aggregated to [ bill] s with [ aggregator] .
51-
52- Billing operates such ideas:
53-
54- - [ Action] - [ customer] 's metered activity of a certain [ type] at a certain [ target]
55- - [ Order] - collection of [ action] s
56- - [ Bill]
57- - [ Charge]
58- - [ Plan]
59- - [ Price]
60- - [ Customer]
61- - [ Sale] - a subscription, binding [ customer] to a [ target] and a [ plan]
62- - [ Target] - object being charged in billing
63- - [ Type]
64- - [ Calculator]
65- - [ Aggregator]
21+ - ** [ Action] ** — a [ Customer] 's metered activity of a certain [ Type] at a certain [ Target]
22+ - ** [ Order] ** — a collection of Actions to be billed together
23+ - ** [ Sale] ** — a subscription binding a [ Customer] to a [ Target] under a [ Plan]
24+ - ** [ Plan] ** — a tariff containing a set of [ Price] s
25+ - ** [ Price] ** — a billing rule that calculates charges (SinglePrice, EnumPrice, RatePrice, ProgressivePrice)
26+ - ** [ Charge] ** — the result of matching an Action to a Price
27+ - ** [ Bill] ** — aggregation of Charges into an invoice line item
28+ - ** [ Calculator] ** — orchestrates the billing pipeline
29+ - ** [ Aggregator] ** — groups Charges into Bills
6630
6731![ Model UML] ( http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/hiqdev/php-billing/master/docs/model.puml )
6832
@@ -75,12 +39,17 @@ Billing operates such ideas:
7539[ Order ] : /src/order/Order.php
7640[ Plan ] : /src/plan/Plan.php
7741[ Price ] : /src/price/AbstractPrice.php
78- [ SinglePrice ] : /src/price/SinglePrice.php
79- [ EnumPrice ] : /src/price/EnumPrice.php
8042[ Sale ] : /src/sale/Sale.php
8143[ Target ] : /src/target/Target.php
8244[ Type ] : /src/type/Type.php
8345
46+ ## Documentation
47+
48+ - [ Domain Model] ( docs/domain-model.md ) — core entities, matching rules, immutability, calculator pipeline
49+ - [ Price Types] ( docs/price-types.md ) — SinglePrice, EnumPrice, RatePrice, ProgressivePrice algorithms
50+ - [ Formula DSL and Charge Modifiers] ( docs/formula-and-modifiers.md ) — discount, installment, cap, and modifier system
51+ - [ Codebase Overview] ( docs/overview.md ) — directory map, patterns, and testing
52+
8453## Disclaimer
8554
8655This billing is designed to be flexible and abstract, so supports different use cases.
@@ -112,4 +81,4 @@ because many of them implement customer-specific logic that cannot be disclosed.
11281This project is released under the terms of the BSD-3-Clause [ license] ( LICENSE ) .
11382Read more [ here] ( http://choosealicense.com/licenses/bsd-3-clause ) .
11483
115- Copyright © 2017-2019 , HiQDev (http://hiqdev.com/ )
84+ Copyright © 2017-2026 , HiQDev (< http://hiqdev.com/ > )
0 commit comments