PHPackages                             andmarruda/billing-module - 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. andmarruda/billing-module

ActiveLibrary[Payment Processing](/categories/payments)

andmarruda/billing-module
=========================

Billing module with one-time payments, recurring billing and NFSe integration

0.0.1(3mo ago)08MITPHPPHP ^8.2

Since May 1Pushed 1mo agoCompare

[ Source](https://github.com/andmarruda/laravel-modules-billing)[ Packagist](https://packagist.org/packages/andmarruda/billing-module)[ RSS](/packages/andmarruda-billing-module/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

BillingModule
=============

[](#billingmodule)

Billing module for Laravel with ports and adapters architecture.

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

[](#installation)

```
composer require andmarruda/billing-module
```

Laravel package auto-discovery loads `Andmarruda\BillingModule\BillingModuleServiceProvider`.

Layers
------

[](#layers)

- `UseCases/`: application workflows.
- `Ports/`: repository and service contracts.
- `Infrastructure/`: adapter implementations.
- `Http/`: controllers, requests, resources and routes.
- `Events/`, `Listeners/`, `Console/Commands/`: async workflows and cron entry points.

Implemented Scope
-----------------

[](#implemented-scope)

- One-time payments.
- Recurring billing managed by module cron flows (not Stripe subscriptions product).
- Stripe webhook processing with signature validation and idempotent event storage.
- NFSe integration adapter (FocusNFe package integration point).
- Reconciliation and retry commands.
- Optional coin credit flow for MVPs (ledger + user balance) on `PaymentSucceeded`.

Routes
------

[](#routes)

- `POST /billing/payments/one-time`
- `POST /billing/subscriptions/recurring`
- `POST /billing/subscriptions/{id}/cancel`
- `GET /billing/invoices/{id}`
- `POST /billing/webhooks/stripe`
- `GET /billing/subscriptions/current` when `billing.stores.enabled = true`
- `POST /billing/webhooks/google-play` when `billing.stores.enabled = true`
- `POST /billing/webhooks/app-store` when `billing.stores.enabled = true`

Commands
--------

[](#commands)

- `billing:renew-subscriptions`
- `billing:retry-failed-payments`
- `billing:sync-nfse`
- `billing:reconcile`
- `billing:expire-store-subscriptions`

Scheduling is configured by `Config/billing.php` under `crons`.

Coins (MVP)
-----------

[](#coins-mvp)

- Enable with `billing.coins.enabled = true`.
- Configure monthly coin recharge by plan with `billing.coins.monthly_plan_credits`.
- You can also credit coins in one-time payments by passing `metadata.coins`.
- Credits are idempotent per payment (`coin_ledger_entries.payment_id` is unique).

Route Middleware
----------------

[](#route-middleware)

- Configure API middleware via `billing.route_middleware` (string or array).
- Configure webhook middleware independently via `billing.webhook_middleware`.
- Example:
    - `billing.route_middleware = ['auth:sanctum']`
    - `billing.webhook_middleware = ['throttle:60,1']`

NFSe Async Emission
-------------------

[](#nfse-async-emission)

- `InvoiceIssued` triggers `IssueNfseForInvoice`, which is queueable (`ShouldQueue`).
- Queue processing strategy stays in the host app (driver/workers/supervision).

Stripe Webhook Security
-----------------------

[](#stripe-webhook-security)

- Signature validation supports timestamp tolerance through:
    - `billing.stripe.webhook_tolerance_seconds` (default `300`).

Store-Driven Subscriptions
--------------------------

[](#store-driven-subscriptions)

- Enable mobile store flows with `billing.stores.enabled = true`.
- Configure product mapping in `billing.stores.google_play.product_map` and `billing.stores.app_store.product_map`.
- Bind concrete implementations for:
    - `Andmarruda\BillingModule\Ports\Services\GooglePlayWebhookVerifierInterface`
    - `Andmarruda\BillingModule\Ports\Services\AppStoreNotificationVerifierInterface`
- Default verifier implementations are null adapters and intentionally do not accept webhooks.

Observability Events
--------------------

[](#observability-events)

- `Andmarruda\BillingModule\Events\NfseIssueFailed`
    - Dispatched when NFSe issuance returns error, misses `external_id`, or provider call throws.
- `Andmarruda\BillingModule\Events\WebhookProcessingFailed`
    - Dispatched when webhook event persistence fails for a non-duplicate reason.

###  Health Score

34

—

LowBetter than 74% of packages

Maintenance85

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

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

Unknown

Total

1

Last Release

116d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fad9d7cc83409d7c7896bc4d1977165fb14125e7accd1429d8e4e3ab462e5e2d?d=identicon)[andmarruda](/maintainers/andmarruda)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/andmarruda-billing-module/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1239.7k25](/packages/fleetbase-core-api)

PHPackages © 2026

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