Skip to content

Commit

Permalink
UNZER-498 Fix backend admin paymentId handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Tkachev committed Oct 9, 2024
1 parent c035417 commit 68f7d04
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Controller/Admin/AdminOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function render()

$transactionService = $this->getServiceFromContainer(TransactionService::class);
$orderId = $this->getEditObjectId();
$paymentId = $transactionService->getPaymentIdByOrderId($orderId, true); //somthesing like s-chg-XXXX
$paymentId = $transactionService->getAdminPaymentIdByOrderId($orderId); //somthesing like s-chg-XXXX
$this->sTypeId = $paymentId; /** may@throws \TypeError if $paymentId due to wrong payment cancellation */
$this->_aViewData['sTypeId'] = $this->sTypeId;
if ($this->sTypeId) {
Expand Down
38 changes: 35 additions & 3 deletions src/Service/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,7 @@ public function getPaymentIdByOrderId(string $orderid, bool $withoutCancel = fal
$queryBuilder = $queryBuilderFactory->create();

$query = $queryBuilder
->select(
'typeid'
)
->select('typeid')
->from('oscunzertransaction')
->distinct()
->where($queryBuilder->expr()->eq('oxorderid', ':oxorderid'))
Expand All @@ -480,6 +478,40 @@ public function getPaymentIdByOrderId(string $orderid, bool $withoutCancel = fal
return $result;
}

/**
* @param string $orderid
* @return string
* @throws Exception
* @throws \Doctrine\DBAL\Exception
* @SuppressWarnings(PHPMD.BooleanArgumentFlag)
*/
public function getAdminPaymentIdByOrderId(string $orderid): string
{
$result = '';

$queryBuilderFactory = $this->getServiceFromContainer(QueryBuilderFactoryInterface::class);
$queryBuilder = $queryBuilderFactory->create();

$query = $queryBuilder
->select('typeid')
->from('oscunzertransaction')
->distinct()
->where($queryBuilder->expr()->eq('oxorderid', ':oxorderid'))
->setMaxResults(1);

$parameters = [
':oxorderid' => $orderid,
];

$queryResult = $query->setParameters($parameters)->execute();
if ($queryResult instanceof ResultStatement && $queryResult->columnCount()) {
$result = $queryResult->fetchOne();
$result = is_string($result) ? $result : '';
}

return $result;
}

/**
* @param string $orderid
* @return string
Expand Down

0 comments on commit 68f7d04

Please sign in to comment.