- How do I install and set up stephenjude/laravel-wallet in a Laravel app?
- Install it with composer require stephenjude/laravel-wallet, then publish the package config and migrations and run php artisan migrate. Add the HasWallet trait to the model that should own balances, such as User or Team, and create a wallet on that model. From there you call deposit, withdraw, and transfer through the package API. A mid-level Laravel developer can have a working proof of concept in under a day.
- Which Laravel and PHP versions does laravel-wallet support?
- The package is a standard Eloquent-based Laravel package, so it needs a Laravel version that supports the migrations and trait conventions it ships with. The exact supported Laravel and PHP ranges are defined in its composer.json constraints and CI matrix on the repository, so check those before committing. Because it is a single-maintainer MIT package, verify the constraints against your target framework version rather than assuming updates.
- Is laravel-wallet safe to use for real money in production?
- It is viable for low-stakes balances such as store credit, refunds, rewards, and prepaid credit, but it requires hardening for high-stakes financial use. The package is a simple wallet with a balance field mutated by credit and debit calls, not a general ledger, so it is not audit-grade on its own. For regulated e-money, multi-party settlement, or dispute handling you must add your own service layer, idempotency, and reconciliation. Treat it as a vendored dependency you may need to fork.
- Does laravel-wallet handle concurrent withdrawals without overdrawing a balance?
- Correctness under concurrency depends on every balance-mutating path running inside a database transaction with a row-level lock such as lockForUpdate on the wallet. If the package does not apply that consistently, two simultaneous withdrawals can both read the same balance and overdraw the wallet. This is the single highest-severity item to verify before adoption, so read the source for the deposit, withdraw, and transfer paths and write a concurrency test against MySQL or PostgreSQL.
- Can a model have multiple wallets and multiple currencies with this package?
- Yes, the HasWallet trait is designed for multiple wallets per owner model, each represented by a Wallet record, with transactions acting as the activity log. Multi-currency support depends on the wallet model attributes and package config, so confirm whether currency is stored per wallet. Also check whether cross-currency transfers are rejected by the package or must be enforced in your own code. Do not assume conversion or mixed-currency protection exists.
- Can I use laravel-wallet for store credit, refunds, and reward points?
- Yes, those are exactly the use cases it fits: customer credit, refunds, loyalty or reward balances, and prepaid amounts where the wallet is a convenience balance rather than a regulated ledger. The API of create wallet, deposit, withdraw, transfer, and read transaction history maps cleanly onto a User, Team, or Account model. Keep the wallet logic behind your own service class so you can swap or extend the package later without touching controllers.
- Does laravel-wallet support idempotency for retried payment webhooks?
- Retried payment webhooks are the normal case, so duplicate credits are the main production risk with any wallet package. The overview does not describe a built-in idempotency key or unique external reference, so verify the schema and add a unique constraint on an external reference column yourself. Wrap deposit and transfer calls in your own service that records the webhook event ID before crediting. Without that, retries will produce duplicate credits.
- Is the transaction history in laravel-wallet an audit-grade ledger?
- No. It is a single-entry balance mutation with a transaction log, which is not the same as an audit-grade double-entry ledger. There is no built-in guarantee that the transaction log reconstructs the wallet balance, and corrections require compensating transactions rather than edits. For financial reporting or dispute handling you must own a reconciliation job and confirm whether transaction rows are append-only or can be updated and deleted.
- Does laravel-wallet support holds, reserves, or authorize-then-capture payments?
- The package centers on immediate credit and debit operations with a transaction history, so holds and reserves are not part of its core model. If you need to authorize now and capture later, you will have to model pending balances yourself, for example with a separate reserved amount column or a status field on transactions, and enforce the rules in your own service. Confirm this against the source before designing around it.
- How is laravel-wallet tested, and what should I test before adopting it?
- Check the repository for a CI matrix across Laravel and PHP versions and look for test coverage on the money paths specifically. Even if unit tests exist, add your own feature tests for deposit, withdraw, transfer atomicity, negative-balance rejection, and concurrent withdrawals using database transactions. Run those tests against the same database engine you use in production, since locking behavior differs between MySQL, PostgreSQL, and SQLite.