Skip to content

Commit

Permalink
Merge pull request #276 from OXID-eSales/UNZER-394_clean_up_tmporder_…
Browse files Browse the repository at this point in the history
…table_oxid_7

UNZER-394 Clean up tmporder table
  • Loading branch information
mariolorenz authored Jun 7, 2024
2 parents 8a39e76 + 0144808 commit d254c0d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions src/Controller/DispatcherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,6 +24,9 @@
use UnzerSDK\Constants\PaymentState;
use UnzerSDK\Exceptions\UnzerApiException;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class DispatcherController extends FrontendController
{
use ServiceContainer;
Expand Down Expand Up @@ -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();
}
}
5 changes: 3 additions & 2 deletions tests/PhpStan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -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
- ../../vendor/oxid-esales/oxideshop-ce/source/overridablefunctions.php
ignoreErrors:
- identifier: missingType.iterableValue

0 comments on commit d254c0d

Please sign in to comment.