sakshsky/saksh-wallet
最新稳定版本:v1.0.0
Composer 安装命令:
composer require sakshsky/saksh-wallet
包简介
A simple wallet system for Laravel applications
README 文档
README
A simple and performant wallet system for Laravel applications, using two tables to manage transactions and balances.
Installation
-
Install via Composer:
composer require sakshsky/saksh-wallet
-
Publish and run migrations:
php artisan vendor:publish --tag=saksh-wallet-migrations php artisan migrate
This creates two tables (
wallet_transactionsandbalances) via a single migration.
Usage
use Saksh\Wallet\Services\SakshWallet; $wallet = app('saksh-wallet'); $userId = 1; // Set admin email (optional) $wallet->setAdmin('admin@example.com'); // Credit an amount echo $wallet->addFunds($userId, 500, 'USD', 'ref123', 'Salary payment'); // Output: Credited 500 USD. New balance is 500 // Debit an amount with a fee echo $wallet->deductFunds($userId, 200, 'USD', 'ref124', 'Grocery shopping', 5); // Output: Debited 200 USD. New balance is 295 // Get balance $balance = $wallet->getBalance($userId, 'USD'); print_r($balance); // Output: ['user_id' => 1, 'currency' => 'USD', 'balance' => 295] // Get balance summary $summary = $wallet->sakshGetBalanceSummary($userId); print_r($summary); // Output: ['user_id' => 1, 'balance' => ['USD' => 295]]
Database Structure
wallet_transactions: Stores transaction history (credits and debits).balances: Stores current balances for each user and currency.
Commands
- Verify wallet integrity:
php artisan saksh-wallet:verify
Testing
Run the tests:
vendor/bin/phpunit
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
Repository
Find the source code at https://github.com/sakshsky/saksh-wallet.
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-12