Metadata-Version: 2.5
Name: boilpayment-credits
Version: 0.1.0
Summary: boilpayment — credits
Project-URL: Homepage, https://github.com/schift-io/boilpayment#readme
Project-URL: Repository, https://github.com/schift-io/boilpayment.git
Project-URL: Issues, https://github.com/schift-io/boilpayment/issues
Author: boilpayment contributors
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: boilpayment-core<0.2,>=0.1.0
Description-Content-Type: text/markdown

# boilpayment-credits

Credit-pool ledger operations on top of `boilpayment-core`'s append-only `Ledger`:
grant on period start, consume against a policy-defined pool order, rollover on renewal,
clawback, expiry, and top-ups. Every function is pure DI — pass in your `Ledger`/`Clock`/`Policy`.

## Install

```
pip install boilpayment-credits
```

## Usage

```python
from boilpayment_credits import consume, ConsumeCreditsInput, grant_for_period, GrantForPeriodInput
from boilpayment_core import InMemoryLedger, SystemClock, resolve_policy

ledger = InMemoryLedger()
clock = SystemClock()
policy = resolve_policy()

await grant_for_period(GrantForPeriodInput(
    sub=sub, plan=plan, period=period, payment=payment, policy=policy, ledger=ledger, clock=clock,
))

result = await consume(ConsumeCreditsInput(
    customer_id="cust_1",
    amount=10,
    policy=policy, ledger=ledger, clock=clock,
    idempotency_key="usage-event-42",
))
```

Full module contract: [docs/ARCHITECTURE.md §3.5](https://github.com/schift-io/boilpayment/blob/main/docs/ARCHITECTURE.md).
