andmarruda/billing-module 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

andmarruda/billing-module

Composer 安装命令:

composer require andmarruda/billing-module

包简介

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

README 文档

README

Billing module for Laravel with ports and adapters architecture.

Installation

composer require andmarruda/billing-module

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

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

  • 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

  • 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

  • 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)

  • 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

  • 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

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

Stripe Webhook Security

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

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

  • 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.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固