diff --git a/Controller/Comeback/Index.php b/Controller/Comeback/Index.php index 4f2c502..c3c172c 100644 --- a/Controller/Comeback/Index.php +++ b/Controller/Comeback/Index.php @@ -105,7 +105,7 @@ public function execute() $metadata = $this->cookieMetadataFactory ->createPublicCookieMetadata() ->setPath('/'); - $sectiondata = json_decode($this->cookieManager->getCookie('section_data_ids')); + $sectiondata = json_decode($this->cookieManager->getCookie('section_data_ids') ?: ''); if($sectiondata){ $sectiondata->cart += 1000; $this->cookieManager->setPublicCookie( diff --git a/Model/Api/Builders/CreateOrderRequestBuilder.php b/Model/Api/Builders/CreateOrderRequestBuilder.php index 2071a9c..13bfab1 100644 --- a/Model/Api/Builders/CreateOrderRequestBuilder.php +++ b/Model/Api/Builders/CreateOrderRequestBuilder.php @@ -111,7 +111,11 @@ public function __construct( public function build(): CreateOrderRequest { - $this->quote = $this->quoteRepository->getActive($this->cartId); + try { + $this->quote = $this->quoteRepository->getActive($this->cartId); + } catch (\Exception $e) { + $this->quote = $this->quoteRepository->get($this->cartId); + } return $this->generateCreateOrderRequest(); } diff --git a/Services/BusinessLogic/OrderService.php b/Services/BusinessLogic/OrderService.php index 50265be..e1a9a40 100644 --- a/Services/BusinessLogic/OrderService.php +++ b/Services/BusinessLogic/OrderService.php @@ -5,7 +5,9 @@ use DateTime; use Exception; use Magento\Framework\Api\SearchCriteriaBuilder; +use Magento\Framework\Exception\NoSuchEntityException; use Magento\Quote\Api\CartManagementInterface; +use Magento\Quote\Api\CartRepositoryInterface; use Magento\Sales\Api\OrderManagementInterface; use Magento\Sales\Api\OrderRepositoryInterface; use SeQura\Core\BusinessLogic\Domain\Order\Exceptions\InvalidOrderStateException; @@ -22,6 +24,7 @@ use SeQura\Core\Infrastructure\Http\Exceptions\HttpRequestException; use SeQura\Core\Infrastructure\ServiceRegister; use SeQura\Core\BusinessLogic\Domain\Order\Service\OrderService as SeQuraOrderService; +use Sequra\Core\Model\Api\Builders\CreateOrderRequestBuilderFactory; use Sequra\Core\Services\BusinessLogic\Utility\SeQuraTranslationProvider; /** @@ -64,6 +67,14 @@ class OrderService implements ShopOrderService * @var SeQuraOrderService */ private $sequraOrderService; + /** + * @var CartRepositoryInterface + */ + private $cartRepository; + /** + * @var CreateOrderRequestBuilderFactory + */ + private $createOrderRequestBuilderFactory; public function __construct( SearchCriteriaBuilder $searchOrderCriteriaBuilder, @@ -71,7 +82,9 @@ public function __construct( OrderManagementInterface $orderManagement, CartManagementInterface $cartManagement, SeQuraOrderRepositoryInterface $seQuraOrderRepository, - SeQuraTranslationProvider $translationProvider + SeQuraTranslationProvider $translationProvider, + CartRepositoryInterface $cartProvider, + CreateOrderRequestBuilderFactory $createOrderRequestBuilderFactory ) { $this->searchOrderCriteriaBuilder = $searchOrderCriteriaBuilder; @@ -80,6 +93,8 @@ public function __construct( $this->cartManagement = $cartManagement; $this->seQuraOrderRepository = $seQuraOrderRepository; $this->translationProvider = $translationProvider; + $this->cartRepository = $cartProvider; + $this->createOrderRequestBuilderFactory = $createOrderRequestBuilderFactory; } /** @@ -141,6 +156,24 @@ public function getOrderUrl(string $merchantReference): string return ''; } + /** + * @inheritDoc + * + * @throws NoSuchEntityException + */ + public function getCreateOrderRequest(string $orderReference): CreateOrderRequest + { + $seQuraOrder = $this->seQuraOrderRepository->getByOrderReference($orderReference); + $quote = $this->cartRepository->get($seQuraOrder->getCartId()); + + $builder = $this->createOrderRequestBuilderFactory->create([ + 'cartId' => $quote->getId(), + 'storeId' => (string)$quote->getStore()->getId(), + ]); + + return $builder->build(); + } + /** * Updates the Magento order and SeQuraOrder statuses. * diff --git a/composer.json b/composer.json index f287105..cd31bf9 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "minimum-stability": "stable", "require": { "php": ">=7.4", - "sequra/integration-core": "v1.0.13", + "sequra/integration-core": "dev-fix/CS-5639", "ext-json": "*" }, "repositories": [ diff --git a/composer.lock b/composer.lock index deeb939..b531ee4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "02abb91b23c5de31dbfaeecaddf6aeb7", + "content-hash": "23c8deb7cb9aaedaf0f38b54cac94a93", "packages": [ { "name": "sequra/integration-core", - "version": "v1.0.13", + "version": "dev-fix/CS-5639", "source": { "type": "git", "url": "git@github.com:sequra/integration-core.git", - "reference": "7c9fd26e796f87f9ec0d8a187f6ec3e8236703bd" + "reference": "26983fb34bcbf463d5ee47ac723e372a2f3b586d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sequra/integration-core/zipball/7c9fd26e796f87f9ec0d8a187f6ec3e8236703bd", - "reference": "7c9fd26e796f87f9ec0d8a187f6ec3e8236703bd", + "url": "https://api.github.com/repos/sequra/integration-core/zipball/26983fb34bcbf463d5ee47ac723e372a2f3b586d", + "reference": "26983fb34bcbf463d5ee47ac723e372a2f3b586d", "shasum": "" }, "require": { @@ -27,6 +27,8 @@ "php": ">=7.2" }, "require-dev": { + "phpcompatibility/php-compatibility": "*", + "phpstan/phpstan": "^1.11", "phpunit/phpunit": "8.5.14" }, "type": "library", @@ -47,7 +49,7 @@ "proprietary" ], "description": "Core SeQura integration library", - "time": "2024-04-25T08:36:24+00:00" + "time": "2024-07-12T08:59:49+00:00" } ], "packages-dev": [ @@ -250,22 +252,22 @@ }, { "name": "phpcsstandards/phpcsutils", - "version": "1.0.10", + "version": "1.0.12", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544" + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/51609a5b89f928e0c463d6df80eb38eff1eaf544", - "reference": "51609a5b89f928e0c463d6df80eb38eff1eaf544", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.9.0 || 4.0.x-dev@dev" + "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" }, "require-dev": { "ext-filter": "*", @@ -334,20 +336,20 @@ "type": "open_collective" } ], - "time": "2024-03-17T23:44:50+00:00" + "time": "2024-05-20T13:34:27+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.66", + "version": "1.11.7", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd" + "reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/94779c987e4ebd620025d9e5fdd23323903950bd", - "reference": "94779c987e4ebd620025d9e5fdd23323903950bd", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/52d2bbfdcae7f895915629e4694e9497d0f8e28d", + "reference": "52d2bbfdcae7f895915629e4694e9497d0f8e28d", "shasum": "" }, "require": { @@ -390,13 +392,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2024-03-28T16:17:31+00:00" + "time": "2024-07-06T11:17:41+00:00" }, { "name": "rector/rector", @@ -456,16 +454,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.1", + "version": "3.10.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909" + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/267a4405fff1d9c847134db3a3c92f1ab7f77909", - "reference": "267a4405fff1d9c847134db3a3c92f1ab7f77909", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/8f90f7a53ce271935282967f53d0894f8f1ff877", + "reference": "8f90f7a53ce271935282967f53d0894f8f1ff877", "shasum": "" }, "require": { @@ -532,20 +530,20 @@ "type": "open_collective" } ], - "time": "2024-03-31T21:03:09+00:00" + "time": "2024-05-22T21:24:41+00:00" }, { "name": "webonyx/graphql-php", - "version": "v15.11.1", + "version": "v15.12.5", "source": { "type": "git", "url": "https://github.com/webonyx/graphql-php.git", - "reference": "ab4ff2719b101dc3bfc3aaaf800edc21a98c56dc" + "reference": "7bcd31d1dcf67781ed5cb493b22c519c539c05e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/ab4ff2719b101dc3bfc3aaaf800edc21a98c56dc", - "reference": "ab4ff2719b101dc3bfc3aaaf800edc21a98c56dc", + "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/7bcd31d1dcf67781ed5cb493b22c519c539c05e6", + "reference": "7bcd31d1dcf67781ed5cb493b22c519c539c05e6", "shasum": "" }, "require": { @@ -558,15 +556,15 @@ "amphp/http-server": "^2.1", "dms/phpunit-arraysubset-asserts": "dev-master", "ergebnis/composer-normalize": "^2.28", - "friendsofphp/php-cs-fixer": "3.51.0", + "friendsofphp/php-cs-fixer": "3.59.3", "mll-lab/php-cs-fixer-config": "^5", "nyholm/psr7": "^1.5", "phpbench/phpbench": "^1.2", "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "1.10.59", - "phpstan/phpstan-phpunit": "1.3.16", - "phpstan/phpstan-strict-rules": "1.5.2", - "phpunit/phpunit": "^9.5 || ^10", + "phpstan/phpstan": "1.11.5", + "phpstan/phpstan-phpunit": "1.4.0", + "phpstan/phpstan-strict-rules": "1.6.0", + "phpunit/phpunit": "^9.5 || ^10.5.21", "psr/http-message": "^1 || ^2", "react/http": "^1.6", "react/promise": "^2.0 || ^3.0", @@ -598,7 +596,7 @@ ], "support": { "issues": "https://github.com/webonyx/graphql-php/issues", - "source": "https://github.com/webonyx/graphql-php/tree/v15.11.1" + "source": "https://github.com/webonyx/graphql-php/tree/v15.12.5" }, "funding": [ { @@ -606,7 +604,7 @@ "type": "open_collective" } ], - "time": "2024-03-11T10:21:05+00:00" + "time": "2024-06-23T11:30:58+00:00" } ], "aliases": [],