bavix / laravel-wallet

It's easy to work with a virtual wallet
https://bavix.github.io/laravel-wallet/
MIT License
1.14k stars 230 forks source link

Why is a new wallet generated when making a purchase? #830

Closed JoelVeloz closed 9 months ago

JoelVeloz commented 10 months ago

Is your feature request related to a problem? Please describe. I am trying this package, and I have a question as to why more wallets are created to pay for a product, I feel that it is very illogical from my point of view. My reason: Having N number of products, I consider that the normal thing should be that N number of withdrawals are generated that are recorded in the transaction table, all referring to a single wallet.

With this package, having N number of products, to make purchases, requires me to have N number of transfers, N of wallets, and 2*N of transactions (deposit and withdrawal), I consider creating data that is not necessary.

I know they exist for a reason, but under what reasoning? What would wallets for products already paid for be useful to me? What would happen to the balance that the wallets of said products have?

Describe alternatives you've considered The package is very good, the proposed solution would be to charge when purchasing, which is a functionality that is already implemented.

Additional context I would like to know if the applied structure is based on some market standard, some paper to be able to understand much better how the data works, it would be of great help to me.

rez1dent3 commented 10 months ago

Hello.

With this package, having N number of products, to make purchases, requires me to have N number of transfers, N of wallets, and 2*N of transactions (deposit and withdrawal), I consider creating data that is not necessary.

The basis of purchases is transfer.

I know they exist for a reason, but under what reasoning?

The product wallet is needed for a refund. Lossless wallet architecture.

Eg,

  1. cashback for purchasing a product can be credited from the product’s wallet;
  2. limitation of the loyalty program relative to the total turnover of goods;

Those, if 10 people bought 1 product and 8 returned the product, then the total fund is equal to two costs of the product.

There are many approaches, but originally I solved my problem, which formed the basis of the wallet. I don’t plan to change the architecture now, because... Quite a lot of people use this product in their projects, I need to maintain backward compatibility.

What would wallets for products already paid for be useful to me?

Hypothetically, you could create one wallet and override the wallet() method, which pulls out the wallet. Then you will create a pool for all items (but returns will likely break down).

What would happen to the balance that the wallets of said products have?

Nothing. These are ordinary wallets; product owners can, for example, withdraw turnover to their cards. "Alya" marketplace.

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 7 days with no activity.