HPWebdeveloper / laravel-pay-pocket

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

[Feature Request]: Restricted Wallets #8

Open 3m1n3nc3 opened 7 months ago

3m1n3nc3 commented 7 months ago

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,

  1. 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.
  2. 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.
3m1n3nc3 commented 7 months ago

If you will allow me, I can add the features and create a PR.

HPWebdeveloper commented 7 months ago

@3m1n3nc3 https://github.com/HPWebdeveloper/laravel-pay-pocket/pull/9#issuecomment-1875254526

3m1n3nc3 commented 7 months ago

@3m1n3nc3 #9 (comment)

Take a look at my new comment on #9

HPWebdeveloper commented 7 months ago

@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:

HPWebdeveloper commented 7 months ago

@3m1n3nc3 Could you please shortly address these doubts?

https://github.com/HPWebdeveloper/laravel-pay-pocket/issues/8#issuecomment-1879761652

I still have doubts

3m1n3nc3 commented 7 months ago

@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?
HPWebdeveloper commented 7 months ago

@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.

3m1n3nc3 commented 7 months ago

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.