Download the PHP package cyrus-48/paysasa without Composer
On this page you can find all versions of the php package cyrus-48/paysasa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cyrus-48/paysasa
More information about cyrus-48/paysasa
Files in cyrus-48/paysasa
Package paysasa
Short Description A unified, driver-based payment gateway abstraction for Laravel, purpose-built for the Kenyan market (M-Pesa, Airtel Money, Stripe, Pesapal, Flutterwave, PesaLink) behind one consistent API.
License MIT
Homepage https://github.com/cyrus-48/paysasa
Informations about the package paysasa
Paysasa
A unified, driver-based payment gateway abstraction for Laravel 11, 12, and 13, purpose-built for the Kenyan market.
Paysasa gives a Laravel application one consistent, hardened API — Payment::driver('mpesa')->amount(2500)->phone('0712345678')->charge() — for M-Pesa, Airtel Money, Stripe, Pesapal, Flutterwave, and PesaLink. Business logic never talks to a provider SDK directly; it talks to Paysasa, and Paysasa orchestrates validation, idempotency, persistence, state transitions, events, and background reconciliation.
This README is the quickstart and overview. The comprehensive architecture specification lives in Documentation/.
Key Highlights
- Unified Fluent API: Consistent methods across all mobile money, card, and banking providers.
- Strict State Machine: Centralized
TransitionPaymentengine with pessimistic row-locking (lockForUpdate()) preventing race conditions (e.g. a late failed callback cannot overwrite a successful payment). - Money Safety (No Silent Truncation): Immutable
Moneyvalue object uses integer minor units. Fractional units for whole-unit rails (like Safaricom M-Pesa) are strictly rejected withInvalidAmountExceptionrather than silently truncated. - Strict Phone Normalization:
KenyanMsisdnvalidates and standardizes07xx,01xx, and+254phone numbers into E.164 formats. - Guaranteed Terminal Lifecycle Events: Both synchronously-settled charges and webhook-settled transactions (such as M-Pesa STK push) reliably dispatch
PaymentSuccessful,PaymentFailed,PaymentCancelled, andPaymentExpired. - Self-Healing Reconciliation: Background sweep (
paysasa:reconcile) combined with single-shotVerifyPaymentStatusJobensures lost or delayed webhooks never leave payments pending indefinitely. - Fail-Closed Webhook Security: Automatic 64KB body size limit, header redaction, SHA-256 raw-body deduplication, and fail-closed M-Pesa verification in production.
Payment::fake()Testing: Comprehensive test assertions that fake network and persistence layers without touching external APIs.
Requirements
- PHP 8.2+
- Laravel 11.x, 12.x, or 13.x
- Database: MySQL 8.0+, PostgreSQL 13+, or SQLite 3.35+
- A queue worker for asynchronous webhook and verification processing (
php artisan queue:work)
Installation
This publishes config/paysasa.php, publishes and runs database migrations, and prompts for provider credentials. See Documentation/01-installation.md for detailed instructions.
Quick Start
Initiating a Payment (e.g. M-Pesa STK Push)
Switching Providers
Swapping gateways requires only changing the driver name:
Digital Wallets (Google Pay & Apple Pay)
Neither Google Pay nor Apple Pay is an independent settlement network. They are client-side tokenization layers over card networks. Frontend SDKs (such as Stripe Elements or the Payment Request Button) exchange device credentials for a payment method token (pm_*), which you process via stripe:
Listening to Lifecycle Events
Because asynchronous payments settle via callbacks or reconciliation jobs, business logic should listen for terminal events:
Anomaly Events
Paysasa also emits events when unexpected conditions occur:
PaymentStateConflict: Triggered when an illegal transition is rejected (e.g. a late Failed callback attempting to overwrite an already Successful payment).PaymentAmountMismatch: Triggered when a callback's amount differs from the expected amount, keeping the payment inprocessingfor manual review.WebhookUnmatched: Triggered when an incoming webhook cannot be matched to any payment record after multiple retry attempts.
Supported Providers & Maturity
| Driver | Category | Status | Capabilities |
|---|---|---|---|
mpesa |
Mobile Money | Stable | STK Push, C2B, B2C, reversals, balance inquiries |
stripe |
Cards | Stable | PaymentIntents, direct charges, refunds, captures |
airtel |
Mobile Money | Beta | USSD push, collections, full refunds, payouts |
pesapal |
Cards | Beta | Hosted checkout, IPN callbacks |
flutterwave |
Cards | Beta | Standard charges, webhook verification |
pesalink |
Banking | Experimental | Account transfers, banking rails (bring your own bank) |
Artisan Commands
Paysasa provides several Artisan commands for operation, reconciliation, and troubleshooting:
Automatic Scheduling:
paysasa:reconcileautomatically registers in Laravel's scheduler to run every minute whenpaysasa.reconcile.schedule_enabledistrue.
Testing Your Integration
Use Payment::fake() in your unit and feature tests to simulate payment flows without hitting third-party APIs:
You can also queue specific failure or pending responses:
Documentation Index
| # | Document | Covers |
|---|---|---|
| — | 00-overview.md | High-level system architecture, principles, package structure |
| 1 | 01-installation.md | Installation guide, prerequisites, and service registration |
| 2 | 02-configuration.md | Comprehensive configuration reference, driver options, env variables |
| 3 | 03-quickstart.md | Step-by-step integration guide for STK push, cards, refunds, and payouts |
| 4 | 04-architecture.md | State machine, contracts, transition flow, class diagrams, lifecycles |
| 5 | 05-database-schema.md | Entity relationship diagrams (ERD) and column-level schema definitions |
| 6 | 06-driver-development-guide.md | Guide to authoring custom drivers and banking implementations |
| 7 | 07-webhook-guide.md | Webhook intake, signature verification, deduping, and retry handling |
| 8 | 08-security.md | Security model: HMAC signing, IP allowlisting, PCI DSS scope, secret vault |
| 9 | 09-testing.md | Testing best practices using Payment::fake(), Pest, and HTTP fakes |
| 10 | 10-performance-and-scalability.md | High-throughput queue configuration, connection pooling, and caching |
| 11 | 11-troubleshooting.md | Common errors, Daraja gotchas, and resolution procedures |
| 12 | 12-upgrade-guide.md | Semantic versioning policy and version-to-version migration notes |
| 13 | 13-contributing.md | Contribution guidelines, coding standards, and PR workflows |
| 14 | 14-roadmap.md | Implemented scope and future feature considerations |
NOTE : BETA
License
MIT License. See LICENSE for details.
All versions of paysasa with dependencies
illuminate/bus Version ^12.73|^13.43
illuminate/cache Version ^12.73|^13.43
illuminate/console Version ^12.73|^13.43
illuminate/database Version ^12.73|^13.43
illuminate/events Version ^12.73|^13.43
illuminate/http Version ^12.73|^13.43
illuminate/queue Version ^12.73|^13.43
illuminate/routing Version ^12.73|^13.43
illuminate/support Version ^12.73|^13.43
guzzlehttp/guzzle Version ^7.17|^8.6
ramsey/uuid Version ^4.10
nesbot/carbon Version ^2.73|^3.15.1