laravel-pay-pocket
laravel-pay-pocket copied to clipboard
[Feature Request]: Restricted Wallets
What happened?
This is not a bug report but the feature flags were not working so I had to use this.
How to reproduce the bug
Make a transaction.
Package Version
1.0.3
PHP Version
8.2.0
Laravel Version
9.0.0
Which operating systems does with happen with?
macOS, Windows, Linux
Notes
I moved from a custom built solution to this library because it had features I needed and do not care to reimplement,
- Wallets should be able to be marked as restricted so that when
$user->pay(amount)
method is called, the system does not attempt to charge from those restricted wallets, like in a case when we have a dedicated escrow wallet. - Secondly my previous solution allowed me to tell the user exactly where the transaction originated, for instance
Funds transfer from User XXX
, it gets really handy and I would love to see it implemented.
If you will allow me, I can add the features and create a PR.
@3m1n3nc3 https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/9#issuecomment-1875254526
@3m1n3nc3
I assume you have read : https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/10#issuecomment-1879728872
Prior to initiating a new Pull Request for the feature: Locked/Restricted Wallet, please address the following queries:
- Who has the authority to designate a wallet as Locked? Is it the Application User or the Application Admin?
- Does this limitation apply universally to all users, or can it be customized for each user?
- What entity is responsible for lifting these restrictions, and what is the underlying process?
- In the existing system, when charging a user (pay()), an exception may occur if the combined total of balances in WL1, WL2, etc., is insufficient. Considering this, do you propose that the sum should exclude balances from restricted wallets?
@3m1n3nc3 Could you please shortly address these doubts?
https://github.com/HPWebdeveloper/laravel-pay-pocket/issues/8#issuecomment-1879761652
I still have doubts
@3m1n3nc3
I assume you have read : #10 (comment)
Prior to initiating a new Pull Request for the feature: Locked/Restricted Wallet, please address the following queries:
- Who has the authority to designate a wallet as Locked? Is it the Application User or the Application Admin?
- Does this limitation apply universally to all users, or can it be customized for each user?
- What entity is responsible for lifting these restrictions, and what is the underlying process?
- In the existing system, when charging a user (pay()), an exception may occur if the combined total of balances in WL1, WL2, etc., is insufficient. Considering this, do you propose that the sum should exclude balances from restricted wallets?
- Determining who designates a wallet as locked should be the sole responsibility of the developer, as t is just a parameter so controls can be hardcoded or set in database for flexible management depending on the use case.
- Also, who this limitation applies to is also the sole responsibility of the developer just as above.
- See above.
- With the implemetation of the
allowed wallets
feature, nothing changes as to how wallet balances are charged, theallowed wallets
are analized for chargeability and the others (restricted) are excluded.
@3m1n3nc3
Indeed it would be a good feature. I am working/thinking on a feature to make things more dynamics and if this becomes also dynamic it would be a great idea.
Doubt 1:
I expect this:
balance WL1 ($60) + WL2 ($40) = $100
WL1 is locked. hence $60 is not accessible.
I have an order which its price is $50.
Can I pay it? No, It should return an exception.
Doubt 2:
Why it is hardcoded or a parameter set in the database?
I am interested to have the ability to lock a wallet through code, something like FacadeName::Lock('WL1')
. Hence even the end user can restrict/lock a wallet.
Doubt 1:
Like I said, nothing changed, the locked wallets are restricted from being analized to be charged, so in your example, it will throw the HPWebdeveloper\LaravelPayPocket\Exceptions\InsufficientBalanceException
exception.
Doubt 2:
When you call pay()
you simply pass the allowedWallets
parameter like pay(orderValue: 10.5, allowedWallets: ['wallet_1'])
(allowedWallets
Also accepts the wallet Enum as a value), this way the developer determines wether to lock the wallet through code, or allow admin to manage it from database.