Skip to content

Commit

Permalink
multi transaction condition
Browse files Browse the repository at this point in the history
  • Loading branch information
shaxzodbek-uzb committed Jun 4, 2024
1 parent 616f6e0 commit 0a65b36
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Http/Classes/Payme/Payme.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 0a65b36

Please sign in to comment.