-
-
Notifications
You must be signed in to change notification settings - Fork 241
How to pay with new wallet? #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
new wallet: $usd = $user->createWallet(['name' => 'USD']);
// todo deposit
$usd->pay($product); find wallet: $usd = $user->getWallet('usd'); // find by slug
$usd->pay($product); |
@moecasts I have noticed that the free is considered not true. Soon to be fixed.... |
@rez1dent3 I have got that, when I pay with the user's second wallet, the product default wallet will get the money. Also, the transfer from_type will be the Wallet Class, it should be the User Class, and the transfer status is 'gift' which should be 'paid'. |
@moecasts fixes in tag 2.3.0. One migration was added. |
@rez1dent3 I got this error after upgraded. Is that a wrong in the package? |
@moecasts funnily... I'll try to catch it. I didn't have one of those. |
@moecasts added doctrine/dbal depending. the problem should disappear... tag 2.3.1 |
@rez1dent3 Yes, I have just found that. Thank you very much! |
@rez1dent3 There is a new error. And I solved it by adding that to the new migration. |
@moecasts able to reproduce... |
@rez1dent3 Will you add this to the package? |
@moecasts yes |
@rez1dent3 Thank you very much! |
@moecasts done. see the tag 2.3.2 |
@rez1dent3 There is a problem, when I pay with new wallet, the transfer's from_type and from_id is wallet class and id, it would cause that |
@moecasts The user is a wallet, so when you buy a product is assigned to him. This feature is necessary for the implementation of the return (refund) of goods. |
@moecasts You can inherit from Wallet and add relations. |
@rez1dent3 I try to get the new wallet transfers, but it only return the default wallet transfers. Is it wrong? |
@moecasts composer req bavix/laravel-wallet:2.4.x-dev Simple: $user = \App\User::first();
$user->load('wallets.transfers');
$item = \App\Item::first();
$usd = $user->getWallet('usd');
$usd->pay($item); // first
$user->wallet->pay($item); // payment by default wallet
$usd->pay($item); // payment with new wallet Result: {
"id":1,
"name":"Arch Schaden",
"email":"[email protected]",
"email_verified_at":"2019-05-13 18:28:23",
"created_at":"2019-05-13 18:28:23",
"updated_at":"2019-05-13 18:28:23",
"wallets":[
{
"id":1,
"holder_type":"App\\User",
"holder_id":1,
"name":"Default Wallet",
"slug":"default",
"description":null,
"balance":238832,
"created_at":"2019-05-13 18:30:40",
"updated_at":"2019-05-13 18:45:25",
"transfers":[
{
"id":3,
"from_type":"Bavix\\Wallet\\Models\\Wallet",
"from_id":1,
"to_type":"App\\Item",
"to_id":1,
"status":"paid",
"status_last":null,
"deposit_id":9,
"withdraw_id":8,
"fee":0,
"uuid":"d52fb86e-37b8-4b5f-994c-ca1cd986bb78",
"created_at":"2019-05-13 18:45:25",
"updated_at":"2019-05-13 18:45:25"
}
]
},
{
"id":3,
"holder_type":"App\\User",
"holder_id":1,
"name":"EUR",
"slug":"eur",
"description":null,
"balance":716496,
"created_at":"2019-05-13 18:30:40",
"updated_at":"2019-05-13 18:35:43",
"transfers":[
]
},
{
"id":2,
"holder_type":"App\\User",
"holder_id":1,
"name":"USD",
"slug":"usd",
"description":null,
"balance":238832,
"created_at":"2019-05-13 18:30:40",
"updated_at":"2019-05-13 18:45:25",
"transfers":[
{
"id":2,
"from_type":"Bavix\\Wallet\\Models\\Wallet",
"from_id":2,
"to_type":"App\\Item",
"to_id":1,
"status":"paid",
"status_last":null,
"deposit_id":7,
"withdraw_id":6,
"fee":0,
"uuid":"ef6b6a71-b375-4d07-b2a3-98f3b1491f96",
"created_at":"2019-05-13 18:41:35",
"updated_at":"2019-05-13 18:41:35"
},
{
"id":4,
"from_type":"Bavix\\Wallet\\Models\\Wallet",
"from_id":2,
"to_type":"App\\Item",
"to_id":1,
"status":"paid",
"status_last":null,
"deposit_id":11,
"withdraw_id":10,
"fee":0,
"uuid":"52289967-76c0-4cdc-ae25-0583b12e83df",
"created_at":"2019-05-13 18:45:25",
"updated_at":"2019-05-13 18:45:25"
}
]
}
]
} |
@rez1dent3 I found that, the
|
@moecasts Here the default wallet will return, you can check. |
@rez1dent3 The
|
@rez1dent3 In my opinion, the transfers table should not have from_type and to_type columns, we can get the holder without that columns. |
@moecasts Initially, the wallet was developed for yourself and without the ability to work with many wallets. Because of this, such a structure was chosen. It works for many wallets, but the goods will be assigned to the wallet. In the next versions, I plan to implement a verification feature similar to yours, but it should be done more accurately and abstractly. PS, |
@rez1dent3 Sorry what's the meaning of |
@moecasts $user->wallet->pay($item);
$user->paid($item); // false
$user->wallet->pay($item); // true |
@moecasts At the moment there can be 2 solutions.
|
I checked,it did't return the default wallet. Code:
Result:
But the default wallet is
|
@moecasts I can replace it with $this, it won't break anything. need to? |
@rez1dent3 just need to add this code |
@moecasts Okay I will try. Thank you. |
@rez1dent3 thank you very much! |
@moecasts done. branch 2.4.x-dev |
@moecasts Edits made. Use the 2.4.0 tag. Thank you. |
There are multi wallets in the app, how to pay with the right wallet?
The text was updated successfully, but these errors were encountered: