From 0a65b365a7644226fe6dcec31f752cf0cc1135e0 Mon Sep 17 00:00:00 2001 From: Shaxzodbek Qambaraliyev <47610909+shaxzodbek-uzb@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:31:56 +0500 Subject: [PATCH] multi transaction condition --- src/Http/Classes/Payme/Payme.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Http/Classes/Payme/Payme.php b/src/Http/Classes/Payme/Payme.php index d1791f1..3a3af8a 100644 --- a/src/Http/Classes/Payme/Payme.php +++ b/src/Http/Classes/Payme/Payme.php @@ -86,9 +86,9 @@ private function CheckPerformTransaction() 'Invalid amount for this object.' ); } - $active_transactions = $this->getModelTransactions($model, true); + $completed_transactions = $this->getModelTransactions($model, true); - if ((count($active_transactions) > 0) && !config('payuz')['multi_transaction']) { + if ((count($completed_transactions) > 0) && !config('payuz')['multi_transaction']) { $this->response->error( Response::ERROR_INVALID_TRANSACTION, 'There is other active/completed transaction for this object.' @@ -124,13 +124,13 @@ public function validateParams(array $params) return true; } - public function getModelTransactions($model, $active = false) + public function getModelTransactions($model, $completed = false) { $transactions = Transaction::where('payment_system', PaymentSystem::PAYME) ->where('transactionable_type', get_class($model)) ->where('transactionable_id', $model->id); - if ($active) - $transactions = $transactions->where('state', Transaction::STATE_CREATED); + if ($completed) + $transactions = $transactions->where('state', Transaction::STATE_COMPLETED); return $transactions->get(); }