Download the PHP package vahidkaargar/laravel-wallet without Composer
On this page you can find all versions of the php package vahidkaargar/laravel-wallet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vahidkaargar/laravel-wallet
More information about vahidkaargar/laravel-wallet
Files in vahidkaargar/laravel-wallet
Package laravel-wallet
Short Description Finance-grade wallet & credit system for Laravel
License MIT
Informations about the package laravel-wallet
Laravel Wallet Enterprise
Finance-grade wallet & credit system for Laravel 10+, 11, and 12.
Features
- Multi-currency support with real-time exchange rates
- Automatic credit repayment with debt management
- Credit limits & aging with configurable interest rates
- Interest on outstanding credit with automated aging
- Transaction workflow: pending/approved/rejected/reversed
- Scheduled batch reversals for expired transactions
- Complete ledger audit trail for financial compliance
- Event-driven notifications for all wallet operations
- Lock/Unlock funds for escrow and hold operations
- Role-based credit enforcement with validation layers
- Precise decimal arithmetic using bcmath for financial accuracy
- Thread-safe operations with pessimistic locking
- Comprehensive test coverage with 80+ tests
- Cross-wallet transfers with automatic currency conversion
Requirements
- PHP: 8.2 or higher
- Laravel: 10.x, 11.x, or 12.x
- Database: MySQL, PostgreSQL, SQLite, or SQL Server
- Extensions: bcmath (required for precise monetary calculations)
Installation
Configuration
Publish the configuration file:
Configure your wallet settings in config/wallet.php:
Environment Variables
Add these to your .env file for logging configuration:
Log Channel Configuration
Configure a dedicated wallet log channel in config/logging.php:
Quick Start
1. Add the HasWallets trait to your User model
2. Create wallets
3. Basic wallet operations
4. Cross-wallet transfers with currency conversion
5. Check wallet status
6. Transaction History and Filtering
7. Transactions Data Model (ULIDs, Descriptions, Meta)
All transactions use ULID primary keys for high-entropy sortable IDs. Each transaction has a required description and a consistent meta schema to improve auditability and retrieval.
Key fields:
id(ULID, string)wallet_id(int, indexed)type(enum, indexed): deposit, withdraw, lock, unlock, credit_grant, credit_revoke, credit_repay, interest_chargestatus(enum, indexed): pending, approved, rejected, reversedamount(decimal 15,2)description(string, required)reference(string, nullable, indexed)meta(json, consistent structure)created_at(indexed),updated_at
Meta structure (standardized and retrievable):
Notes:
descriptionis auto-generated when not provided (e.g., "Deposit of 100.00 (ref: ORDER-1001)").- Custom meta keys you pass are preserved and merged at the root for easy querying.
- DB indexes:
wallet_id,type,status,reference,created_at.
Advanced Usage
Transaction Workflow
Credit Management
Custom Exchange Rate Provider
You can implement your own exchange rate provider to fetch live rates from external APIs. Here's a complete example:
Registering Your Custom Provider
Option 1: Service Provider (Recommended)
Option 2: Runtime Registration
Configuration Example
Add to your config/services.php:
Usage Example
Error Handling
Batch Operations
Multi-Currency Operations
Credit and Debt Management
Fund Locking and Escrow
Interest and Aging
Event Handling
Testing
The package includes comprehensive test coverage with 80+ tests covering:
- Financial calculations and precision
- Transaction workflows and state management
- Credit management and debt calculations
- Batch operations and reversals
- Laravel compatibility across versions 10, 11, and 12
- Edge cases and error handling
- Multi-currency transfers and conversions
Run the tests:
Run tests with code coverage (requires Xdebug or PCOV):
If you get a "No code coverage driver available" warning, you can:
-
Install a coverage driver:
-
Or use the setup script:
- Or just run tests without coverage:
Security Features
- Precise decimal arithmetic using bcmath to prevent floating-point errors
- Pessimistic locking to prevent race conditions
- Atomic transactions for all financial operations
- Comprehensive validation before any wallet state changes
- Audit trail for all financial operations
- Role-based access control through Laravel's authorization system
- Currency validation to prevent invalid currency operations
Laravel Compatibility
This package is fully compatible with:
- Laravel 10.x
- Laravel 11.x
- Laravel 12.x
- PHP 8.2+
The package automatically adapts to different Laravel versions and includes compatibility tests to ensure smooth operation across all supported versions.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This package is open-sourced software licensed under the MIT license.
Support
For support and questions:
- Create an issue on GitHub
- Email: [email protected]
Acknowledgments
- Built with Laravel's excellent service container and Eloquent ORM
- Inspired by financial industry best practices
- Designed for enterprise-grade reliability and security
All versions of laravel-wallet with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/events Version ^10.0|^11.0|^12.0
illuminate/console Version ^10.0|^11.0|^12.0