Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2025-04-24 (4 days ago) ![]() | Not yet rated by the users | Total: Not yet counted | Not yet ranked |
Version | License | PHP version | Categories | |||
laravel-virtual-wall 1.0.0 | Custom (specified... | 7 | Finances, PHP 7 |
Description | Author | |
This package can manage money amounts stored in a wallet. |
|
Please read this documentation with usage instructions to learn [how to use PHP to manage money amounts stored in wallets] using this package.(https://www.phpclasses.org/browse/file/399447.html).
<h1 align="center">? Laravel Virtual Wallet Documentation</h1>
<p align="center">
<img src="laravel-virtual-wallet-logo.png" alt="Laravel Virtual Wallet Logo" style="width: 100%; max-width: 800px;" />
</p>
A lightweight, plug-and-play Laravel package for managing virtual wallets, supporting multiple wallet types, transaction logs, and seamless integration with any model like User
.
? Multi-Wallet Support ? Create and manage multiple wallet types per user. ? Transaction Management ? All wallet operations are recorded for full traceability. ? Payment Processing ? Seamlessly handle payments between wallets or external systems. ? Deposit Handling ? Accept and log deposits from users or third-party services. ? Multiple Currency Support ? Manage wallet balances in different currencies with ease. ? Wallet Status Tracking ? Monitor and update wallet statuses like active, frozen, or closed. ? Secure & Reliable ? Built using Laravel's Eloquent, enums, morphs & policy-friendly structure. ?? Highly Configurable ? Override models, table names, and more via config. ? Easy Integration ? Just use a trait on your model and you're ready to go. ? Balance Management ? Simple credit, debit, transfer, and balance APIs.
composer require haxneeraj/laravel-virtual-wallet
php artisan vendor:publish --provider="Haxneeraj\LaravelVirtualWallet\LaravelVirtualWalletServiceProvider"
php artisan migrate
After publishing the config file, you can modify config/laravel-virtual-wallet.php
to override models, table names, and enums if needed.
Add the trait and implement the interface in your User
(or any Eloquent model):
use Haxneeraj\LaravelVirtualWallet\Interfaces\WalletInterface;
use Haxneeraj\LaravelVirtualWallet\Traits\HasVirtualWallet;
class User extends Authenticatable implements WalletInterface
{
use HasVirtualWallet;
}
$user->wallets()->create([
'wallet_type' => 'main', // Type of wallet (e.g., 'main', 'bonus', 'savings'). Define these in your WalletType enum.
'currency' => 'usd', // ISO currency code. Ensure 'usd' or your required currencies are defined in your Currency enum.
'balance' => 100, // Initial wallet balance. Usually set to 0 or default starting value.
'currency_type' => 'fiat_currency', // Define whether the currency is fiat, crypto, token, etc. Set values in CurrencyType enum.
'status' => 'active' // Current status of wallet (e.g., 'active', 'frozen', 'closed'). Defined in WalletStatus enum.
]);
$paymentData = new PaymentData([
'owner_type' => User::class,
'owner_id' => $this->user->id,
'txid' => 'test-txid',
'amount' => 100,
'description' => 'Test deposit',
'wallet_type' => 'wallet1',
'method' => 'automatic',
'transaction_type' => 'deposit',
'status' => 'approved',
'currency' => 'usd',
'currency_type' => 'fiat_currency'
]);
$user->deposit($paymentData);
$paymentData = new PaymentData([
'owner_type' => User::class,
'owner_id' => $this->user->id,
'txid' => 'test-txid-withdraw1',
'amount' => 50,
'description' => 'Test withdrawal',
'wallet_type' => 'wallet1',
'method' => 'automatic',
'transaction_type' => 'withdraw',
'status' => 'approved',
'currency' => 'usd',
'currency_type' => 'fiat_currency'
]);
$user->pay($paymentData);
$balance = $user->getBalance('main');
$user->hasSufficientBalance(50, 'main');
| Method | Parameters | Returns | Description |
|--------------------------|--------------------------------------------------|------------------|----------------------------------------|
| wallets()
| string $walletType = null
| MorphMany
| Get all wallets or filter by type |
| getBalance()
| string $walletType = null
| int OR float
| Get wallet balance |
| hasBalance()
| string $walletType = null
| bool
| Check if wallet has positive balance |
| hasSufficientBalance()
| int OR float $amount, string $walletType = null
| bool
| Check if wallet has sufficient balance |
| Method | Parameters | Returns | Description |
|----------|----------------------------|---------|--------------------------------|
| pay()
| PaymentData $paymentData
| void
| Process payment from wallet(s) |
| Method | Parameters | Returns | Description |
|-------------|----------------------------|---------|---------------------------|
| deposit()
| PaymentData $paymentData
| void
| Deposit funds into wallet |
The PaymentData
object is used for both payments and deposits. It accepts the following parameters:
The package throws the following exceptions:
This package comes with feature and unit tests to ensure everything works smoothly.
? Run Tests
composer test
Contributions, issues and feature requests are welcome!
Neeraj Saini ? hax-neeraj@outlook.com ? https://github.com/haxneeraj/laravel-virtual-wallet
Licensed under the MIT License.
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Icon | Icon image | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
![]() | laravel-virtual-wall-2025-04-24.zip 664KB |
![]() | laravel-virtual-wall-2025-04-24.tar.gz 645KB |
![]() | Install with Composer |
Version Control | Unique User Downloads | |||||||
100% |
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.