From 9d5f6388f5d6df0b7c5e3d172c70121c4a101a08 Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Thu, 12 Sep 2024 08:47:12 +0200 Subject: [PATCH 01/12] [ECP-9458] Update the handlers for the tasks (#546) Co-authored-by: Can Demiralp --- src/ScheduledTask/ProcessNotificationsHandler.php | 2 ++ src/ScheduledTask/ScheduleNotificationsHandler.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/ScheduledTask/ProcessNotificationsHandler.php b/src/ScheduledTask/ProcessNotificationsHandler.php index 30df31bd..51cc374a 100644 --- a/src/ScheduledTask/ProcessNotificationsHandler.php +++ b/src/ScheduledTask/ProcessNotificationsHandler.php @@ -46,7 +46,9 @@ use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; +use Symfony\Component\Messenger\Attribute\AsMessageHandler; +#[AsMessageHandler(handles: ProcessNotifications::class)] class ProcessNotificationsHandler extends ScheduledTaskHandler { use LoggerAwareTrait; diff --git a/src/ScheduledTask/ScheduleNotificationsHandler.php b/src/ScheduledTask/ScheduleNotificationsHandler.php index 253a1527..98842958 100644 --- a/src/ScheduledTask/ScheduleNotificationsHandler.php +++ b/src/ScheduledTask/ScheduleNotificationsHandler.php @@ -28,7 +28,9 @@ use Psr\Log\LoggerAwareTrait; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; +use Symfony\Component\Messenger\Attribute\AsMessageHandler; +#[AsMessageHandler(handles: ScheduleNotifications::class)] class ScheduleNotificationsHandler extends ScheduledTaskHandler { use LoggerAwareTrait; From 072fa0f6c3e254aedf83155a6afcfb2a77bb2396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Campos?= Date: Thu, 12 Sep 2024 11:46:23 +0200 Subject: [PATCH 02/12] Create codeql.yml (#534) Co-authored-by: Can Demiralp --- .github/workflows/codeql.yml | 95 ++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..63ca9d6c --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,95 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "develop", "develop*", "main*" ] + pull_request: + branches: [ "develop", "develop*", "main*" ] + paths-ignore: + - 'src/Resources/public/js/**' + schedule: + - cron: '16 17 * * 2' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: javascript-typescript + build-mode: none + # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" From 35c9bb2cb5b93eac9b0c99726f384d850d160c74 Mon Sep 17 00:00:00 2001 From: Khushboo Date: Tue, 17 Sep 2024 14:08:01 +0200 Subject: [PATCH 03/12] Making changes to release asset yml, passing php version (#549) --- .github/workflows/upload-release-asset.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/upload-release-asset.yml b/.github/workflows/upload-release-asset.yml index 22c45144..b2111bd8 100644 --- a/.github/workflows/upload-release-asset.yml +++ b/.github/workflows/upload-release-asset.yml @@ -12,6 +12,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2+' + - name: Prepare release artifact run: .github/workflows/scripts/prepare-release-asset.sh From 0205dc25b053836e327f015c04a97d932b5d3800 Mon Sep 17 00:00:00 2001 From: Goran Stamenkovski Date: Tue, 24 Sep 2024 13:04:00 +0200 Subject: [PATCH 04/12] Add explicit association for deliveries.stateMachineState in webhooks processor ISSUE: CS-5938 --- src/Service/CaptureService.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Service/CaptureService.php b/src/Service/CaptureService.php index 91b979e0..1b704d5d 100644 --- a/src/Service/CaptureService.php +++ b/src/Service/CaptureService.php @@ -88,7 +88,10 @@ public function doOpenInvoiceCapture(string $orderNumber, $captureAmount, Contex $order = $this->orderRepository->getOrderByOrderNumber( $orderNumber, $context, - ['transactions', 'currency', 'lineItems', 'deliveries', 'deliveries.shippingMethod'] + [ + 'transactions', 'currency', 'lineItems', 'deliveries', + 'deliveries.shippingMethod', 'deliveries.stateMachineState' + ] ); if (is_null($order)) { From c558c5e501934a06ee071c7d02536e0707304b40 Mon Sep 17 00:00:00 2001 From: Tamara Date: Wed, 25 Sep 2024 18:25:11 +0200 Subject: [PATCH 05/12] Remove unnecessary foreign key CS-5927 --- .../Migration1626331358AdyenRefund.php | 4 +-- ...Migration1646742586AdyenPaymentCapture.php | 4 +-- .../Migration1669129247AdyenPayment.php | 4 +-- .../Migration1727273181AlterAdyenRefund.php | 26 +++++++++++++++++++ ...tion1727273183AlterAdyenPaymentCapture.php | 26 +++++++++++++++++++ .../Migration1727273187AlterAdyenPayment.php | 26 +++++++++++++++++++ 6 files changed, 81 insertions(+), 9 deletions(-) create mode 100755 src/Migration/Migration1727273181AlterAdyenRefund.php create mode 100755 src/Migration/Migration1727273183AlterAdyenPaymentCapture.php create mode 100755 src/Migration/Migration1727273187AlterAdyenPayment.php diff --git a/src/Migration/Migration1626331358AdyenRefund.php b/src/Migration/Migration1626331358AdyenRefund.php index df7337bc..211a6954 100644 --- a/src/Migration/Migration1626331358AdyenRefund.php +++ b/src/Migration/Migration1626331358AdyenRefund.php @@ -24,9 +24,7 @@ public function update(Connection $connection): void `created_at` DATETIME(3) NOT NULL, `updated_at` DATETIME(3) NULL, `amount` INT(11) NOT NULL, - PRIMARY KEY (`id`), - CONSTRAINT `fk.adyen_refund.order_transaction_id` - FOREIGN KEY (order_transaction_id) references `order_transaction` (id) + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; SQL ); diff --git a/src/Migration/Migration1646742586AdyenPaymentCapture.php b/src/Migration/Migration1646742586AdyenPaymentCapture.php index 89a1cf0a..4e90bf0a 100644 --- a/src/Migration/Migration1646742586AdyenPaymentCapture.php +++ b/src/Migration/Migration1646742586AdyenPaymentCapture.php @@ -24,9 +24,7 @@ public function update(Connection $connection): void `created_at` DATETIME(3) NOT NULL, `updated_at` DATETIME(3) NULL, `amount` INT(11) NOT NULL, - PRIMARY KEY (`id`), - CONSTRAINT `fk.adyen_payment_capture.order_transaction_id` - FOREIGN KEY (order_transaction_id) references `order_transaction` (id) + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; SQL ); diff --git a/src/Migration/Migration1669129247AdyenPayment.php b/src/Migration/Migration1669129247AdyenPayment.php index 785d48f3..0bf026d5 100644 --- a/src/Migration/Migration1669129247AdyenPayment.php +++ b/src/Migration/Migration1669129247AdyenPayment.php @@ -31,9 +31,7 @@ public function update(Connection $connection): void `updated_at` DATETIME(3) DEFAULT NULL COMMENT 'Updated at', PRIMARY KEY (`id`), KEY `ADYEN_PAYMENT_MERCHANT_REFERENCE` (`merchant_reference`), - KEY `ADYEN_PAYMENT_MERCHANT_ORDER_REFERENCE` (`merchant_order_reference`), - CONSTRAINT `fk.adyen_payment.order_transaction_id` - FOREIGN KEY (order_transaction_id) references `order_transaction` (id) + KEY `ADYEN_PAYMENT_MERCHANT_ORDER_REFERENCE` (`merchant_order_reference`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; SQL; diff --git a/src/Migration/Migration1727273181AlterAdyenRefund.php b/src/Migration/Migration1727273181AlterAdyenRefund.php new file mode 100755 index 00000000..1c55593f --- /dev/null +++ b/src/Migration/Migration1727273181AlterAdyenRefund.php @@ -0,0 +1,26 @@ +executeStatement(<<executeStatement(<<executeStatement(<< Date: Thu, 26 Sep 2024 12:28:00 +0200 Subject: [PATCH 06/12] Add check if domain url exists CS-5931 --- src/Handlers/AbstractPaymentMethodHandler.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index d5f78b5c..316047de 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -613,12 +613,13 @@ protected function preparePaymentsRequest( !is_null($orderLine->getProductId()) ? $this->getProduct($orderLine->getProductId(), $salesChannelContext->getContext()) : null; + $domainUrl = $salesChannelContext->getSalesChannel()->getDomains()->first()->getUrl(); // Add url for only real product and not for the custom cart items. - if (!is_null($product->getId())) { + if (!is_null($product->getId()) && !is_null($domainUrl)) { $productUrl = sprintf( "%s/detail/%s", - $salesChannelContext->getSalesChannel()->getDomains()->first()->getUrl(), + $domainUrl, $product->getId() ); } else { @@ -640,7 +641,7 @@ protected function preparePaymentsRequest( $currency = $salesChannelContext->getCurrency(); //Building open invoice line - + $lineItem = new LineItem(); $lineItem->setDescription($productName); @@ -836,7 +837,7 @@ private function getSplitStreetAddressHouseNumber(string $address): array */ public function handleAdyenOrderPayment( AsyncPaymentTransactionStruct $transaction, - $adyenOrderResponse, + $adyenOrderResponse, SalesChannelContext $salesChannelContext ): void { if (empty($adyenOrderResponse)) { From 3c0d44fbc93515a5b7478d0d1e252f5c2db0c0f1 Mon Sep 17 00:00:00 2001 From: Marija Date: Fri, 27 Sep 2024 16:02:46 +0200 Subject: [PATCH 07/12] Add check if domain url exists CS-5931 --- src/Handlers/AbstractPaymentMethodHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 316047de..1d3d5f8d 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -613,7 +613,7 @@ protected function preparePaymentsRequest( !is_null($orderLine->getProductId()) ? $this->getProduct($orderLine->getProductId(), $salesChannelContext->getContext()) : null; - $domainUrl = $salesChannelContext->getSalesChannel()->getDomains()->first()->getUrl(); + $domainUrl = $salesChannelContext->getSalesChannel()->getDomains()?->first()?->getUrl(); // Add url for only real product and not for the custom cart items. if (!is_null($product->getId()) && !is_null($domainUrl)) { From 97ab214a22233b30d51f7399a1b9955568a417dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Campos?= Date: Mon, 30 Sep 2024 09:04:06 +0200 Subject: [PATCH 08/12] Update CODEOWNERS (#554) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4d4d1c6d..33a67474 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @Adyen/plugin-developers +* @brankologeecom @MarijaIv @tamaralogeecom @AleksandarBoljanovic @goran-stamenkovski-logeecom @teodoratimoti @DamjanLogeecom From 78998c94f827dcbd08cff459c81063a1deed1ced Mon Sep 17 00:00:00 2001 From: Marija Date: Mon, 30 Sep 2024 10:54:19 +0200 Subject: [PATCH 09/12] Fix PHP code sniffer issue --- src/Handlers/AbstractPaymentMethodHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 1d3d5f8d..ce295919 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -837,7 +837,7 @@ private function getSplitStreetAddressHouseNumber(string $address): array */ public function handleAdyenOrderPayment( AsyncPaymentTransactionStruct $transaction, - $adyenOrderResponse, + $adyenOrderResponse, SalesChannelContext $salesChannelContext ): void { if (empty($adyenOrderResponse)) { From 2e50b64c287e06d021fe9684d90c95920fe75068 Mon Sep 17 00:00:00 2001 From: Marija Date: Mon, 30 Sep 2024 11:23:02 +0200 Subject: [PATCH 10/12] Fix SonarCloud issue --- src/Migration/Migration1727273181AlterAdyenRefund.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Migration/Migration1727273181AlterAdyenRefund.php b/src/Migration/Migration1727273181AlterAdyenRefund.php index 1c55593f..c7a4d6c2 100755 --- a/src/Migration/Migration1727273181AlterAdyenRefund.php +++ b/src/Migration/Migration1727273181AlterAdyenRefund.php @@ -21,6 +21,7 @@ public function update(Connection $connection): void SQL ); } catch (Exception) { + // Intentionally left empty, if foreign key is missing, the migration should be skipped. } } } From 2e28e75be78349930177eeb455852e821123dbe1 Mon Sep 17 00:00:00 2001 From: Marija Date: Mon, 30 Sep 2024 11:24:19 +0200 Subject: [PATCH 11/12] Fix SonarCloud issues --- src/Migration/Migration1727273183AlterAdyenPaymentCapture.php | 1 + src/Migration/Migration1727273187AlterAdyenPayment.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Migration/Migration1727273183AlterAdyenPaymentCapture.php b/src/Migration/Migration1727273183AlterAdyenPaymentCapture.php index 730c7e5d..ecbe5033 100755 --- a/src/Migration/Migration1727273183AlterAdyenPaymentCapture.php +++ b/src/Migration/Migration1727273183AlterAdyenPaymentCapture.php @@ -21,6 +21,7 @@ public function update(Connection $connection): void SQL ); } catch (Exception) { + // Intentionally left empty, if foreign key is missing, the migration should be skipped. } } } diff --git a/src/Migration/Migration1727273187AlterAdyenPayment.php b/src/Migration/Migration1727273187AlterAdyenPayment.php index 6cfce34c..59a4bd41 100755 --- a/src/Migration/Migration1727273187AlterAdyenPayment.php +++ b/src/Migration/Migration1727273187AlterAdyenPayment.php @@ -21,6 +21,7 @@ public function update(Connection $connection): void SQL ); } catch (Exception) { + // Intentionally left empty, if foreign key is missing, the migration should be skipped. } } } From 7ae47328142112a4d8ca9649d6ecd4e80e0dcc11 Mon Sep 17 00:00:00 2001 From: Goran Stamenkovski Date: Mon, 30 Sep 2024 13:23:47 +0200 Subject: [PATCH 12/12] Version bump ISSUE: CS-5938 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b0a45663..64df2db8 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ } ], "description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen", - "version": "4.1.1", + "version": "4.1.2", "type": "shopware-platform-plugin", "license": "MIT", "require": {