From eefdb662f2316511c84a2fbbf2d95625ad05e2bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Jun 2023 05:05:41 +0000 Subject: [PATCH 001/115] Bump docker/metadata-action from 4.4.0 to 4.5.0 Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4.4.0 to 4.5.0. - [Release notes](https://github.com/docker/metadata-action/releases) - [Commits](https://github.com/docker/metadata-action/compare/c4ee3adeed93b1fa6a762f209fb01608c1a22f1e...2c0bd771b40637d97bf205cbccdd294a32112176) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 8a6419e6..35cad652 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -85,7 +85,7 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e + uses: docker/metadata-action@2c0bd771b40637d97bf205cbccdd294a32112176 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} From f352eff9d25cd329c58ac86727d523760d3cc06b Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 8 Jun 2023 14:49:01 +0200 Subject: [PATCH 002/115] delete unecessary Test --- .../Controller/PaymentControllerTest.php | 29 -------------- .../Unit/Controller/PaymentControllerTest.php | 39 ------------------- src/Controller/PaymentController.php | 8 ---- 3 files changed, 76 deletions(-) delete mode 100644 Tests/Integration/Controller/PaymentControllerTest.php delete mode 100644 Tests/Unit/Controller/PaymentControllerTest.php diff --git a/Tests/Integration/Controller/PaymentControllerTest.php b/Tests/Integration/Controller/PaymentControllerTest.php deleted file mode 100644 index 14e73137..00000000 --- a/Tests/Integration/Controller/PaymentControllerTest.php +++ /dev/null @@ -1,29 +0,0 @@ -SubjectUnderTest = oxNew(PaymentController::class); - } - - public function testSomething() - { - self::assertEquals( - true, - $this->SubjectUnderTest->doSomething() - ); - } -} diff --git a/Tests/Unit/Controller/PaymentControllerTest.php b/Tests/Unit/Controller/PaymentControllerTest.php deleted file mode 100644 index ef2e8958..00000000 --- a/Tests/Unit/Controller/PaymentControllerTest.php +++ /dev/null @@ -1,39 +0,0 @@ -SubjectUnderTest = new PaymentController(); - } - - public function testSomething() - { - class_alias( - \OxidEsales\Eshop\Application\Controller\PaymentController::class, - 'OxidSolutionCatalysts\Unzer\Controller\PaymentController_parent' - ); - - self::assertEquals( - true, - $this->SubjectUnderTest->doSomething() - ); - } -} diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index ddbae066..67d65698 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -20,14 +20,6 @@ class PaymentController extends PaymentController_parent { use ServiceContainer; - /** - * @return bool - */ - public function doSomething(): bool - { - return true; - } - /** * Executes parent method parent::render(). */ From 5c82f822e739b9d1c711942323be15fa176cbee0 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 8 Jun 2023 14:50:49 +0200 Subject: [PATCH 003/115] correct path to ViewConfig --- Tests/Integration/Core/ViewConfigTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Integration/Core/ViewConfigTest.php b/Tests/Integration/Core/ViewConfigTest.php index 17de4f00..27aea27a 100644 --- a/Tests/Integration/Core/ViewConfigTest.php +++ b/Tests/Integration/Core/ViewConfigTest.php @@ -13,7 +13,7 @@ use OxidEsales\TestingLibrary\UnitTestCase; use OxidSolutionCatalysts\Unzer\Module; use OxidSolutionCatalysts\Unzer\Service\ModuleSettings; -use OxidSolutionCatalysts\Unzer\Core\ViewConfig; +use OxidEsales\Eshop\Core\ViewConfig; class ViewConfigTest extends UnitTestCase { From 564fb4fcafe11f469f7456e16d46516adf23253b Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 9 Jun 2023 13:37:04 +0200 Subject: [PATCH 004/115] fix unit test because these tests influenced subsequent tests to start --- Tests/Integration/Core/ShopControlTest.php | 53 ++++++++++++---------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/Tests/Integration/Core/ShopControlTest.php b/Tests/Integration/Core/ShopControlTest.php index cdc8e910..ec3dbce6 100644 --- a/Tests/Integration/Core/ShopControlTest.php +++ b/Tests/Integration/Core/ShopControlTest.php @@ -7,7 +7,6 @@ namespace OxidSolutionCatalysts\Unzer\Tests\Integration\Core; -use OxidEsales\Eshop\Core\ConfigFile; use OxidEsales\Eshop\Core\Exception\StandardException; use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Utils; @@ -25,19 +24,19 @@ class ShopControlTest extends UnitTestCase */ public function testHandleCustomException($expectedException): void { - $configFile = $this->createPartialMock(ConfigFile::class, ['getVar']); - $configFile->method('getVar')->with('iDebug')->willReturn(0); - Registry::set(ConfigFile::class, $configFile); - - class_alias( - \OxidEsales\Eshop\Core\ShopControl::class, - 'OxidSolutionCatalysts\Unzer\Core\ShopControl_parent' - ); - $mock = $this->createPartialMock(ShopControl::class, ['isAdmin']); - $mock->method('isAdmin')->willThrowException(new $expectedException()); + /** @var \Throwable $exceptionMock */ + $exceptionMock = $this->createPartialMock($expectedException, ['debugOut']); + $exceptionMock->expects($this->once())->method('debugOut'); + /* _runOnce is the earliest method call in the ShopControl. + That is why the exception is simulated in this method. + !Important, this test only works with Config "iDebug" = 0, + since in the other cases with exceptions too much OXID is made, + which makes further mocking very time-consuming. + */ + $mock = $this->createPartialMock(ShopControl::class, ['_runOnce']); + $mock->method('_runOnce')->willThrowException($exceptionMock); $mock->start(); - $this->assertLoggedException($expectedException); } public function customStandardExceptionTestDataProvider(): array @@ -52,12 +51,14 @@ public function testHandleRedirectException(): void { $redirectDestination = 'someDestination'; - class_alias( - \OxidEsales\Eshop\Core\ShopControl::class, - 'OxidSolutionCatalysts\Unzer\Core\ShopControl_parent' - ); - $mock = $this->createPartialMock(ShopControl::class, ['isAdmin']); - $mock->method('isAdmin')->willThrowException(new Redirect($redirectDestination)); + /* _runOnce is the earliest method call in the ShopControl. + That is why the exception is simulated in this method. + !Important, this test only works with Config "iDebug" = 0, + since in the other cases with exceptions too much OXID is made, + which makes further mocking very time-consuming. + */ + $mock = $this->createPartialMock(ShopControl::class, ['_runOnce']); + $mock->method('_runOnce')->willThrowException(new Redirect($redirectDestination)); $utilsMock = $this->createPartialMock(Utils::class, ['redirect']); $utilsMock->expects($this->once()) @@ -73,12 +74,14 @@ public function testHandleMessageRedirectException(): void { $redirectDestination = 'someDestination'; - class_alias( - \OxidEsales\Eshop\Core\ShopControl::class, - 'OxidSolutionCatalysts\Unzer\Core\ShopControl_parent' - ); - $mock = $this->createPartialMock(ShopControl::class, ['isAdmin']); - $mock->method('isAdmin')->willThrowException( + /* _runOnce is the earliest method call in the ShopControl. + That is why the exception is simulated in this method. + !Important, this test only works with Config "iDebug" = 0, + since in the other cases with exceptions too much OXID is made, + which makes further mocking very time-consuming. + */ + $mock = $this->createPartialMock(ShopControl::class, ['_runOnce']); + $mock->method('_runOnce')->willThrowException( new RedirectWithMessage($redirectDestination, 'MESSAGE', ['param1']) ); @@ -96,4 +99,4 @@ class_alias( $mock->start(); } -} +} \ No newline at end of file From 63b2331d621dd0087b3b173d2340ece9a646b0d1 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 9 Jun 2023 13:43:54 +0200 Subject: [PATCH 005/115] fix codestyle --- Tests/Integration/Core/ShopControlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Integration/Core/ShopControlTest.php b/Tests/Integration/Core/ShopControlTest.php index ec3dbce6..7dbae159 100644 --- a/Tests/Integration/Core/ShopControlTest.php +++ b/Tests/Integration/Core/ShopControlTest.php @@ -99,4 +99,4 @@ public function testHandleMessageRedirectException(): void $mock->start(); } -} \ No newline at end of file +} From 6893e4865be13cef3fe50671be1b3f93a9fa3622 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 05:02:10 +0000 Subject: [PATCH 006/115] Bump docker/metadata-action from 4.5.0 to 4.6.0 Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4.5.0 to 4.6.0. - [Release notes](https://github.com/docker/metadata-action/releases) - [Commits](https://github.com/docker/metadata-action/compare/2c0bd771b40637d97bf205cbccdd294a32112176...818d4b7b91585d195f67373fd9cb0332e31a7175) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 35cad652..bac86663 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -85,7 +85,7 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@2c0bd771b40637d97bf205cbccdd294a32112176 + uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} From 0b1223c9243d40b5ec1b4b6c0890adddfca4bfe4 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 15 Jun 2023 16:44:25 +0200 Subject: [PATCH 007/115] fix CI-Line Error with undefined variables --- metadata.php | 2 +- src/Service/ApplePaySessionHandler.php | 32 ++++++++++++++++---------- src/Service/ModuleSettings.php | 2 +- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/metadata.php b/metadata.php index be5ed711..52ca8e1c 100644 --- a/metadata.php +++ b/metadata.php @@ -226,7 +226,7 @@ 'group' => 'unzerapplepay', 'name' => 'applepay_label', 'type' => 'str', - 'value' => '' + 'value' => 'default lable please change' ], [ 'group' => 'unzerapplepay', diff --git a/src/Service/ApplePaySessionHandler.php b/src/Service/ApplePaySessionHandler.php index 04736d01..79267cd8 100644 --- a/src/Service/ApplePaySessionHandler.php +++ b/src/Service/ApplePaySessionHandler.php @@ -34,18 +34,21 @@ private function initialize(): void ), '/' ); - /** @var string $applePatLabel */ - $applePatLabel = $this->moduleSettings->getApplePayLabel(); - $this->session = new ApplepaySession( - $this->moduleSettings->getApplePayMerchantIdentifier(), - $applePatLabel, - $domainName - ); - $this->adapter = new ApplepayAdapter(); - $this->adapter->init( - $this->moduleSettings->getApplePayMerchantCertFilePath(), - $this->moduleSettings->getApplePayMerchantCertKeyFilePath() - ); + // if we have no credentials we could not initiate + if ($this->moduleSettings->isApplePayEligibility()) { + /** @var string $applePatLabel */ + $applePatLabel = $this->moduleSettings->getApplePayLabel(); + $this->session = new ApplepaySession( + $this->moduleSettings->getApplePayMerchantIdentifier(), + $applePatLabel, + $domainName + ); + $this->adapter = new ApplepayAdapter(); + $this->adapter->init( + $this->moduleSettings->getApplePayMerchantCertFilePath(), + $this->moduleSettings->getApplePayMerchantCertKeyFilePath() + ); + } } /** @@ -54,6 +57,11 @@ private function initialize(): void */ public function validateMerchant(string $validationUrl): ?array { + // if we have no credentials we could not validate Merchant + if (!$this->moduleSettings->isApplePayEligibility()) { + return null; + } + try { /** @var string $validApplePayMerch */ $validApplePayMerch = $this->adapter->validateApplePayMerchant($validationUrl, $this->session); diff --git a/src/Service/ModuleSettings.php b/src/Service/ModuleSettings.php index 77147580..a841716e 100644 --- a/src/Service/ModuleSettings.php +++ b/src/Service/ModuleSettings.php @@ -178,7 +178,7 @@ public function isApplePayEligibility(): bool public function getApplePayLabel() { return $this->getSettingValue('applepay_label') ?: - $this->config->getActiveShop()->getFieldData('oxcompany'); + $this->config->getActiveShop()->getFieldData('oxcompany') ?: 'default_label'; } /** From befc2229c6d5a06812ef5ee94391844a8259e52f Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 16 Jun 2023 10:02:09 +0200 Subject: [PATCH 008/115] remove wrong use --- src/Controller/Admin/AdminOrderController.php | 1 - src/Model/Payment.php | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index b495e220..4ff256cb 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -7,7 +7,6 @@ namespace OxidSolutionCatalysts\Unzer\Controller\Admin; -use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController as AdminDetailsController_parent; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Registry; use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions; diff --git a/src/Model/Payment.php b/src/Model/Payment.php index be7c504f..60bd8373 100644 --- a/src/Model/Payment.php +++ b/src/Model/Payment.php @@ -11,8 +11,6 @@ use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions; use OxidSolutionCatalysts\Unzer\Service\PaymentValidator; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; -use OxidEsales\Eshop\Application\Model\Payment as Payment_parent; - class Payment extends Payment_parent { use ServiceContainer; From 46eccdcf78cd63bcd43e96992e09774e87a149d3 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Mon, 19 Jun 2023 17:42:28 +0200 Subject: [PATCH 009/115] added class alias for AdminOrderController --- Tests/PhpStan/phpstan-bootstrap.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/PhpStan/phpstan-bootstrap.php b/Tests/PhpStan/phpstan-bootstrap.php index e67c3e64..7408ce7e 100644 --- a/Tests/PhpStan/phpstan-bootstrap.php +++ b/Tests/PhpStan/phpstan-bootstrap.php @@ -17,6 +17,10 @@ class_alias( \OxidSolutionCatalysts\Unzer\Controller\OrderController_parent::class ); +class_alias( + \OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController::class, + \OxidSolutionCatalysts\Unzer\Controller\Admin\AdminDetailsController_parent::class +); class_alias( \OxidEsales\Eshop\Application\Controller\PaymentController::class, \OxidSolutionCatalysts\Unzer\Controller\PaymentController_parent::class From af9ee730500165c31e0eb3f17355b7409a8b9fad Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Mon, 19 Jun 2023 17:44:04 +0200 Subject: [PATCH 010/115] v1.1.1 --- metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.php b/metadata.php index 52ca8e1c..5a3f4455 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.0', + 'version' => '1.1.1', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 5e90f0e3c1cf39365d053364bd5156554c3e2a37 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Mon, 19 Jun 2023 17:45:56 +0200 Subject: [PATCH 011/115] init webhook configuration on activate --- src/Core/Events.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Core/Events.php b/src/Core/Events.php index 9eb8cc49..3108af36 100644 --- a/src/Core/Events.php +++ b/src/Core/Events.php @@ -15,6 +15,8 @@ use OxidSolutionCatalysts\Unzer\Service\StaticContent; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions as UnzerDefinitionsService; +use OxidSolutionCatalysts\Unzer\Service\UnzerWebhooks; +use OxidSolutionCatalysts\Unzer\Service\ModuleSettings; /** * Class defines what module does on Shop events. @@ -38,6 +40,9 @@ public static function onActivate() self::addStaticContents(); self::removeNonExistingUnzerPaymentMethodsFromDatabase(); + + // init the webhooks (either create or load from unzer) + self::initializeWebhookConfiguration(); } /** @@ -134,4 +139,21 @@ private static function removeNonExistingUnzerPaymentMethodsFromDatabase(): void ->andWhere(sprintf("oxid not in (%s)", implode(',', $unzerPaymentMethods))); $statement->execute(); } + + private static function initializeWebhookConfiguration(): void + { + /** @var ContainerInterface $container */ + $container = ContainerFactory::getInstance() + ->getContainer(); + + /** @var UnzerWebhooks $webhooks */ + $webhooks = $container->get(UnzerWebhooks::class); + /** @var ModuleSettings $moduleSettings */ + $moduleSettings = $container->get(ModuleSettings::class); + + $webhooks->setPrivateKeys( + $moduleSettings->getPrivateKeysWithContext() + ); + $webhooks->registerWebhookConfiguration(); + } } From d82d5cedb0a44203cf9173a2948ed5c3a770d85d Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Mon, 19 Jun 2023 17:50:00 +0200 Subject: [PATCH 012/115] changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f89786cb..f6c1539e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.1] - 2023-06-19 + +### FIXED +- init webhooks on module activation +- apple pay session init only when eligible + ## [1.1.0] - 2023-06-02 ### NEW From 30c268b6350f5a35289558b7087fd89d74024154 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Mon, 19 Jun 2023 18:14:40 +0200 Subject: [PATCH 013/115] code style --- src/Model/Payment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Model/Payment.php b/src/Model/Payment.php index 60bd8373..80d5374f 100644 --- a/src/Model/Payment.php +++ b/src/Model/Payment.php @@ -11,6 +11,7 @@ use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions; use OxidSolutionCatalysts\Unzer\Service\PaymentValidator; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; + class Payment extends Payment_parent { use ServiceContainer; From e8d9fd577d51508ace6370beea325b41b6af7f29 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 20 Jun 2023 10:00:55 +0200 Subject: [PATCH 014/115] removed init webhooks on module activate (try to find another way for demo installation) --- src/Core/Events.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/Core/Events.php b/src/Core/Events.php index 3108af36..9eb8cc49 100644 --- a/src/Core/Events.php +++ b/src/Core/Events.php @@ -15,8 +15,6 @@ use OxidSolutionCatalysts\Unzer\Service\StaticContent; use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions as UnzerDefinitionsService; -use OxidSolutionCatalysts\Unzer\Service\UnzerWebhooks; -use OxidSolutionCatalysts\Unzer\Service\ModuleSettings; /** * Class defines what module does on Shop events. @@ -40,9 +38,6 @@ public static function onActivate() self::addStaticContents(); self::removeNonExistingUnzerPaymentMethodsFromDatabase(); - - // init the webhooks (either create or load from unzer) - self::initializeWebhookConfiguration(); } /** @@ -139,21 +134,4 @@ private static function removeNonExistingUnzerPaymentMethodsFromDatabase(): void ->andWhere(sprintf("oxid not in (%s)", implode(',', $unzerPaymentMethods))); $statement->execute(); } - - private static function initializeWebhookConfiguration(): void - { - /** @var ContainerInterface $container */ - $container = ContainerFactory::getInstance() - ->getContainer(); - - /** @var UnzerWebhooks $webhooks */ - $webhooks = $container->get(UnzerWebhooks::class); - /** @var ModuleSettings $moduleSettings */ - $moduleSettings = $container->get(ModuleSettings::class); - - $webhooks->setPrivateKeys( - $moduleSettings->getPrivateKeysWithContext() - ); - $webhooks->registerWebhookConfiguration(); - } } From dddbcf8446d9391be4248e244494df835e46efc7 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 20 Jun 2023 10:02:16 +0200 Subject: [PATCH 015/115] added translation for webhook configuration (admin), which is seen when the module is inactive --- views/admin/de/module_options.php | 1 + views/admin/en/module_options.php | 1 + 2 files changed, 2 insertions(+) diff --git a/views/admin/de/module_options.php b/views/admin/de/module_options.php index 8ce4e297..ec776d20 100644 --- a/views/admin/de/module_options.php +++ b/views/admin/de/module_options.php @@ -19,6 +19,7 @@ 'SHOP_MODULE_GROUP_unzerwebhooks' => 'Webhook Einstellungen', 'SHOP_MODULE_GROUP_unzerother' => 'Sonstiges', + 'SHOP_MODULE_webhookConfiguration' => '', 'SHOP_MODULE_webhook_id' => 'Webhook ID', 'SHOP_MODULE_webhook_context' => 'Kontext', 'SHOP_MODULE_webhook_register' => 'Webhooks anlegen', diff --git a/views/admin/en/module_options.php b/views/admin/en/module_options.php index f4285faa..4ab66428 100644 --- a/views/admin/en/module_options.php +++ b/views/admin/en/module_options.php @@ -19,6 +19,7 @@ 'SHOP_MODULE_GROUP_unzerwebhooks' => 'Webhook settings', 'SHOP_MODULE_GROUP_unzerother' => 'Other', + 'SHOP_MODULE_webhookConfiguration' => '', 'SHOP_MODULE_webhook_id' => 'Webhook ID', 'SHOP_MODULE_webhook_context' => 'Context', 'SHOP_MODULE_webhook_register' => 'Create webhooks', From 9220598a5f372243126a826ded10ebe1310799cc Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 20 Jun 2023 10:03:35 +0200 Subject: [PATCH 016/115] changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c1539e..49025acc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [1.1.1] - 2023-06-19 ### FIXED -- init webhooks on module activation - apple pay session init only when eligible ## [1.1.0] - 2023-06-02 From 93ef99ed927435581141cce5a84b05960734cb8c Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 20 Jun 2023 12:23:11 +0200 Subject: [PATCH 017/115] v1.1.1-rc.1 --- metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.php b/metadata.php index 5a3f4455..8d38c645 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.1', + 'version' => '1.1.1-rc.1', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 8c15c81a2457601457d33ebc89b6e9544b6c0567 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 20 Jun 2023 12:35:16 +0200 Subject: [PATCH 018/115] v1.1.1-rc.2 --- metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.php b/metadata.php index 8d38c645..d1470f6b 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.1-rc.1', + 'version' => '1.1.1-rc.2', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 2ec6e33215921ffce6bb420b4d525adc1909da04 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 20 Jun 2023 13:29:11 +0200 Subject: [PATCH 019/115] v1.1.1-rc.3 --- metadata.php | 2 +- src/Controller/Admin/AdminOrderController.php | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/metadata.php b/metadata.php index d1470f6b..02d4a5cb 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.1-rc.2', + 'version' => '1.1.1-rc.3', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 4ff256cb..3230067a 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -7,9 +7,9 @@ namespace OxidSolutionCatalysts\Unzer\Controller\Admin; +use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Registry; -use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions; use OxidSolutionCatalysts\Unzer\Model\Payment; use OxidSolutionCatalysts\Unzer\Model\Order as UnzerOrder; use OxidSolutionCatalysts\Unzer\Model\TransactionList; @@ -19,10 +19,6 @@ use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; use UnzerSDK\Exceptions\UnzerApiException; use UnzerSDK\Resources\PaymentTypes\InstallmentSecured; -use UnzerSDK\Resources\PaymentTypes\Invoice; -use UnzerSDK\Resources\PaymentTypes\PaylaterInvoice; -use UnzerSDK\Resources\PaymentTypes\Prepayment; -use UnzerSDK\Resources\PaymentTypes\Card; use UnzerSDK\Resources\TransactionTypes\Authorization; use UnzerSDK\Resources\TransactionTypes\Cancellation; use UnzerSDK\Resources\TransactionTypes\Charge; @@ -37,7 +33,7 @@ * TODO: Decrease complexity to 50 or under * @SuppressWarnings(PHPMD.ExcessiveClassComplexity) */ -class AdminOrderController extends AdminDetailsController_parent +class AdminOrderController extends AdminDetailsController { use ServiceContainer; From 3f0ba2571774b9491356851f31257ee8f9aa23a1 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Thu, 22 Jun 2023 16:01:46 +0200 Subject: [PATCH 020/115] UNZER v1.1.1-rc.4 --- metadata.php | 2 +- src/Controller/PaymentController.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/metadata.php b/metadata.php index 02d4a5cb..d5dff6b8 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.1-rc.3', + 'version' => '1.1.1-rc.4', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index 67d65698..465ff696 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -25,8 +25,9 @@ class PaymentController extends PaymentController_parent */ public function render() { + $template = parent::render(); $this->checkForUnzerPaymentErrors(); - return parent::render(); + return $template; } /** From 1ccb08fb4362e8dc9f01ff593ab4add0d321e1a9 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 27 Jun 2023 10:22:41 +0200 Subject: [PATCH 021/115] UNZER v1.1.1 --- metadata.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.php b/metadata.php index d5dff6b8..5a3f4455 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.1-rc.4', + 'version' => '1.1.1', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 6d3bc596ab9b2eb835eee1f6aff36c50e562d7df Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 1 Aug 2023 14:21:26 +0200 Subject: [PATCH 022/115] remove "correct" returnTypes of Methods that are extended from core In the core the returnTypes are missing. So also the returnTypes in the extension must be missing... --- CHANGELOG.md | 5 +++++ metadata.php | 2 +- src/Controller/Admin/AdminOrderController.php | 2 +- src/Controller/Admin/ModuleConfiguration.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49025acc..f64fd7f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.2] - 2023-XX-XX + +### FIXED +- compatibility-issue against other modules that also extend the moduleconfiguration + ## [1.1.1] - 2023-06-19 ### FIXED diff --git a/metadata.php b/metadata.php index 5a3f4455..5fe32d0f 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.1', + 'version' => '1.1.2-rc.1', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 3230067a..5e5e3722 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -60,7 +60,7 @@ class AdminOrderController extends AdminDetailsController * * @SuppressWarnings(PHPMD.ElseExpression) */ - public function render(): string + public function render() { parent::render(); diff --git a/src/Controller/Admin/ModuleConfiguration.php b/src/Controller/Admin/ModuleConfiguration.php index e59f8270..1a671eac 100644 --- a/src/Controller/Admin/ModuleConfiguration.php +++ b/src/Controller/Admin/ModuleConfiguration.php @@ -47,7 +47,7 @@ public function __construct() * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - public function render(): string + public function render() { parent::render(); From 5672fbc46c6c195a97a6ddd084c55eaf3e23de4b Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 4 Aug 2023 16:18:30 +0200 Subject: [PATCH 023/115] set ShortID as OXTRANSID --- CHANGELOG.md | 1 + src/Model/Order.php | 11 ++++++++++- src/Service/Transaction.php | 8 ++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f64fd7f0..0dd83436 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### FIXED - compatibility-issue against other modules that also extend the moduleconfiguration +- [0007503](https://bugs.oxid-esales.com/view.php?id=7503) When ordering via the Unzer module, the OXID standard field OXORDER__OXTRANSID remains empty ## [1.1.1] - 2023-06-19 diff --git a/src/Model/Order.php b/src/Model/Order.php index e091804a..62a95ea3 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -104,11 +104,20 @@ public function markUnzerOrderAsPaid(): void if ($oxpaid == '0000-00-00 00:00:00') { $utilsDate = Registry::getUtilsDate(); $date = date('Y-m-d H:i:s', $utilsDate->getTime()); - $this->_setFieldData('oxpaid', $date); + $this->setFieldData('oxpaid', $date); $this->save(); } } + /** + * Update order oxtransid + */ + public function setUnzerTransId($sTransId): void + { + $this->setFieldData('oxtransid', $sTransId); + $this->save(); + } + /** * @inheritDoc */ diff --git a/src/Service/Transaction.php b/src/Service/Transaction.php index c637163d..5e2aac09 100644 --- a/src/Service/Transaction.php +++ b/src/Service/Transaction.php @@ -76,6 +76,9 @@ public function writeTransactionToDB( ): bool { $transaction = $this->getNewTransactionObject(); + $oOrder = oxNew(Order::class); + $oOrder->load($orderid); + $params = [ 'oxorderid' => $orderid, 'oxshopid' => $this->context->getCurrentShopId(), @@ -90,8 +93,6 @@ public function writeTransactionToDB( // for PaylaterInvoice, store the customer type if ($unzerPayment->getPaymentType() instanceof PaylaterInvoice) { - $oOrder = oxNew(Order::class); - $oOrder->load($orderid); $delCompany = $oOrder->getFieldData('oxdelcompany') ?? ''; $billCompany = $oOrder->getFieldData('oxbillcompany') ?? ''; $params['customertype'] = 'B2C'; @@ -114,6 +115,9 @@ public function writeTransactionToDB( $transaction->save(); $this->deleteInitOrder($params); + // Fallback: set ShortID as OXTRANSID + $oOrder->setUnzerTransId($params['shortid']); + return true; } From 9460df1527472667bb4503592c11ec2ae292640a Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 15 Aug 2023 12:11:10 +0200 Subject: [PATCH 024/115] UNZER-182 display charge datetime in local timezone --- src/Controller/Admin/AdminOrderController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 5e5e3722..03f259ea 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -10,6 +10,7 @@ use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Registry; +use OxidEsales\Eshop\Core\Utils; use OxidSolutionCatalysts\Unzer\Model\Payment; use OxidSolutionCatalysts\Unzer\Model\Order as UnzerOrder; use OxidSolutionCatalysts\Unzer\Model\TransactionList; @@ -169,7 +170,12 @@ protected function getUnzerViewData(string $sPaymentId): void $aRv['chargeId'] = $charge->getId(); $aRv['cancellationPossible'] = $charge->getAmount() > $charge->getCancelledAmount(); $fCharged += $charge->getAmount(); - $aRv['chargeDate'] = $charge->getDate(); + // datetime from unzer is in GMT, convert it to local datetime + $chargeDate = $charge->getDate(); + $dt = new \DateTime($chargeDate, new \DateTimeZone('GMT')); + $dt->setTimezone(new \DateTimeZone(date_default_timezone_get())); + $localDate = $dt->format('Y-m-d H:i:s'); + $aRv['chargeDate'] = $localDate; $charges[] = $aRv; } From 1d1cb5dfe225cf6b752289ea83827d4924e5aa1f Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 15 Aug 2023 12:12:29 +0200 Subject: [PATCH 025/115] UNZER-182 display charge datetime in local timezone --- src/Controller/Admin/AdminOrderController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 03f259ea..9394ca26 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -10,7 +10,6 @@ use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Registry; -use OxidEsales\Eshop\Core\Utils; use OxidSolutionCatalysts\Unzer\Model\Payment; use OxidSolutionCatalysts\Unzer\Model\Order as UnzerOrder; use OxidSolutionCatalysts\Unzer\Model\TransactionList; From c9a338b41c542736188bbcb28ba22866706be9cf Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 15 Aug 2023 12:37:34 +0200 Subject: [PATCH 026/115] UNZER-182 display any date from unzer in local timezone --- src/Controller/Admin/AdminOrderController.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 9394ca26..51a32020 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -134,7 +134,7 @@ protected function getUnzerViewData(string $sPaymentId): void /** @var Shipment $shipment */ foreach ($unzerPayment->getShipments() as $shipment) { $aRv = []; - $aRv['shipingDate'] = $shipment->getDate(); + $aRv['shipingDate'] = $this->toLocalDateString($shipment->getDate()); $aRv['shipId'] = $shipment->getId(); $aRv['invoiceid'] = $unzerPayment->getInvoiceId(); $aRv['amount'] = $shipment->getAmount(); @@ -170,11 +170,7 @@ protected function getUnzerViewData(string $sPaymentId): void $aRv['cancellationPossible'] = $charge->getAmount() > $charge->getCancelledAmount(); $fCharged += $charge->getAmount(); // datetime from unzer is in GMT, convert it to local datetime - $chargeDate = $charge->getDate(); - $dt = new \DateTime($chargeDate, new \DateTimeZone('GMT')); - $dt->setTimezone(new \DateTimeZone(date_default_timezone_get())); - $localDate = $dt->format('Y-m-d H:i:s'); - $aRv['chargeDate'] = $localDate; + $aRv['chargeDate'] = $this->toLocalDateString($charge->getDate()); $charges[] = $aRv; } @@ -189,7 +185,7 @@ protected function getUnzerViewData(string $sPaymentId): void if ($cancellation->isSuccess()) { $aRv = []; $aRv['cancelledAmount'] = $cancellation->getAmount(); - $aRv['cancelDate'] = $cancellation->getDate(); + $aRv['cancelDate'] = $this->toLocalDateString($cancellation->getDate()); $aRv['cancellationId'] = $cancellation->getId(); $aRv['cancelReason'] = $cancellation->getReasonCode(); $fCancelled += $cancellation->getAmount(); @@ -221,7 +217,7 @@ protected function getUnzerViewData(string $sPaymentId): void protected function addAuthorizationViewData(Authorization $authorization): void { - $this->_aViewData["AuthFetchedAt"] = $authorization->getFetchedAt(); + $this->_aViewData["AuthFetchedAt"] = $this->toLocalDateString($authorization->getFetchedAt()); $this->_aViewData["AuthShortId"] = $authorization->getShortId(); $this->_aViewData["AuthId"] = $authorization->getId(); $this->_aViewData["AuthAmount"] = $authorization->getAmount(); @@ -449,4 +445,11 @@ public function getEditObject(): ?object return $this->editObject; } + + private function toLocalDateString(string $gmtDateString): string + { + $dt = new \DateTime($gmtDateString, new \DateTimeZone('GMT')); + $dt->setTimezone(new \DateTimeZone(date_default_timezone_get())); + return $dt->format('Y-m-d H:i:s'); + } } From 02fe8a6396e6d2d67c76bde59feb6cde58ea05b5 Mon Sep 17 00:00:00 2001 From: Lars Stegelitz Date: Tue, 15 Aug 2023 13:06:42 +0200 Subject: [PATCH 027/115] code style --- src/Controller/Admin/AdminOrderController.php | 21 ++++++++++++------- src/Model/Order.php | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 51a32020..0867d2da 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -24,6 +24,8 @@ use UnzerSDK\Resources\TransactionTypes\Charge; use UnzerSDK\Resources\TransactionTypes\Shipment; use UnzerSDK\Unzer; +use DateTime; +use DateTimeZone; /** * Order class wrapper for Unzer module @@ -134,7 +136,7 @@ protected function getUnzerViewData(string $sPaymentId): void /** @var Shipment $shipment */ foreach ($unzerPayment->getShipments() as $shipment) { $aRv = []; - $aRv['shipingDate'] = $this->toLocalDateString($shipment->getDate()); + $aRv['shipingDate'] = $this->toLocalDateString($shipment->getDate() ?? ''); $aRv['shipId'] = $shipment->getId(); $aRv['invoiceid'] = $unzerPayment->getInvoiceId(); $aRv['amount'] = $shipment->getAmount(); @@ -170,7 +172,7 @@ protected function getUnzerViewData(string $sPaymentId): void $aRv['cancellationPossible'] = $charge->getAmount() > $charge->getCancelledAmount(); $fCharged += $charge->getAmount(); // datetime from unzer is in GMT, convert it to local datetime - $aRv['chargeDate'] = $this->toLocalDateString($charge->getDate()); + $aRv['chargeDate'] = $this->toLocalDateString($charge->getDate() ?? ''); $charges[] = $aRv; } @@ -185,7 +187,7 @@ protected function getUnzerViewData(string $sPaymentId): void if ($cancellation->isSuccess()) { $aRv = []; $aRv['cancelledAmount'] = $cancellation->getAmount(); - $aRv['cancelDate'] = $this->toLocalDateString($cancellation->getDate()); + $aRv['cancelDate'] = $this->toLocalDateString($cancellation->getDate() ?? ''); $aRv['cancellationId'] = $cancellation->getId(); $aRv['cancelReason'] = $cancellation->getReasonCode(); $fCancelled += $cancellation->getAmount(); @@ -217,7 +219,12 @@ protected function getUnzerViewData(string $sPaymentId): void protected function addAuthorizationViewData(Authorization $authorization): void { - $this->_aViewData["AuthFetchedAt"] = $this->toLocalDateString($authorization->getFetchedAt()); + $date = ''; + $datetime = $authorization->getFetchedAt(); + if ($datetime) { + $date = $datetime->format('Y-m-d H:i:s'); + } + $this->_aViewData["AuthFetchedAt"] = $this->toLocalDateString($date); $this->_aViewData["AuthShortId"] = $authorization->getShortId(); $this->_aViewData["AuthId"] = $authorization->getId(); $this->_aViewData["AuthAmount"] = $authorization->getAmount(); @@ -448,8 +455,8 @@ public function getEditObject(): ?object private function toLocalDateString(string $gmtDateString): string { - $dt = new \DateTime($gmtDateString, new \DateTimeZone('GMT')); - $dt->setTimezone(new \DateTimeZone(date_default_timezone_get())); - return $dt->format('Y-m-d H:i:s'); + $datetime = new DateTime($gmtDateString, new DateTimeZone('GMT')); + $datetime->setTimezone(new DateTimeZone(date_default_timezone_get())); + return $datetime->format('Y-m-d H:i:s'); } } diff --git a/src/Model/Order.php b/src/Model/Order.php index 62a95ea3..d6a6b310 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -112,7 +112,7 @@ public function markUnzerOrderAsPaid(): void /** * Update order oxtransid */ - public function setUnzerTransId($sTransId): void + public function setUnzerTransId(string $sTransId): void { $this->setFieldData('oxtransid', $sTransId); $this->save(); From 3870a5556dd0b9b939d7432e44c9ea76f2493fb2 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 18 Aug 2023 09:59:28 +0200 Subject: [PATCH 028/115] add CHANGELOG --- CHANGELOG.md | 1 + metadata.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dd83436..d5715a92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### FIXED - compatibility-issue against other modules that also extend the moduleconfiguration - [0007503](https://bugs.oxid-esales.com/view.php?id=7503) When ordering via the Unzer module, the OXID standard field OXORDER__OXTRANSID remains empty +- Adjust payment date when the payment has been completed ## [1.1.1] - 2023-06-19 diff --git a/metadata.php b/metadata.php index 5fe32d0f..13fb1ef5 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.2-rc.1', + 'version' => '1.1.2-rc.2', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 3e45092e8400844550c80af3c70f414f482b24de Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 18 Aug 2023 16:16:38 +0200 Subject: [PATCH 029/115] Release v1.1.2 --- CHANGELOG.md | 2 +- metadata.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5715a92..114a9a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [1.1.2] - 2023-XX-XX +## [1.1.2] - 2023-08-18 ### FIXED - compatibility-issue against other modules that also extend the moduleconfiguration diff --git a/metadata.php b/metadata.php index 13fb1ef5..c6a3e7e2 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.2-rc.2', + 'version' => '1.1.2', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 14e1415c77c813607ddbabcdd9eab9a2c6121c65 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 1 Sep 2023 19:30:03 +0200 Subject: [PATCH 030/115] correct oxNew(CoreClass) not oxNew(ModelClass) --- src/Controller/DispatcherController.php | 19 +++++++++++-------- src/Controller/InstallmentController.php | 8 +++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index 13b4b7c3..8ff52acf 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -7,7 +7,9 @@ namespace OxidSolutionCatalysts\Unzer\Controller; +use Exception; use OxidEsales\Eshop\Application\Controller\FrontendController; +use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Registry; @@ -28,6 +30,7 @@ class DispatcherController extends FrontendController * @throws DatabaseConnectionException * @throws DatabaseErrorException * @throws UnzerApiException + * @throws Exception * * @SuppressWarnings(PHPMD.StaticAccess) * @SuppressWarnings(PHPMD.CyclomaticComplexity) @@ -42,7 +45,7 @@ public function updatePaymentTransStatus(): void $jsonRequest = file_get_contents('php://input'); /** @var array $aJson */ - $aJson = json_decode($jsonRequest, true); + $aJson = json_decode($jsonRequest, true, 512, JSON_THROW_ON_ERROR); /** @var array $url */ $url = parse_url($aJson['retrieveUrl']); /** @var Transaction $transaction */ @@ -61,7 +64,7 @@ public function updatePaymentTransStatus(): void } if ( - ($url['scheme'] != "https" || ($url['host'] != "api.unzer.com" && $url['host'] != "sbx-api.heidelpay.com")) + ($url['scheme'] !== "https" || ($url['host'] !== "api.unzer.com" && $url['host'] !== "sbx-api.heidelpay.com")) ) { Registry::getUtils()->showMessageAndExit("No valid retrieveUrl"); } @@ -76,28 +79,28 @@ public function updatePaymentTransStatus(): void $paymentId = $resource->getId(); if (is_string($paymentId)) { /** @var \OxidSolutionCatalysts\Unzer\Model\Order $order */ - $order = oxNew(\OxidSolutionCatalysts\Unzer\Model\Order::class); + $order = oxNew(Order::class); /** @var array $data */ - $data = $transaction->getTransactionDataByPaymentId($paymentId); + $data = $transaction::getTransactionDataByPaymentId($paymentId); $unzerPayment = $unzer->fetchPayment($paymentId); if ($order->load($data[0]['OXORDERID'])) { /** @var string $oxTransStatus */ $oxTransStatus = $order->getFieldData('oxtransstatus'); - if ($unzerPayment->getState() == 1 && $oxTransStatus == "OK") { + if ($oxTransStatus === "OK" && $unzerPayment->getState() === 1) { $order->markUnzerOrderAsPaid(); } - if ($unzerPayment->getState() == 2) { + if ($unzerPayment->getState() === 2) { $order->cancelOrder(); } $translator = $this->getServiceFromContainer(Translator::class); - if ($unzerPayment->getState() != 2 && $oxTransStatus != "OK") { + if ($oxTransStatus !== "OK" && $unzerPayment->getState() !== 2) { $ret = $order->reinitializeOrder(); - if ($ret != 1) { + if ($ret !== 1) { $unzer->debugLog("Order-Recalculation failed and returned with code: " . $ret); } } diff --git a/src/Controller/InstallmentController.php b/src/Controller/InstallmentController.php index 64e48c71..267d06ba 100644 --- a/src/Controller/InstallmentController.php +++ b/src/Controller/InstallmentController.php @@ -10,11 +10,13 @@ use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Application\Model\User; +use OxidEsales\Eshop\Application\Model\Payment as PaymentModel; use OxidEsales\Eshop\Core\Registry; use OxidEsales\EshopCommunity\Application\Model\Basket; use OxidSolutionCatalysts\Unzer\Exception\Redirect; use OxidSolutionCatalysts\Unzer\Service\Transaction; use OxidSolutionCatalysts\Unzer\Service\Unzer; +use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; use UnzerSDK\Resources\Payment; use UnzerSDK\Resources\PaymentTypes\InstallmentSecured; @@ -117,7 +119,7 @@ public function getPayment() // payment is set ? $sPaymentid = $oBasket->getPaymentId(); - $oPayment = oxNew(\OxidSolutionCatalysts\Unzer\Model\Payment::class); + $oPayment = oxNew(PaymentModel::class); /** @var string $sShipSet */ $sShipSet = Registry::getSession()->getVariable('sShipSet'); @@ -156,7 +158,7 @@ protected function getUnzerSessionPayment(): ?Payment if ($this->uzrPayment === null) { /** @var \OxidSolutionCatalysts\Unzer\Service\Payment $payment */ $payment = $this->getServiceFromContainer( - \OxidSolutionCatalysts\Unzer\Service\Payment::class + PaymentService::class ); /** @var Payment $sessionUnzerPayment */ $sessionUnzerPayment = $payment->getSessionUnzerPayment(); @@ -170,7 +172,7 @@ protected function getUnzerSessionPayment(): ?Payment */ public function cancelInstallment() { - $paymentService = $this->getServiceFromContainer(\OxidSolutionCatalysts\Unzer\Service\Payment::class); + $paymentService = $this->getServiceFromContainer(PaymentService::class); $paymentService->removeTemporaryOrder(); $unzerService = $this->getServiceFromContainer(Unzer::class); From c99497d943c36fbc20e7cd50f11a8e29e44d0658 Mon Sep 17 00:00:00 2001 From: OXIDFabian Date: Sat, 2 Sep 2023 01:10:28 +0200 Subject: [PATCH 031/115] added workflow to build v7 demoshop image --- .github/workflows/build-v7-image.yml | 88 ++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/build-v7-image.yml diff --git a/.github/workflows/build-v7-image.yml b/.github/workflows/build-v7-image.yml new file mode 100644 index 00000000..96f7a624 --- /dev/null +++ b/.github/workflows/build-v7-image.yml @@ -0,0 +1,88 @@ +name: Build image for v7 Demoshop + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +on: + schedule: + - cron: '16 6 * * *' + push: + branches: + - b-7.0.x + repository_dispatch: + types: [docker-build] + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} + +jobs: + + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + ref: b-7.0.x + + - name: Checkout dockerfiles + uses: actions/checkout@v3 + with: + repository: OXID-eSales/module-demoshop-images + token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT + path: dockerfiles + + - name: move dockerfiles to root folder + run: mv dockerfiles/unzer/* . + + - name: downcase REPO + run: | + echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + # Login against a Docker registry except on PR + # https://github.com/docker/login-action + - name: Log into registry ${{ env.REGISTRY }} + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Extract metadata (tags, labels) for Docker + # https://github.com/docker/metadata-action + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + # Build and push Docker image with Buildx (don't push on PR) + # https://github.com/docker/build-push-action + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.v7 + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: | + ${{ env.REGISTRY }}/${{ env.REPO }}:v7 + secrets: | + "github_token=${{ secrets.GITHUB_TOKEN }}" + From 7a2bbb28220d44fb9cc06158887ffaaed8d30cd3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 04:46:53 +0000 Subject: [PATCH 032/115] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-v7-image.yml | 4 ++-- .github/workflows/default.yml | 6 +++--- .github/workflows/docker-publish.yml | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-v7-image.yml b/.github/workflows/build-v7-image.yml index 96f7a624..7e90321a 100644 --- a/.github/workflows/build-v7-image.yml +++ b/.github/workflows/build-v7-image.yml @@ -30,12 +30,12 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: b-7.0.x - name: Checkout dockerfiles - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: OXID-eSales/module-demoshop-images token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index f4ae3dca..26c4d90c 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -72,7 +72,7 @@ jobs: sleep 2 - name: Checkout current module - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: source/test-module @@ -126,7 +126,7 @@ jobs: php: [ '8.0' ] steps: - name: Checkout current module - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: source/test-module @@ -298,7 +298,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout current module - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Download phpunit artifacts continue-on-error: true diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index bac86663..30eb9f31 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -30,7 +30,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -47,12 +47,12 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ needs.get_latest_tag.outputs.tag }} - name: Checkout dockerfiles - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: OXID-eSales/module-demoshop-images token: ${{ secrets.GH_PAT }} # `GH_PAT` is a secret that contains your PAT From 12dad5f1f88f910d88a07a13a71eec750b72c827 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 5 Sep 2023 14:07:46 +0200 Subject: [PATCH 033/115] prevent double submit by disable submit-button during submit --- views/frontend/tpl/order/unzer_card.tpl | 1 + views/frontend/tpl/order/unzer_eps_charge.tpl | 1 + views/frontend/tpl/order/unzer_installment.tpl | 1 + views/frontend/tpl/order/unzer_invoice.tpl | 1 + views/frontend/tpl/order/unzer_sepa.tpl | 1 + views/frontend/tpl/order/unzer_sepa_secured.tpl | 1 + 6 files changed, 6 insertions(+) diff --git a/views/frontend/tpl/order/unzer_card.tpl b/views/frontend/tpl/order/unzer_card.tpl index 46d218f0..3c115119 100644 --- a/views/frontend/tpl/order/unzer_card.tpl +++ b/views/frontend/tpl/order/unzer_card.tpl @@ -29,6 +29,7 @@ event.preventDefault(); $( "#payment-form-card" ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); // Create an Unzer instance with your public key diff --git a/views/frontend/tpl/order/unzer_eps_charge.tpl b/views/frontend/tpl/order/unzer_eps_charge.tpl index 68d6afa6..6583988c 100644 --- a/views/frontend/tpl/order/unzer_eps_charge.tpl +++ b/views/frontend/tpl/order/unzer_eps_charge.tpl @@ -12,6 +12,7 @@ event.preventDefault(); $( '#payment-form' ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); // Create an Unzer instance with your public key diff --git a/views/frontend/tpl/order/unzer_installment.tpl b/views/frontend/tpl/order/unzer_installment.tpl index 22cd3f89..2dec04cb 100644 --- a/views/frontend/tpl/order/unzer_installment.tpl +++ b/views/frontend/tpl/order/unzer_installment.tpl @@ -96,6 +96,7 @@ event.preventDefault(); $( '#payment-form-installment' ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); // Handling payment form submission diff --git a/views/frontend/tpl/order/unzer_invoice.tpl b/views/frontend/tpl/order/unzer_invoice.tpl index 24c71b08..348b3ab4 100644 --- a/views/frontend/tpl/order/unzer_invoice.tpl +++ b/views/frontend/tpl/order/unzer_invoice.tpl @@ -212,6 +212,7 @@ event.preventDefault(); $("#payment-form").submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); [{/capture}] diff --git a/views/frontend/tpl/order/unzer_sepa.tpl b/views/frontend/tpl/order/unzer_sepa.tpl index 358f21d4..cf241d38 100644 --- a/views/frontend/tpl/order/unzer_sepa.tpl +++ b/views/frontend/tpl/order/unzer_sepa.tpl @@ -28,6 +28,7 @@ event.preventDefault(); $( "#payment-form-sepa" ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); // Create an Unzer instance with your public key diff --git a/views/frontend/tpl/order/unzer_sepa_secured.tpl b/views/frontend/tpl/order/unzer_sepa_secured.tpl index 9ec54caa..c9effd38 100644 --- a/views/frontend/tpl/order/unzer_sepa_secured.tpl +++ b/views/frontend/tpl/order/unzer_sepa_secured.tpl @@ -131,6 +131,7 @@ event.preventDefault(); $( "#payment-form-sepa-secured" ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); [{/capture}] [{oxscript add=$unzerSepaDirectSecurredJS}] \ No newline at end of file From 2f2059b7a9133a09ac951fc974d16fbc554f8c1f Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 5 Sep 2023 15:57:06 +0200 Subject: [PATCH 034/115] WIP: use getExecuteFnc ... instead of running direct Execute. So Order is not created ... --- src/Controller/DispatcherController.php | 7 ++- src/Controller/OrderController.php | 29 ++++++++++++ src/Model/PaymentGateway.php | 8 ++-- src/Service/Payment.php | 63 +++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 4 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index 8ff52acf..90955996 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -45,7 +45,12 @@ public function updatePaymentTransStatus(): void $jsonRequest = file_get_contents('php://input'); /** @var array $aJson */ - $aJson = json_decode($jsonRequest, true, 512, JSON_THROW_ON_ERROR); + try { + $aJson = json_decode($jsonRequest, true, 512, JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + Registry::getUtils()->showMessageAndExit("Invalid Json"); + } + /** @var array $url */ $url = parse_url($aJson['retrieveUrl']); /** @var Transaction $transaction */ diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 0d136711..3161d3ec 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -16,6 +16,7 @@ use OxidSolutionCatalysts\Unzer\Exception\Redirect; use OxidSolutionCatalysts\Unzer\Model\Payment; use OxidSolutionCatalysts\Unzer\Service\ModuleSettings; +use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService; use OxidSolutionCatalysts\Unzer\Service\ResponseHandler; use OxidSolutionCatalysts\Unzer\Service\Translator; use OxidSolutionCatalysts\Unzer\Service\Unzer; @@ -247,4 +248,32 @@ public function getUnzerCompanyTypes(): array } return $this->companyTypes; } + + /** + * execute Unzer defined via getExecuteFnc + */ + public function executeoscunzer(): ?string + { + $paymentService = $this->getServiceFromContainer(PaymentService::class); + /** @var \OxidEsales\Eshop\Application\Model\Payment $payment */ + $payment = $this->getPayment(); + $paymentService->executeUnzerPayment2($payment); + + return null; + } + + /** + * OXID-Core + * @inheritDoc + */ + public function getExecuteFnc() + { + $payment = $this->getPayment(); + if ( + $payment->isUnzerPayment() + ) { + return 'executeoscunzer'; + } + return parent::getExecuteFnc(); + } } diff --git a/src/Model/PaymentGateway.php b/src/Model/PaymentGateway.php index be30e7ad..599fe44c 100644 --- a/src/Model/PaymentGateway.php +++ b/src/Model/PaymentGateway.php @@ -19,18 +19,20 @@ class PaymentGateway extends PaymentGateway_parent * * @param Order $oOrder */ - public function executePayment($dAmount, &$oOrder) + public function executePayment_notnecessary($dAmount, &$oOrder) { + $success = parent::executePayment($dAmount, $oOrder); + /** @var string $oxpaymenttype */ $oxpaymenttype = $oOrder->getFieldData('oxpaymenttype'); $oPayment = oxNew(Payment::class); if ($oPayment->load($oxpaymenttype)) { if ($oPayment->isUnzerPayment()) { $paymentService = $this->getServiceFromContainer(PaymentService::class); - $paymentService->executeUnzerPayment($oPayment); + $success = $paymentService->executeUnzerPayment($oPayment); } } - return parent::executePayment($dAmount, $oOrder); + return $success; } } diff --git a/src/Service/Payment.php b/src/Service/Payment.php index a8e2e64a..188a0e37 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -159,6 +159,69 @@ public function executeUnzerPayment(PaymentModel $paymentModel): bool return $paymentStatus; } + /** + * @throws Redirect + * @throws RedirectWithMessage + */ + public function executeUnzerPayment2(PaymentModel $paymentModel): bool + { + try { + /** @var string $customerType */ + $customerType = Registry::getRequest()->getRequestParameter('unzer_customer_type', ''); + $user = $this->session->getUser(); + $basket = $this->session->getBasket(); + $currency = $basket->getBasketCurrency()->name; + + /** @var AbstractUnzerPayment $paymentExtension */ + $paymentExtension = $this->paymentExtLoader->getPaymentExtensionByCustomerTypeAndCurrency( + $paymentModel, + $customerType, + $currency + ); + $paymentExtension->execute( + $user, + $basket + ); + + /** @var string $sess_challenge */ + $sess_challenge = $this->session->getVariable('sess_challenge'); + $this->transactionService->writeTransactionToDB( + $sess_challenge, + $this->session->getUser()->getId(), + $this->getSessionUnzerPayment() + ); + + $paymentStatus = $this->getUnzerPaymentStatus() !== self::STATUS_ERROR; + + if ($this->redirectUrl) { + throw new Redirect($this->redirectUrl); + } + + if ($this->pdfLink) { + throw new Redirect($this->unzerService->preparePdfConfirmRedirectUrl()); + } + } catch (Redirect $e) { + throw $e; + } catch (UnzerApiException $e) { + throw new RedirectWithMessage( + $this->unzerService->prepareOrderRedirectUrl( +// $paymentExtension instanceof AbstractUnzerPayment && $paymentExtension->redirectUrlNeedPending() + ), + $this->translator->translateCode($e->getErrorId(), $e->getClientMessage()) + ); + } catch (Exception $e) { + + throw new RedirectWithMessage( + $this->unzerService->prepareOrderRedirectUrl( +// $paymentExtension instanceof AbstractUnzerPayment && $paymentExtension->redirectUrlNeedPending() + ), + $e->getMessage() + ); + } + + return $paymentStatus; + } + /** * @return bool */ From 78e48a1e15f824e1c1f98c06ec2012981636fb64 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 7 Sep 2023 14:38:42 +0200 Subject: [PATCH 035/115] use more functions from finalizeOrder --- metadata.php | 1 - src/Model/Order.php | 49 ++++++++++++++++-------------------- src/Model/PaymentGateway.php | 38 ---------------------------- 3 files changed, 22 insertions(+), 66 deletions(-) delete mode 100644 src/Model/PaymentGateway.php diff --git a/metadata.php b/metadata.php index c6a3e7e2..e6523d6c 100644 --- a/metadata.php +++ b/metadata.php @@ -61,7 +61,6 @@ \OxidEsales\Eshop\Core\Config::class => Config::class, \OxidEsales\Eshop\Application\Model\Payment::class => Payment::class, \OxidEsales\Eshop\Application\Controller\OrderController::class => OrderController::class, - \OxidEsales\Eshop\Application\Model\PaymentGateway::class => PaymentGateway::class, \OxidEsales\Eshop\Application\Model\Order::class => Order::class, \OxidEsales\Eshop\Core\ShopControl::class => ShopControl::class, \OxidEsales\Eshop\Application\Controller\Admin\ModuleConfiguration::class => ModuleConfiguration::class, diff --git a/src/Model/Order.php b/src/Model/Order.php index d6a6b310..b012fbca 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -23,9 +23,6 @@ class Order extends Order_parent { use ServiceContainer; - /** @var bool $isRedirectOrder */ - protected $isRedirectOrder = false; - /** * @param Basket $oBasket * @param User $oUser @@ -38,27 +35,39 @@ public function finalizeUnzerOrderAfterRedirect( Basket $oBasket, User $oUser ) { - $this->isRedirectOrder = true; + $orderId = Registry::getSession()->getVariable('sess_challenge'); + $this->setId($orderId); $unzerPaymentStatus = $this->getServiceFromContainer(PaymentService::class)->getUnzerPaymentStatus(); - if ($unzerPaymentStatus != "ERROR") { + if ($unzerPaymentStatus !== "ERROR") { + + // copies user info + $this->_setUser($oUser); + + // copies basket info + $this->_loadFromBasket($oBasket); + + $oUserPayment = $this->_setPayment($oBasket->getPaymentId()); + + //saving all order data to DB + $this->save(); + if (!$this->getFieldData('oxordernr')) { $this->_setNumber(); } - // else { - // oxNew(\OxidEsales\Eshop\Core\Counter::class) - // ->update($this->_getCounterIdent(), $this->oxorder__oxordernr->value); - //} + + // set folder information, order is new + $this->_setFolder(); // deleting remark info only when order is finished - \OxidEsales\Eshop\Core\Registry::getSession()->deleteVariable('ordrem'); + Registry::getSession()->deleteVariable('ordrem'); //#4005: Order creation time is not updated when order processing is complete $this->_updateOrderDate(); // store orderid - $oBasket->setOrderId($this->getId()); + $oBasket->setOrderId($orderId); // updating wish lists $this->_updateWishlist($oBasket->getContents(), $oUser); @@ -69,9 +78,7 @@ public function finalizeUnzerOrderAfterRedirect( // marking vouchers as used and sets them to $this->_aVoucherList (will be used in order email) $this->_markVouchers($oBasket, $oUser); - $oUserPayment = $this->_setPayment($oBasket->getPaymentId()); // send order by email to shop owner and current user - // don't let order fail due to stock check while sending out the order mail Registry::getSession()->setVariable('blDontCheckProductStockForUnzerMails', true); $iRet = $this->_sendOrderByEmail($oUser, $oBasket, $oUserPayment); @@ -79,7 +86,7 @@ public function finalizeUnzerOrderAfterRedirect( $this->_setOrderStatus($unzerPaymentStatus); - if ($unzerPaymentStatus == 'OK') { + if ($unzerPaymentStatus === 'OK') { $this->markUnzerOrderAsPaid(); } @@ -101,7 +108,7 @@ public function markUnzerOrderAsPaid(): void { /** @var string $oxpaid */ $oxpaid = $this->getFieldData('oxpaid'); - if ($oxpaid == '0000-00-00 00:00:00') { + if ($oxpaid === '0000-00-00 00:00:00') { $utilsDate = Registry::getUtilsDate(); $date = date('Y-m-d H:i:s', $utilsDate->getTime()); $this->setFieldData('oxpaid', $date); @@ -118,18 +125,6 @@ public function setUnzerTransId(string $sTransId): void $this->save(); } - /** - * @inheritDoc - */ - protected function _checkOrderExist($sOxId = null): bool // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore - { - if ($this->isRedirectOrder) { - return false; - } - - return parent::_checkOrderExist($sOxId); - } - /** * @param \UnzerSDK\Resources\Payment|null $unzerPayment * @return bool diff --git a/src/Model/PaymentGateway.php b/src/Model/PaymentGateway.php deleted file mode 100644 index 599fe44c..00000000 --- a/src/Model/PaymentGateway.php +++ /dev/null @@ -1,38 +0,0 @@ -getFieldData('oxpaymenttype'); - $oPayment = oxNew(Payment::class); - if ($oPayment->load($oxpaymenttype)) { - if ($oPayment->isUnzerPayment()) { - $paymentService = $this->getServiceFromContainer(PaymentService::class); - $success = $paymentService->executeUnzerPayment($oPayment); - } - } - - return $success; - } -} From 6e69fe9e2a10d6f709acf0e16a5b797cc775802b Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 12:16:58 +0200 Subject: [PATCH 036/115] remove unecessary try catch --- src/Controller/OrderController.php | 48 +++++++++++++++++------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 3161d3ec..a4009045 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -9,7 +9,9 @@ use OxidEsales\Eshop\Application\Model\Country; use OxidEsales\Eshop\Application\Model\Order; +use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\Exception\ArticleInputException; +use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Exception\NoArticleException; use OxidEsales\Eshop\Core\Exception\OutOfStockException; use OxidEsales\Eshop\Core\Registry; @@ -99,6 +101,7 @@ public function execute() /** * @throws Redirect + * @throws DatabaseErrorException */ public function unzerExecuteAfterRedirect(): void { @@ -106,27 +109,32 @@ public function unzerExecuteAfterRedirect(): void $oUser = $this->getUser(); $oBasket = $this->getSession()->getBasket(); if ($oBasket->getProductsCount()) { - try { - /** @var \OxidSolutionCatalysts\Unzer\Model\Order $oOrder */ - $oOrder = $this->getActualOrder(); - - //finalizing ordering process (validating, storing order into DB, executing payment, setting status ...) - $iSuccess = (int)$oOrder->finalizeUnzerOrderAfterRedirect($oBasket, $oUser); - - // performing special actions after user finishes order (assignment to special user groups) - $oUser->onOrderExecute($oBasket, $iSuccess); - - $nextStep = $this->_getNextStep($iSuccess); - - // proceeding to next view - $unzerService = $this->getServiceFromContainer(Unzer::class); - throw new Redirect($unzerService->prepareRedirectUrl($nextStep)); - } catch (OutOfStockException $oEx) { - $oEx->setDestination('basket'); - Registry::getUtilsView()->addErrorToDisplay($oEx, false, true, 'basket'); - } catch (NoArticleException | ArticleInputException $oEx) { - Registry::getUtilsView()->addErrorToDisplay($oEx); + + $oDB = DatabaseProvider::getDb(); + + /** @var \OxidSolutionCatalysts\Unzer\Model\Order $oOrder */ + $oOrder = $this->getActualOrder(); + + $oDB->startTransaction(); + + //finalizing ordering process (validating, storing order into DB, executing payment, setting status ...) + $iSuccess = (int)$oOrder->finalizeUnzerOrderAfterRedirect($oBasket, $oUser); + + // performing special actions after user finishes order (assignment to special user groups) + $oUser->onOrderExecute($oBasket, $iSuccess); + + $nextStep = $this->_getNextStep($iSuccess); + + if ('thankyou' === $nextStep) { + $oDB->commitTransaction(); } + else { + $oDB->rollbackTransaction(); + } + + // proceeding to next view + $unzerService = $this->getServiceFromContainer(Unzer::class); + throw new Redirect($unzerService->prepareRedirectUrl($nextStep)); } } From 836a61e71b56443bffa2581378e8a623a20bba70 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 12:17:21 +0200 Subject: [PATCH 037/115] set folder before save the order --- src/Model/Order.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index b012fbca..031ebd28 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -50,6 +50,9 @@ public function finalizeUnzerOrderAfterRedirect( $oUserPayment = $this->_setPayment($oBasket->getPaymentId()); + // set folder information, order is new + $this->_setFolder(); + //saving all order data to DB $this->save(); @@ -57,9 +60,6 @@ public function finalizeUnzerOrderAfterRedirect( $this->_setNumber(); } - // set folder information, order is new - $this->_setFolder(); - // deleting remark info only when order is finished Registry::getSession()->deleteVariable('ordrem'); From c406b085d4eac41377eeb44f95921659a42ca46c Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 12:19:13 +0200 Subject: [PATCH 038/115] glue executeUnzerPayment2 and executeUnzerPayment togehter --- src/Service/Payment.php | 75 ----------------------------------------- 1 file changed, 75 deletions(-) diff --git a/src/Service/Payment.php b/src/Service/Payment.php index 188a0e37..a757b449 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -117,14 +117,6 @@ public function executeUnzerPayment(PaymentModel $paymentModel): bool $basket ); - /** @var string $sess_challenge */ - $sess_challenge = $this->session->getVariable('sess_challenge'); - $this->transactionService->writeTransactionToDB( - $sess_challenge, - $this->session->getUser()->getId(), - $this->getSessionUnzerPayment() - ); - $paymentStatus = $this->getUnzerPaymentStatus() !== self::STATUS_ERROR; if ($this->redirectUrl) { @@ -137,8 +129,6 @@ public function executeUnzerPayment(PaymentModel $paymentModel): bool } catch (Redirect $e) { throw $e; } catch (UnzerApiException $e) { - $this->removeTemporaryOrder(); - throw new RedirectWithMessage( $this->unzerService->prepareOrderRedirectUrl( $paymentExtension instanceof AbstractUnzerPayment && $paymentExtension->redirectUrlNeedPending() @@ -146,8 +136,6 @@ public function executeUnzerPayment(PaymentModel $paymentModel): bool $this->translator->translateCode($e->getErrorId(), $e->getClientMessage()) ); } catch (Exception $e) { - $this->removeTemporaryOrder(); - throw new RedirectWithMessage( $this->unzerService->prepareOrderRedirectUrl( $paymentExtension instanceof AbstractUnzerPayment && $paymentExtension->redirectUrlNeedPending() @@ -159,69 +147,6 @@ public function executeUnzerPayment(PaymentModel $paymentModel): bool return $paymentStatus; } - /** - * @throws Redirect - * @throws RedirectWithMessage - */ - public function executeUnzerPayment2(PaymentModel $paymentModel): bool - { - try { - /** @var string $customerType */ - $customerType = Registry::getRequest()->getRequestParameter('unzer_customer_type', ''); - $user = $this->session->getUser(); - $basket = $this->session->getBasket(); - $currency = $basket->getBasketCurrency()->name; - - /** @var AbstractUnzerPayment $paymentExtension */ - $paymentExtension = $this->paymentExtLoader->getPaymentExtensionByCustomerTypeAndCurrency( - $paymentModel, - $customerType, - $currency - ); - $paymentExtension->execute( - $user, - $basket - ); - - /** @var string $sess_challenge */ - $sess_challenge = $this->session->getVariable('sess_challenge'); - $this->transactionService->writeTransactionToDB( - $sess_challenge, - $this->session->getUser()->getId(), - $this->getSessionUnzerPayment() - ); - - $paymentStatus = $this->getUnzerPaymentStatus() !== self::STATUS_ERROR; - - if ($this->redirectUrl) { - throw new Redirect($this->redirectUrl); - } - - if ($this->pdfLink) { - throw new Redirect($this->unzerService->preparePdfConfirmRedirectUrl()); - } - } catch (Redirect $e) { - throw $e; - } catch (UnzerApiException $e) { - throw new RedirectWithMessage( - $this->unzerService->prepareOrderRedirectUrl( -// $paymentExtension instanceof AbstractUnzerPayment && $paymentExtension->redirectUrlNeedPending() - ), - $this->translator->translateCode($e->getErrorId(), $e->getClientMessage()) - ); - } catch (Exception $e) { - - throw new RedirectWithMessage( - $this->unzerService->prepareOrderRedirectUrl( -// $paymentExtension instanceof AbstractUnzerPayment && $paymentExtension->redirectUrlNeedPending() - ), - $e->getMessage() - ); - } - - return $paymentStatus; - } - /** * @return bool */ From ad552ba4929381980159d3e0b378c801c609facf Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 12:43:16 +0200 Subject: [PATCH 039/115] fix codestyle, PHPMD, PHPStan --- src/Controller/DispatcherController.php | 18 ++++++++++++++---- src/Controller/InstallmentController.php | 2 +- src/Controller/OrderController.php | 14 ++++++-------- src/Model/Order.php | 2 +- src/Service/Payment.php | 1 + 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index 90955996..4374bf8d 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -8,6 +8,7 @@ namespace OxidSolutionCatalysts\Unzer\Controller; use Exception; +use JsonException; use OxidEsales\Eshop\Application\Controller\FrontendController; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; @@ -36,6 +37,7 @@ class DispatcherController extends FrontendController * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) * @SuppressWarnings(PHPMD.ElseExpression) + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function updatePaymentTransStatus(): void { @@ -44,14 +46,18 @@ public function updatePaymentTransStatus(): void /** @var string $jsonRequest */ $jsonRequest = file_get_contents('php://input'); - /** @var array $aJson */ + $aJson = []; + try { + /** @var array $aJson */ $aJson = json_decode($jsonRequest, true, 512, JSON_THROW_ON_ERROR); - } catch (\JsonException $e) { + if (!count($aJson)) { + throw new JsonException('Invalid Json'); + } + } catch (JsonException $e) { Registry::getUtils()->showMessageAndExit("Invalid Json"); } - /** @var array $url */ $url = parse_url($aJson['retrieveUrl']); /** @var Transaction $transaction */ $transaction = $this->getServiceFromContainer(Transaction::class); @@ -69,7 +75,11 @@ public function updatePaymentTransStatus(): void } if ( - ($url['scheme'] !== "https" || ($url['host'] !== "api.unzer.com" && $url['host'] !== "sbx-api.heidelpay.com")) + $url['scheme'] !== "https" || + ( + $url['host'] !== "api.unzer.com" && + $url['host'] !== "sbx-api.heidelpay.com" + ) ) { Registry::getUtils()->showMessageAndExit("No valid retrieveUrl"); } diff --git a/src/Controller/InstallmentController.php b/src/Controller/InstallmentController.php index 267d06ba..a1588c1f 100644 --- a/src/Controller/InstallmentController.php +++ b/src/Controller/InstallmentController.php @@ -37,7 +37,7 @@ class InstallmentController extends FrontendController /** @var Payment $uzrPayment */ protected $uzrPayment; - /** @var \OxidSolutionCatalysts\Unzer\Model\Payment $oxPayment */ + /** @var PaymentModel $oxPayment */ protected $oxPayment; /** diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index a4009045..f9f273c3 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -10,10 +10,7 @@ use OxidEsales\Eshop\Application\Model\Country; use OxidEsales\Eshop\Application\Model\Order; use OxidEsales\Eshop\Core\DatabaseProvider; -use OxidEsales\Eshop\Core\Exception\ArticleInputException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; -use OxidEsales\Eshop\Core\Exception\NoArticleException; -use OxidEsales\Eshop\Core\Exception\OutOfStockException; use OxidEsales\Eshop\Core\Registry; use OxidSolutionCatalysts\Unzer\Exception\Redirect; use OxidSolutionCatalysts\Unzer\Model\Payment; @@ -102,6 +99,8 @@ public function execute() /** * @throws Redirect * @throws DatabaseErrorException + * @SuppressWarnings(PHPMD.StaticAccess) + * @SuppressWarnings(PHPMD.ElseExpression) */ public function unzerExecuteAfterRedirect(): void { @@ -109,7 +108,6 @@ public function unzerExecuteAfterRedirect(): void $oUser = $this->getUser(); $oBasket = $this->getSession()->getBasket(); if ($oBasket->getProductsCount()) { - $oDB = DatabaseProvider::getDb(); /** @var \OxidSolutionCatalysts\Unzer\Model\Order $oOrder */ @@ -125,10 +123,9 @@ public function unzerExecuteAfterRedirect(): void $nextStep = $this->_getNextStep($iSuccess); - if ('thankyou' === $nextStep) { + if ('thankyou' === $nextStep) { $oDB->commitTransaction(); - } - else { + } else { $oDB->rollbackTransaction(); } @@ -265,7 +262,7 @@ public function executeoscunzer(): ?string $paymentService = $this->getServiceFromContainer(PaymentService::class); /** @var \OxidEsales\Eshop\Application\Model\Payment $payment */ $payment = $this->getPayment(); - $paymentService->executeUnzerPayment2($payment); + $paymentService->executeUnzerPayment($payment); return null; } @@ -276,6 +273,7 @@ public function executeoscunzer(): ?string */ public function getExecuteFnc() { + /** @var Payment $payment */ $payment = $this->getPayment(); if ( $payment->isUnzerPayment() diff --git a/src/Model/Order.php b/src/Model/Order.php index 031ebd28..2c06ee75 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -36,12 +36,12 @@ public function finalizeUnzerOrderAfterRedirect( User $oUser ) { $orderId = Registry::getSession()->getVariable('sess_challenge'); + $orderId = is_string($orderId) ? $orderId : ''; $this->setId($orderId); $unzerPaymentStatus = $this->getServiceFromContainer(PaymentService::class)->getUnzerPaymentStatus(); if ($unzerPaymentStatus !== "ERROR") { - // copies user info $this->_setUser($oUser); diff --git a/src/Service/Payment.php b/src/Service/Payment.php index a757b449..9ee73730 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -99,6 +99,7 @@ public function __construct( */ public function executeUnzerPayment(PaymentModel $paymentModel): bool { + $paymentExtension = null; try { /** @var string $customerType */ $customerType = Registry::getRequest()->getRequestParameter('unzer_customer_type', ''); From dedfc16d5200cb62cbf2fcdc80406e314d89f78a Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 12:48:29 +0200 Subject: [PATCH 040/115] fix Unit-Error --- src/Service/Transaction.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Service/Transaction.php b/src/Service/Transaction.php index 5e2aac09..1f6588f5 100644 --- a/src/Service/Transaction.php +++ b/src/Service/Transaction.php @@ -116,7 +116,8 @@ public function writeTransactionToDB( $this->deleteInitOrder($params); // Fallback: set ShortID as OXTRANSID - $oOrder->setUnzerTransId($params['shortid']); + $shortId = $params['shortid'] ?? ''; + $oOrder->setUnzerTransId($shortId); return true; } From 136914df953a714cab0ae8186403303858643b0d Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 13:27:52 +0200 Subject: [PATCH 041/115] fix missing Payment-IDs that run into Maintenance --- src/Model/Order.php | 9 +++++++-- src/Service/Payment.php | 6 +++++- src/Service/Transaction.php | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index 2c06ee75..884a93c0 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -37,8 +37,13 @@ public function finalizeUnzerOrderAfterRedirect( ) { $orderId = Registry::getSession()->getVariable('sess_challenge'); $orderId = is_string($orderId) ? $orderId : ''; - $this->setId($orderId); + $iRet = self::ORDER_STATE_PAYMENTERROR; + + if (!$orderId) { + return $iRet; + } + $this->setId($orderId); $unzerPaymentStatus = $this->getServiceFromContainer(PaymentService::class)->getUnzerPaymentStatus(); if ($unzerPaymentStatus !== "ERROR") { @@ -94,7 +99,7 @@ public function finalizeUnzerOrderAfterRedirect( } else { // payment is canceled $this->delete(); - $iRet = self::ORDER_STATE_PAYMENTERROR; + } return $iRet; diff --git a/src/Service/Payment.php b/src/Service/Payment.php index 9ee73730..4d4053de 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -167,8 +167,12 @@ public function getUnzerPaymentStatus(): string { $result = self::STATUS_ERROR; - /** @var \UnzerSDK\Resources\Payment $sessionUnzerPayment */ $sessionUnzerPayment = $this->getSessionUnzerPayment(); + if (is_null($sessionUnzerPayment)) { + return $result; + } + + /** @var \UnzerSDK\Resources\Payment $sessionUnzerPayment */ $transaction = $sessionUnzerPayment->getInitialTransaction(); if ($sessionUnzerPayment->isCompleted()) { diff --git a/src/Service/Transaction.php b/src/Service/Transaction.php index 1f6588f5..b52f10c6 100644 --- a/src/Service/Transaction.php +++ b/src/Service/Transaction.php @@ -350,7 +350,7 @@ protected function getUnzerPaymentData(Payment $unzerPayment): array /** @var AbstractTransactionType $initialTransaction */ $initialTransaction = $unzerPayment->getInitialTransaction(); - $params['shortid'] = $initialTransaction->getShortId() !== null ? + $params['shortid'] = !is_null($initialTransaction) && !is_null($initialTransaction->getShortId()) ? $initialTransaction->getShortId() : Registry::getSession()->getVariable('ShortId'); From 1884a7da055617e8ed2839a3e0d7fe81927d1ccf Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 13:57:01 +0200 Subject: [PATCH 042/115] CHANGELOG --- CHANGELOG.md | 6 ++++++ metadata.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 114a9a8d..76d058c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.3] - 2023-??-?? + +- [0007526](https://bugs.oxid-esales.com/view.php?id=7526) Order would be saved only, if everything is correct. In all other cases redirect to checkout +- [0007509](https://bugs.oxid-esales.com/view.php?id=7509) Order would be saved only, if everything is correct. In all other cases redirect to checkout +- [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout + ## [1.1.2] - 2023-08-18 ### FIXED diff --git a/metadata.php b/metadata.php index e6523d6c..c65b894e 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.2', + 'version' => '1.1.3-rc.1', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 2b95a28c2999514075b4e9c6bf292933960de478 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 17:06:11 +0200 Subject: [PATCH 043/115] move SepaValidation the executeoscunzer --- src/Controller/OrderController.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index f9f273c3..9ea19467 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -67,10 +67,6 @@ public function render() */ public function execute() { - if (!$this->isSepaConfirmed()) { - return ''; - } - $ret = parent::execute(); if ($ret && str_starts_with($ret, 'thankyou')) { @@ -87,10 +83,6 @@ public function execute() $response->setData([ 'redirectUrl' => $unzer->prepareRedirectUrl('thankyou') ])->sendJson(); - } elseif ($this->isSepaPayment()) { - /** @var \OxidSolutionCatalysts\Unzer\Model\Order $order */ - $order = $this->getActualOrder(); - $order->markUnzerOrderAsPaid(); } return $ret; @@ -259,10 +251,24 @@ public function getUnzerCompanyTypes(): array */ public function executeoscunzer(): ?string { + if (!$this->isSepaConfirmed()) { + return null; + } + + if (!$this->_validateTermsAndConditions()) { + $this->_blConfirmAGBError = 1; + return null; + } + $paymentService = $this->getServiceFromContainer(PaymentService::class); /** @var \OxidEsales\Eshop\Application\Model\Payment $payment */ $payment = $this->getPayment(); - $paymentService->executeUnzerPayment($payment); + $paymentOk = $paymentService->executeUnzerPayment($payment); + + // all orders without redirect would be finalized now + if ($paymentOk) { + $this->unzerExecuteAfterRedirect(); + } return null; } From 6d9beba333c97176eda0c7efac839160d3750ae6 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 8 Sep 2023 17:06:34 +0200 Subject: [PATCH 044/115] null is now also possible --- src/Model/Order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index 884a93c0..a4bd9f09 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -113,7 +113,7 @@ public function markUnzerOrderAsPaid(): void { /** @var string $oxpaid */ $oxpaid = $this->getFieldData('oxpaid'); - if ($oxpaid === '0000-00-00 00:00:00') { + if ($oxpaid === '0000-00-00 00:00:00' || is_null($oxpaid)) { $utilsDate = Registry::getUtilsDate(); $date = date('Y-m-d H:i:s', $utilsDate->getTime()); $this->setFieldData('oxpaid', $date); From 04308c91af81d376bb09b3337787091ee54a0d91 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 12 Sep 2023 10:19:20 +0200 Subject: [PATCH 045/115] add error-message if rollbackTransaction --- src/Controller/OrderController.php | 16 +++++++++++----- translations/de/oscunzer_lang.php | 3 +++ translations/en/oscunzer_lang.php | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 9ea19467..2583b716 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -13,6 +13,7 @@ use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Registry; use OxidSolutionCatalysts\Unzer\Exception\Redirect; +use OxidSolutionCatalysts\Unzer\Exception\RedirectWithMessage; use OxidSolutionCatalysts\Unzer\Model\Payment; use OxidSolutionCatalysts\Unzer\Service\ModuleSettings; use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService; @@ -115,15 +116,20 @@ public function unzerExecuteAfterRedirect(): void $nextStep = $this->_getNextStep($iSuccess); + // commit transaction and proceeding to next view + $unzerService = $this->getServiceFromContainer(Unzer::class); + if ('thankyou' === $nextStep) { $oDB->commitTransaction(); - } else { - $oDB->rollbackTransaction(); + throw new Redirect($unzerService->prepareRedirectUrl($nextStep)); } - // proceeding to next view - $unzerService = $this->getServiceFromContainer(Unzer::class); - throw new Redirect($unzerService->prepareRedirectUrl($nextStep)); + $oDB->rollbackTransaction(); + $translator = $this->getServiceFromContainer(Translator::class); + throw new RedirectWithMessage( + $unzerService->prepareRedirectUrl($nextStep), + $translator->translate('OSCUNZER_ERROR_DURING_CHECKOUT') + ); } } diff --git a/translations/de/oscunzer_lang.php b/translations/de/oscunzer_lang.php index 8cc40105..8792c9ef 100644 --- a/translations/de/oscunzer_lang.php +++ b/translations/de/oscunzer_lang.php @@ -13,6 +13,9 @@ $aLang = [ 'charset' => 'UTF-8', + // Error + 'OSCUNZER_ERROR_DURING_CHECKOUT' => 'Bei der Abwicklung der Zahlung ist ein Fehler aufgetreten. Der Prozess wurde rückgängig gemacht. Bitte wählen Sie alternativ eine andere Zahlart aus.', + // Invoice 'OSCUNZER_BANK_DETAILS_AMOUNT' => 'Bitte überweisen sie den Betrag von %s %s auf folgendes Bankkonto:

', 'OSCUNZER_BANK_DETAILS_HOLDER' => 'Kontoinhaber: %s
', diff --git a/translations/en/oscunzer_lang.php b/translations/en/oscunzer_lang.php index d4b022c6..8bc19894 100644 --- a/translations/en/oscunzer_lang.php +++ b/translations/en/oscunzer_lang.php @@ -13,6 +13,9 @@ $aLang = [ 'charset' => 'UTF-8', + // Error + 'OSCUNZER_ERROR_DURING_CHECKOUT' => 'An error occurred while processing the payment. The process was reversed. Alternatively, please select another payment method.', + //Invoice 'OSCUNZER_BANK_DETAILS_AMOUNT' => 'Please transfer the amount of %s %s to the following account:

', 'OSCUNZER_BANK_DETAILS_HOLDER' => 'Holder: %s
', From f8a9aa1329c84d13f4c4a8803f3141595e30d6c6 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 12 Sep 2023 10:24:14 +0200 Subject: [PATCH 046/115] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76d058c6..d0f66825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007526](https://bugs.oxid-esales.com/view.php?id=7526) Order would be saved only, if everything is correct. In all other cases redirect to checkout - [0007509](https://bugs.oxid-esales.com/view.php?id=7509) Order would be saved only, if everything is correct. In all other cases redirect to checkout - [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout +- [0007527](https://bugs.oxid-esales.com/view.php?id=7527) prevent clicking the buy-now-button several times ## [1.1.2] - 2023-08-18 From 8c0f518276d6a2bd150d1adeec342c2f8590fe5f Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 12 Sep 2023 10:46:10 +0200 Subject: [PATCH 047/115] fix PHP-Stan -MD and -Style-Errors --- src/Controller/DispatcherController.php | 1 + src/Controller/OrderController.php | 2 +- src/Model/Order.php | 2 -- src/Service/Payment.php | 1 + src/Service/Transaction.php | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index 4374bf8d..b5f99a04 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -58,6 +58,7 @@ public function updatePaymentTransStatus(): void Registry::getUtils()->showMessageAndExit("Invalid Json"); } + /** @var array $url */ $url = parse_url($aJson['retrieveUrl']); /** @var Transaction $transaction */ $transaction = $this->getServiceFromContainer(Transaction::class); diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 2583b716..14f8ca26 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -262,7 +262,7 @@ public function executeoscunzer(): ?string } if (!$this->_validateTermsAndConditions()) { - $this->_blConfirmAGBError = 1; + $this->_blConfirmAGBError = true; return null; } diff --git a/src/Model/Order.php b/src/Model/Order.php index a4bd9f09..b6f47ac1 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -99,7 +99,6 @@ public function finalizeUnzerOrderAfterRedirect( } else { // payment is canceled $this->delete(); - } return $iRet; @@ -111,7 +110,6 @@ public function finalizeUnzerOrderAfterRedirect( */ public function markUnzerOrderAsPaid(): void { - /** @var string $oxpaid */ $oxpaid = $this->getFieldData('oxpaid'); if ($oxpaid === '0000-00-00 00:00:00' || is_null($oxpaid)) { $utilsDate = Registry::getUtilsDate(); diff --git a/src/Service/Payment.php b/src/Service/Payment.php index 4d4053de..edab6ecf 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -162,6 +162,7 @@ public function removeTemporaryOrder(): bool /** * @return string * @throws UnzerApiException + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function getUnzerPaymentStatus(): string { diff --git a/src/Service/Transaction.php b/src/Service/Transaction.php index b52f10c6..809db2fe 100644 --- a/src/Service/Transaction.php +++ b/src/Service/Transaction.php @@ -348,7 +348,6 @@ protected function getUnzerPaymentData(Payment $unzerPayment): array 'traceid' => $unzerPayment->getTraceId() ]; - /** @var AbstractTransactionType $initialTransaction */ $initialTransaction = $unzerPayment->getInitialTransaction(); $params['shortid'] = !is_null($initialTransaction) && !is_null($initialTransaction->getShortId()) ? $initialTransaction->getShortId() : From dcd2b826423577033333f943b68ea90edf2932ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 04:12:16 +0000 Subject: [PATCH 048/115] Bump docker/metadata-action from 4.6.0 to 5.0.0 Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4.6.0 to 5.0.0. - [Release notes](https://github.com/docker/metadata-action/releases) - [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md) - [Commits](https://github.com/docker/metadata-action/compare/818d4b7b91585d195f67373fd9cb0332e31a7175...96383f45573cb7f253c731d3b3ab81c87ef81934) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-v7-image.yml | 2 +- .github/workflows/docker-publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v7-image.yml b/.github/workflows/build-v7-image.yml index 7e90321a..b0ed9721 100644 --- a/.github/workflows/build-v7-image.yml +++ b/.github/workflows/build-v7-image.yml @@ -68,7 +68,7 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 30eb9f31..045994cd 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -85,7 +85,7 @@ jobs: # https://github.com/docker/metadata-action - name: Extract Docker metadata id: meta - uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 + uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} From 31d80d977fe9abeef9ea681b91f7e9b92cf351d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 04:12:18 +0000 Subject: [PATCH 049/115] Bump docker/setup-qemu-action from 2 to 3 Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-qemu-action/releases) - [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-qemu-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-v7-image.yml | 2 +- .github/workflows/docker-publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v7-image.yml b/.github/workflows/build-v7-image.yml index 7e90321a..322bfd19 100644 --- a/.github/workflows/build-v7-image.yml +++ b/.github/workflows/build-v7-image.yml @@ -49,7 +49,7 @@ jobs: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 30eb9f31..3825368d 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -66,7 +66,7 @@ jobs: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV} - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 From 330795527ba8982200b1a6a4134e60012d30c018 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 04:12:21 +0000 Subject: [PATCH 050/115] Bump docker/setup-buildx-action from 2 to 3 Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-v7-image.yml | 2 +- .github/workflows/docker-publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v7-image.yml b/.github/workflows/build-v7-image.yml index 7e90321a..18c76483 100644 --- a/.github/workflows/build-v7-image.yml +++ b/.github/workflows/build-v7-image.yml @@ -52,7 +52,7 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 # Login against a Docker registry except on PR # https://github.com/docker/login-action diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 30eb9f31..3a4c1479 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -69,7 +69,7 @@ jobs: uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 # Login against a Docker registry except on PR # https://github.com/docker/login-action From 2fad1bd851531f883dad0ccc2d5d2224b908e775 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 04:12:25 +0000 Subject: [PATCH 051/115] Bump docker/build-push-action from 4 to 5 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v4...v5) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-v7-image.yml | 2 +- .github/workflows/docker-publish.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-v7-image.yml b/.github/workflows/build-v7-image.yml index 7e90321a..ec06c871 100644 --- a/.github/workflows/build-v7-image.yml +++ b/.github/workflows/build-v7-image.yml @@ -75,7 +75,7 @@ jobs: # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile.v7 diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 30eb9f31..b36d2e0a 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -92,7 +92,7 @@ jobs: # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 From e79d28871799fcafd9a2940a2f190ecb066358ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 04:12:28 +0000 Subject: [PATCH 052/115] Bump docker/login-action from 2 to 3 Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-v7-image.yml | 2 +- .github/workflows/default.yml | 4 ++-- .github/workflows/docker-publish.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-v7-image.yml b/.github/workflows/build-v7-image.yml index 7e90321a..a9ac2aa4 100644 --- a/.github/workflows/build-v7-image.yml +++ b/.github/workflows/build-v7-image.yml @@ -58,7 +58,7 @@ jobs: # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 26c4d90c..99ec6db0 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -184,7 +184,7 @@ jobs: development-${{ matrix.php }}-${{ github.run_number }}-${{ github.run_attempt }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} @@ -249,7 +249,7 @@ jobs: development-${{ matrix.php }}-${{ github.run_number }}-${{ github.run_attempt }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 30eb9f31..9dfefc08 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -75,7 +75,7 @@ jobs: # https://github.com/docker/login-action - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} From 8e6a01764c7f6c954105a760b9a3fa349a0d2735 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 19 Sep 2023 15:41:20 +0200 Subject: [PATCH 053/115] PrePayments not written in Database --- metadata.php | 2 +- src/Model/Order.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/metadata.php b/metadata.php index c65b894e..4b0179d9 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.3-rc.1', + 'version' => '1.1.3-rc.2', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', diff --git a/src/Model/Order.php b/src/Model/Order.php index b6f47ac1..29f65de2 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -138,8 +138,7 @@ public function initWriteTransactionToDB($unzerPayment = null): bool /** @var string $oxpaymenttype */ $oxpaymenttype = $this->getFieldData('oxpaymenttype'); if ( - $this->getFieldData('oxtransstatus') == "OK" - && strpos($oxpaymenttype, "oscunzer") !== false + strpos($oxpaymenttype, "oscunzer") !== false ) { $transactionService = $this->getServiceFromContainer(TransactionService::class); return $transactionService->writeTransactionToDB( From 77e237dba77e28c1d3f43db2e8cd86af3af17518 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 29 Sep 2023 15:12:27 +0200 Subject: [PATCH 054/115] Log only in Unzer-Log --- services.yaml | 32 +++++++++----------------- src/Service/ApplePaySessionHandler.php | 7 +++++- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/services.yaml b/services.yaml index 47da3919..d44a435e 100644 --- a/services.yaml +++ b/services.yaml @@ -3,26 +3,17 @@ services: _defaults: public: false autowire: true - - OxidEsales\Eshop\Core\Registry: + bind: + OxidEsales\Eshop\Core\Config: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getConfig()' + OxidEsales\Eshop\Core\Session: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getSession()' + OxidEsales\Eshop\Core\Language: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getLang()' + OxidEsales\Eshop\Core\UtilsDate: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getUtilsDate()' + OxidEsales\Eshop\Core\Request: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getRequest()' + + OxidSolutionCatalysts\Unzer\Core\Registry: class: OxidEsales\Eshop\Core\Registry - - OxidEsales\Eshop\Core\Config: - factory: [ '@OxidEsales\Eshop\Core\Registry', 'getConfig' ] public: true - OxidEsales\Eshop\Core\Session: - factory: [ '@OxidEsales\Eshop\Core\Registry', 'getSession' ] - - OxidEsales\Eshop\Core\Language: - factory: [ '@OxidEsales\Eshop\Core\Registry', 'getLang' ] - - OxidEsales\Eshop\Core\UtilsDate: - factory: [ '@OxidEsales\Eshop\Core\Registry', 'getUtilsDate' ] - - OxidEsales\Eshop\Core\Request: - factory: [ '@OxidEsales\Eshop\Core\Registry', 'getRequest' ] - OxidSolutionCatalysts\Unzer\Logger: class: Monolog\Logger factory: ['@OxidSolutionCatalysts\Unzer\Logger\Factory', 'create'] @@ -42,12 +33,11 @@ services: $logFilePath: '@=service("OxidSolutionCatalysts\\Unzer\\Service\\Context").getUnzerLogFilePath()' $logLevel: !php/const Psr\Log\LogLevel::INFO - OxidSolutionCatalysts\Unzer\Service\: - resource: 'src/Service/*' - exclude: 'src/Service/{DebugHandler}' + OxidSolutionCatalysts\Unzer\Core\Response: public: true - OxidSolutionCatalysts\Unzer\Core\Response: + OxidSolutionCatalysts\Unzer\Service\: + resource: 'src/Service/*' public: true OxidSolutionCatalysts\Unzer\Service\DebugHandler: diff --git a/src/Service/ApplePaySessionHandler.php b/src/Service/ApplePaySessionHandler.php index 79267cd8..2a19c03a 100644 --- a/src/Service/ApplePaySessionHandler.php +++ b/src/Service/ApplePaySessionHandler.php @@ -3,11 +3,14 @@ namespace OxidSolutionCatalysts\Unzer\Service; use OxidEsales\Eshop\Core\Registry; +use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; +use Psr\Log\LoggerInterface; use UnzerSDK\Adapter\ApplepayAdapter; use UnzerSDK\Resources\ExternalResources\ApplepaySession; class ApplePaySessionHandler { + use ServiceContainer; private ApplepaySession $session; private ApplepayAdapter $adapter; private ModuleSettings $moduleSettings; @@ -74,7 +77,9 @@ public function validateMerchant(string $validationUrl): ?array ); return $jsonDecoded; } catch (\Throwable $e) { - Registry::getLogger()->error($e->getMessage()); + /** @var LoggerInterface $logger */ + $logger = $this->getServiceFromContainer('OxidSolutionCatalysts\Unzer\Logger'); + $logger->error($e->getMessage()); return null; } } From 5f8b85e621e4f4ab193a2fef5c49e52f06792d3d Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 29 Sep 2023 15:19:00 +0200 Subject: [PATCH 055/115] remove "null"-order functionality --- src/Controller/DispatcherController.php | 10 +-- src/Model/Order.php | 25 ------ src/Service/Transaction.php | 107 ------------------------ 3 files changed, 1 insertion(+), 141 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index b5f99a04..b66e7bd5 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -113,15 +113,8 @@ public function updatePaymentTransStatus(): void } $translator = $this->getServiceFromContainer(Translator::class); - - if ($oxTransStatus !== "OK" && $unzerPayment->getState() !== 2) { - $ret = $order->reinitializeOrder(); - if ($ret !== 1) { - $unzer->debugLog("Order-Recalculation failed and returned with code: " . $ret); - } - } - $transactionService = $this->getServiceFromContainer(Transaction::class); + if ( $transactionService->writeTransactionToDB( $order->getId(), @@ -139,7 +132,6 @@ public function updatePaymentTransStatus(): void } } } - $transaction->cleanUpNotFinishedOrders(); Registry::getUtils()->showMessageAndExit($result); } diff --git a/src/Model/Order.php b/src/Model/Order.php index b6f47ac1..f0757007 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -166,31 +166,6 @@ public function getUnzerInvoiceNr() return $number; } - /** - * @throws DatabaseErrorException - * @throws DatabaseConnectionException - * - * @return false|int - * - * @SuppressWarnings(PHPMD.StaticAccess) - */ - public function reinitializeOrder() - { - $oDB = DatabaseProvider::getDb(DatabaseProvider::FETCH_MODE_ASSOC); - $rowSelect = $oDB->getRow("SELECT OXUSERID, SERIALIZED_BASKET from oscunzertransaction - where OXORDERID = :oxorderid AND OXACTION = 'init'", [':oxorderid' => $this->getId()]); - if ($rowSelect) { - $oUser = oxNew(User::class); - $oUser->load($rowSelect['OXUSERID']); - if ($oUser->isLoaded()) { - /** @var Basket $oBasket */ - $oBasket = unserialize(base64_decode($rowSelect['SERIALIZED_BASKET'])); - return $this->finalizeOrder($oBasket, $oUser, true); - } - } - return false; - } - /** * @inerhitDoc * diff --git a/src/Service/Transaction.php b/src/Service/Transaction.php index 809db2fe..fbbe1624 100644 --- a/src/Service/Transaction.php +++ b/src/Service/Transaction.php @@ -102,10 +102,6 @@ public function writeTransactionToDB( } } - if ($unzerPayment && $unzerPayment->getState() == 2) { - $this->deleteOldInitOrders(); - } - // building oxid from unique index columns // only write to DB if oxid doesn't exist to prevent multiple entries of the same transaction $oxid = $this->prepareTransactionOxid($params); @@ -125,47 +121,6 @@ public function writeTransactionToDB( return false; } - /** - * @param string $orderid - * @param string $userId - * @param Payment|null $unzerPayment - * @param Basket|null $basketModel - * @return bool - * @throws \Exception - */ - public function writeInitOrderToDB( - string $orderid, - string $userId, - ?Payment $unzerPayment, - ?Basket $basketModel - ): bool { - $transaction = $this->getNewTransactionObject(); - - $params = [ - 'oxorderid' => $orderid, - 'oxshopid' => $this->context->getCurrentShopId(), - 'oxuserid' => $userId, - 'oxactiondate' => date('Y-m-d H:i:s', $this->utilsDate->getTime()), - ]; - - if ($unzerPayment instanceof Payment && $basketModel instanceof Basket) { - $params = array_merge($params, $this->getUnzerInitOrderData($unzerPayment, $basketModel)); - } - - // building oxid from unique index columns - // only write to DB if oxid doesn't exist to prevent multiple entries of the same transaction - $oxid = $this->prepareTransactionOxid($params); - if (!$transaction->load($oxid)) { - $transaction->assign($params); - $transaction->setId($oxid); - $transaction->save(); - - return true; - } - - return false; - } - /** * @param (int|mixed|string)[] $params * @@ -180,56 +135,6 @@ public function deleteInitOrder(array $params): void } } - public function deleteOldInitOrders(): void - { - DatabaseProvider::getDb()->Execute( - "DELETE from oscunzertransaction where OXACTION = 'init' AND OXACTIONDATE < NOW() - INTERVAL 1 DAY" - ); - } - - public function cleanUpNotFinishedOrders(): void - { - /** @var ContainerInterface $container */ - $container = ContainerFactory::getInstance()->getContainer(); - /** @var QueryBuilderFactoryInterface $queryBuilderFactory */ - $queryBuilderFactory = $container->get(QueryBuilderFactoryInterface::class); - - /** @var QueryBuilder $queryBuilder */ - $queryBuilder = $queryBuilderFactory->create(); - - $parameters = [ - 'oxordernr' => '0', - 'oxtransstatus' => 'NOT_FINISHED', - 'oxpaymenttype' => 'oscunzer', - 'sessiontime' => 600 - ]; - - $queryBuilder->select('oxid') - ->from('oxorder') - ->where('oxordernr = :oxordernr') - ->andWhere('oxtransstatus = :oxtransstatus') - ->andWhere($queryBuilder->expr()->like( - 'oxpaymenttype', - $queryBuilder->expr()->literal('%' . $parameters['oxpaymenttype'] . '%') - )) - ->andWhere('oxorderdate < now() - interval :sessiontime SECOND'); - - /** @var Result $result */ - $result = $queryBuilder->setParameters($parameters)->execute(); - $ids = $result->fetchAllAssociative(); - - /** @var string $id */ - foreach ($ids as $id) { - $order = oxNew(EshopModelOrder::class); - if ($order->load($id)) { - // storno - $order->cancelOrder(); - // delete - $order->delete(); - } - } - } - /** * @param string $orderid * @param string $userId @@ -444,18 +349,6 @@ protected function getUnzerShipmentData(Shipment $unzerShipment, Payment $unzerP return $params; } - /** - * @throws UnzerApiException - */ - protected function getUnzerInitOrderData(Payment $unzerPayment, Basket $basketModel): array - { - $params = $this->getUnzerPaymentData($unzerPayment); - $params["oxaction"] = 'init'; - $params["serialized_basket"] = base64_encode(serialize($basketModel)); - - return $params; - } - /** * @return TransactionModel */ From cf76f6b599ba827f0fe466eccaba8a629cab5525 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 29 Sep 2023 16:54:25 +0200 Subject: [PATCH 056/115] WIP: --- src/Model/Order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index f0757007..49631e7f 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -138,7 +138,7 @@ public function initWriteTransactionToDB($unzerPayment = null): bool /** @var string $oxpaymenttype */ $oxpaymenttype = $this->getFieldData('oxpaymenttype'); if ( - $this->getFieldData('oxtransstatus') == "OK" + $this->getFieldData('oxtransstatus') === "OK" && strpos($oxpaymenttype, "oscunzer") !== false ) { $transactionService = $this->getServiceFromContainer(TransactionService::class); From db53e5504466a5c8cb2564a00c189dcdddc1241e Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Sat, 30 Sep 2023 00:03:57 +0200 Subject: [PATCH 057/115] revert services because incompatibility with OXID 6.3 --- services.yaml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/services.yaml b/services.yaml index d44a435e..4037bbb5 100644 --- a/services.yaml +++ b/services.yaml @@ -3,17 +3,26 @@ services: _defaults: public: false autowire: true - bind: - OxidEsales\Eshop\Core\Config: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getConfig()' - OxidEsales\Eshop\Core\Session: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getSession()' - OxidEsales\Eshop\Core\Language: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getLang()' - OxidEsales\Eshop\Core\UtilsDate: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getUtilsDate()' - OxidEsales\Eshop\Core\Request: '@=service("OxidSolutionCatalysts\\Unzer\\Core\\Registry").getRequest()' - - OxidSolutionCatalysts\Unzer\Core\Registry: + + OxidEsales\Eshop\Core\Registry: class: OxidEsales\Eshop\Core\Registry + + OxidEsales\Eshop\Core\Config: + factory: [ '@OxidEsales\Eshop\Core\Registry', 'getConfig' ] public: true + OxidEsales\Eshop\Core\Session: + factory: [ '@OxidEsales\Eshop\Core\Registry', 'getSession' ] + + OxidEsales\Eshop\Core\Language: + factory: [ '@OxidEsales\Eshop\Core\Registry', 'getLang' ] + + OxidEsales\Eshop\Core\UtilsDate: + factory: [ '@OxidEsales\Eshop\Core\Registry', 'getUtilsDate' ] + + OxidEsales\Eshop\Core\Request: + factory: [ '@OxidEsales\Eshop\Core\Registry', 'getRequest' ] + OxidSolutionCatalysts\Unzer\Logger: class: Monolog\Logger factory: ['@OxidSolutionCatalysts\Unzer\Logger\Factory', 'create'] From 2df29982d277170ef2814931af23e57b37b9857c Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 5 Oct 2023 16:35:47 +0200 Subject: [PATCH 058/115] redirect after checkout-error --- src/Controller/OrderController.php | 2 +- src/Core/ShopControl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 14f8ca26..1519b2e7 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -116,10 +116,10 @@ public function unzerExecuteAfterRedirect(): void $nextStep = $this->_getNextStep($iSuccess); - // commit transaction and proceeding to next view $unzerService = $this->getServiceFromContainer(Unzer::class); if ('thankyou' === $nextStep) { + // commit transaction and proceeding to next view $oDB->commitTransaction(); throw new Redirect($unzerService->prepareRedirectUrl($nextStep)); } diff --git a/src/Core/ShopControl.php b/src/Core/ShopControl.php index 1b747ad5..d4627354 100644 --- a/src/Core/ShopControl.php +++ b/src/Core/ShopControl.php @@ -75,6 +75,6 @@ protected function handleUnzerRedirectWithMessageException(RedirectWithMessage $ Registry::getUtilsView()->addErrorToDisplay($displayError); - $this->handleUnzerRedirectException($redirectException); + $this->handleUnzerRedirectException($redirectException, false); } } From e22febdbdd3bb31d0f52c599d69adcaa4e02bd17 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 6 Oct 2023 08:29:42 +0200 Subject: [PATCH 059/115] add errorhandling for errors during CC-Checkout --- src/Core/ShopControl.php | 3 ++- views/frontend/tpl/order/unzer_card.tpl | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Core/ShopControl.php b/src/Core/ShopControl.php index d4627354..118fdc90 100644 --- a/src/Core/ShopControl.php +++ b/src/Core/ShopControl.php @@ -61,7 +61,8 @@ public function handleCustomUnzerException(UnzerException $exception): void */ protected function handleUnzerRedirectException(Redirect $redirectException, bool $blAddRedirectParam = true): void { - Registry::getUtils()->redirect($redirectException->getDestination(), $blAddRedirectParam); + $url = $redirectException->getDestination(); + Registry::getUtils()->redirect($url, $blAddRedirectParam); } /** diff --git a/views/frontend/tpl/order/unzer_card.tpl b/views/frontend/tpl/order/unzer_card.tpl index 3c115119..98893bf5 100644 --- a/views/frontend/tpl/order/unzer_card.tpl +++ b/views/frontend/tpl/order/unzer_card.tpl @@ -38,16 +38,16 @@ // Create a Card instance and render the input fields let Card = unzerInstance.Card(); Card.create('number', { - containerId: 'card-element-id-number', - onlyIframe: false + containerId: 'card-element-id-number', + onlyIframe: false }); Card.create('expiry', { - containerId: 'card-element-id-expiry', - onlyIframe: false + containerId: 'card-element-id-expiry', + onlyIframe: false }); Card.create('cvc', { - containerId: 'card-element-id-cvc', - onlyIframe: false + containerId: 'card-element-id-cvc', + onlyIframe: false }); $( "#payment-form-card" ).submit(function( event ) { @@ -66,6 +66,14 @@ $('html, body').animate({ scrollTop: $("#orderPayment").offset().top - 150 }, 350); + + errorField = $("#card-element-id-number"); + errorField.find('div').first().addClass('error'); + errorEl = errorField.find('div.error.message'); + errorEl.css('display', 'inline-block'); + errorEl.text(error.message); + + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', false); }) }); From ad112ffbf065bff2036b21b877e9cff389b75485 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 6 Oct 2023 08:32:54 +0200 Subject: [PATCH 060/115] Add CHANGELOG --- CHANGELOG.md | 1 + metadata.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0f66825..cdda864f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007509](https://bugs.oxid-esales.com/view.php?id=7509) Order would be saved only, if everything is correct. In all other cases redirect to checkout - [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout - [0007527](https://bugs.oxid-esales.com/view.php?id=7527) prevent clicking the buy-now-button several times +- [0007544](https://bugs.oxid-esales.com/view.php?id=7544) Add Error handling When unsupported Credit Card is used (e.g. Amex) ## [1.1.2] - 2023-08-18 diff --git a/metadata.php b/metadata.php index 4b0179d9..61336d6b 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.3-rc.2', + 'version' => '1.1.3-rc.3', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From 2bdf9b35fc73366c3ad3fdd7cb7070876ec446be Mon Sep 17 00:00:00 2001 From: dmitrii Date: Thu, 12 Oct 2023 13:06:59 +0200 Subject: [PATCH 061/115] UNZER-240 fix code style --- src/Service/ApplePaySessionHandler.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Service/ApplePaySessionHandler.php b/src/Service/ApplePaySessionHandler.php index 2a19c03a..36813b67 100644 --- a/src/Service/ApplePaySessionHandler.php +++ b/src/Service/ApplePaySessionHandler.php @@ -11,6 +11,7 @@ class ApplePaySessionHandler { use ServiceContainer; + private ApplepaySession $session; private ApplepayAdapter $adapter; private ModuleSettings $moduleSettings; @@ -78,6 +79,7 @@ public function validateMerchant(string $validationUrl): ?array return $jsonDecoded; } catch (\Throwable $e) { /** @var LoggerInterface $logger */ + /** @phpstan-ignore-next-line */ $logger = $this->getServiceFromContainer('OxidSolutionCatalysts\Unzer\Logger'); $logger->error($e->getMessage()); return null; From d1ab5ab6a663c0525e941882f2900676c6302152 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 26 Oct 2023 09:13:52 +0200 Subject: [PATCH 062/115] use Constants for better Code-Reading --- src/Controller/DispatcherController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index b66e7bd5..36e47952 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -20,6 +20,7 @@ use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader; use OxidSolutionCatalysts\Unzer\Service\UnzerWebhooks; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; +use UnzerSDK\Constants\PaymentState; use UnzerSDK\Exceptions\UnzerApiException; class DispatcherController extends FrontendController @@ -104,11 +105,11 @@ public function updatePaymentTransStatus(): void if ($order->load($data[0]['OXORDERID'])) { /** @var string $oxTransStatus */ $oxTransStatus = $order->getFieldData('oxtransstatus'); - if ($oxTransStatus === "OK" && $unzerPayment->getState() === 1) { + if ($oxTransStatus === "OK" && $unzerPayment->getState() === PaymentState::STATE_COMPLETED) { $order->markUnzerOrderAsPaid(); } - if ($unzerPayment->getState() === 2) { + if ($unzerPayment->getState() === PaymentState::STATE_CANCELED) { $order->cancelOrder(); } From 056b9f7e90587aaa6c28a16a1379dbb0754c9785 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 27 Oct 2023 18:58:28 +0200 Subject: [PATCH 063/115] Change some Metadata --- src/Module.php | 1 + src/Service/ModuleSettings.php | 8 ++++++++ src/Service/Unzer.php | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Module.php b/src/Module.php index 3b90ffa3..f1b31c70 100644 --- a/src/Module.php +++ b/src/Module.php @@ -13,4 +13,5 @@ class Module { public const MODULE_ID = 'osc-unzer'; + public const GITHUB_NAME = 'OXID-eSales/unzer-module'; } diff --git a/src/Service/ModuleSettings.php b/src/Service/ModuleSettings.php index a841716e..5b42de21 100644 --- a/src/Service/ModuleSettings.php +++ b/src/Service/ModuleSettings.php @@ -160,6 +160,14 @@ public function getModuleVersion(): string return $this->moduleInfoBridge->get(Module::MODULE_ID)->getVersion(); } + /** + * @return string + */ + public function getGitHubName(): string + { + return Module::GITHUB_NAME; + } + /** * @return bool */ diff --git a/src/Service/Unzer.php b/src/Service/Unzer.php index d9d15bdc..3682644a 100644 --- a/src/Service/Unzer.php +++ b/src/Service/Unzer.php @@ -621,7 +621,8 @@ public function getShopMetadata(string $paymentMethod): Metadata $metadata->addMetadata('shopid', (string)Registry::getConfig()->getShopId()); $metadata->addMetadata('paymentmethod', $paymentMethod); $metadata->addMetadata('paymentprocedure', $this->getPaymentProcedure($paymentMethod)); - $metadata->addMetadata('moduleversion', $this->moduleSettings->getModuleVersion()); + $metadata->addMetadata('pluginType', $this->moduleSettings->getGitHubName()); + $metadata->addMetadata('pluginVersion', $this->moduleSettings->getModuleVersion()); return $metadata; } From af871cdf4cf22f4a743a2fd930398f75b6c0b437 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Fri, 27 Oct 2023 19:00:20 +0200 Subject: [PATCH 064/115] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdda864f..b2c8dd30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout - [0007527](https://bugs.oxid-esales.com/view.php?id=7527) prevent clicking the buy-now-button several times - [0007544](https://bugs.oxid-esales.com/view.php?id=7544) Add Error handling When unsupported Credit Card is used (e.g. Amex) +- change information for Unzer-Metadata ## [1.1.2] - 2023-08-18 From da375d146bf8269dab87f94f0e0247f33782603c Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 15:31:36 +0100 Subject: [PATCH 065/115] PrePayments starts with transstatus "not_finished". This should also be possible to see as transactions --- src/Controller/DispatcherController.php | 4 +--- src/Model/Order.php | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Controller/DispatcherController.php b/src/Controller/DispatcherController.php index 36e47952..6a41e4a5 100644 --- a/src/Controller/DispatcherController.php +++ b/src/Controller/DispatcherController.php @@ -103,9 +103,7 @@ public function updatePaymentTransStatus(): void $unzerPayment = $unzer->fetchPayment($paymentId); if ($order->load($data[0]['OXORDERID'])) { - /** @var string $oxTransStatus */ - $oxTransStatus = $order->getFieldData('oxtransstatus'); - if ($oxTransStatus === "OK" && $unzerPayment->getState() === PaymentState::STATE_COMPLETED) { + if ($unzerPayment->getState() === PaymentState::STATE_COMPLETED) { $order->markUnzerOrderAsPaid(); } diff --git a/src/Model/Order.php b/src/Model/Order.php index 49631e7f..f48c179f 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -117,6 +117,9 @@ public function markUnzerOrderAsPaid(): void $this->setFieldData('oxpaid', $date); $this->save(); } + // e.g. prepayments start with "NO_FINISHED", if they are marked as paid, + // we set the status to OK here + $this->_setOrderStatus('OK'); } /** @@ -138,8 +141,7 @@ public function initWriteTransactionToDB($unzerPayment = null): bool /** @var string $oxpaymenttype */ $oxpaymenttype = $this->getFieldData('oxpaymenttype'); if ( - $this->getFieldData('oxtransstatus') === "OK" - && strpos($oxpaymenttype, "oscunzer") !== false + strpos($oxpaymenttype, "oscunzer") !== false ) { $transactionService = $this->getServiceFromContainer(TransactionService::class); return $transactionService->writeTransactionToDB( From 687037ffc3f5e7e7a72e082eaf20cbab34b06bb4 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 15:33:53 +0100 Subject: [PATCH 066/115] README --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdda864f..11464bb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout - [0007527](https://bugs.oxid-esales.com/view.php?id=7527) prevent clicking the buy-now-button several times - [0007544](https://bugs.oxid-esales.com/view.php?id=7544) Add Error handling When unsupported Credit Card is used (e.g. Amex) - +- Prepayment - Adjust payment date when the payment has been completed + ## [1.1.2] - 2023-08-18 ### FIXED From 7bb42f56f08009fe93a7545b5430fa0f406f74e1 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 16:10:06 +0100 Subject: [PATCH 067/115] According to Unzer, the billing and delivery address must be identical for invoice purchases (Paylater) --- src/Controller/PaymentController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index 465ff696..c7d6f573 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -8,6 +8,7 @@ namespace OxidSolutionCatalysts\Unzer\Controller; use OxidEsales\Eshop\Application\Model\Order; +use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions as CoreUnzerDefinitions; use OxidSolutionCatalysts\Unzer\Service\UserRepository; use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions; use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions as UnzerDefinitionsService; @@ -63,6 +64,8 @@ public function getPaymentList() continue; } + $invAndDelAddrIdent = !Registry::getSession()->getVariable('blshowshipaddress'); + if ( ( $payment->isUnzerPaymentHealthy() @@ -74,6 +77,10 @@ public function getPaymentList() ( empty($unzerDefinitions[$key]['countries']) || in_array($userCountryIso, $unzerDefinitions[$key]['countries'], true) + ) && + ( + $key !== CoreUnzerDefinitions::INVOICE_UNZER_PAYMENT_ID || + ($key === CoreUnzerDefinitions::INVOICE_UNZER_PAYMENT_ID && $invAndDelAddrIdent) ) ) { $paymentList[$key] = $payment; From ca9ac86a8391a3ffb45bb2913bf580e98bffe76d Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 16:19:18 +0100 Subject: [PATCH 068/115] README --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdda864f..343dd0f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout - [0007527](https://bugs.oxid-esales.com/view.php?id=7527) prevent clicking the buy-now-button several times - [0007544](https://bugs.oxid-esales.com/view.php?id=7544) Add Error handling When unsupported Credit Card is used (e.g. Amex) + [0007553](https://bugs.oxid-esales.com/view.php?id=7553) The billing and delivery address must be identical for invoice purchases (Paylater) ## [1.1.2] - 2023-08-18 From c40a875b4d69aa7ed02281adead4c05414a448c1 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 10:58:36 +0100 Subject: [PATCH 069/115] New Column for Order-Table --- migration/data/Version20231107212500.php | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 migration/data/Version20231107212500.php diff --git a/migration/data/Version20231107212500.php b/migration/data/Version20231107212500.php new file mode 100644 index 00000000..510f95f6 --- /dev/null +++ b/migration/data/Version20231107212500.php @@ -0,0 +1,51 @@ +platform->registerDoctrineTypeMapping('enum', 'string'); + } + + public function getDescription(): string + { + return ''; + } + + public function up(Schema $schema): void + { + $this->updateOxOrderTable($schema); + } + + public function down(Schema $schema): void + { + } + + protected function updateOxOrderTable(Schema $schema): void + { + $oxorder = $schema->getTable('oxorder'); + if (!$oxorder->hasColumn('OXUNZERORDERNR')) { + $oxorder->addColumn('OXUNZERORDERNR', Types::INTEGER, ['columnDefinition' => 'int(11)', 'default' => 0, 'comment' => 'Unzer Order Nr']); + } + } +} From bc3614f96a757f8bdf6258515efcad649ad84d92 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 11:04:43 +0100 Subject: [PATCH 070/115] new template for Order Over --- metadata.php | 5 ++++ views/admin/blocks/admin_order_list_item.tpl | 27 ++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 views/admin/blocks/admin_order_list_item.tpl diff --git a/metadata.php b/metadata.php index 61336d6b..0f638231 100644 --- a/metadata.php +++ b/metadata.php @@ -132,6 +132,11 @@ 'block' => 'admin_module_config_var', 'file' => 'views/admin/blocks/admin_module_config_var.tpl' ], + [ + 'template' => 'order_list.tpl', + 'block' => 'admin_order_list_item', + 'file' => 'views/admin/blocks/admin_order_list_item.tpl' + ], //email [ 'template' => 'email/plain/order_cust.tpl', diff --git a/views/admin/blocks/admin_order_list_item.tpl b/views/admin/blocks/admin_order_list_item.tpl new file mode 100644 index 00000000..8d0e01d9 --- /dev/null +++ b/views/admin/blocks/admin_order_list_item.tpl @@ -0,0 +1,27 @@ +if [{$listitem|method_exists:'isUnzerPayment' && $listitem->isUnzerPayment}] + [{if $listitem->oxorder__oxstorno->value == 1}] + [{assign var="listclass" value=listitem3}] + [{else}] + [{if $listitem->blacklist == 1}] + [{assign var="listclass" value=listitem3}] + [{else}] + [{assign var="listclass" value=listitem$blWhite}] + [{/if}] + [{/if}] + [{if $listitem->getId() == $oxid}] + [{assign var="listclass" value=listitem4}] + [{/if}] + + + + + + + [{if !$readonly}] + + + [{/if}] + +[{else}] + [{$smarty.block.parent}] +[{/if}] \ No newline at end of file From 124dfb3634ebd11a76d0e6c56e9566b74aa4890b Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 11:29:33 +0100 Subject: [PATCH 071/115] WIP: set UnzerOrder ID in Order-Model --- src/Model/Order.php | 50 ++++++++++++++++++++++++++++++++++++++--- src/Service/Payment.php | 13 +++++++++++ src/Service/Unzer.php | 18 ++++++++++++++- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index f48c179f..b27c2406 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -7,8 +7,10 @@ namespace OxidSolutionCatalysts\Unzer\Model; +use Exception; use OxidEsales\Eshop\Application\Model\Basket; use OxidEsales\Eshop\Application\Model\User; +use OxidEsales\Eshop\Core\Counter; use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; @@ -16,6 +18,7 @@ use OxidEsales\Eshop\Core\Registry; use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService; use OxidSolutionCatalysts\Unzer\Service\Transaction as TransactionService; +use OxidSolutionCatalysts\Unzer\Service\Unzer; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; use UnzerSDK\Exceptions\UnzerApiException; @@ -27,7 +30,7 @@ class Order extends Order_parent * @param Basket $oBasket * @param User $oUser * @return int|bool - * @throws \Exception + * @throws Exception * * @SuppressWarnings(PHPMD.ElseExpression) */ @@ -44,7 +47,9 @@ public function finalizeUnzerOrderAfterRedirect( } $this->setId($orderId); - $unzerPaymentStatus = $this->getServiceFromContainer(PaymentService::class)->getUnzerPaymentStatus(); + /** @var Unzer $paymentService */ + $paymentService = $this->getServiceFromContainer(PaymentService::class); + $unzerPaymentStatus = $paymentService->getUnzerPaymentStatus(); if ($unzerPaymentStatus !== "ERROR") { // copies user info @@ -65,6 +70,10 @@ public function finalizeUnzerOrderAfterRedirect( $this->_setNumber(); } + // setUnzerOrderId + $this->setUnzerOrderNr($paymentService->getUnzerOrderId()); + $paymentService->resetUnzerOrderId(); + // deleting remark info only when order is finished Registry::getSession()->deleteVariable('ordrem'); @@ -104,6 +113,41 @@ public function finalizeUnzerOrderAfterRedirect( return $iRet; } + /** + * @return bool + */ + public function isUnzerPayment(): bool + { + return stripos($this->getFieldData('oxpaymenttype'), "oscunzer") !== false; + } + + public function getUnzerOrderNr(): int + { + return (int)$this->getFieldData('oxunzerordernr'); + } + + /** + * @throws DatabaseErrorException + * @throws DatabaseConnectionException + * @throws Exception + */ + public function setUnzerOrderNr(int $unzerOrderId): int + { + $db = DatabaseProvider::getDb(); + + $sQ = "update oxorder set oxunzerordernr = :oxunzerordernr where oxid = :oxid"; + $isUpdated = (bool) $db->execute($sQ, [ + ':oxunzerordernr' => $unzerOrderId, + ':oxid' => $this->getId() + ]); + + if ($isUpdated) { + $this->oxorder__oxunzerordernr = new Field($unzerOrderId); + } + + return $unzerOrderId; + } + /** * @return void * @SuppressWarnings(PHPMD.StaticAccess) @@ -198,7 +242,7 @@ public function delete($sOxId = null) * @param int $dataType * @return false|void */ - public function setFieldData($fieldName, $value, $dataType = \OxidEsales\Eshop\Core\Field::T_TEXT) + public function setFieldData($fieldName, $value, $dataType = Field::T_TEXT) { return parent::_setFieldData($fieldName, $value, $dataType); } diff --git a/src/Service/Payment.php b/src/Service/Payment.php index edab6ecf..785dec2e 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -205,6 +205,19 @@ public function getUnzerPaymentStatus(): string return $result; } + /** + * @return string + * @throws UnzerApiException + */ + public function getUnzerOrderId(): string + { + $result = ''; + if ($sessionUnzerPayment = $this->getSessionUnzerPayment()) { + $result = $sessionUnzerPayment->getInitialTransaction()->getOrderId(); + } + return $result; + } + /** * @param string $customerType * @param string $currency diff --git a/src/Service/Unzer.php b/src/Service/Unzer.php index 3682644a..5015c001 100644 --- a/src/Service/Unzer.php +++ b/src/Service/Unzer.php @@ -12,6 +12,7 @@ use OxidEsales\Eshop\Application\Model\Basket as BasketModel; use OxidEsales\Eshop\Application\Model\Country; use OxidEsales\Eshop\Application\Model\Order; +use OxidEsales\Eshop\Core\Counter; use OxidEsales\Eshop\Core\Model\ListModel; use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Registry; @@ -629,10 +630,25 @@ public function getShopMetadata(string $paymentMethod): Metadata /** * @return string + * @throws Exception */ public function generateUnzerOrderId(): string { - return 'o' . str_replace(['0.', ' '], '', microtime(false)); +// return 'o' . str_replace(['0.', ' '], '', microtime(false)); + $config = Registry::getConfig(); + $session = Registry::getSession(); + if (!($unzerOrderId = $session->getVariable('UnzerOrderId'))) { + $separateNumbering = $config->getConfigParam('blSeparateNumbering'); + $counterIdent = $separateNumbering ? 'oxUnzerOrder_' . $config->getShopId() : 'oxUnzerOrder'; + $unzerOrderId = oxNew(Counter::class)->getNext($counterIdent); + $session->setVariable('UnzerOrderId', $unzerOrderId); + } + return $unzerOrderId; + } + + public function resetUnzerOrderId(): void + { + Registry::getSession()->deleteVariable('UnzerOrderId'); } /** From d51110604147fee154aa56b613d1d90ddf16ca81 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 14:03:15 +0100 Subject: [PATCH 072/115] Show Order Number in Backend --- src/Model/Order.php | 12 ++---------- views/admin/blocks/admin_order_list_item.tpl | 13 +++++++++---- views/admin/de/oscunzer_lang.php | 1 + views/admin/en/oscunzer_lang.php | 1 + views/admin/tpl/oscunzer_order.tpl | 2 +- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index b27c2406..9b326bfe 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -47,8 +47,8 @@ public function finalizeUnzerOrderAfterRedirect( } $this->setId($orderId); - /** @var Unzer $paymentService */ $paymentService = $this->getServiceFromContainer(PaymentService::class); + $unzerService = $this->getServiceFromContainer(Unzer::class); $unzerPaymentStatus = $paymentService->getUnzerPaymentStatus(); if ($unzerPaymentStatus !== "ERROR") { @@ -72,7 +72,7 @@ public function finalizeUnzerOrderAfterRedirect( // setUnzerOrderId $this->setUnzerOrderNr($paymentService->getUnzerOrderId()); - $paymentService->resetUnzerOrderId(); + $unzerService->resetUnzerOrderId(); // deleting remark info only when order is finished Registry::getSession()->deleteVariable('ordrem'); @@ -113,14 +113,6 @@ public function finalizeUnzerOrderAfterRedirect( return $iRet; } - /** - * @return bool - */ - public function isUnzerPayment(): bool - { - return stripos($this->getFieldData('oxpaymenttype'), "oscunzer") !== false; - } - public function getUnzerOrderNr(): int { return (int)$this->getFieldData('oxunzerordernr'); diff --git a/views/admin/blocks/admin_order_list_item.tpl b/views/admin/blocks/admin_order_list_item.tpl index 8d0e01d9..0ca062fc 100644 --- a/views/admin/blocks/admin_order_list_item.tpl +++ b/views/admin/blocks/admin_order_list_item.tpl @@ -1,7 +1,8 @@ -if [{$listitem|method_exists:'isUnzerPayment' && $listitem->isUnzerPayment}] +[{assign var="isUnzerPayment" value=$listitem->oxorder__oxpaymenttype->value|stripos:"oscunzer"}] +[{if $isUnzerPayment !== false}] [{if $listitem->oxorder__oxstorno->value == 1}] - [{assign var="listclass" value=listitem3}] - [{else}] + [{assign var="listclass" value=listitem3}] + [{else}] [{if $listitem->blacklist == 1}] [{assign var="listclass" value=listitem3}] [{else}] @@ -13,7 +14,11 @@ if [{$listitem|method_exists:'isUnzerPayment' && $listitem->isUnzerPayment}] [{/if}] - + + + diff --git a/views/admin/de/oscunzer_lang.php b/views/admin/de/oscunzer_lang.php index f28258af..e3932d07 100644 --- a/views/admin/de/oscunzer_lang.php +++ b/views/admin/de/oscunzer_lang.php @@ -19,6 +19,7 @@ 'OSCUNZER_TRANSACTION_CREATED' => 'Transaktion erstellt', 'OSCUNZER_TRANSACTION_CUSTOMERID' => 'Unzer Kunden-ID', 'OSCUNZER_TRANSACTION_STATUS' => 'Unzer Auftragsstatus', + 'OSCUNZER_TRANSACTION_ORDERNR' => 'Unzer OrderNr', 'OSCUNZER_TRANSACTION_TYPEID' => 'Unzer Type-ID', 'OSCUNZER_TRANSACTION_AMOUNT' => 'Betrag', 'OSCUNZER_TRANSACTION_STATUS_pending' => 'ausstehend', diff --git a/views/admin/en/oscunzer_lang.php b/views/admin/en/oscunzer_lang.php index 5d594efa..284153f1 100644 --- a/views/admin/en/oscunzer_lang.php +++ b/views/admin/en/oscunzer_lang.php @@ -19,6 +19,7 @@ 'OSCUNZER_TRANSACTION_CREATED' => 'Transaction created', 'OSCUNZER_TRANSACTION_CUSTOMERID' => 'Unzer Customer-ID', 'OSCUNZER_TRANSACTION_STATUS' => 'Unzer OrderState', + 'OSCUNZER_TRANSACTION_ORDERNR' => 'Unzer OrderNr', 'OSCUNZER_TRANSACTION_TYPEID' => 'Unzer Type-ID', 'OSCUNZER_TRANSACTION_AMOUNT' => 'Amount', 'OSCUNZER_TRANSACTION_STATUS_pending' => 'pending', diff --git a/views/admin/tpl/oscunzer_order.tpl b/views/admin/tpl/oscunzer_order.tpl index f2b6c7ea..7281fca6 100644 --- a/views/admin/tpl/oscunzer_order.tpl +++ b/views/admin/tpl/oscunzer_order.tpl @@ -1,7 +1,7 @@ [{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}] [{if $paymentTitle && $totalBasketPrice}] -

[{$paymentTitle}] : [{$totalBasketPrice}]

+

[{$paymentTitle}] : [{$totalBasketPrice}] / [{oxmultilang ident='OSCUNZER_TRANSACTION_ORDERNR' suffix='COLON'}] [{$oOrder->oxorder__oxunzerordernr->value}]

[{/if}] [{* payment abilities *}] From e0017003c4e4d9f86323fac87d585aa7037ba56a Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 14:51:31 +0100 Subject: [PATCH 073/115] Codestyle --- src/Model/Order.php | 18 +++++++++++++----- src/PaymentExtensions/UnzerPayment.php | 6 +++++- src/Service/Payment.php | 14 +++++++++----- src/Service/Unzer.php | 10 ++++++---- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index 9b326bfe..eaf1d9d0 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -10,7 +10,6 @@ use Exception; use OxidEsales\Eshop\Application\Model\Basket; use OxidEsales\Eshop\Application\Model\User; -use OxidEsales\Eshop\Core\Counter; use OxidEsales\Eshop\Core\DatabaseProvider; use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; @@ -22,6 +21,10 @@ use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; use UnzerSDK\Exceptions\UnzerApiException; +/** + * TODO: Decrease count of dependencies to 13 + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Order extends Order_parent { use ServiceContainer; @@ -115,25 +118,30 @@ public function finalizeUnzerOrderAfterRedirect( public function getUnzerOrderNr(): int { - return (int)$this->getFieldData('oxunzerordernr'); + $value = $this->getFieldData('oxunzerordernr'); + return is_numeric($value) ? (int)$value : 0; } /** * @throws DatabaseErrorException * @throws DatabaseConnectionException * @throws Exception + * @SuppressWarnings(PHPMD.StaticAccess) */ public function setUnzerOrderNr(int $unzerOrderId): int { - $db = DatabaseProvider::getDb(); + $oDB = DatabaseProvider::getDb(); - $sQ = "update oxorder set oxunzerordernr = :oxunzerordernr where oxid = :oxid"; - $isUpdated = (bool) $db->execute($sQ, [ + $sSQL = "update oxorder set oxunzerordernr = :oxunzerordernr where oxid = :oxid"; + $isUpdated = (bool) $oDB->execute($sSQL, [ ':oxunzerordernr' => $unzerOrderId, ':oxid' => $this->getId() ]); if ($isUpdated) { + // TODO fixme Access to an undefined property + // OxidSolutionCatalysts\Unzer\Model\Order::$oxorder__oxunzerordernr. + /** @phpstan-ignore-next-line */ $this->oxorder__oxunzerordernr = new Field($unzerOrderId); } diff --git a/src/PaymentExtensions/UnzerPayment.php b/src/PaymentExtensions/UnzerPayment.php index 4fea2e12..4fcb23c0 100644 --- a/src/PaymentExtensions/UnzerPayment.php +++ b/src/PaymentExtensions/UnzerPayment.php @@ -7,6 +7,7 @@ namespace OxidSolutionCatalysts\Unzer\PaymentExtensions; +use Exception; use OxidEsales\Eshop\Application\Model\Basket; use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Exception\StandardException; @@ -43,6 +44,9 @@ abstract class UnzerPayment /** @var array */ protected $allowedCurrencies = []; + /** + * @throws Exception + */ public function __construct( Unzer $unzerSDK, UnzerService $unzerService @@ -50,7 +54,7 @@ public function __construct( $this->unzerSDK = $unzerSDK; $this->unzerService = $unzerService; - $this->unzerOrderId = $this->unzerService->generateUnzerOrderId(); + $this->unzerOrderId = (string)$this->unzerService->generateUnzerOrderId(); $this->unzerService->setIsAjaxPayment($this->ajaxResponse); } diff --git a/src/Service/Payment.php b/src/Service/Payment.php index 785dec2e..16d5be69 100644 --- a/src/Service/Payment.php +++ b/src/Service/Payment.php @@ -206,14 +206,18 @@ public function getUnzerPaymentStatus(): string } /** - * @return string + * @return int * @throws UnzerApiException */ - public function getUnzerOrderId(): string + public function getUnzerOrderId(): int { - $result = ''; - if ($sessionUnzerPayment = $this->getSessionUnzerPayment()) { - $result = $sessionUnzerPayment->getInitialTransaction()->getOrderId(); + $result = 0; + $sessionUnzerPayment = $this->getSessionUnzerPayment(); + if ($sessionUnzerPayment) { + $transaction = $sessionUnzerPayment->getInitialTransaction(); + if ($transaction) { + $result = (int)$transaction->getOrderId(); + } } return $result; } diff --git a/src/Service/Unzer.php b/src/Service/Unzer.php index 5015c001..dc8bb82e 100644 --- a/src/Service/Unzer.php +++ b/src/Service/Unzer.php @@ -629,15 +629,17 @@ public function getShopMetadata(string $paymentMethod): Metadata } /** - * @return string + * @return int * @throws Exception + * @SuppressWarnings(PHPMD.StaticAccess) */ - public function generateUnzerOrderId(): string + public function generateUnzerOrderId(): int { -// return 'o' . str_replace(['0.', ' '], '', microtime(false)); $config = Registry::getConfig(); $session = Registry::getSession(); - if (!($unzerOrderId = $session->getVariable('UnzerOrderId'))) { + $unzerOrderId = $session->getVariable('UnzerOrderId'); + $unzerOrderId = is_numeric($unzerOrderId) ? (int)$unzerOrderId : 0; + if (!$unzerOrderId) { $separateNumbering = $config->getConfigParam('blSeparateNumbering'); $counterIdent = $separateNumbering ? 'oxUnzerOrder_' . $config->getShopId() : 'oxUnzerOrder'; $unzerOrderId = oxNew(Counter::class)->getNext($counterIdent); From d6c7c636fde384339cee7d3eebf25f0ddff229f5 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 14:55:25 +0100 Subject: [PATCH 074/115] README --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d542e5a0..56a5e890 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout - [0007527](https://bugs.oxid-esales.com/view.php?id=7527) prevent clicking the buy-now-button several times - [0007544](https://bugs.oxid-esales.com/view.php?id=7544) Add Error handling When unsupported Credit Card is used (e.g. Amex) +- [0007546](https://bugs.oxid-esales.com/view.php?id=7546): We provide an additional Order Number to Unzer for identify the Order in OXID-Backend and Unzer-Insights - Prepayment - Adjust payment date when the payment has been completed - change information for Unzer-Metadata From 80f323a192187708bd34cbb5ffbdff8507576078 Mon Sep 17 00:00:00 2001 From: dmitrii Date: Thu, 9 Nov 2023 16:39:56 +0100 Subject: [PATCH 075/115] UNZER-241 Update work with database --- src/Model/Order.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index eaf1d9d0..9083484b 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -10,15 +10,15 @@ use Exception; use OxidEsales\Eshop\Application\Model\Basket; use OxidEsales\Eshop\Application\Model\User; -use OxidEsales\Eshop\Core\DatabaseProvider; -use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; -use OxidEsales\Eshop\Core\Exception\DatabaseErrorException; use OxidEsales\Eshop\Core\Field; use OxidEsales\Eshop\Core\Registry; +use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; +use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService; use OxidSolutionCatalysts\Unzer\Service\Transaction as TransactionService; use OxidSolutionCatalysts\Unzer\Service\Unzer; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; +use Psr\Container\ContainerInterface; use UnzerSDK\Exceptions\UnzerApiException; /** @@ -123,27 +123,30 @@ public function getUnzerOrderNr(): int } /** - * @throws DatabaseErrorException - * @throws DatabaseConnectionException - * @throws Exception * @SuppressWarnings(PHPMD.StaticAccess) */ public function setUnzerOrderNr(int $unzerOrderId): int { - $oDB = DatabaseProvider::getDb(); + /** @var ContainerInterface $container */ + $container = ContainerFactory::getInstance() + ->getContainer(); + + /** @var QueryBuilderFactoryInterface $queryBuilderFactory */ + $queryBuilderFactory = $container->get(QueryBuilderFactoryInterface::class); + + $queryBuilder = $queryBuilderFactory->create(); - $sSQL = "update oxorder set oxunzerordernr = :oxunzerordernr where oxid = :oxid"; - $isUpdated = (bool) $oDB->execute($sSQL, [ + $query = $queryBuilder + ->update('oxorder') + ->set("oxunzerordernr", ":oxunzerordernr") + ->where("oxid = :oxid"); + + $parameters = [ ':oxunzerordernr' => $unzerOrderId, ':oxid' => $this->getId() - ]); + ]; - if ($isUpdated) { - // TODO fixme Access to an undefined property - // OxidSolutionCatalysts\Unzer\Model\Order::$oxorder__oxunzerordernr. - /** @phpstan-ignore-next-line */ - $this->oxorder__oxunzerordernr = new Field($unzerOrderId); - } + $query->setParameters($parameters)->execute(); return $unzerOrderId; } From 8f5a4b6c476a3720a16e80b7e72c4a098f8abf32 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 19:48:44 +0100 Subject: [PATCH 076/115] small tweak to set field too ... --- src/Model/Order.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Model/Order.php b/src/Model/Order.php index 9083484b..a90642d4 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -148,6 +148,11 @@ public function setUnzerOrderNr(int $unzerOrderId): int $query->setParameters($parameters)->execute(); + // TODO fixme Access to an undefined property + // OxidSolutionCatalysts\Unzer\Model\Order::$oxorder__oxunzerordernr. + /** @phpstan-ignore-next-line */ + $this->oxorder__oxunzerordernr = new Field($unzerOrderId); + return $unzerOrderId; } From f907ea8d1197f6d831f81ab992e5fd0774aeaedf Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Thu, 9 Nov 2023 20:06:00 +0100 Subject: [PATCH 077/115] CodeStyle --- src/Controller/OrderController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 1519b2e7..6154fb18 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -149,9 +149,11 @@ public function isSepaPayment(): ?bool $payment = $this->getPayment(); return ( - ($payment instanceof Payment) ? - ( $payment->getId() === CoreUnzerDefinitions::SEPA_UNZER_PAYMENT_ID - || $payment->getId() === CoreUnzerDefinitions::SEPA_SECURED_UNZER_PAYMENT_ID) : false + $payment instanceof Payment && + ( + $payment->getId() === CoreUnzerDefinitions::SEPA_UNZER_PAYMENT_ID || + $payment->getId() === CoreUnzerDefinitions::SEPA_SECURED_UNZER_PAYMENT_ID + ) ); } From f4689e767dd57d345507921d6274d6abdd5e224f Mon Sep 17 00:00:00 2001 From: markusmichalski-fc Date: Mon, 13 Nov 2023 16:36:12 +0100 Subject: [PATCH 078/115] Unzer-214: Added display of bank detail on unzer order tab --- src/Controller/Admin/AdminOrderController.php | 6 +++++ views/admin/de/oscunzer_lang.php | 1 + views/admin/en/oscunzer_lang.php | 1 + views/admin/tpl/oscunzer_order.tpl | 24 +++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/src/Controller/Admin/AdminOrderController.php b/src/Controller/Admin/AdminOrderController.php index 0867d2da..53773e8d 100644 --- a/src/Controller/Admin/AdminOrderController.php +++ b/src/Controller/Admin/AdminOrderController.php @@ -228,6 +228,12 @@ protected function addAuthorizationViewData(Authorization $authorization): void $this->_aViewData["AuthShortId"] = $authorization->getShortId(); $this->_aViewData["AuthId"] = $authorization->getId(); $this->_aViewData["AuthAmount"] = $authorization->getAmount(); + $holderData = []; + $holderData['bic'] = $authorization->getBic(); + $holderData['iban'] = $authorization->getIban(); + $holderData['descriptor'] = $authorization->getDescriptor(); + $holderData['holder'] = $authorization->getHolder(); + $this->_aViewData["holderData"] = $holderData; } /** diff --git a/views/admin/de/oscunzer_lang.php b/views/admin/de/oscunzer_lang.php index e3932d07..ed4e28ef 100644 --- a/views/admin/de/oscunzer_lang.php +++ b/views/admin/de/oscunzer_lang.php @@ -51,6 +51,7 @@ 'OSCUNZER_CHARGE_COLLECT' => 'Einziehen', 'OSCUNZER_CHARGE_ID' => 'Charge-ID', 'OSCUNZER_CANCEL_ID' => 'Cancel-ID', + 'OSCUNZER_BANK_HOLDER_DETAILS' => 'Bankdetails', 'OSCUNZER_AUTHORIZATION' => 'Autorisierung', 'OSCUNZER_NOSHIPINGYET' => 'Bestellung ist bei Unzer noch nicht als Versendet markiert', 'OSCUNZER_SHIPMENTS' => 'Auslieferungen', diff --git a/views/admin/en/oscunzer_lang.php b/views/admin/en/oscunzer_lang.php index 284153f1..470d281a 100644 --- a/views/admin/en/oscunzer_lang.php +++ b/views/admin/en/oscunzer_lang.php @@ -51,6 +51,7 @@ 'OSCUNZER_CHARGE_COLLECT' => 'Collect', 'OSCUNZER_CHARGE_ID' => 'Charge-ID', 'OSCUNZER_CANCEL_ID' => 'Cancel-ID', + 'OSCUNZER_BANK_HOLDER_DETAILS' => 'Bankdetails', 'OSCUNZER_AUTHORIZATION' => 'Authorization', 'OSCUNZER_NOSHIPINGYET' => 'order has not yet been marked as shipped', 'OSCUNZER_SHIPMENTS' => 'Shipments', diff --git a/views/admin/tpl/oscunzer_order.tpl b/views/admin/tpl/oscunzer_order.tpl index 7281fca6..7aef4c80 100644 --- a/views/admin/tpl/oscunzer_order.tpl +++ b/views/admin/tpl/oscunzer_order.tpl @@ -281,6 +281,30 @@ [{/if}] [{/block}] + [{block name="unzer_holder"}] + [{if $holderData }] +

[{oxmultilang ident="OSCUNZER_BANK_HOLDER_DETAILS"}]

+ + + + + + + + + + + + + + + + + + +
IBANBICHolderDescriptor
[{$holderData.iban}][{$holderData.bic}][{$holderData.holder}][{$holderData.descriptor}]
+ [{/if}] + [{/block}] [{capture assign="cancelConfirm"}] let handleUnzerForm = function(formElement) { From 97829819f20a5cd68570968ee9491b1f3cf108b1 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 14 Nov 2023 11:23:13 +0100 Subject: [PATCH 079/115] Add missing translations --- views/admin/de/oscunzer_lang.php | 6 ++++- views/admin/en/oscunzer_lang.php | 4 +++ views/admin/tpl/oscunzer_order.tpl | 41 ++++++++++++++---------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/views/admin/de/oscunzer_lang.php b/views/admin/de/oscunzer_lang.php index ed4e28ef..1e36e7e0 100644 --- a/views/admin/de/oscunzer_lang.php +++ b/views/admin/de/oscunzer_lang.php @@ -51,7 +51,11 @@ 'OSCUNZER_CHARGE_COLLECT' => 'Einziehen', 'OSCUNZER_CHARGE_ID' => 'Charge-ID', 'OSCUNZER_CANCEL_ID' => 'Cancel-ID', - 'OSCUNZER_BANK_HOLDER_DETAILS' => 'Bankdetails', + 'OSCUNZER_BANK_HOLDER_DETAILS' => 'Bankinformationen', + 'OSCUNZER_IBAN' => 'IBAN', + 'OSCUNZER_BIC' => 'BIC', + 'OSCUNZER_HOLDER' => 'Inhaber', + 'OSCUNZER_DESCRIPTOR' => 'Beschreibung', 'OSCUNZER_AUTHORIZATION' => 'Autorisierung', 'OSCUNZER_NOSHIPINGYET' => 'Bestellung ist bei Unzer noch nicht als Versendet markiert', 'OSCUNZER_SHIPMENTS' => 'Auslieferungen', diff --git a/views/admin/en/oscunzer_lang.php b/views/admin/en/oscunzer_lang.php index 470d281a..c5ede358 100644 --- a/views/admin/en/oscunzer_lang.php +++ b/views/admin/en/oscunzer_lang.php @@ -52,6 +52,10 @@ 'OSCUNZER_CHARGE_ID' => 'Charge-ID', 'OSCUNZER_CANCEL_ID' => 'Cancel-ID', 'OSCUNZER_BANK_HOLDER_DETAILS' => 'Bankdetails', + 'OSCUNZER_IBAN' => 'IBAN', + 'OSCUNZER_BIC' => 'BIC', + 'OSCUNZER_HOLDER' => 'Holder', + 'OSCUNZER_DESCRIPTOR' => 'Descriptor', 'OSCUNZER_AUTHORIZATION' => 'Authorization', 'OSCUNZER_NOSHIPINGYET' => 'order has not yet been marked as shipped', 'OSCUNZER_SHIPMENTS' => 'Shipments', diff --git a/views/admin/tpl/oscunzer_order.tpl b/views/admin/tpl/oscunzer_order.tpl index 7aef4c80..051cf957 100644 --- a/views/admin/tpl/oscunzer_order.tpl +++ b/views/admin/tpl/oscunzer_order.tpl @@ -282,28 +282,25 @@ [{/if}] [{/block}] [{block name="unzer_holder"}] - [{if $holderData }] -

[{oxmultilang ident="OSCUNZER_BANK_HOLDER_DETAILS"}]

- - - - - - - - - - - - - - - - - - -
IBANBICHolderDescriptor
[{$holderData.iban}][{$holderData.bic}][{$holderData.holder}][{$holderData.descriptor}]
- [{/if}] + [{if $holderData }] +

[{oxmultilang ident="OSCUNZER_BANK_HOLDER_DETAILS"}]

+ + + + + + + + + + + + + + + +
[{oxmultilang ident="OSCUNZER_IBAN"}][{oxmultilang ident="OSCUNZER_BIC"}][{oxmultilang ident="OSCUNZER_HOLDER"}][{oxmultilang ident="OSCUNZER_DESCRIPTOR"}]
[{$holderData.iban}][{$holderData.bic}][{$holderData.holder}][{$holderData.descriptor}]
+ [{/if}] [{/block}] [{capture assign="cancelConfirm"}] From 45fed3ee19e08cbe2e071e6460229a1dc482f931 Mon Sep 17 00:00:00 2001 From: Mario Lorenz Date: Tue, 14 Nov 2023 11:23:39 +0100 Subject: [PATCH 080/115] Add CHANGELOG and Version --- CHANGELOG.md | 4 ++-- metadata.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 006ab735..05648ecb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [1.1.3] - 2023-??-?? +## [1.1.3] - 2023-11-14 - [0007526](https://bugs.oxid-esales.com/view.php?id=7526) Order would be saved only, if everything is correct. In all other cases redirect to checkout - [0007509](https://bugs.oxid-esales.com/view.php?id=7509) Order would be saved only, if everything is correct. In all other cases redirect to checkout @@ -13,9 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [0007544](https://bugs.oxid-esales.com/view.php?id=7544) Add Error handling When unsupported Credit Card is used (e.g. Amex) - [0007553](https://bugs.oxid-esales.com/view.php?id=7553) The billing and delivery address must be identical for invoice purchases (Paylater) - [0007546](https://bugs.oxid-esales.com/view.php?id=7546): We provide an additional Order Number to Unzer for identify the Order in OXID-Backend and Unzer-Insights - - Prepayment - Adjust payment date when the payment has been completed - change information for Unzer-Metadata +- Unzer Invoice (Paylater): Display bank details for invoice ## [1.1.2] - 2023-08-18 diff --git a/metadata.php b/metadata.php index 0f638231..dcee4d8e 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '1.1.3-rc.3', + 'version' => '1.1.3', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', From ce116addbcb5c2b69c6a72238e95ee9e9958cf3b Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Tue, 14 Nov 2023 16:20:41 +0100 Subject: [PATCH 081/115] Temporary disabling oxactive snippet --- metadata.php | 2 + src/Controller/OrderController.php | 1 + src/Model/DiscountList.php | 100 +++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 src/Model/DiscountList.php diff --git a/metadata.php b/metadata.php index 61336d6b..76ff5910 100644 --- a/metadata.php +++ b/metadata.php @@ -9,6 +9,7 @@ * Metadata version */ +use OxidSolutionCatalysts\Unzer\Model\DiscountList; use OxidSolutionCatalysts\Unzer\Controller\Admin\AdminOrderController; use OxidSolutionCatalysts\Unzer\Controller\Admin\ModuleConfiguration; use OxidSolutionCatalysts\Unzer\Controller\Admin\OrderMain; @@ -60,6 +61,7 @@ \OxidEsales\Eshop\Core\ViewConfig::class => ViewConfig::class, \OxidEsales\Eshop\Core\Config::class => Config::class, \OxidEsales\Eshop\Application\Model\Payment::class => Payment::class, + \OxidEsales\Eshop\Application\Model\DiscountList::class => DiscountList::class, \OxidEsales\Eshop\Application\Controller\OrderController::class => OrderController::class, \OxidEsales\Eshop\Application\Model\Order::class => Order::class, \OxidEsales\Eshop\Core\ShopControl::class => ShopControl::class, diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 1519b2e7..bb7a07b0 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -121,6 +121,7 @@ public function unzerExecuteAfterRedirect(): void if ('thankyou' === $nextStep) { // commit transaction and proceeding to next view $oDB->commitTransaction(); + Registry::getSession()->setVariable('orderDisableSqlActiveSnippet', false); throw new Redirect($unzerService->prepareRedirectUrl($nextStep)); } diff --git a/src/Model/DiscountList.php b/src/Model/DiscountList.php new file mode 100644 index 00000000..3609834a --- /dev/null +++ b/src/Model/DiscountList.php @@ -0,0 +1,100 @@ +forceReload(); + $aDiscList = $this->_getList($oUser)->getArray(); + foreach ($aDiscList as $oDiscount) { + if ($oDiscount->isForArticle($oArticle)) { + $aList[$oDiscount->getId()] = $oDiscount; + } + } + + return $aList; + } + + + /** + * Creates discount list filter SQL to load current state discount list + * + * @param \OxidEsales\Eshop\Application\Model\User $oUser user object + * + * @return string + * @deprecated underscore prefix violates PSR12, will be renamed to "getFilterSelect" in next major + */ + protected function _getFilterSelect($oUser) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore + { + $oBaseObject = $this->getBaseObject(); + $bDisableSqlActiveSnippet = Registry::getSession()->getVariable('disableSqlActiveSnippet'); + $sTable = $oBaseObject->getViewName(); + $sQ = "select " . $oBaseObject->getSelectFields() . " from $sTable "; + $sQ .= true === $bDisableSqlActiveSnippet ? "where 1=1 " : "where " . $oBaseObject->getSqlActiveSnippet() . ' '; + + + // defining initial filter parameters + $sUserId = null; + $sGroupIds = null; + $sCountryId = $this->getCountryId($oUser); + $oDb = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(); + + // checking for current session user which gives additional restrictions for user itself, users group and country + if ($oUser) { + // user ID + $sUserId = $oUser->getId(); + + // user group ids + foreach ($oUser->getUserGroups() as $oGroup) { + if ($sGroupIds) { + $sGroupIds .= ', '; + } + $sGroupIds .= $oDb->quote($oGroup->getId()); + } + } + + $sUserTable = getViewName('oxuser'); + $sGroupTable = getViewName('oxgroups'); + $sCountryTable = getViewName('oxcountry'); + + $sCountrySql = $sCountryId ? "EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxcountry' and oxobject2discount.OXOBJECTID=" . $oDb->quote($sCountryId) . ")" : '0'; + $sUserSql = $sUserId ? "EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxuser' and oxobject2discount.OXOBJECTID=" . $oDb->quote($sUserId) . ")" : '0'; + $sGroupSql = $sGroupIds ? "EXISTS(select oxobject2discount.oxid from oxobject2discount where oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxgroups' and oxobject2discount.OXOBJECTID in ($sGroupIds) )" : '0'; + + $sQ .= "and ( + if(EXISTS(select 1 from oxobject2discount, $sCountryTable where $sCountryTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxcountry' LIMIT 1), + $sCountrySql, + 1) && + if(EXISTS(select 1 from oxobject2discount, $sUserTable where $sUserTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxuser' LIMIT 1), + $sUserSql, + 1) && + if(EXISTS(select 1 from oxobject2discount, $sGroupTable where $sGroupTable.oxid=oxobject2discount.oxobjectid and oxobject2discount.OXDISCOUNTID=$sTable.OXID and oxobject2discount.oxtype='oxgroups' LIMIT 1), + $sGroupSql, + 1) + )"; + + $sQ .= " order by $sTable.oxsort "; + + return $sQ; + } +} From 8ce281a5d811e07a73a5bbe501fc33bc41c9f3c4 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Tue, 14 Nov 2023 17:15:25 +0100 Subject: [PATCH 082/115] Temporary disabling oxactive snippet update --- src/Controller/OrderController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 3c14a43c..33e337b1 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -117,11 +117,11 @@ public function unzerExecuteAfterRedirect(): void $nextStep = $this->_getNextStep($iSuccess); $unzerService = $this->getServiceFromContainer(Unzer::class); + Registry::getSession()->setVariable('orderDisableSqlActiveSnippet', false); if ('thankyou' === $nextStep) { // commit transaction and proceeding to next view $oDB->commitTransaction(); - Registry::getSession()->setVariable('orderDisableSqlActiveSnippet', false); throw new Redirect($unzerService->prepareRedirectUrl($nextStep)); } From 2f125efdcf3c973b6d9ead0db2aadc1354fcf67e Mon Sep 17 00:00:00 2001 From: dmitrii Date: Thu, 16 Nov 2023 12:18:44 +0100 Subject: [PATCH 083/115] UNZER-275 Actualize b-7.0.x branch --- CHANGELOG.md | 18 ++ metadata.php | 4 +- views/twig/admin/tpl/oscunzer_order.html.twig | 280 ++++++++++++------ .../themes/admin_twig/order_list.html.twig | 36 +++ .../frontend/tpl/order/unzer_card.html.twig | 57 ++-- .../tpl/order/unzer_eps_charge.html.twig | 3 +- .../tpl/order/unzer_installment.html.twig | 87 +++--- .../tpl/order/unzer_invoice.html.twig | 21 +- .../frontend/tpl/order/unzer_sepa.html.twig | 3 +- .../tpl/order/unzer_sepa_secured.html.twig | 5 +- 10 files changed, 339 insertions(+), 175 deletions(-) create mode 100644 views/twig/extensions/themes/admin_twig/order_list.html.twig diff --git a/CHANGELOG.md b/CHANGELOG.md index 9464c849..9f5ec547 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.0.3] - 2023-11-?? + +### FIXED +- [0007503](https://bugs.oxid-esales.com/view.php?id=7503) When ordering via the Unzer module, the OXID standard field OXORDER__OXTRANSID remains empty +- [0007526](https://bugs.oxid-esales.com/view.php?id=7526) Order would be saved only, if everything is correct. In all other cases redirect to checkout +- [0007509](https://bugs.oxid-esales.com/view.php?id=7509) Order would be saved only, if everything is correct. In all other cases redirect to checkout +- [0007524](https://bugs.oxid-esales.com/view.php?id=7524) catch Error if Unzer-API not working and redirect to Checkout +- [0007527](https://bugs.oxid-esales.com/view.php?id=7527) prevent clicking the buy-now-button several times +- [0007544](https://bugs.oxid-esales.com/view.php?id=7544) Add Error handling When unsupported Credit Card is used (e.g. Amex) +- [0007553](https://bugs.oxid-esales.com/view.php?id=7553) The billing and delivery address must be identical for invoice purchases (Paylater) +- [0007546](https://bugs.oxid-esales.com/view.php?id=7546): We provide an additional Order Number to Unzer for identify the Order in OXID-Backend and Unzer-Insights + +- apple pay session init only when eligible +- compatibility-issue against other modules that also extend the moduleconfiguration +- Adjust payment date when the payment has been completed +- Prepayment - Adjust payment date when the payment has been completed +- change information for Unzer-Metadata + ## [2.0.0] - 2023-07-XX ### NEW diff --git a/metadata.php b/metadata.php index 9285375d..b5023189 100644 --- a/metadata.php +++ b/metadata.php @@ -51,7 +51,7 @@ ', ], 'thumbnail' => 'logo.svg', - 'version' => '2.0.0', + 'version' => '2.0.3', 'author' => 'OXID eSales AG', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', @@ -63,8 +63,6 @@ \OxidEsales\Eshop\Application\Model\Article::class => Article::class, \OxidEsales\Eshop\Application\Model\Order::class => Order::class, \OxidEsales\Eshop\Application\Model\Payment::class => Payment::class, - \OxidEsales\Eshop\Application\Controller\OrderController::class => OrderController::class, - \OxidEsales\Eshop\Application\Model\Order::class => Order::class, \OxidEsales\Eshop\Core\ShopControl::class => ShopControl::class, \OxidEsales\Eshop\Core\ViewConfig::class => ViewConfig::class, ], diff --git a/views/twig/admin/tpl/oscunzer_order.html.twig b/views/twig/admin/tpl/oscunzer_order.html.twig index ef103c38..ecf3493e 100644 --- a/views/twig/admin/tpl/oscunzer_order.html.twig +++ b/views/twig/admin/tpl/oscunzer_order.html.twig @@ -1,15 +1,28 @@ {% include "headitem.html.twig" with {title: "GENERAL_ADMIN_TITLE"|translate} %} -{% if readonly %} - {% set readonly = "readonly disabled" %} -{% else %} - {% set readonly = "" %} +{% if paymentTitle and totalBasketPrice %} +

{{ paymentTitle }} : {{ totalBasketPrice }} / {{ translate({ ident: 'OSCUNZER_TRANSACTION_ORDERNR', suffix: 'COLON' }) }} {{ oOrder.oxorder__oxunzerordernr.value }}

+{% endif %} + +{# payment abilities #} +{% set canCollectFully = oView.canCollectFully() %} +{% set canCollectPartially = oView.canCollectPartially() %} +{% set canRefundFully = oView.canRefundFully() %} +{% set canRefundPartially = oView.canRefundPartially() %} +{% set canRevertPartially = oView.canRevertPartially() %} + +{% if isChargeBack %} + {% set canCollectFully = false %} + {% set canCollectPartially = false %} + {% set canRefundFully = false %} + {% set canRefundPartially = false %} + {% set canRevertPartially = false %} {% endif %}
{{ oViewConf.getHiddenSid()|raw }} - +
@@ -18,25 +31,29 @@ {% else %} + + + + + + + + + + {% for oUnzerTransaction in oUnzerTransactions %} + {% set transaction_state = oUnzerTransaction.getUnzerState()|escape %} - - - - - - + + + + + + + - {% for oUnzerTransaction in oUnzerTransactions %} - {% set transaction_state = oUnzerTransaction.getUnzerState()|escape %} - - - - - - - - - {% endfor %} + {% endfor %}
{{ translate({ ident: "OSCUNZER_TRANSACTION_CREATED" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_SHORTID" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_TRACEID" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_CUSTOMERID" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_STATUS" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_TYPEID" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_AMOUNT" }) }}
{{ translate({ ident: "OSCUNZER_TRANSACTION_CREATED" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_SHORTID" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_TRACEID" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_CUSTOMERID" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_STATUS" }) }}{{ translate({ ident: "OSCUNZER_TRANSACTION_TYPEID" }) }}{{ oUnzerTransaction.getUnzerCreated()|escape }}{{ oUnzerTransaction.getUnzerShortId()|escape }}{{ oUnzerTransaction.getUnzerTraceId()|escape }}{{ oUnzerTransaction.getUnzerCustomerId()|escape }}{{ 'OSCUNZER_TRANSACTION_STATUS_'|cat("transaction_state")|translate }}{{ oUnzerTransaction.getUnzerTypeId()|escape }}{{ oUnzerTransaction.getUnzerAmount()|number_format(2, '.', ' ') }} + {{ oUnzerTransaction.getUnzerCurrency() }} +
{{ oUnzerTransaction.getUnzerCreated()|escape }}{{ oUnzerTransaction.getUnzerShortId()|escape }}{{ oUnzerTransaction.getUnzerTraceId()|escape }}{{ oUnzerTransaction.getUnzerCustomerId()|escape }}{{ 'OSCUNZER_TRANSACTION_STATUS_'|cat("transaction_state")|translate }}{{ oUnzerTransaction.getUnzerTypeId()|escape }}
{% endif %} @@ -48,25 +65,25 @@ {% if aShipments %} + + + + + + + {% for oUnzerShipment in aShipments %} + {% if not oUnzerShipment.success %} + {% set unzStyle = 'class ="listitem3"' %} + {% else %} + {% set unzStyle = '' %} + {% endif %} - - - - + + + + - {% for oUnzerShipment in aShipments %} - {% if not oUnzerShipment.success %} - {% set unzStyle = 'class ="listitem3"' %} - {% else %} - {% set unzStyle = '' %} - {% endif %} - - - - - - - {% endfor %} + {% endfor %}
{{ translate({ ident: "GENERAL_DATE" }) }}{{ translate({ ident: "OSCUNZER_SHIP_ID" }) }}{{ translate({ ident: "OSCUNZER_ORDER_AMOUNT" }) }}{{ translate({ ident: "ORDER_MAIN_BILLNUM" }) }}
{{ translate({ ident: "GENERAL_DATE" }) }}{{ translate({ ident: "OSCUNZER_SHIP_ID" }) }}{{ translate({ ident: "OSCUNZER_ORDER_AMOUNT" }) }}{{ translate({ ident: "ORDER_MAIN_BILLNUM" }) }}{{ oUnzerShipment.shipingDate|escape }}{{ oUnzerShipment.shipId|escape }}{{ oUnzerShipment.amount|escape|number_format(2, '.', ' ') }}{{ oUnzerShipment.invoiceid|escape }}
{{ oUnzerShipment.shipingDate|escape }}{{ oUnzerShipment.shipId|escape }}{{ oUnzerShipment.amount|escape|number_format(2, '.', ' ') }}{{ oUnzerShipment.invoiceid|escape }}
{% endif %} @@ -108,8 +125,8 @@ {% endif %} - {% if AuthAmountRemaining == AuthAmount %} -
+ {% if AuthAmountRemaining > 0 %} + @@ -118,6 +135,13 @@ {{ translate({ ident: "OSCUNZER_AUTHORIZE_CANCEL_POSSIBLE" }) }} + {% if canRevertPartially %} + {{ AuthCur }} + {% else %} + + {% endif %} @@ -136,19 +160,18 @@

{{ translate({ ident: "OSCUNZER_CHARGES" }) }}

- - - - - - {% if blCancelReasonReq %} - - {% endif %} - - - - - {% for oUnzerCharge in aCharges %} + + + + + + {% if blCancelReasonReq %} + + {% endif %} + + + + {% for oUnzerCharge in aCharges %} {{ oViewConf.getHiddenSid()|raw }} @@ -162,63 +185,78 @@ - {% if oUnzerCharge.cancellationPossible %} + + {% if blCancelReasonReq %} - {% if blCancelReasonReq %} - - {% endif %} - - + - {% capture assign = "cancelConfirm" %} - const inAmount = document.getElementById('amount_{{ oUnzerCharge.chargeId }}'); - const form = document.getElementById('uzr_{{ oUnzerCharge.chargeId }}'); - form.addEventListener('submit', function (e) { - if (window.confirm('{{ translate({ ident: "OSCUNZER_CANCEL_ALERT" }) }}' + ' ' + inAmount.value)) { - return true; - } else { - return false; - } - }); - {% endcapture %} - {{ script({ add: cancelConfirm, dynamic: __oxid_include_dynamic }) }} - {% else %} - - {% endif %} + {% endif %} - {% endfor %} - {% if errCancel %} + {% endfor %} + {% if canCancelAmount > 0 %} + + {{ oViewConf.getHiddenSid() }} + + + + + - + + + + {% if canRefundFully %} + + + {% else %} + + + {% endif %} - {% endif %} + + {% endif %} + {% if errCancel %} + + + + {% endif %}
{{ translate({ ident: "GENERAL_DATE" }) }}{{ translate({ ident: "OSCUNZER_CHARGE_ID" }) }}{{ translate({ ident: "OSCUNZER_CHARGED_AMOUNT" }) }}{{ translate({ ident: "OSCUNZER_CHARGED_CANCELLED" }) }}{{ translate({ ident: "OSCUNZER_CHARGE_CANCELREASON" }) }}{{ translate({ ident: "OSCUNZER_CHARGE_CANCELAMOUNT" }) }}
{{ translate({ ident: "GENERAL_DATE" }) }}{{ translate({ ident: "OSCUNZER_CHARGE_ID" }) }}{{ translate({ ident: "OSCUNZER_CHARGED_AMOUNT" }) }}{{ translate({ ident: "OSCUNZER_CHARGED_CANCELLED" }) }}{{ translate({ ident: "OSCUNZER_CHARGE_CANCELREASON" }) }}{{ translate({ ident: "OSCUNZER_CHARGE_CANCELAMOUNT" }) }}
{{ oUnzerCharge.chargeDate|escape }} {{ oUnzerCharge.chargeId|escape }} {{ oUnzerCharge.chargedAmount|escape|number_format(2, '.', ' ') }} {{ uzrCurrency }}{{ oUnzerCharge.cancelledAmount|escape|number_format(2, '.', ' ') }} {{ uzrCurrency }} - {{ oUnzerCharge.cancelledAmount|escape|number_format(2, '.', ' ') }} {{ uzrCurrency }} + - - + {% endif %} + + {% if canRefundPartially %} - {{ uzrCurrency }} - + {% else %} + {{ oUnzerCharge.chargedAmount - oUnzerCharge.cancelledAmount | format("%.2f") }} + {% endif %} + {{ uzrCurrency }} + + {% if canRefundPartially %} -
{{ errCancel }}
+ {{ translate({ ident: "OSCUNZER_CHARGE_CANCEL_FROM_PAYMENT" }) }} + {{ totalAmountCharge|string_format(" % .2f") }} {{ uzrCurrency }}{{ totalAmountCancel|string_format(" % .2f") }} {{ uzrCurrency }} {{ uzrCurrency }}{{ canCancelAmount|string_format(" % .2f") }} {{ uzrCurrency }}
{{ errCancel }}
{% endif %} - {% endblock %} + {% if isChargeBack %} +
{{ translate({ ident: "OSCUNZER_CHARGEBACK" }) }}
+ {% endif %} + {% endblock %} {% block unzer_cancellation %} -

+

{% if aCancellations %}

{{ translate({ ident: "OSCUNZER_CANCELLATIONS" }) }}

@@ -244,6 +282,66 @@ {% endif %} {% endblock %} +{% capture assign = "cancelConfirm" %} + let handleUnzerForm = function(formElement) { + if(formElement.id.indexOf('uzr_') is same as(0) { // make absolutely sure to start with "uzr_") + let paymentId = formElement.id.slice(4); + let amountId = 'amount_' + paymentId; // f.e. "uzr_s-chg-1" + let inAmount = document.getElementById(amountId); + + if (null !== inAmount) { + return window.confirm('{{ translate({ ident: "OSCUNZER_CANCEL_ALERT" }) }}' + ' ' + inAmount.value + ' {{ uzrCurrency }}'); + } + return false; + } + // if it is not a form we want to process, let it proceed + return true; + }; + + document.addEventListener('DOMContentLoaded', function () { + let forms = document.querySelectorAll('form[id^="uzr_s-chg"]'); + for(var i = 0; i < forms.length; i++) { + forms[i].addEventListener('submit', function(event) { + let returnValue = handleUnzerForm(this); + if (!returnValue) { + event.preventDefault(); + } + return returnValue; + }); + } + }, false); +{% endcapture %} +{{ script({ add: cancelConfirm, dynamic: __oxid_include_dynamic }) }} + +{% capture assign = "cancelAuthConfirm" %} + let handleUnzerAuthForm = function(formElement) { + if(formElement.id.indexOf('uzr_authorize') is same as(0)) { + let paymentId = formElement.id.slice(4); + let amountId = 'amount_' + paymentId; + let inAmount = document.getElementById(amountId); + + if (null !== inAmount) { + return window.confirm('{{ translate({ ident: "OSCUNZER_AUTHORIZE_CANCEL_ALERT" }) }}' + ' ' + inAmount.value + ' {{ uzrCurrency }}'); + } + return false; + } + return true; + }; + + document.addEventListener('DOMContentLoaded', function () { + let forms = document.querySelectorAll('form[id^="uzr_authorize"]'); + for(var i = 0; i < forms.length; i++) { + forms[i].addEventListener('submit', function(event) { + let returnValue = handleUnzerAuthForm(this); + if (!returnValue) { + event.preventDefault(); + } + return returnValue; + }); + } + }, false); +{% endcapture %} +{{ script({ add: cancelAuthConfirm, dynamic: __oxid_include_dynamic }) }} {% include "bottomnaviitem.html.twig" %} diff --git a/views/twig/extensions/themes/admin_twig/order_list.html.twig b/views/twig/extensions/themes/admin_twig/order_list.html.twig new file mode 100644 index 00000000..3dee4fc1 --- /dev/null +++ b/views/twig/extensions/themes/admin_twig/order_list.html.twig @@ -0,0 +1,36 @@ +{% extends "order_list.html.twig" %} + +{% block admin_order_list_item %} + {% set isUnzerPayment = listitem.oxorder__oxpaymenttype.value|stripos("oscunzer") %} + {% if isUnzerPayment != false %} + {% if listitem.oxorder__oxstorno.value == 1 %} + {% set listclass = "listitem3" %} + {% else %} + {% if listitem.blacklist == 1 %} + {% set listclass = "listitem3" %} + {% else %} + {% set listclass = "listitem"|blWhite %} + {% endif %} + {% endif %} + {% if listitem.getId() == oxid %} + {% set listclass = "listitem4" %} + {% endif %} + + + + + + + {% else %} + {{ parent() }} + {% endif %} +{% endblock %} \ No newline at end of file diff --git a/views/twig/frontend/tpl/order/unzer_card.html.twig b/views/twig/frontend/tpl/order/unzer_card.html.twig index cf535c90..ac2c34da 100644 --- a/views/twig/frontend/tpl/order/unzer_card.html.twig +++ b/views/twig/frontend/tpl/order/unzer_card.html.twig @@ -29,46 +29,55 @@ event.preventDefault(); $( "#payment-form-card" ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); // Create an Unzer instance with your public key - let unzerInstance = new unzer('{{ unzerpub }}'); + let unzerInstance = new unzer('{{ unzerpub }}', {locale: "{{ unzerLocale }}"}); // Create a Card instance and render the input fields let Card = unzerInstance.Card(); Card.create('number', { - containerId: 'card-element-id-number', - onlyIframe: false + containerId: 'card-element-id-number', + onlyIframe: false }); Card.create('expiry', { - containerId: 'card-element-id-expiry', - onlyIframe: false + containerId: 'card-element-id-expiry', + onlyIframe: false }); Card.create('cvc', { - containerId: 'card-element-id-cvc', - onlyIframe: false + containerId: 'card-element-id-cvc', + onlyIframe: false }); $( "#payment-form-card" ).submit(function( event ) { - event.preventDefault(); - Card.createResource() - .then(function(result) { - let hiddenInput = $(document.createElement('input')) - .attr('type', 'hidden') - .attr('name', 'paymentData') - .val(JSON.stringify(result)); - $('#orderConfirmAgbBottom').find(".hidden").append(hiddenInput); - $( '#orderConfirmAgbBottom' ).addClass("submitable"); - $('#orderConfirmAgbBottom').submit(); - }) - .catch(function(error) { - $('html, body').animate({ - scrollTop: $("#orderPayment").offset().top - 150 - }, 350); - }) + event.preventDefault(); + Card.createResource() + .then(function(result) { + let hiddenInput = $(document.createElement('input')) + .attr('type', 'hidden') + .attr('name', 'paymentData') + .val(JSON.stringify(result)); + $('#orderConfirmAgbBottom').find(".hidden").append(hiddenInput); + $( '#orderConfirmAgbBottom' ).addClass("submitable"); + $('#orderConfirmAgbBottom').submit(); + }) + .catch(function(error) { + $('html, body').animate({ + scrollTop: $("#orderPayment").offset().top - 150 + }, 350); + + errorField = $("#card-element-id-number"); + errorField.find('div').first().addClass('error'); + errorEl = errorField.find('div.error.message'); + errorEl.css('display', 'inline-block'); + errorEl.text(error.message); + + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', false); + }) }); - {% endcapture %} +{% endcapture %} {% if false %} {% endif %} diff --git a/views/twig/frontend/tpl/order/unzer_eps_charge.html.twig b/views/twig/frontend/tpl/order/unzer_eps_charge.html.twig index b6e8fb75..27212ff5 100644 --- a/views/twig/frontend/tpl/order/unzer_eps_charge.html.twig +++ b/views/twig/frontend/tpl/order/unzer_eps_charge.html.twig @@ -12,10 +12,11 @@ event.preventDefault(); $( '#payment-form' ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); // Create an Unzer instance with your public key - let unzerInstance = new unzer('{{ unzerpub }}'); + let unzerInstance = new unzer('{{ unzerpub }}', {locale: "{{ unzerLocale }}"}); // Create an EPS instance and render the EPS form let EPS = unzerInstance.EPS(); diff --git a/views/twig/frontend/tpl/order/unzer_installment.html.twig b/views/twig/frontend/tpl/order/unzer_installment.html.twig index 803d88dc..74aff89d 100644 --- a/views/twig/frontend/tpl/order/unzer_installment.html.twig +++ b/views/twig/frontend/tpl/order/unzer_installment.html.twig @@ -69,52 +69,53 @@ {% capture assign = "unzerInstallmentJS" %} - // Create an Unzer instance with your public key - let unzerInstance = new unzer('{{ unzerpub }}'); + // Create an Unzer instance with your public key + let unzerInstance = new unzer('[{$unzerpub}]', {locale: "[{$unzerLocale}]"}); - let InstallmentSecured = unzerInstance.InstallmentSecured(); + let InstallmentSecured = unzerInstance.InstallmentSecured(); - function toggleDateVisbility() { - if ($('#installment-secured-account-owner').length < 1) $('#oxDateForInstallment').hide(); - $('#installment-secured-account-owner').each(function() { - if ($(this).is(':visible')){ - $('#oxDateForInstallment').show(); - } - }); - } - window.setInterval(toggleDateVisbility, 100); - - InstallmentSecured.create({ - containerId: 'unzer-installment', - amount: {{ totalgross }}, - currency: '{{ uzrcurrency }}', - effectiveInterest: {{ installrate }} - }); - - $( '#orderConfirmAgbBottom' ).submit(function( event ) { - if(!$( '#orderConfirmAgbBottom' ).hasClass("submitable")){ - event.preventDefault(); - $( '#payment-form-installment' ).submit(); + function toggleDateVisbility() { + if ($('#installment-secured-account-owner').length < 1) $('#oxDateForInstallment').hide(); + $('#installment-secured-account-owner').each(function() { + if ($(this).is(':visible')){ + $('#oxDateForInstallment').show(); } }); + } + window.setInterval(toggleDateVisbility, 100); + + InstallmentSecured.create({ + containerId: 'unzer-installment', + amount: [{$totalgross}], + currency: '[{$uzrcurrency}]', + effectiveInterest: [{$installrate}] + }); - // Handling payment form submission - $( "#payment-form-installment" ).submit(function( event ) { + $( '#orderConfirmAgbBottom' ).submit(function( event ) { + if(!$( '#orderConfirmAgbBottom' ).hasClass("submitable")){ event.preventDefault(); - if($('.unzerUI-installment-secured__selected-rate').length){ - InstallmentSecured.createResource() + $( '#payment-form-installment' ).submit(); + } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); + }); + + // Handling payment form submission + $( "#payment-form-installment" ).submit(function( event ) { + event.preventDefault(); + if($('.unzerUI-installment-secured__selected-rate').length){ + InstallmentSecured.createResource() .then(function(data) { let hiddenInput = $(document.createElement('input')) - .attr('type', 'hidden') - .attr('name', 'paymentData') - .val(JSON.stringify(data)); + .attr('type', 'hidden') + .attr('name', 'paymentData') + .val(JSON.stringify(data)); $('#orderConfirmAgbBottom').find(".hidden").append(hiddenInput); let hiddenInputBirthdate = $(document.createElement('input')) - .attr('type', 'hidden') - .attr('name', 'birthdate') - .val($('#birthdate_year').val()+'-'+$('#birthdate_month').val()+'-'+$('#birthdate_day').val()); + .attr('type', 'hidden') + .attr('name', 'birthdate') + .val($('#birthdate_year').val()+'-'+$('#birthdate_month').val()+'-'+$('#birthdate_day').val()); $('#orderConfirmAgbBottom').find(".hidden").append(hiddenInputBirthdate); $( '#orderConfirmAgbBottom' ).addClass("submitable"); @@ -123,14 +124,14 @@ .catch(function(error) { $('#error-holder').html(error.message); $('html, body').animate({ - scrollTop: $("#orderPayment").offset().top - 150 - }, 350); - }); - }else{ - $('html, body').animate({ - scrollTop: $("#orderPayment").offset().top - 150 + scrollTop: $("#orderPayment").offset().top - 150 }, 350); - } - }); + }); + }else{ + $('html, body').animate({ + scrollTop: $("#orderPayment").offset().top - 150 + }, 350); + } + }); {% endcapture %} -{{ script({ add: unzerInstallmentJS, dynamic: __oxid_include_dynamic }) }} +{{ script({ add: unzerInstallmentJS, dynamic: __oxid_include_dynamic }) }} \ No newline at end of file diff --git a/views/twig/frontend/tpl/order/unzer_invoice.html.twig b/views/twig/frontend/tpl/order/unzer_invoice.html.twig index 1a046e54..c1eed9c1 100644 --- a/views/twig/frontend/tpl/order/unzer_invoice.html.twig +++ b/views/twig/frontend/tpl/order/unzer_invoice.html.twig @@ -1,7 +1,9 @@ {% include "@osc-unzer/frontend/tpl/order/unzer_assets.html.twig" %} + {% set invadr = oView.getInvoiceAddress() %} -{% set deladr = oView.getDelAddress() %} {% set iBirthdayMonth = 0 %} {% set iBirthdayDay = 0 %} {% set iBirthdayYear = 0 %} @@ -9,25 +11,24 @@ {% set isBoth = false %} {% set isB2B = false %} {% set isB2C = false %} -{% set customerType = "" %} {% if isset( invadr.oxuser__oxbirthdate.month ) %} {% set iBirthdayMonth = invadr.oxuser__oxbirthdate.month %} {% elseif oxcmp_user.oxuser__oxbirthdate.value and oxcmp_user.oxuser__oxbirthdate.value != "0000-00-00" %} - {% set iBirthdayMonth = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/^([0-9]{4})[-]/", "")|regex_replace("/[-]([0-9]{1,2})$/", "") %} + {% set iBirthdayMonth = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/^([0-9]{4)})[-]/":""|regex_replace("/[-]([0-9]{1,) 2})$/":"" %} {% endif %} {% if isset( invadr.oxuser__oxbirthdate.day ) %} {% set iBirthdayDay = invadr.oxuser__oxbirthdate.day %} {% elseif oxcmp_user.oxuser__oxbirthdate.value and oxcmp_user.oxuser__oxbirthdate.value != "0000-00-00" %} - {% set iBirthdayDay = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/^([0-9]{4})[-]([0-9]{1,2})[-]/", "") %} + {% set iBirthdayDay = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/^([0-9]{4)})[-]([0-9]{1, 2})[-]/":"" %} {% endif %} {% if isset( invadr.oxuser__oxbirthdate.year ) %} {% set iBirthdayYear = invadr.oxuser__oxbirthdate.year %} {% elseif oxcmp_user.oxuser__oxbirthdate.value and oxcmp_user.oxuser__oxbirthdate.value != "0000-00-00" %} - {% set iBirthdayYear = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/[-]([0-9]{1,2})[-]([0-9]{1,2})$/", "") %} + {% set iBirthdayYear = oxcmp_user.oxuser__oxbirthdate.value|regex_replace("/[-]([0-9]{1,) 2})[-]([0-9]{1, 2})$/":"" %} {% endif %} -{% if (oxcmp_user.oxuser__oxcompany.value or (deladr and deladr.oxaddress__oxcompany.value)) %} +{% if (oxcmp_user.oxuser__oxcompany.value or (invadr and invadr.oxaddress__oxcompany.value)) %} {% set isCompany = true %} {% endif %} @@ -47,8 +48,8 @@ {% endif %} {% block unzer_inv_secured_birthdate %} - - {% if isBoth %} + + {% if false and isBoth %}
@@ -73,7 +73,7 @@ {% capture assign = "unzerSepaDirectSecurredJS" %} // Create an Unzer instance with your public key - let unzerInstance = new unzer('{{ unzerpub }}'); + let unzerInstance = new unzer('{{ unzerpub }}', {locale: "{{ unzerLocale }}"}); // Create a SEPA Direct Debit Secured instance and render the form let SepaDirectDebitSecured = unzerInstance.SepaDirectDebitSecured(); @@ -131,6 +131,7 @@ event.preventDefault(); $( "#payment-form-sepa-secured" ).submit(); } + $( '#orderConfirmAgbBottom .submitButton' ).prop('disabled', true); }); {% endcapture %} {{ script({ add: unzerSepaDirectSecurredJS, dynamic: __oxid_include_dynamic }) }} \ No newline at end of file From e317a24e5c80583e9eb5e75a5fd8712637a3c521 Mon Sep 17 00:00:00 2001 From: dmitrii Date: Thu, 16 Nov 2023 12:35:44 +0100 Subject: [PATCH 084/115] UNZER-275 update migration --- migration/data/Version20231107212500.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/migration/data/Version20231107212500.php b/migration/data/Version20231107212500.php index 510f95f6..cd199cf1 100644 --- a/migration/data/Version20231107212500.php +++ b/migration/data/Version20231107212500.php @@ -9,10 +9,12 @@ namespace OxidSolutionCatalysts\Unzer\Migrations; +use Doctrine\DBAL\Connection; use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Types\Types; use Doctrine\Migrations\AbstractMigration; +use Psr\Log\LoggerInterface; /** * Auto-generated Migration: Please modify to your needs! @@ -20,9 +22,9 @@ final class Version20231107212500 extends AbstractMigration { /** @throws Exception */ - public function __construct($version) + public function __construct(Connection $connection, LoggerInterface $logger) { - parent::__construct($version); + parent::__construct($connection, $logger); $this->platform->registerDoctrineTypeMapping('enum', 'string'); } From f4960d823766d43f209b271e3fc34b1e2ccf9ed7 Mon Sep 17 00:00:00 2001 From: dmitrii Date: Thu, 16 Nov 2023 12:39:40 +0100 Subject: [PATCH 085/115] UNZER-275 delete unused github action --- .github/workflows/default.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .github/workflows/default.yml diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml deleted file mode 100644 index e69de29b..00000000 From 6d2af54a0dfb5853c8eb140fa4b7b4656a868189 Mon Sep 17 00:00:00 2001 From: dmitrii Date: Thu, 16 Nov 2023 13:16:08 +0100 Subject: [PATCH 086/115] UNZER-275 fix codestyle --- src/Controller/OrderController.php | 6 ++--- src/Controller/PaymentController.php | 3 --- src/Model/Order.php | 36 ++++++++++------------------ 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/src/Controller/OrderController.php b/src/Controller/OrderController.php index 6154fb18..ef355a72 100644 --- a/src/Controller/OrderController.php +++ b/src/Controller/OrderController.php @@ -99,7 +99,7 @@ public function unzerExecuteAfterRedirect(): void { // get basket contents $oUser = $this->getUser(); - $oBasket = $this->getSession()->getBasket(); + $oBasket = Registry::getSession()->getBasket(); if ($oBasket->getProductsCount()) { $oDB = DatabaseProvider::getDb(); @@ -114,7 +114,7 @@ public function unzerExecuteAfterRedirect(): void // performing special actions after user finishes order (assignment to special user groups) $oUser->onOrderExecute($oBasket, $iSuccess); - $nextStep = $this->_getNextStep($iSuccess); + $nextStep = $this->getNextStep($iSuccess); $unzerService = $this->getServiceFromContainer(Unzer::class); @@ -263,7 +263,7 @@ public function executeoscunzer(): ?string return null; } - if (!$this->_validateTermsAndConditions()) { + if (!$this->validateTermsAndConditions()) { $this->_blConfirmAGBError = true; return null; } diff --git a/src/Controller/PaymentController.php b/src/Controller/PaymentController.php index e3506d7a..93d2d95d 100644 --- a/src/Controller/PaymentController.php +++ b/src/Controller/PaymentController.php @@ -10,12 +10,9 @@ use OxidEsales\Eshop\Application\Model\Order; use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions as CoreUnzerDefinitions; use OxidSolutionCatalysts\Unzer\Service\UserRepository; -use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions as CoreUnzerDefinitions; use OxidSolutionCatalysts\Unzer\Service\UnzerDefinitions; -use OxidSolutionCatalysts\Unzer\Service\ModuleSettings; use OxidSolutionCatalysts\Unzer\Traits\ServiceContainer; use OxidEsales\Eshop\Application\Model\Payment; -use OxidEsales\Eshop\Application\Controller\PaymentController as PaymentController_parent; use OxidEsales\Eshop\Core\Registry; class PaymentController extends PaymentController_parent diff --git a/src/Model/Order.php b/src/Model/Order.php index d593b1c3..81959c81 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -9,7 +9,6 @@ use Exception; use OxidEsales\Eshop\Application\Model\Basket; -use OxidEsales\Eshop\Application\Model\Order as Order_parent; use OxidEsales\Eshop\Application\Model\User; use OxidEsales\Eshop\Core\Field; use OxidEsales\Eshop\Core\Registry; @@ -57,21 +56,21 @@ public function finalizeUnzerOrderAfterRedirect( if ($unzerPaymentStatus !== "ERROR") { // copies user info - $this->_setUser($oUser); + $this->setUser($oUser); // copies basket info - $this->_loadFromBasket($oBasket); + $this->loadFromBasket($oBasket); - $oUserPayment = $this->_setPayment($oBasket->getPaymentId()); + $oUserPayment = $this->setPayment($oBasket->getPaymentId()); // set folder information, order is new - $this->_setFolder(); + $this->setFolder(); //saving all order data to DB $this->save(); if (!$this->getFieldData('oxordernr')) { - $this->_setNumber(); + $this->setNumber(); } // setUnzerOrderId @@ -82,27 +81,27 @@ public function finalizeUnzerOrderAfterRedirect( Registry::getSession()->deleteVariable('ordrem'); //#4005: Order creation time is not updated when order processing is complete - $this->_updateOrderDate(); + $this->updateOrderDate(); // store orderid $oBasket->setOrderId($orderId); // updating wish lists - $this->_updateWishlist($oBasket->getContents(), $oUser); + $this->updateWishlist($oBasket->getContents(), $oUser); // updating users notice list - $this->_updateNoticeList($oBasket->getContents(), $oUser); + $this->updateNoticeList($oBasket->getContents(), $oUser); // marking vouchers as used and sets them to $this->_aVoucherList (will be used in order email) - $this->_markVouchers($oBasket, $oUser); + $this->markVouchers($oBasket, $oUser); // send order by email to shop owner and current user // don't let order fail due to stock check while sending out the order mail Registry::getSession()->setVariable('blDontCheckProductStockForUnzerMails', true); - $iRet = $this->_sendOrderByEmail($oUser, $oBasket, $oUserPayment); + $iRet = $this->sendOrderByEmail($oUser, $oBasket, $oUserPayment); Registry::getSession()->deleteVariable('blDontCheckProductStockForUnzerMails'); - $this->_setOrderStatus($unzerPaymentStatus); + $this->setOrderStatus($unzerPaymentStatus); if ($unzerPaymentStatus === 'OK') { $this->markUnzerOrderAsPaid(); @@ -172,7 +171,7 @@ public function markUnzerOrderAsPaid(): void } // e.g. prepayments start with "NO_FINISHED", if they are marked as paid, // we set the status to OK here - $this->_setOrderStatus('OK'); + $this->setOrderStatus('OK'); } /** @@ -244,15 +243,4 @@ public function delete($sOxId = null) return parent::delete($sOxId); } - - /** - * @param string $fieldName - * @param string $value - * @param int $dataType - * @return false|void - */ - public function setFieldData($fieldName, $value, $dataType = Field::T_TEXT) - { - return parent::_setFieldData($fieldName, $value, $dataType); - } } From 3cc87ad4fab2c97c4db31d19dea2e54076dac4d3 Mon Sep 17 00:00:00 2001 From: dmitrii Date: Thu, 16 Nov 2023 15:14:24 +0100 Subject: [PATCH 087/115] UNZER-275 fix unit and integration tests --- tests/Integration/Controller/PaymentControllerTest.php | 0 tests/Integration/Core/ShopControlTest.php | 4 ++-- tests/Unit/PaymentExtensions/UnzerPaymentTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 tests/Integration/Controller/PaymentControllerTest.php diff --git a/tests/Integration/Controller/PaymentControllerTest.php b/tests/Integration/Controller/PaymentControllerTest.php deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/Integration/Core/ShopControlTest.php b/tests/Integration/Core/ShopControlTest.php index 7dbae159..595a2afb 100644 --- a/tests/Integration/Core/ShopControlTest.php +++ b/tests/Integration/Core/ShopControlTest.php @@ -11,13 +11,13 @@ use OxidEsales\Eshop\Core\Registry; use OxidEsales\Eshop\Core\Utils; use OxidEsales\Eshop\Core\UtilsView; -use OxidEsales\TestingLibrary\UnitTestCase; +use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase; use OxidSolutionCatalysts\Unzer\Core\ShopControl; use OxidSolutionCatalysts\Unzer\Exception\Redirect; use OxidSolutionCatalysts\Unzer\Exception\RedirectWithMessage; use OxidSolutionCatalysts\Unzer\Exception\UnzerException; -class ShopControlTest extends UnitTestCase +class ShopControlTest extends IntegrationTestCase { /** * @dataProvider customStandardExceptionTestDataProvider diff --git a/tests/Unit/PaymentExtensions/UnzerPaymentTest.php b/tests/Unit/PaymentExtensions/UnzerPaymentTest.php index 2374ce55..b9048fbd 100644 --- a/tests/Unit/PaymentExtensions/UnzerPaymentTest.php +++ b/tests/Unit/PaymentExtensions/UnzerPaymentTest.php @@ -42,7 +42,7 @@ public function testDefaultExecute(): void $unzerServiceMock->method('prepareOrderRedirectUrl')->willReturn('someRedirectUrl'); $unzerServiceMock->method('getUnzerCustomer')->with($userModel)->willReturn($customer = new Customer()); $unzerServiceMock->method('getShopMetadata')->willReturn($metadata = new Metadata()); - $unzerServiceMock->method('generateUnzerOrderId')->willReturn('unzerOrderId'); + $unzerServiceMock->method('generateUnzerOrderId')->willReturn(123456789); $unzerServiceMock->method('getUnzerBasket')->willReturn($unzerBasket); $chargeResult = $this->createPartialMock(Charge::class, []); @@ -66,7 +66,7 @@ public function testDefaultExecute(): void 'EUR', 'someRedirectUrl', $customer, - 'unzerOrderId', + 123456789, $metadata, $unzerBasket ) From a28faf2fd0de7cfbe7cda5328963bea928c2fe2b Mon Sep 17 00:00:00 2001 From: dmitrii Date: Fri, 17 Nov 2023 13:19:06 +0100 Subject: [PATCH 088/115] UNZER-275 fix integration tests --- tests/Integration/Core/ShopControlTest.php | 52 ++++++++++------------ 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/tests/Integration/Core/ShopControlTest.php b/tests/Integration/Core/ShopControlTest.php index 595a2afb..9b457dfa 100644 --- a/tests/Integration/Core/ShopControlTest.php +++ b/tests/Integration/Core/ShopControlTest.php @@ -24,17 +24,17 @@ class ShopControlTest extends IntegrationTestCase */ public function testHandleCustomException($expectedException): void { - /** @var \Throwable $exceptionMock */ - $exceptionMock = $this->createPartialMock($expectedException, ['debugOut']); - $exceptionMock->expects($this->once())->method('debugOut'); - /* _runOnce is the earliest method call in the ShopControl. - That is why the exception is simulated in this method. - !Important, this test only works with Config "iDebug" = 0, - since in the other cases with exceptions too much OXID is made, - which makes further mocking very time-consuming. - */ - $mock = $this->createPartialMock(ShopControl::class, ['_runOnce']); - $mock->method('_runOnce')->willThrowException($exceptionMock); + class_alias( + \OxidEsales\Eshop\Core\ShopControl::class, + 'OxidSolutionCatalysts\Unzer\Core\ShopControl_parent' + ); + $someException = new $expectedException(); + + $mock = $this->createPartialMock(ShopControl::class, ['isAdmin', 'logException']); + $mock->method('isAdmin')->willThrowException($someException); + + $this->addToAssertionCount(1); + $mock->expects($this->once())->method('logException')->with($someException); $mock->start(); } @@ -51,14 +51,12 @@ public function testHandleRedirectException(): void { $redirectDestination = 'someDestination'; - /* _runOnce is the earliest method call in the ShopControl. - That is why the exception is simulated in this method. - !Important, this test only works with Config "iDebug" = 0, - since in the other cases with exceptions too much OXID is made, - which makes further mocking very time-consuming. - */ - $mock = $this->createPartialMock(ShopControl::class, ['_runOnce']); - $mock->method('_runOnce')->willThrowException(new Redirect($redirectDestination)); + class_alias( + \OxidEsales\Eshop\Core\ShopControl::class, + 'OxidSolutionCatalysts\Unzer\Core\ShopControl_parent' + ); + $mock = $this->createPartialMock(ShopControl::class, ['isAdmin']); + $mock->method('isAdmin')->willThrowException(new Redirect($redirectDestination)); $utilsMock = $this->createPartialMock(Utils::class, ['redirect']); $utilsMock->expects($this->once()) @@ -74,14 +72,12 @@ public function testHandleMessageRedirectException(): void { $redirectDestination = 'someDestination'; - /* _runOnce is the earliest method call in the ShopControl. - That is why the exception is simulated in this method. - !Important, this test only works with Config "iDebug" = 0, - since in the other cases with exceptions too much OXID is made, - which makes further mocking very time-consuming. - */ - $mock = $this->createPartialMock(ShopControl::class, ['_runOnce']); - $mock->method('_runOnce')->willThrowException( + class_alias( + \OxidEsales\Eshop\Core\ShopControl::class, + 'OxidSolutionCatalysts\Unzer\Core\ShopControl_parent' + ); + $mock = $this->createPartialMock(ShopControl::class, ['isAdmin']); + $mock->method('isAdmin')->willThrowException( new RedirectWithMessage($redirectDestination, 'MESSAGE', ['param1']) ); @@ -99,4 +95,4 @@ public function testHandleMessageRedirectException(): void $mock->start(); } -} +} \ No newline at end of file From c43749e31275a31056f38a01ea82a9ac7c2ba188 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Mon, 20 Nov 2023 16:08:06 +0100 Subject: [PATCH 089/115] CR fixes --- src/Model/Order.php | 3 + .../themes/admin_twig/order_list.html.twig | 6 +- .../default/page/checkout/order.html.twig | 281 ++++++++++++++++-- .../frontend/tpl/order/unzer_card.html.twig | 16 +- 4 files changed, 267 insertions(+), 39 deletions(-) diff --git a/src/Model/Order.php b/src/Model/Order.php index 81959c81..4e5d1dd3 100644 --- a/src/Model/Order.php +++ b/src/Model/Order.php @@ -58,6 +58,9 @@ public function finalizeUnzerOrderAfterRedirect( // copies user info $this->setUser($oUser); + // copies user info + $this->assignUserInformation($oUser); + // copies basket info $this->loadFromBasket($oBasket); diff --git a/views/twig/extensions/themes/admin_twig/order_list.html.twig b/views/twig/extensions/themes/admin_twig/order_list.html.twig index 3dee4fc1..330e13f6 100644 --- a/views/twig/extensions/themes/admin_twig/order_list.html.twig +++ b/views/twig/extensions/themes/admin_twig/order_list.html.twig @@ -1,15 +1,15 @@ {% extends "order_list.html.twig" %} {% block admin_order_list_item %} - {% set isUnzerPayment = listitem.oxorder__oxpaymenttype.value|stripos("oscunzer") %} + {% set isUnzerPayment = "oscunzer" in listitem.oxorder__oxpaymenttype.value %} {% if isUnzerPayment != false %} {% if listitem.oxorder__oxstorno.value == 1 %} {% set listclass = "listitem3" %} {% else %} - {% if listitem.blacklist == 1 %} + {% if listitem['blacklist'] is defined and listitem.blacklist == 1 %} {% set listclass = "listitem3" %} {% else %} - {% set listclass = "listitem"|blWhite %} + {% set listclass = "listitem"~blWhite %} {% endif %} {% endif %} {% if listitem.getId() == oxid %} diff --git a/views/twig/extensions/themes/default/page/checkout/order.html.twig b/views/twig/extensions/themes/default/page/checkout/order.html.twig index b6361728..a30c07c6 100644 --- a/views/twig/extensions/themes/default/page/checkout/order.html.twig +++ b/views/twig/extensions/themes/default/page/checkout/order.html.twig @@ -1,29 +1,252 @@ -{% extends "page/checkout/order.html.twig" %} - -{% block shippingAndPayment %} - {% set payment = oView.getPayment() %} - {% if payment.isUnzerPayment() %} - {% include "@osc-unzer/frontend/tpl/order/unzer_shippingAndPayment.html.twig" %} - {% else %} - {{ parent() }} - {% endif %} - -{% endblock %} - -{% block checkout_order_errors %} - {{ parent() }} - {% set sepaError = oView.isSepaMandateConfirmationError() %} - {% if sepaError == 1 %} - {% include "message/error.html.twig" with {statusMessage: "ERROR_UNZER_SEPA_CONFIRMATION_MISSING"|translate} %} - {% endif %} - {% include "@osc-unzer/frontend/tpl/message/js-errors.html.twig" %}v -{% endblock %} - -{% block checkout_order_btn_submit_bottom %} - {% set payment = oView.getPayment() %} - {% if payment.getId() is same as('oscunzer_applepay') %} - {% include "@osc-unzer/frontend/tpl/order/applepay_button.html.twig" %} - {% else %} - {{ parent() }} - {% endif %} -{% endblock %} \ No newline at end of file +{% capture append = "oxidBlock_content" %} + + {% block checkout_order_errors %} + {% if oView.isConfirmAGBActive() and oView.isConfirmAGBError() == 1 %} + {% include "message/error.html.twig" with {statusMessage: "READ_AND_CONFIRM_TERMS"|translate} %} + {% endif %} + {% set iError = oView.getAddressError() %} + {% if iError == 1 %} + {% include "message/error.html.twig" with {statusMessage: "ERROR_DELIVERY_ADDRESS_WAS_CHANGED_DURING_CHECKOUT"|translate} %} + {% endif %} + + {% set sepaError = oView.isSepaMandateConfirmationError() %} + {% if sepaError == 1 %} + {% include "message/error.html.twig" with {statusMessage: "ERROR_UNZER_SEPA_CONFIRMATION_MISSING"|translate} %} + {% endif %} + {% include "@osc-unzer/frontend/tpl/message/js-errors.html.twig" %}v + {% endblock %} + +
+
+
+
+
+
+ {% block checkout_order_main %} + + {% block checkout_order_details %} + {% if not oxcmp_basket.getProductsCount() %} + {% block checkout_order_emptyshippingcart %} +
+
{{ translate({ ident: "BASKET_EMPTY" }) }}
+
+ {% endblock %} + {% else %} + {% set currency = oView.getActCurrency() %} + {% block checkout_order_address %} +
+ + {{ oViewConf.getHiddenSid()|raw }} + + +

+ {{ translate({ ident: "BILLING_ADDRESS" }) }} + +

+
+ {% include "widget/address/billing_address.html.twig" %} +
+ +
+ {{ oViewConf.getHiddenSid()|raw }} + + +

+ {{ translate({ ident: "SHIPPING_ADDRESS" }) }} + +

+
+ {% set oDelAdress = oView.getDelAddress() %} + {% if oDelAdress %} + {% include "widget/address/shipping_address.html.twig" with {delivadr: oDelAdress} %} + {% else %} + {% include "widget/address/billing_address.html.twig" %} + {% endif %} +
+ +
+ {% endblock %} + + {% block shippingAndPayment %} + {% set payment = oView.getPayment() %} + {% if payment.isUnzerPayment() %} + {% include "@osc-unzer/frontend/tpl/order/unzer_shippingAndPayment.html.twig" %} + {% else %} +
+ {{ oViewConf.getHiddenSid()|raw }} + + +

+ {{ translate({ ident: "SHIPPING_CARRIER" }) }} + +

+ {% set oShipSet = oView.getShipSet() %} +
+ {{ oShipSet.oxdeliveryset__oxtitle.value }} +
+ +
+ {{ oViewConf.getHiddenSid()|raw }} + + +

+ {{ translate({ ident: "PAYMENT_METHOD" }) }} + +

+
+ {% set payment = oView.getPayment() %} + {{ payment.oxpayments__oxdesc.value }} +
+ + {% endif %} + {% endblock %} + + {% block checkout_order_remark %} + {% if oView.getOrderRemark() %} +
+ {{ oViewConf.getHiddenSid()|raw }} + + +

+ {{ translate({ ident: "WHAT_I_WANTED_TO_SAY" }) }} + +

+
+ {{ oView.getOrderRemark()|nl2br }} +
+ + {% endif %} + {% endblock %} + +
+
+ {{ oViewConf.getHiddenSid()|raw }} + + +

+ {{ translate({ ident: "CART" }) }} + +

+ {% block order_basket %} +
+ {% include "page/checkout/inc/basketcontents.html.twig" with {editable: false} %} +
+ {% endblock %} + +
+ {% endif %} + + {% block checkout_order_next_step_bottom %} + {% if oView.isLowOrderPrice() %} + {% block checkout_order_loworderprice_bottom %} +
+
{{ translate({ ident: "MIN_ORDER_PRICE" }) }} {{ oView.getMinOrderPrice() }} {{ currency.sign }}
+
+ {% endblock %} + {% else %} + {% block checkout_order_btn_confirm_bottom %} +
+ {{ oViewConf.getHiddenSid()|raw }} + {{ oViewConf.getNavFormParams()|raw }} + + + + + + {% if oView.isActive('PsLogin') or not oView.isConfirmAGBActive() %} + + {% else %} + + {% endif %} + + + + {% block checkout_order_btn_submit_bottom %} + {% set payment = oView.getPayment() %} + {% if payment.getId() is same as('oscunzer_applepay') %} + {% include "@osc-unzer/frontend/tpl/order/applepay_button.html.twig" %} + {% else %} + + {% endif %} + {% endblock %} + + {% endblock %} + {% endif %} + {% endblock %} + {% endblock %} + {% endblock %} +
+
+
+
+ {% include "page/checkout/inc/summary_sidebar.html.twig" %} + + {% if not oView.isLowOrderPrice() %} +
+
+ {{ oViewConf.getHiddenSid()|raw }} + {{ oViewConf.getNavFormParams()|raw }} + + + + + + {% include "page/checkout/inc/agb.html.twig" %} + +
+ {% endif %} + + +
+
+
+
+
+
+ {{ insert_tracker({title: template_title}) }} +{% endcapture %} + +{% set template_title = "REVIEW_YOUR_ORDER"|translate %} +{% include "layout/page.html.twig" with {title: template_title, location: template_title, active_step: 3} %} diff --git a/views/twig/frontend/tpl/order/unzer_card.html.twig b/views/twig/frontend/tpl/order/unzer_card.html.twig index ac2c34da..c4f50249 100644 --- a/views/twig/frontend/tpl/order/unzer_card.html.twig +++ b/views/twig/frontend/tpl/order/unzer_card.html.twig @@ -24,13 +24,17 @@
+ + + {% if not readonly %} + + + {% endif %} +