Add extra credit if transaction is greater than some amount #602
-
I want to add extra credit to user wallet if transaction type is deposit and greater than amount x. As I am initiating new transaction (to add extra credit) inside listener of first transaction event, listener is called multiple times (first time for main transaction and second time for credit transaction). This results in incorrect user balance. How to handle this? Any help will be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If we are talking about the credit limit, then you can not replenish the wallet, but increase the credit limit of the wallet. Then, increase the value inside meta. If you want to do the accrual of funds through the deposit method, then you can add meta data. Conditionally add "internal" to meta. $wallet->deposit(..., ['internal' => true]); And already inside the event, check this field and if it exists, then interrupt the additional accrual. if ($transaction['meta']['internal'] ?? false) { return; } Something like that. |
Beta Was this translation helpful? Give feedback.
If we are talking about the credit limit, then you can not replenish the wallet, but increase the credit limit of the wallet.
https://github.com/bavix/laravel-wallet/blob/4ea8dada0f47fa973dbe24502fdc1a4c524c34b3/docs/credit-limits.md
Then, increase the value inside meta.
If you want to do the accrual of funds through the deposit method, then you can add meta data. Conditionally add "internal" to meta.
And already inside the event, check this field and if it exists, then interrupt the additional accrual.
Something like that.