Replace ::with('balance') to ::with('wallet')
Replace CanBePaid to CanPay.
Replace CanBePaidFloat to CanPayFloat.
Replace calculateBalance to refreshBalance
Replace path bavix.wallet::transaction to Zotel\Wallet\Models\WalletTransaction::class
Replace path bavix.wallet::transfer to Zotel\Wallet\Models\WalletTransfer::class
Replace path bavix.wallet::wallet to Zotel\Wallet\Models\Wallet::class
// old
app('bavix.wallet::transaction');
// new
app(Zotel\Wallet\Models\WalletTransaction::class);
Add the $quantity parameter to the canBuy method.
// old
public function canBuy(Customer $customer, bool $force = false): bool
// new
public function canBuy(Customer $customer, int $quantity = 1, bool $force = false): bool
Add method getUniqueId to Interface Product
class Item extends Model implements Product
{
// Your method
public function getUniqueId(): string
{
return (string)$this->getKey();
}
}
Replace Taxing to Taxable.
If you are using php 7.1, then version 4.0 is not available to you. You need to update php.
Removed support for older versions of laravel/cashier. We support 7+.
You must add the argument Customer $customer to the getAmountProduct
method of your model.
Your code on 3.x:
public function getAmountProduct(): int
{
return $this->price;
}
Your code on 4.x:
public function getAmountProduct(Customer $customer): int
{
return $this->price;
}
By updating the library from 4.x to 5.x you lose strong typing. This solution was necessary to support APM (Arbitrary Precision Mathematics).
In your goods:
Your code on 4.x:
public function getAmountProduct(Customer $customer): int { ... }
public function getFeePercent(): float { ... }
public function getMinimalFee(): int { ... }
Your code on 5.x:
public function getAmountProduct(Customer $customer) { ... }
public function getFeePercent() { ... }
public function getMinimalFee() { ... }
In the exchange rate processing service:
Your code on 4.x:
protected function rate(Wallet $wallet): float { ... }
public function convertTo(Wallet $wallet): float { ... }
Your code on 5.x:
protected function rate(Wallet $wallet) { ... }
public function convertTo(Wallet $wallet) { ... }
Go to config/wallet.php file (if you have it) and edit it.
Removing unnecessary code.
$bcLoaded = extension_loaded('bcmath');
$mathClass = Math::class;
switch (true) {
case class_exists(BigDecimal::class):
$mathClass = BrickMath::class;
break;
case $bcLoaded:
$mathClass = BCMath::class;
break;
}
Replace your math class ($mathClass) with brick/math.
Your code on 5.x:
'mathable' => $mathClass,
Your code on 6.x:
'mathable' => BrickMath::class,
You need to update to the latest version for all migrations to appear.
Update config/wallet.php
The config/wallet.php config has changed a lot, if you have it in your project, then replace it run.
php artisan vendor:publish --tag=laravel-wallet-config --force
Then return your settings. The package configuration has changed globally and there is no point in describing each key 🔑
UUID for wallet
The uuid field has been added to the wallet table, which is now actively used. If you have a highload, then I recommend that you add the field yourself and mark the migration (UpdateWalletsUuidTable) completed. If you have mysql, it is better to do this via pt-online-schema-change.
If you have a small project and a small wallet base, then the migration will be applied automatically.
That's it, you can use all 7.x functions to the fullest. The contract did not change globally, added more stringency and toned down the performance of the package. On a basket of 150 products, the acceleration is a whopping 24x.
All changes can be found in the pull request. The kernel has changed globally, I would not recommend switching to version 7.0.0 at the very beginning, there may be bugs. I advise you should at least 7.0.1.
Nothing needs to be done.
Replace getAvailableBalance to getAvailableBalanceAttribute (method) or available_balance (property).
Cart methods now support fluent-dto. It is necessary to replace the old code with a new one, for example:
// old
$cart = app(\Zotel\Wallet\Objects\Cart::class)
->addItems($products)
->addItem($product)
->setMeta(['hello' => 'world']);
$cart->addItem($product);
// new. fluent
$cart = app(\Zotel\Wallet\Objects\Cart::class)
->withItems($products)
->withItem($product)
->withMeta(['hello' => 'world']);
$cart = $cart->withItem($product);
The logic of storing transfers between accounts has changed. Previously, money could be credited to the user directly, but starting from version nine, all transactions go strictly between wallets. Thanks to this approach, finally, there will be full-fledged work with uuid identifiers in the project.
To migrate to the correct structure, you need to run the command:
artisan bx:transfer:fix
If the command fails, then the command must be restarted. Continue until the command starts executing immediately (no bad entries left).
The product has been divided into two interfaces:
ProductLimitedInterface. Needed to create limited goods;ProductInterface. Needed for an infinite number of products;The old Product interface should be replaced with one of these.
Replace Zotel\Wallet\Interfaces\Product to Zotel\Wallet\Interfaces\ProductLimitedInterface.
from_type, to_type in the transfers table have been physically removed. Make sure you don't use them;extra column has been added to the transfers table. Don't forget to apply all new migrations;Zotel\Wallet\Interfaces\Wallet contract has been extended with the receivedTransfers method. If you overridden the implementation, then implement the new method;How can I help you explore Laravel packages today?