Need wallet functionality in your Laravel app? If you’re building deposits, transfers, fees, payment approvals, or scheduled payments, handling balances yourself can quickly become complicated.
Advanced Laravel Wallet is a Laravel package for building double-entry, multi-account wallets. It gives you a ledger-oriented foundation for common payment flows, while letting your application decide how those flows fit into your product.
Why double-entry?
A balance by itself tells you what an account has now—but not necessarily how it got there. In a double-entry ledger, transfers are the source of truth, and balances are a projection that can be reconciled against the transaction history.
That approach is useful when you need more than "subtract from one user, add to another." For example, a payment might involve a fee account, an authorization step, or a later chargeback.
What you can build
Laravanced Wallet includes:
- Multiple account types, including user and system accounts
- Accounts owned by any Eloquent model
- Transfer types with amount and frequency limits
- Fixed and percentage fees, with configurable payer and receiver
- Payment previews designed to match what the eventual payment books
- Authorization flows that reserve funds while a payment is pending
- Chargebacks for a transaction or an individual transfer
- Scheduled and recurring payments, including installment plans
- Paginated history, totals, and ledger balances as of a date
- Events and commands for processing scheduled payments and reconciling balances
Install it
composer require hsemix/laravanced-wallet
php artisan migrate
php artisan vendor:publish --tag=wallet-config
Publishing the configuration is optional. The package requires the PHP ext-bcmath extension. Monetary values use decimal(20,4) storage and string-based arithmetic rather than floats.
Give a model a wallet
Add the HasWallet trait to any Eloquent model that should own wallet accounts:
use Hsemix\AdvancedWallet\Concerns\HasWallet;
class User extends Model
{
use HasWallet;
}
Then, after configuring an account type, open an account for a user:
$user->openAccount('wallet');
Accounts are polymorphic, so they don’t have to belong only to a User model.
Configure transfers and make a payment
The package uses account types and transfer types to describe which accounts can participate in a payment. For example, you might configure a user wallet, a system treasury, and a transfer type for deposits.
Once those are configured, a payment can move funds from the system account to a user:
Wallet::pay([
'from' => 'system',
'to' => $user,
'type' => 'treasury.deposit',
'amount' => 100,
]);
You can also transfer between wallet owners:
$alice->payTo(
$bob,
'wallet.transfer',
40,
'rent'
);
Payment types use the format "account_type.transfer_type". The from and to values can be an account, an owner model, 'system', or an account ID.
Preview before booking
Sometimes you need to show the user what a payment will do before they confirm it. Use preview() to inspect the proposed payment:
$preview = Wallet::preview([
'from' => $alice,
'to' => $bob,
'type' => 'wallet.transfer',
'amount' => 40,
]);
The package’s preview flow is designed to match what perform() books, which is especially useful when fees affect the final amounts.
Add fees and approval flows
Fees can be configured as fixed amounts or percentages, with options for who pays and who receives them. For example, a percentage fee can be charged to the source account and credited to a system account.
For payments that need approval, the package supports pending payments that reserve funds. You can then authorize, deny, or cancel the payment:
Wallet::payments()->authorize($transaction);
// Other available actions:
Wallet::payments()->deny($transaction, $reviewer, 'Reason');
Wallet::payments()->cancel($transaction);
The wallet balance API can report the balance, reserved amount, and available amount:
$balance = $user->walletBalance('wallet');
Scheduled payments and chargebacks
You can schedule payments as installments—for example, splitting a total principal across three monthly payments:
Wallet::scheduled()->schedule([
'from' => $alice,
'to' => $bob,
'type' => 'wallet.plan',
'amount' => 900,
'installments' => 3,
'immediate' => false,
'first_date' => '2026-02-01',
'frequency_unit' => 'month',
]);
The package also supports chargebacks for a whole transaction or a single transfer, including fees. Scheduled payments can support flat or annual amortized interest, with optional full reservation.
Give it a try
Laravanced Wallet can help you get started with ledger-based wallet functionality without building every payment mechanism from scratch. Explore the Docs for setup details and the available APIs, then adapt the account and transfer types to your application.
Top comments (0)