HPWebdeveloper / laravel-pay-pocket

A modern multi-wallet Laravel 10,11 package with comprehensive logging and payments capabilities and more than 3.5k installed
https://github.com/HPWebdeveloper/demo-pay-pocket
MIT License
272 stars 30 forks source link

Fix Wallet type validation bug #22

Closed 3m1n3nc3 closed 5 months ago

3m1n3nc3 commented 5 months ago

The getWalletBalanceByType() method of the HasWallet trait requires a string parameter as wallet type and does checks wallet validity using WalletEnums::isValid($walletType) which also requires a string parameter, the isValid method of the WalletEnums enum checks the wallet vality by looping through self::cases() and checking for a match self::cases() is an array of WalletEnum case instances and not strings, meaning a match will never be found, this pull request fixes that by allowing the $type parameter to be either a string or an instance of WalletEnums and then checking if it's a string then converting it to the appropriete case using WalletEnums::from($type).