From 40693ea26ac5b64edcf9e296254b92364d10a233 Mon Sep 17 00:00:00 2001 From: dmitrii Date: Wed, 5 Jun 2024 15:15:53 +0200 Subject: [PATCH 1/2] UNZER-394 Clean up tmporder table --- src/Controller/DispatcherController.php | 27 +++++++++++++++++++++++++ tests/PhpStan/phpstan.neon | 5 +++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index ae5b37ea..c09714a4 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -15,6 +15,7 @@ use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Request; +use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; use OxidSolutionCatalysts\Unzer\Service\Transaction; use OxidSolutionCatalysts\Unzer\Service\Translator; use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader; @@ -23,6 +24,9 @@ use UnzerSDK\Constants\PaymentState; use UnzerSDK\Exceptions\UnzerApiException; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class DispatcherController extends FrontendController { use ServiceContainer; @@ -137,6 +141,29 @@ public function updatePaymentTransStatus(): void } } + $this->cleanUpTmpOrder(); Registry::getUtils()->showMessageAndExit($result); } + + /** + * @return void + * @throws \Doctrine\DBAL\Exception + */ + private function cleanUpTmpOrder() + { + /** @var QueryBuilderFactoryInterface $queryBuilderFactory */ + $queryBuilderFactory = $this->getServiceFromContainer(QueryBuilderFactoryInterface::class); + + $queryBuilder = $queryBuilderFactory->create(); + + $query = $queryBuilder + ->delete('oscunzertmporder') + ->where('timestamp < :timestamp'); + + $parameters = [ + ':timestamp' => date("Y-m-d H:i:s", ( time() - ( 60 * 60 * 24 ) )) + ]; + + $query->setParameters($parameters)->execute(); + } } diff --git a/tests/PhpStan/phpstan.neon b/tests/PhpStan/phpstan.neon index 42e0bdd8..71a2516c 100644 --- a/tests/PhpStan/phpstan.neon +++ b/tests/PhpStan/phpstan.neon @@ -1,9 +1,10 @@ parameters: - checkMissingIterableValueType: false treatPhpDocTypesAsCertain: false bootstrapFiles: - phpstan-bootstrap.php level: max scanFiles: - ../../vendor/oxid-esales/oxideshop-ce/source/oxfunctions.php - - ../../vendor/oxid-esales/oxideshop-ce/source/overridablefunctions.php \ No newline at end of file + - ../../vendor/oxid-esales/oxideshop-ce/source/overridablefunctions.php + ignoreErrors: + - identifier: missingType.iterableValue \ No newline at end of file From 0144808c4696a6d3255d58512145eded66981231 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 7 Jun 2024 10:00:58 +0200 Subject: [PATCH 2/2] CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f15ad8bc..56727b41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### NEW - provide content for smarty and twig -- If a customer interrupt the order in the checkout for any reason, the order is still saved using a temporary order and Unzer's webhook +- If a customer interrupt the order in the checkout for any reason, the order is still saved using a temporary order and Unzer's webhook + scheduled cleanup temporary order - Save Payment Data for registered Users ### FIXED