misaf/vendra-subscription

Generic plans and polymorphic subscriptions for Vendra applications

Maintainers

Package info

github.com/misaf/vendra-subscription

Type:vendra-module

pkg:composer/misaf/vendra-subscription

Transparency log

Statistics

Installs: 8

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

v1.10.0 2026-08-01 01:24 UTC

This package is auto-updated.

Last update: 2026-08-01 01:29:22 UTC


README

Generic plans and polymorphic subscriptions for Vendra applications.

Features

  • Defines plans with periods, pricing, trials, grace windows, feature entitlements, and usage limits
  • Stores price and currency snapshots for each subscription period
  • Persists provider-neutral subscription payment operations with stable idempotency keys and lifecycle states
  • Supports any Eloquent subscriber through a polymorphic relationship and the SubscriptionSubscriber contract
  • Enforces one active subscription per subscriber
  • Provides pending-payment, active, past-due, lapsed, and expiry-reminder lifecycle primitives
  • Runs a durable, retriable payment engine — queued collection (ProcessSubscriptionPayment), idempotent charge/retrieve, and reconciliation
  • Emits lifecycle events (SubscriptionPaymentPaid/Failed, SubscriptionActivated, SubscriptionExpiringSoon, SubscriptionGraceExpired) for host reactions

The engine is subscriber-agnostic: subscribe, activate, charge, and enforce all operate through the SubscriptionSubscriber contract and never reference a concrete subscriber. Subscriber-specific reactions — the concrete subscriber model, quota enforcement, provisioning, and owner notifications — belong to the host application, which implements the contract and subscribes to the engine's events. Provider adapters implement the SubscriptionCharger contract exposed by misaf/vendra-support; they must never collect more than once for the same idempotency key and financial payload.

Requirements

  • PHP 8.3+
  • Laravel 13
  • misaf/vendra-support

Installation

composer require misaf/vendra-subscription
php artisan vendor:publish --tag=vendra-subscription-migrations
php artisan migrate

The host application defines the inverse morphMany relationship and registers stable morph aliases for its subscriber models.

Requeue stale, interrupted, or reconciliation-ready payment operations after an outage with:

php artisan vendra-subscription:recover-payments

Inspect reconciliation, stalled-processing, and paid-but-not-activated backlog without mutating payments:

php artisan vendra-subscription:report-payment-backlog
php artisan vendra-subscription:report-payment-backlog --stale-minutes=60

Testing

Run the package checks from the package directory:

composer test
composer analyse

License

MIT. See LICENSE.