PHPackages                             bavix/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. [Database &amp; ORM](/categories/database)
4. /
5. bavix/laravel-wallet

ActiveLibrary[Database &amp; ORM](/categories/database)

bavix/laravel-wallet
====================

It's easy to work with a virtual wallet.

12.0.3(5d ago)1.3k1.3M↓20.9%247[2 PRs](https://github.com/bavix/laravel-wallet/pulls)13MITPHPPHP ^8.3CI passing

Since Nov 7Pushed 1w ago41 watchersCompare

[ Source](https://github.com/bavix/laravel-wallet)[ Packagist](https://packagist.org/packages/bavix/laravel-wallet)[ Docs](https://bavix.github.io/laravel-wallet/)[ Fund](https://www.buymeacoffee.com/babichev)[ Fund](https://opencollective.com/laravel-wallet)[ RSS](/packages/bavix-laravel-wallet/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (10)Dependencies (64)Versions (171)Used By (13)

[![Laravel Wallet](https://private-user-images.githubusercontent.com/5111255/342062304-95e7877c-a950-4b04-9414-de62216d31c2.jpeg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI2NzYwMzUsIm5iZiI6MTc4MjY3NTczNSwicGF0aCI6Ii81MTExMjU1LzM0MjA2MjMwNC05NWU3ODc3Yy1hOTUwLTRiMDQtOTQxNC1kZTYyMjE2ZDMxYzIuanBlZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EY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

[![Coverage Status](https://camo.githubusercontent.com/b3932fa27d521b0177fb64fe711efa83afbe2e02390e8efb91ad8c3d88dd7c55/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f62617669782f6c61726176656c2d77616c6c65742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/bavix/laravel-wallet?branch=master) [![Financial Contributors on Open Collective](https://camo.githubusercontent.com/b727255cd9d74d19050d4f8481c66562f99914e667594680e13da28c869ad12b/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f6c61726176656c2d77616c6c65742f616c6c2f62616467652e7376673f6c6162656c3d66696e616e6369616c2b636f6e7472696275746f7273)](https://opencollective.com/laravel-wallet) [![Mutation testing badge](https://camo.githubusercontent.com/cf4d068af0fd42a0058ef464bf71166be116f142dd09dfc2c31b571b51a2604d/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d25324662617669782532466c61726176656c2d77616c6c65742532466d6173746572)](https://packagist.org/packages/bavix/laravel-wallet)

[![Latest Stable Version](https://camo.githubusercontent.com/61865f74314f89bcb84aa796dfb4dc1754d72a155d7d76dcd897389bd9d8268c/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f76)](https://packagist.org/packages/bavix/laravel-wallet) [![Latest Unstable Version](https://camo.githubusercontent.com/16905de8dc2edf3ec6223429da4be9937e9f6d2af3cb2b56ad12bafe675d15ea/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f762f756e737461626c65)](https://packagist.org/packages/bavix/laravel-wallet) [![License](https://camo.githubusercontent.com/6de443f6f31da5e3143cbe8c9536b1b3ed9978267ce792c57d05d738e59d3def/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f6c6963656e7365)](https://packagist.org/packages/bavix/laravel-wallet) [![composer.lock](https://camo.githubusercontent.com/9e96f0e03e71258c398eda14d460dd93dc0921392639aef41c855c4691425fa4/68747470733a2f2f706f7365722e707567782e6f72672f62617669782f6c61726176656c2d77616c6c65742f636f6d706f7365726c6f636b)](https://packagist.org/packages/bavix/laravel-wallet)

laravel-wallet - It's easy to work with a virtual wallet.

\[[Benchmark](https://github.com/bavix/laravel-wallet-benchmark/)\] \[[Documentation](https://bavix.github.io/laravel-wallet/)\] \[[Get Started](https://bavix.github.io/laravel-wallet/guide/introduction/)\]

- **Vendor**: bavix
- **Package**: laravel-wallet
- **[Composer](https://getcomposer.org/):** `composer require bavix/laravel-wallet`

### Support Policy

[](#support-policy)

VersionLaravelPHPRelease dateEnd of improvementsEnd of support12.x^13.08.3,8.4,8.5Apr 18, 2026May 1, 2028Sep 6, 202811.x^11.0, ^12.0, ^13.08.3,8.4,8.5Mar 14, 2024May 1, 2026Sep 6, 2026### Upgrade Guide

[](#upgrade-guide)

To perform the migration, you will be [helped by the instruction](https://bavix.github.io/laravel-wallet/#/upgrade-guide).

### Community

[](#community)

I want to create a cozy place for developers using the wallet package. This will help you find bugs faster, get feedback and discuss ideas.

[![telegram](https://private-user-images.githubusercontent.com/5111255/341986764-ed2b1193-c0c6-41af-83cb-0fe61ae8df21.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODI2NzYwMzUsIm5iZiI6MTc4MjY3NTczNSwicGF0aCI6Ii81MTExMjU1LzM0MTk4Njc2NC1lZDJiMTE5My1jMGM2LTQxYWYtODNjYi0wZmU2MWFlOGRmMjEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDYyOCUyRnVzLWVhc3QtMSUyRnMzJTJ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Su4jXUrqeEgKU8rwf0)

Telegram: [@laravel\_wallet](https://t.me/laravel_wallet)

### Extensions

[](#extensions)

ExtensionDescription[Swap](https://github.com/bavix/laravel-wallet-swap)Addition to the laravel-wallet library for quick setting of exchange rates[uuid](https://github.com/bavix/laravel-wallet-uuid)Addition to laravel-wallet to support model uuid keys[Warm Up](https://github.com/bavix/laravel-wallet-warmup)Addition to the laravel-wallet library for refresh balance wallets### Usage

[](#usage)

Add the `HasWallet` trait and `Wallet` interface to model.

```
use Bavix\Wallet\Traits\HasWallet;
use Bavix\Wallet\Interfaces\Wallet;

class User extends Model implements Wallet
{
    use HasWallet;
}
```

Now we make transactions.

```
$user = User::first();
$user->balanceInt; // 0

$user->deposit(10);
$user->balance; // 10
$user->balanceInt; // int(10)

$user->withdraw(1);
$user->balance; // 9

$user->forceWithdraw(200, ['description' => 'payment of taxes']);
$user->balance; // -191
```

### Purchases

[](#purchases)

Add the `CanPay` trait and `Customer` interface to your `User` model.

```
use Bavix\Wallet\Traits\CanPay;
use Bavix\Wallet\Interfaces\Customer;

class User extends Model implements Customer
{
    use CanPay;
}
```

Add the `HasWallet` trait and interface to `Item` model.

Starting from version 9.x there are two product interfaces:

- For an unlimited number of products (`ProductInterface`);
- For a limited number of products (`ProductLimitedInterface`);

An example with an unlimited number of products:

```
use Bavix\Wallet\Traits\HasWallet;
use Bavix\Wallet\Interfaces\Customer;
use Bavix\Wallet\Interfaces\ProductInterface;

class Item extends Model implements ProductInterface
{
    use HasWallet;

    public function getAmountProduct(Customer $customer): int|string
    {
        return 100;
    }

    public function getMetaProduct(): ?array
    {
        return [
            'title' => $this->title,
            'description' => 'Purchase of Product #' . $this->id,
        ];
    }
}
```

Example with a limited number of products:

```
use Bavix\Wallet\Traits\HasWallet;
use Bavix\Wallet\Interfaces\Customer;
use Bavix\Wallet\Interfaces\ProductLimitedInterface;
use Bavix\Wallet\External\Api\PurchaseQuery;
use Bavix\Wallet\External\Api\PurchaseQueryHandlerInterface;

class Item extends Model implements ProductLimitedInterface
{
    use HasWallet;

    public function canBuy(Customer $customer, int $quantity = 1, bool $force = false): bool
    {
        /**
         * This is where you implement the constraint logic.
         *
         * If the service can be purchased once, then
         *  return ! app(PurchaseQueryHandlerInterface::class)->one(PurchaseQuery::create($customer, $this));
         */
        return true;
    }

    public function getAmountProduct(Customer $customer): int|string
    {
        return 100;
    }

    public function getMetaProduct(): ?array
    {
        return [
            'title' => $this->title,
            'description' => 'Purchase of Product #' . $this->id,
        ];
    }
}
```

I do not recommend using the limited interface when working with a shopping cart. If you are working with a shopping cart, then you should override the `PurchaseServiceInterface` interface. With it, you can check the availability of all products with one request, there will be no N-queries in the database.

Proceed to purchase.

```
$user = User::first();
$user->balance; // 100

$item = Item::first();
$user->pay($item); // If you do not have enough money, throw an exception
var_dump($user->balance); // 0

if ($user->safePay($item)) {
  // try to buy again
}

var_dump((bool) app(PurchaseQueryHandlerInterface::class)->one(PurchaseQuery::create($user, $item))); // bool(true)

var_dump($user->refund($item)); // bool(true)
var_dump((bool) app(PurchaseQueryHandlerInterface::class)->one(PurchaseQuery::create($user, $item))); // bool(false)
```

### Eager Loading

[](#eager-loading)

```
// When working with one wallet
User::with('wallet');

// When using the multi-wallet functionality
User::with('wallets');
```

### How to work with fractional numbers?

[](#how-to-work-with-fractional-numbers)

Add the `HasWalletFloat` trait and `WalletFloat` interface to model.

```
use Bavix\Wallet\Traits\HasWalletFloat;
use Bavix\Wallet\Interfaces\WalletFloat;
use Bavix\Wallet\Interfaces\Wallet;

class User extends Model implements Wallet, WalletFloat
{
    use HasWalletFloat;
}
```

Now we make transactions.

```
$user = User::first();
$user->balance; // 100
$user->balanceFloat; // 1.00

$user->depositFloat(1.37);
$user->balance; // 237
$user->balanceFloat; // 2.37
```

Contributors
------------

[](#contributors)

### Code Contributors

[](#code-contributors)

This project exists thanks to all the people who contribute. \[[Contribute](CONTRIBUTING.md)\]. [![](https://camo.githubusercontent.com/250ed6eb5180c053298850feeabd99e6d1217c9189e49f7e623cd6d09ec76f91/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f6c61726176656c2d77616c6c65742f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365)](https://github.com/bavix/laravel-wallet/graphs/contributors)

### Financial Contributors

[](#financial-contributors)

Become a financial contributor and help us sustain our community. \[[Contribute](https://opencollective.com/laravel-wallet/contribute)\]

#### Individuals

[](#individuals)

[![](https://camo.githubusercontent.com/d5ce74091ab4cb617607636e0763d0f4b32e906810ce3ea613d5169023cc355a/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f6c61726176656c2d77616c6c65742f696e646976696475616c732e7376673f77696474683d383930)](https://opencollective.com/laravel-wallet)

#### Organizations

[](#organizations)

Support this project with your organization. Your logo will show up here with a link to your website. \[[Contribute](https://opencollective.com/laravel-wallet/contribute)\]

###  Health Score

80

—

ExcellentBetter than 100% of packages

Maintenance98

Actively maintained with recent releases

Popularity66

Solid adoption and visibility

Community45

Growing community involvement

Maturity96

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 85% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Total

163

Last Release

5d ago

Major Versions

9.6.4 → 10.1.42024-03-09

10.1.5 → 11.0.02024-03-13

10.1.6 → 11.0.32024-03-26

10.1.7 → 11.2.22024-09-10

11.5.0 → 12.0.02026-04-18

PHP version history (9 changes)0.0.1PHP ^7.1

3.1.5PHP ^7.1|^8.0

4.0.0PHP ^7.2|^8.0

5.4.0PHP ^7.3|^8.0

6.2.0PHP ^7.4|^8.0

8.0.0PHP ^8.0

10.0.0PHP ^8.1

11.0.0PHP ^8.2

11.4.3PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/266f28651b740a279e636ef42fadcc7d72941c7a4bf9a29c4fd62c72476f0c0e?d=identicon)[REZ1DENT3](/maintainers/REZ1DENT3)

---

Top Contributors

[![rez1dent3](https://avatars.githubusercontent.com/u/5111255?v=4)](https://github.com/rez1dent3 "rez1dent3 (1864 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (184 commits)")[![bavixbot](https://avatars.githubusercontent.com/u/142083844?v=4)](https://github.com/bavixbot "bavixbot (62 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (15 commits)")[![gkmk](https://avatars.githubusercontent.com/u/4238408?v=4)](https://github.com/gkmk "gkmk (13 commits)")[![justinkekeocha](https://avatars.githubusercontent.com/u/39213342?v=4)](https://github.com/justinkekeocha "justinkekeocha (11 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (11 commits)")[![keatliang2005](https://avatars.githubusercontent.com/u/473990?v=4)](https://github.com/keatliang2005 "keatliang2005 (5 commits)")[![snyk-bot](https://avatars.githubusercontent.com/u/19733683?v=4)](https://github.com/snyk-bot "snyk-bot (5 commits)")[![adesege](https://avatars.githubusercontent.com/u/20769821?v=4)](https://github.com/adesege "adesege (3 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![cispl-shaswatad](https://avatars.githubusercontent.com/u/59719293?v=4)](https://github.com/cispl-shaswatad "cispl-shaswatad (2 commits)")[![hosni](https://avatars.githubusercontent.com/u/47793698?v=4)](https://github.com/hosni "hosni (2 commits)")[![bharb82](https://avatars.githubusercontent.com/u/159435438?v=4)](https://github.com/bharb82 "bharb82 (1 commits)")[![Thiritin](https://avatars.githubusercontent.com/u/6755282?v=4)](https://github.com/Thiritin "Thiritin (1 commits)")[![MarJose123](https://avatars.githubusercontent.com/u/18107626?v=4)](https://github.com/MarJose123 "MarJose123 (1 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 commits)")[![moecasts](https://avatars.githubusercontent.com/u/37169906?v=4)](https://github.com/moecasts "moecasts (1 commits)")[![monkeywithacupcake](https://avatars.githubusercontent.com/u/7316730?v=4)](https://github.com/monkeywithacupcake "monkeywithacupcake (1 commits)")[![nathanwritescode-uk](https://avatars.githubusercontent.com/u/22125007?v=4)](https://github.com/nathanwritescode-uk "nathanwritescode-uk (1 commits)")

---

Tags

balancecomposereloquentlaravellaravel-walletmulti-walletphppurchasevirtualwalletlaravelcurrencylaravel-packagepaymentswalletvirtualcreditslaravel-walletbavix

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bavix-laravel-wallet/health.svg)

```
[![Health](https://phpackages.com/badges/bavix-laravel-wallet/health.svg)](https://phpackages.com/packages/bavix-laravel-wallet)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.7k](/packages/illuminate-database)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[bavix/laravel-wallet-swap

Addition to the package laravel-wallet.

2529.6k](/packages/bavix-laravel-wallet-swap)[api-platform/laravel

API Platform support for Laravel

58171.8k14](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
