PHPackages                             vahidkaargar/laravel-wallet - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. vahidkaargar/laravel-wallet

ActiveLibrary[Payment Processing](/categories/payments)

vahidkaargar/laravel-wallet
===========================

Finance-grade wallet &amp; credit system for Laravel

v0.4.2(6mo ago)511MITPHPPHP ^8.2CI passing

Since Oct 27Pushed 6mo agoCompare

[ Source](https://github.com/vahidkaargar/laravel-wallet)[ Packagist](https://packagist.org/packages/vahidkaargar/laravel-wallet)[ RSS](/packages/vahidkaargar-laravel-wallet/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (6)Versions (8)Used By (0)

Laravel Wallet Enterprise
=========================

[](#laravel-wallet-enterprise)

Finance-grade wallet &amp; credit system for Laravel 10+, 11, and 12.

Features
--------

[](#features)

- **Multi-currency support** with real-time exchange rates
- **Automatic credit repayment** with debt management
- **Credit limits &amp; 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
------------

[](#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
------------

[](#installation)

```
composer require vahidkaargar/laravel-wallet
php artisan vendor:publish --provider="vahidkaargar\LaravelWallet\WalletServiceProvider"
php artisan migrate
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=config --provider="vahidkaargar\LaravelWallet\WalletServiceProvider"
```

Configure your wallet settings in `config/wallet.php`:

```
return [
    'max_credit_limit' => 100000.00,
    'interest_rate' => 0.05, // 5% annual interest
    'exchange_rates' => [
        'USD' => ['EUR' => 0.95, 'GBP' => 0.82],
        'EUR' => ['USD' => 1.05, 'GBP' => 0.86],
        'GBP' => ['USD' => 1.22, 'EUR' => 1.16],
    ],
    'supported_currencies' => ['USD', 'EUR', 'GBP', 'JPY'],

    // Logging Configuration
    'logging' => [
        'enabled' => env('WALLET_ERROR_LOGGING', true),
        'audit_enabled' => env('WALLET_AUDIT_LOGGING', true),
        // Null (default) uses the app default channel; set to a custom channel name to route logs
        'channel' => env('WALLET_LOG_CHANNEL', 'null'),
        'level' => env('WALLET_LOG_LEVEL', 'error'),
        'include_stack_trace' => env('WALLET_LOG_STACK_TRACE', true),
        'mask_sensitive_data' => env('WALLET_MASK_SENSITIVE_DATA', false),
    ],
];
```

### Environment Variables

[](#environment-variables)

Add these to your `.env` file for logging configuration:

```
# Enable/disable error logging
WALLET_ERROR_LOGGING=true

# Enable/disable audit logging for compliance
WALLET_AUDIT_LOGGING=true

# Custom log channel (optional)
WALLET_LOG_CHANNEL=wallet

# Minimum log level
WALLET_LOG_LEVEL=error

# Include stack traces in logs
WALLET_LOG_STACK_TRACE=true

# Mask sensitive data in logs
WALLET_MASK_SENSITIVE_DATA=false
```

### Log Channel Configuration

[](#log-channel-configuration)

Configure a dedicated wallet log channel in `config/logging.php`:

```
'channels' => [
    // ... other channels ...

    'wallet' => [
        'driver' => 'daily',
        'path' => storage_path('logs/wallet.log'),
        'level' => env('LOG_LEVEL', 'debug'),
        'days' => 14,
    ],

    // For production with external logging services
    'wallet_production' => [
        'driver' => 'stack',
        'channels' => ['wallet_daily', 'wallet_slack'],
        'ignore_exceptions' => false,
    ],

    'wallet_daily' => [
        'driver' => 'daily',
        'path' => storage_path('logs/wallet.log'),
        'level' => 'error',
        'days' => 30,
    ],

    'wallet_slack' => [
        'driver' => 'slack',
        'url' => env('WALLET_SLACK_WEBHOOK_URL'),
        'username' => 'Wallet Bot',
        'emoji' => ':money_with_wings:',
        'level' => 'critical',
    ],
],
```

Quick Start
-----------

[](#quick-start)

### 1. Add the HasWallets trait to your User model

[](#1-add-the-haswallets-trait-to-your-user-model)

```
