bavix/laravel-wallet
Virtual wallet system for Laravel: manage balances, deposits/withdrawals, transfers, and multi-wallet support with robust transaction history and concurrency safety. Well-tested, benchmarked, and extensible for payments, loyalty points, and in-app credits.
HasWalletFloat), multi-wallet systems, and limited/unlimited product purchases. The PurchaseServiceInterface allows overriding default purchase validation, reducing N+1 query issues in cart-based systems.wallet:transaction, purchase:completed) for auditing or third-party integrations (e.g., Stripe, PayPal).bavix/laravel-wallet), publish migrations (php artisan vendor:publish --provider="Bavix\Wallet\WalletServiceProvider"), and extend models with traits (HasWallet, CanPay).bavix/laravel-wallet (no heavy external deps).laravel-wallet-swap for exchange rates, laravel-wallet-uuid for UUID support).| Risk Area | Severity | Mitigation |
|---|---|---|
| Database Schema Changes | Medium | Run migrations carefully; backup existing data before schema updates. |
| Transaction Consistency | High | Test edge cases (e.g., concurrent withdrawals, refunds on failed purchases). |
| Fractional Currency | Medium | Use HasWalletFloat only if precise decimal handling is critical (e.g., crypto). |
| Performance (N+1 Queries) | High | Implement PurchaseServiceInterface for bulk cart validation. |
| Upgrade Path | Low | Follow upgrade guide. |
| Custom Logic Overrides | Medium | Extend base services (e.g., PrepareService) for business-specific rules. |
swap could add this.)HasGift trait and PrepareService.)getAmountProduct() or use middleware.)| Phase | Tasks | Tools/Commands |
|---|---|---|
| Assessment | Audit existing payment flows; identify wallet-eligible use cases (e.g., subscriptions, tips). | Manual review + benchmark. |
| Setup | Install package, publish migrations, configure config/wallet.php. |
composer require bavix/laravel-wallet + php artisan vendor:publish. |
| Model Refactoring | Extend User, Product, and Order models with traits (HasWallet, CanPay). |
Manual or generator script. |
| Core Functionality | Implement deposits/withdrawals, purchases, and refunds in key workflows. | Unit tests for deposit(), withdraw(), pay(), refund(). |
| Advanced Features | Add fractional currency (HasWalletFloat), merchant fees, or multi-wallet support. |
Extend traits/services as needed. |
| Testing | Validate transactions, edge cases (insufficient funds, concurrent access), and rollbacks. | PHPUnit + Pest; use forceWithdraw() for negative balance testing. |
| Deployment | Run migrations, seed initial balances, monitor performance. | php artisan migrate + php artisan db:seed. |
| Monitoring | Set up alerts for failed transactions or balance inconsistencies. | Laravel Horizon or third-party APM (e.g., New Relic). |
safePay() + webhooks for external gateways (e.g., Stripe).wallet:transaction).ProductInterface for simple products (avoid ProductLimitedInterface initially).CanPay trait) for core products.PurchaseServiceInterface for carts.12.x for Laravel 13). Minor updates are low-risk; major versions require testing.PurchaseService) may need updates if the package’s core interfaces change.How can I help you explore Laravel packages today?