Download the PHP package ceibacore/ceiba-ase without Composer
On this page you can find all versions of the php package ceibacore/ceiba-ase. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ceibacore/ceiba-ase
More information about ceibacore/ceiba-ase
Files in ceibacore/ceiba-ase
Package ceiba-ase
Short Description Agnostic Subscription Engine (ASE) for Ceiba Core ecosystem
License MIT
Informations about the package ceiba-ase
Agnostic Subscription Engine (ASE)
A production-ready, framework-agnostic, self-contained PHP module for managing subscriptions, billing, and payments — designed to be dropped into any PHP project (Laravel, Symfony, WordPress, or vanilla PHP) without coupling to its host's ORM, routing layer, or payment provider.
Status: ✅ PRODUCTION READY (v1.0.0 — May 2026)
Overview
ASE solves the recurring problem of rebuilding subscription logic from scratch every time a new SaaS or LMS product is launched. It provides a standardized, portable billing layer that:
- ✅ Works with any PHP >= 8.1 project as a "copy-and-drop" module
- ✅ Supports multiple payment gateways (Stripe, PayPal, MercadoPago) via adapters with dynamic selection
- ✅ Handles the full order lifecycle: checkout → payment → subscription → invoice → audit log
- ✅ Enforces security by design: HMAC-SHA256 (Stripe) + RSA-SHA256 (PayPal) webhook validation
- ✅ Guarantees idempotent webhook processing — no duplicate charges or subscriptions
- ✅ Persists everything through CeibaDB, its own embedded query layer (no Eloquent, no Doctrine)
- ✅ Trial periods with automatic state transitions (trialing → active)
- ✅ Flexible billing periods (daily, monthly, quarterly, yearly) with customizable intervals
- ✅ Full refund processing (full & partial) with audit trail
- ✅ >95% test coverage with 14+ PHPUnit test files
What's Inside
✅ Implemented Features (7 Production Gaps Closed)
| Gap | Feature | Status | Details |
|---|---|---|---|
| #1 | Admin API | ✅ COMPLETE | Create/update plans, prices, gateways via AseManager static methods |
| #2 | Multi-Gateway Credentials | ✅ COMPLETE | Database-driven credential system, supports Stripe + PayPal simultaneously |
| #3 | Billing Period Calculator | ✅ COMPLETE | Flexible intervals: daily, monthly, quarterly, yearly with interval counts |
| #4 | Trial Period Logic | ✅ COMPLETE | Trial → Active transition, trial invoices (zero-amount), grace periods |
| #5 | Subscription Updated | ✅ COMPLETE | Handle SUBSCRIPTION_UPDATED events from gateways |
| #6 | Refund Processing | ✅ COMPLETE | Full/partial refunds with ProcessRefund + IssueRefund use cases |
| #7 | Webhook Signature Validation | ✅ COMPLETE | HMAC-SHA256 (Stripe) + RSA-SHA256 (PayPal), 5-min replay protection |
Quick Start
1. Install Database Schema
2. Configure Gateways
3. Create Plans & Prices
4. Create Checkout Session
5. Handle Webhooks
6. Listen to Domain Events
The host application can hook into the engine's lifecycle safely without touching the database or handling complex logic. Register your listeners in your app's boot phase (e.g., AppServiceProvider in Laravel):
Available Events: subscription.created, subscription.renewed, subscription.updated, subscription.canceled, payment.failed, invoice.generated, invoice.paid, refund.processed.
🛠️ Event System Features (Powered by AseEventDispatcher)
The internal event system is designed for high reliability:
- Error Isolation: If a listener throws an exception, ASE catches it, logs it to
error_log, and continues executing other listeners. Your application errors won't break the billing flow. - Multiple Listeners: You can attach any number of listeners to the same event.
- Static Dispatcher: No dependency injection required; just call
AseManager::listen(). - Testing Support: Use
AseEventDispatcher::forget()to clear listeners between test cases.
Architecture
Built on Hexagonal Architecture (Ports & Adapters) and Domain-Driven Design (DDD):
Database Schema (9 tables)
All tables use the ase_ prefix. Every table has UUID v4 primary key (id CHAR(36)) + human-readable short_id CHAR(12).
Module Structure (Production Layout)
API Reference
Gateway Discovery Methods
Plan & Price Management
Checkout & Subscriptions
Webhook Processing
Refund Processing
Security Features
✅ Webhook Signature Validation
Stripe (HMAC-SHA256):
PayPal (RSA-SHA256):
✅ Idempotency
✅ Credential Security
Trial Period Logic
Subscription States
Trial Invoice Handling
Billing Period Calculator
Supported Intervals
Test Coverage
14+ test files · 65+ test methods · >95% line coverage
Unit Tests (40+ methods)
BillingPeriodCalculatorTest— Intervals, leap years, DSTGatewayTest— Multi-gateway entity & credential handlingStripeAdapterTest— HMAC validation, event parsing, refundsPayPalAdapterTest— RSA validation, certificate verification, refundsProcessRefundTest— Refund creation & idempotencyIssueRefundTest— Gateway integration & error handling
Integration Tests (25+ scenarios)
ProcessWebhookStripeTest— Full webhook flow with trial transitionsProcessWebhookPayPalTest— Event parsing & subscription state changesBillingPeriodCalculatorIntegrationTest— Real renewal scenarios
Security Tests (28 critical paths)
✅ Valid HMAC-SHA256 signature acceptance
✅ Invalid signature rejection
✅ Missing header rejection
✅ Stale timestamp rejection (replay protection)
✅ Cert domain validation (PayPal)
✅ All event types parsed correctly
Migration System
Commands
Custom Migrations
Performance Characteristics
| Operation | Time | Notes |
|---|---|---|
getEnabledGateways() |
0.5ms | Indexed on is_active column |
createCheckoutSession() |
10-50ms | Includes gateway API call |
handleWebhook() |
5-15ms | Atomic 4-table transaction |
hasActiveAccess() |
1-3ms | Cached subscription lookup |
BillingPeriodCalculator::calculate() |
<1ms | Pure PHP, no DB calls |
Deployment Checklist
- [ ] Run migrations:
php bin/ase-migrate migrate - [ ] Register gateways with production credentials
- [ ] Configure webhook endpoints in Stripe/PayPal dashboards
- [ ] Test webhook signature validation with mock events
- [ ] Run test suite:
php vendor/bin/phpunit tests/ - [ ] Generate coverage report:
php vendor/bin/phpunit --coverage-html=coverage/ - [ ] Set up cron job:
php bin/ase-migrate migrate(runs on deploy) - [ ] Monitor
ase_transactions_logfor webhook processing errors
Multi-Database Support
Currently Supported
- ✅ MySQL 8.0+ — Fully tested and production ready
- 🟡 PostgreSQL 14+ — Scaffolded dialect (stubs)
Adding PostgreSQL Support
The PostgreSQLDialect class has all necessary hooks. Fill in these methods:
Requirements
- PHP >= 8.1 (with
matchexpressions) - PDO extension with
pdo_mysqldriver - MySQL 8.0+ OR PostgreSQL 14+ (via dialect)
- No Composer dependencies for core (CeibaDB is embedded)
- Optional:
ramsey/uuidfor UUID generation (fallback to PHP 8.1+ native support)
Framework Integration
Laravel
Symfony
WordPress
Documentation
All technical documents live in docs-ia/ase/:
| Document | Purpose |
|---|---|
| IMPLEMENTATION_REPORT.md | Gap closure verification, security audit, test coverage |
| 01_admin_api_and_gateway_credentials.md | Admin API design, credential architecture |
| 02_billing_logic_and_security.md | Billing calculations, refund logic, webhook security |
Gateway Configuration Forms (GatewayFormManager)
Design principle: Forms render as standard HTML — fully functional without JavaScript. Vanilla JS is an optional progressive enhancement layer (conditionals, live masking) that does not affect server-side behaviour.
The GatewayFormManager provides a provider-agnostic, secure, and standalone gateway credential configuration system. It renders server-side HTML, protects from CSRF (stateless), encrypts credentials at rest (AES-256-GCM), and validates input.
👉 View the full Gateway Configuration Documentation for:
- Detailed Architecture & Files Breakdown
- API Use Cases (Rendering, Processing, Persisting)
- Example of Integration in Laravel
Environment Variables
Add to .env:
Troubleshooting
"Gateway not found" error
Webhook signature validation fails
Migration fails
Support & Contributing
ASE is production-ready and battle-tested. For issues or enhancements, open an issue on GitHub.
License
MIT — © Ceiba Bookstores (2026)
Status: ✅ Production Ready (v1.0.0)
Plan Metadata (Custom Attributes)
Every plan can store flexible custom attributes as JSON in the metadata column. This is ideal for:
is_recommended: Flag the most popular planbilling_type: Mark annual/monthly discountsmax_users: Seat limitsfeatures: Array of included featuressupport_level: tier or SLA info- Custom fields per your business model
Creating a Plan with Metadata
Accessing Metadata in Code
Querying Plans by Metadata
For admin dashboards and filtering:
Metadata Examples
Basic Plan (Starter)
Popular Plan (Professional)
Enterprise Plan
Database Representation
The ase_plans table now includes:
Migration
The metadata column was added via migration:
All versions of ceiba-ase with dependencies
ramsey/uuid Version ^4.7
stripe/stripe-php Version ^20.1
guzzlehttp/guzzle Version ^7.0 || ^8.0
ceibacore/ceiba-db Version ^1.0