bavix/laravel-wallet
Virtual wallet system for Laravel: attach wallets to models, track balances, perform deposits/withdrawals/transfers, handle atomic transactions and events, and support multi-currency and bookkeeping. Includes docs, benchmarks, and upgrade guide.
wallet.updated, payment.processed) for audit logs, notifications, or integrations with third-party services.HasWallet, CanPay, AtomicService). A TPM should assess whether this aligns with the team’s preference for cohesive vs. loosely coupled components.HasWallet trait).array driver).CanPay trait).POST /wallets/{id}/deposit).| Risk Area | Severity | Mitigation |
|---|---|---|
| Race Conditions | High | Requires Redis for production (configurable but array driver is unsafe). |
| Transaction Locks | Medium | Long-running transactions risk wallet deadlocks; optimize transaction scope. |
| Float Precision | Medium | Uses integer storage for floats (e.g., 1.37 → 137), which may require custom rounding logic. |
| Multi-Wallet Complexity | High | Atomic operations on multiple wallets generate N lock requests; benchmark under load. |
| Custom Logic Overhead | Medium | Extending interfaces (e.g., ProductLimitedInterface) requires boilerplate. |
| Upgrade Path | Low | Clear upgrade guide and LTS support (Laravel 11/12, PHP 8.3–8.5). |
array (unsafe for production).deposit() can be dispatched to a queue).Wallet, Customer).User, Product).composer require bavix/laravel-wallet
php artisan vendor:publish --tag=laravel-wallet-config
HasWallet for core models (e.g., User).deposit(), withdraw()).CanPay for product purchases; test atomic operations.wallets table.CanPay to bridge to Stripe/PayPal.GET /wallets/{user}/balance).| Priority | Task | Dependencies |
|---|---|---|
| P0 | Install, configure, and publish migrations. | None |
| P0 | Backfill existing balances into wallets table. |
DB schema |
| P1 | Implement HasWallet for core models (e.g., User). |
Migrations |
| P1 | Replace custom balance logic with package methods. | HasWallet trait |
| P2 | Add CanPay for product purchases; test basic transactions. |
HasWallet |
| P2 | Set up Redis for locks/atomic ops (if high volume). | Config |
| P3 | Extend for multi-wallet, float, or credit limits. | Core functionality |
| P3 | Integrate with payment gateways (e.g., Stripe webhooks). | CanPay trait |
| P4 | Add event listeners for audit logs/notifications. | Core functionality |
ProductLimitedInterface).getAmountProduct()).balanceFloat vs. balanceInt consistency.wallet.transactions table).How can I help you explore Laravel packages today?