PHPackages                             cynchro/modux-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. [Payment Processing](/categories/payments)
4. /
5. cynchro/modux-billing

ActiveLibrary[Payment Processing](/categories/payments)

cynchro/modux-billing
=====================

SDK de billing para SaaS multi-tenant: planes, suscripciones y entitlements. Agnóstico de pasarela (Stripe, Mercado Pago).

v0.0.2(2d ago)01↑2900%MITPHPPHP &gt;=8.2CI passing

Since Jun 7Pushed 2d agoCompare

[ Source](https://github.com/cynchro/modux-billing)[ Packagist](https://packagist.org/packages/cynchro/modux-billing)[ Docs](https://github.com/cynchro/modux-billing)[ RSS](/packages/cynchro-modux-billing/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

cynchro/modux-billing
=====================

[](#cynchromodux-billing)

SDK de billing para SaaS multi-tenant: **planes, suscripciones y entitlements**. Agnóstico de pasarela (Stripe, Mercado Pago) y framework-agnóstico (recibe un `PDO`).

Es el módulo opcional de la capa comercial de [Modux](https://github.com/cynchro/modux). Diseño completo: `docs/adr/0001-saas-identity-entitlements-billing.md` del framework.

Idea central
------------

[](#idea-central)

> **Billing escribe, el base solo lee.**

Cuando un tenant contrata o renueva un plan, billing proyecta los entitlements del plan sobre la tabla `tenant_entitlements` del host (con el período del ciclo). El framework base hace el gating (feature flags, cuotas) leyendo esa tabla, **sin conocer billing**. Así los módulos de producto (p. ej. `modux-ia`) nunca dependen de billing.

```
contratar plan ──► BillingManager.subscribe() ──► tenant_entitlements (source=billing:*)
webhook pasarela ─► BillingManager.handleEvent() ─► renueva / cancela → reescribe / limpia

```

Instalación
-----------

[](#instalación)

```
composer require cynchro/modux-billing
```

Requiere PHP ≥ 8.2, `ext-pdo`, `ext-json`.

Uso
---

[](#uso)

```
use Cynchro\Billing\{Schema, PlanRepository, SubscriptionRepository,
    TenantEntitlementWriter, BillingManager};
use Cynchro\Billing\Models\PlanEntitlement;

Schema::up($pdo); // crea plans, plan_entitlements, subscriptions

$plans = new PlanRepository($pdo);
$pro   = $plans->create('pro', 'Pro', 29.0, 'USD', 'month', 'stripe');
$plans->addEntitlement($pro->id, new PlanEntitlement('ia.rag', 'flag'));
$plans->addEntitlement($pro->id, new PlanEntitlement('api.calls', 'quota', 1000));

$billing = new BillingManager(
    $plans,
    new SubscriptionRepository($pdo),
    new TenantEntitlementWriter($pdo) // escribe tenant_entitlements del base
);

// Tras un checkout exitoso:
$billing->subscribe($tenantId, 'pro', 'stripe', $externalSubscriptionId);

// Desde un webhook de la pasarela (ya verificado con el WebhookVerifier del base):
$billing->handleEvent($gateway->parseWebhook($payload));
```

Pasarelas
---------

[](#pasarelas)

El core es agnóstico: las pasarelas implementan `PaymentGatewayInterface`.

- `cynchro/modux-billing-stripe`
- `cynchro/modux-billing-mercadopago`

Calidad
-------

[](#calidad)

```
composer test      # PHPUnit
composer analyse   # PHPStan level 6
composer lint      # PSR-12
```

MIT.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

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

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22827205?v=4)[cynchro](/maintainers/cynchro)[@cynchro](https://github.com/cynchro)

---

Top Contributors

[![cynchro](https://avatars.githubusercontent.com/u/22827205?v=4)](https://github.com/cynchro "cynchro (3 commits)")

---

Tags

phpstripebillingsubscriptionsmercadopagosaasentitlements

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cynchro-modux-billing/health.svg)

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

###  Alternatives

[mmanos/laravel-billing

A billing package for Laravel 4.

461.3k](/packages/mmanos-laravel-billing)

PHPackages © 2026

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