vanthao03596/walletly

A flexible, feature-rich wallet library for Laravel with multi-currency support

Maintainers

Package info

github.com/vanthao03596/walletly

pkg:composer/vanthao03596/walletly

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-26 03:16 UTC

This package is auto-updated.

Last update: 2026-03-26 04:03:52 UTC


README

A flexible, feature-rich wallet library for Laravel with multi-currency support.

Latest Version on Packagist Total Downloads License

Features

  • Multiple Wallets - Support multiple wallet types per user (main, bonus, credit)
  • Multi-Currency Support - Handle different currencies with ease
  • Transaction History - Complete audit trail of all transactions
  • Flexible Operations - Deposit, withdraw, transfer between wallets
  • Event-Driven Architecture - Hooks into every wallet operation
  • Balance Calculations - Real-time balance with pending transactions support
  • Comprehensive Testing Utilities - Fake mode, assertions, and factories

Requirements

  • PHP 8.1+
  • Laravel 10.0, 11.0 or 12.0

Installation

composer require vanthao03596/walletly

The package uses Laravel's auto-discovery, so the service provider and facade are registered automatically.

Publish Configuration

php artisan vendor:publish --provider="Wallet\WalletServiceProvider" --tag="config"

Database Setup

php artisan vendor:publish --provider="Wallet\WalletServiceProvider" --tag="migrations"
php artisan migrate

Quick Start

Basic Usage

use Wallet\Wallet;

// Get user's wallet
$wallet = Wallet::of($user);

// Deposit funds
$transaction = $wallet->deposit(10000); // 100.00 in cents

// Withdraw funds
$transaction = $wallet->withdraw(5000); // 50.00 in cents

// Get balance (in cents)
$balance = $wallet->balance(); // 5000

// Transfer between wallets
$wallet->transfer($anotherWallet, 2500);

Using HasWallet Trait

Add the HasWallet trait to your User model:

use Wallet\Traits\HasWallet;

class User extends Model
{
    use HasWallet;
}

Then you can use:

$user->deposit(10000);
$user->withdraw(5000);
$user->balance();
$user->transfer($anotherUser, 2500);

Multiple Wallets

// Work with different wallet types
$mainWallet = Wallet::of($user)->wallet('main');
$bonusWallet = Wallet::of($user)->wallet('bonus');

// Deposit to bonus wallet
$bonusWallet->deposit(5000, ['reason' => 'Welcome bonus']);

// Transfer from bonus to main
$bonusWallet->transfer($mainWallet, 2500);

Transaction Metadata

// Add metadata to transactions
$wallet->deposit(10000, [
    'description' => 'Order payment',
    'order_id' => 12345,
    'source' => 'stripe',
]);

// Get transactions with metadata
$transactions = $wallet->transactions()
    ->where('meta->order_id', 12345)
    ->get();

Documentation

For complete documentation, see the docs folder:

Testing

composer test

License

The MIT License (MIT). Please see License File for more information.