laravel-pay-pocket icon indicating copy to clipboard operation
laravel-pay-pocket copied to clipboard

[Bug]: Can't Intiate wallet with 0 amount

Open greatsami opened this issue 11 months ago • 1 comments

What happened?

I try to intiate wallets for new register user but I faced exception error:

Invalie value to deposit

How to reproduce the bug

I updated the triat vendor/hpwebdeveloper/laravel-pay-pocket/src/Traits/HandlesDeposit.php

line 26: from if ($amount =< 0) { to if ($amount < 0) {

its works

Package Version

2.0.0

PHP Version

8.2.12

Laravel Version

10.46.0

Which operating systems does with happen with?

Windows

Notes

No response

greatsami avatar Mar 01 '24 00:03 greatsami

This is not a bug but an intended behaviour, you're not supposed to deposit an amount less than 0 to the wallet. I think what you should rather do shoud be somthing like this:

use HPWebdeveloper\LaravelPayPocket\Exceptions\InvalidValueException;

$user = auth()->user();

try {
    $user->deposit('wallet_2', 67.89);
} catch (InvalidValueException $e) {
    // Do anything here.
}

3m1n3nc3 avatar Mar 22 '24 02:03 3m1n3nc3