From 75df11516bac452adb72d9b2f0a322b12fb6ead6 Mon Sep 17 00:00:00 2001 From: Daniil Tkachev Date: Thu, 10 Oct 2024 16:00:06 +0200 Subject: [PATCH] UNZER-499 Fix paymentId handling in admin backend --- src/Controller/Admin/AdminOrderController.php | 4 +- src/Service/Transaction.php | 38 +++---------------- 2 files changed, 8 insertions(+), 34 deletions(-) diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 4d0bf986..88023c38 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -88,7 +88,9 @@ public function render() $transactionService = $this->getServiceFromContainer(TransactionService::class); $orderId = $this->getEditObjectId(); - $paymentId = $transactionService->getAdminPaymentIdByOrderId($orderId); //somthesing like s-chg-XXXX + + $paymentId = $transactionService->getPaymentIdByOrderId($orderId, true); // ~ s-chg-XXXXX + $this->sTypeId = $paymentId; /** may@throws \TypeError if $paymentId due to wrong payment cancellation */ $this->_aViewData['sTypeId'] = $this->sTypeId; if ($this->sTypeId) { diff --git a/src/Service/Transaction.php b/src/Service/Transaction.php index 78eebc8b..d39f1056 100644 --- a/src/Service/Transaction.php +++ b/src/Service/Transaction.php @@ -9,6 +9,7 @@ namespace OxidSolutionCatalysts\Unzer\Service; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\ResultStatement; use OxidEsales\Eshop\Application\Model\User; @@ -469,41 +470,12 @@ public function getPaymentIdByOrderId(string $orderid, bool $withoutCancel = fal ':oxaction' => $transActionConst ]; - $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 - * @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, + $parameterTypes = [ + ':oxorderid' => \PDO::PARAM_STR, + ':oxaction' => Connection::PARAM_STR_ARRAY // Specify array type ]; - $queryResult = $query->setParameters($parameters)->execute(); + $queryResult = $query->setParameters($parameters, $parameterTypes)->execute(); if ($queryResult instanceof ResultStatement && $queryResult->columnCount()) { $result = $queryResult->fetchOne(); $result = is_string($result) ? $result : '';