From da50719e8d61f20c416ed856d26a66a97f0a0d68 Mon Sep 17 00:00:00 2001 From: Cenk Kucukiravul Date: Fri, 19 Jan 2024 15:21:32 +0100 Subject: [PATCH 01/15] [ECP-8825] Enable pipeline runs for external contributions (#2451) * Add e2e flow for external contributors * Add dispatch for debugging * Tweak workflow name * Tweak workflow * Debug * Remove draft pipeline * Update e2e test pipeline * Update GraphQL test pipeline * Update Main CI workflow * Update RestAPI test workflow * DEBUG - Add test pipeline * Add authorization step * DEBUG - Test auth step * Define an internal environment * DEBUG - Try removing auth step and switch to conditional * Remove trial pipeline * Add designated worklfow for debugging * Embed authorize step in build and add conditional * Remove debug pipeline --- .github/workflows/e2e-test.yml | 17 ++++--- .github/workflows/graphql-test.yml | 4 +- .github/workflows/main.yml | 76 +++++++++++++++--------------- .github/workflows/restapi-test.yml | 4 +- 4 files changed, 53 insertions(+), 48 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 8331abca6..968ede2ad 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -1,17 +1,16 @@ name: Magento 2 E2E Pipeline run-name: Adyen Magento 2 Payment Plugin E2E tests -on: +on: pull_request: - types: [opened, synchronize] + types: [opened, synchronize, ready_for_review] + pull_request_target: + types: [opened, synchronize, ready_for_review] jobs: build: - if: | - ${{ - github.event.pull_request.draft == false && - (github.actor != 'renovate[bot]' || github.actor != 'lgtm-com[bot]') - }} + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} runs-on: group: larger-runners labels: ubuntu-latest-8-cores @@ -43,7 +42,7 @@ jobs: - name: Install plugin run: docker exec -u www-data magento2-container make plugin - + - name: Kill Cron Jobs run: docker exec magento2-container /etc/init.d/cron stop @@ -51,7 +50,7 @@ jobs: uses: actions/checkout@v3 with: repository: Adyen/adyen-magento2-dev - ref: 'main' + ref: "main" token: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }} path: Developer diff --git a/.github/workflows/graphql-test.yml b/.github/workflows/graphql-test.yml index 0486e3e4d..ef1627349 100644 --- a/.github/workflows/graphql-test.yml +++ b/.github/workflows/graphql-test.yml @@ -1,8 +1,10 @@ name: GraphQL Tests -on: [pull_request] +on: [pull_request, pull_request_target] jobs: build: + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} strategy: matrix: php-version: ["8.1"] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a844d5a96..272f8b25c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,47 +1,49 @@ name: Main CI workflow -on: [pull_request] +on: [pull_request, pull_request_target] jobs: build: + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} runs-on: ubuntu-latest - + strategy: matrix: php-version: [8.1] - + steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Use PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - tools: composer:v1 - - - name: Test plugin installation - run: | - echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json - composer install --prefer-dist - env: - CI: true - MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }} - MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }} - - - name: Code Sniffer - run: vendor/bin/phpcs --extensions=php,phtml --error-severity=10 --ignore-annotations - - - name: Run PHPUnit - run: vendor/bin/phpunit --coverage-clover=build/clover.xml --log-junit=build/tests-log.xml -c Test/phpunit.xml Test/Unit - - - name: Fix code coverage paths - run: sed -i "s;`pwd`/;;g" build/*.xml - - - name: SonarCloud Scan - if: ${{ env.SONAR_TOKEN }} - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Use PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v1 + + - name: Test plugin installation + run: | + echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json + composer install --prefer-dist + env: + CI: true + MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }} + MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }} + + - name: Code Sniffer + run: vendor/bin/phpcs --extensions=php,phtml --error-severity=10 --ignore-annotations + + - name: Run PHPUnit + run: vendor/bin/phpunit --coverage-clover=build/clover.xml --log-junit=build/tests-log.xml -c Test/phpunit.xml Test/Unit + + - name: Fix code coverage paths + run: sed -i "s;`pwd`/;;g" build/*.xml + + - name: SonarCloud Scan + if: ${{ env.SONAR_TOKEN }} + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/restapi-test.yml b/.github/workflows/restapi-test.yml index d7227b9b9..ba4607099 100644 --- a/.github/workflows/restapi-test.yml +++ b/.github/workflows/restapi-test.yml @@ -1,8 +1,10 @@ name: REST API Tests -on: [pull_request] +on: [pull_request, pull_request_target] jobs: build: + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) + environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }} strategy: matrix: php-version: ["8.1"] From 9da5a63f1133198411e62ed1e8cf7423f409d472 Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Mon, 22 Jan 2024 08:52:16 +0100 Subject: [PATCH 02/15] [ECP-8890] Update class references (#2441) --- Model/Api/PaymentRequest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Model/Api/PaymentRequest.php b/Model/Api/PaymentRequest.php index 8abecb4fd..63c27f2df 100755 --- a/Model/Api/PaymentRequest.php +++ b/Model/Api/PaymentRequest.php @@ -12,7 +12,7 @@ namespace Adyen\Payment\Model\Api; use Adyen\AdyenException; -use Adyen\Config; +use Adyen\Payment\Helper\Config; use Adyen\Payment\Helper\Data; use Adyen\Payment\Logger\AdyenLogger; use Adyen\Payment\Model\RecurringType; @@ -101,8 +101,8 @@ public function authorise3d(Payment $payment): mixed ]; try { - $client = $this->configHelper->initializeAdyenClient($storeId); - $service = $this->configHelper->createAdyenCheckoutService($client); + $client = $this->adyenHelper->initializeAdyenClient($storeId); + $service = $this->adyenHelper->createAdyenCheckoutService($client); $result = $service->paymentsDetails($request); } catch (AdyenException $e) { throw new LocalizedException(__('3D secure failed')); @@ -173,13 +173,13 @@ public function listRecurringContractByType(string $shopperReference, int $store $contract = ['contract' => $recurringType]; $request = [ "merchantAccount" => $this->configHelper->getAdyenAbstractConfigData('merchant_account', $storeId), - "shopperReference" => $this->configHelper->padShopperReference($shopperReference), + "shopperReference" => $this->adyenHelper->padShopperReference($shopperReference), "recurring" => $contract, ]; // call lib - $client = $this->configHelper->initializeAdyenClient($storeId); - $service = $this->configHelper->createAdyenRecurringService($client); + $client = $this->adyenHelper->initializeAdyenClient($storeId); + $service = $this->adyenHelper->createAdyenRecurringService($client); $result = $service->listRecurringDetails($request); return $result; @@ -200,7 +200,7 @@ public function disableRecurringContract( int $storeId ): bool { $merchantAccount = $this->configHelper->getAdyenAbstractConfigData("merchant_account", $storeId); - $shopperReference = $this->configHelper->padShopperReference($shopperReference); + $shopperReference = $this->adyenHelper->padShopperReference($shopperReference); $request = [ "merchantAccount" => $merchantAccount, "shopperReference" => $shopperReference, @@ -208,8 +208,8 @@ public function disableRecurringContract( ]; // call lib - $client = $this->configHelper->initializeAdyenClient($storeId); - $service = $this->configHelper->createAdyenRecurringService($client); + $client = $this->adyenHelper->initializeAdyenClient($storeId); + $service = $this->adyenHelper->createAdyenRecurringService($client); try { $result = $service->disable($request); From 2da1077461067c357125b34baad5a4977f102eb7 Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Mon, 22 Jan 2024 09:34:08 +0100 Subject: [PATCH 03/15] [ECP-8878] Add pspReference to additional_information (#2443) --- Gateway/Response/PaymentPosCloudHandler.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gateway/Response/PaymentPosCloudHandler.php b/Gateway/Response/PaymentPosCloudHandler.php index b8a1ae215..b697b7b3c 100644 --- a/Gateway/Response/PaymentPosCloudHandler.php +++ b/Gateway/Response/PaymentPosCloudHandler.php @@ -57,6 +57,10 @@ public function handle(array $handlingSubject, array $response) ); $payment->setAdditionalInformation('additionalData', $paymentResponseDecoded['additionalData']); + if (isset($paymentResponseDecoded['additionalData']['pspReference'])) { + $payment->setAdditionalInformation('pspReference', $paymentResponseDecoded['additionalData']['pspReference']); + } + $this->vaultHelper->handlePaymentResponseRecurringDetails( $payment->getOrder()->getPayment(), $paymentResponseDecoded From dffea8852430736154d0252f84f0e68e7f600e4b Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Mon, 22 Jan 2024 10:21:08 +0100 Subject: [PATCH 04/15] [ECP-8787] Handle Pending resultCode on multishipping (#2448) --- Block/Checkout/Multishipping/Success.php | 16 ++++++++-------- .../checkout/multishipping/success.phtml | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Block/Checkout/Multishipping/Success.php b/Block/Checkout/Multishipping/Success.php index f718a7ff2..f647976a6 100644 --- a/Block/Checkout/Multishipping/Success.php +++ b/Block/Checkout/Multishipping/Success.php @@ -28,12 +28,12 @@ class Success extends \Magento\Multishipping\Block\Checkout\Success { - const FINAL_RESULT_CODES = array( - PaymentResponseHandler::AUTHORISED, - PaymentResponseHandler::PENDING, - PaymentResponseHandler::REFUSED, - PaymentResponseHandler::PRESENT_TO_SHOPPER - ); + const ACTION_REQUIRED_STATUSES = [ + PaymentResponseHandler::REDIRECT_SHOPPER, + PaymentResponseHandler::IDENTIFY_SHOPPER, + PaymentResponseHandler::CHALLENGE_SHOPPER, + PaymentResponseHandler::PENDING + ]; /** * @var bool @@ -122,7 +122,7 @@ public function __construct( public function renderAction() { foreach ($this->paymentResponseEntities as $paymentResponseEntity) { - if (!in_array($paymentResponseEntity['result_code'], self::FINAL_RESULT_CODES)) { + if (in_array($paymentResponseEntity['result_code'], self::ACTION_REQUIRED_STATUSES)) { return true; } } @@ -189,7 +189,7 @@ private function setOrderInfo($orderIds) public function getIsPaymentCompleted(int $orderId) { // TODO check for all completed responses, not only Authorised, Refused, Pending or PresentToShopper - return in_array($this->ordersInfo[$orderId]['resultCode'], self::FINAL_RESULT_CODES); + return !in_array($this->ordersInfo[$orderId]['resultCode'], self::ACTION_REQUIRED_STATUSES); } public function getPaymentButtonLabel(int $orderId) diff --git a/view/frontend/templates/checkout/multishipping/success.phtml b/view/frontend/templates/checkout/multishipping/success.phtml index 373325898..7216b59b1 100644 --- a/view/frontend/templates/checkout/multishipping/success.phtml +++ b/view/frontend/templates/checkout/multishipping/success.phtml @@ -187,9 +187,7 @@ $paymentResponseEntities = $block->getPaymentResponseEntities(); try { let response = $(this).data('adyen-response'); - // Only show the modal for some result codes - const modalResponseCodes = ['IdentifyShopper']; - if (modalResponseCodes.includes(response.resultCode)) { + if (response.resultCode !== 'RedirectShopper') { showModal(); } From 99df86d734cf618415b5f55822585c1808ecbb36 Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Mon, 22 Jan 2024 10:59:46 +0100 Subject: [PATCH 05/15] [ECP-8822] Update management webhook endpoint (#2440) --- Model/Config/Backend/WebhookCredentials.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Config/Backend/WebhookCredentials.php b/Model/Config/Backend/WebhookCredentials.php index 5f4f8853c..77f0d9e95 100644 --- a/Model/Config/Backend/WebhookCredentials.php +++ b/Model/Config/Backend/WebhookCredentials.php @@ -62,7 +62,7 @@ public function beforeSave() $username = $this->getValue(); $password = $this->getFieldsetDataValue('notification_password'); - $webhookUrl = $this->url->getBaseUrl() . 'adyen/process/json'; + $webhookUrl = $this->url->getBaseUrl() . 'adyen/webhook'; $isDemoMode = (int)$this->getFieldsetDataValue('demo_mode'); $environment = $isDemoMode ? 'test' : 'live'; From 7bbd2dd6d76ef5f3da35772c83922626c676ea14 Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Wed, 24 Jan 2024 09:17:29 +0100 Subject: [PATCH 06/15] Remove post install commands for phpcompatibility/php-compatibility (#2458) * Remove post install commands * Fix codesniffing errors * Fix codesniffing errors * Fix Multishipping and Donations * Fix POS cloud receipt --- composer.json | 6 ---- .../templates/config/applepay_button.phtml | 2 +- .../config/configuration_wizard.phtml | 8 ++--- .../templates/config/required_settings.phtml | 6 ++-- .../config/token_type_table_array.phtml | 2 +- .../templates/config/webhook_test.phtml | 8 ++--- .../templates/form/pay_by_link.phtml | 2 +- view/adminhtml/templates/form/pos_cloud.phtml | 4 +-- .../adminhtml/templates/info/adyen_moto.phtml | 2 +- .../templates/info/adyen_pos_cloud.phtml | 2 +- .../templates/support/custom_title.phtml | 2 +- view/adminhtml/templates/support/menu.phtml | 6 ++-- .../adminhtml/templates/support/success.phtml | 8 ++--- .../templates/support/support_links.phtml | 6 ++-- .../checkout/multishipping/billing.phtml | 2 +- .../checkout/multishipping/success.phtml | 2 +- .../frontend/templates/checkout/success.phtml | 34 +++++++++---------- .../customer_account/payment_method.phtml | 2 +- .../form/multishipping/abstract-form.phtml | 4 +-- .../templates/info/adyen_boleto.phtml | 2 +- view/frontend/templates/info/adyen_cc.phtml | 4 +-- .../templates/info/adyen_giftcard.phtml | 4 +-- view/frontend/templates/info/adyen_pm.phtml | 4 +-- .../templates/info/adyen_pos_cloud.phtml | 2 +- 24 files changed, 59 insertions(+), 65 deletions(-) diff --git a/composer.json b/composer.json index b83d9e45f..96aa32553 100755 --- a/composer.json +++ b/composer.json @@ -41,12 +41,6 @@ "test": [ "Composer\\Config::disableProcessTimeout", "vendor/bin/phpunit -c Test/phpunit.xml" - ], - "post-install-cmd": [ - "([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility)" - ], - "post-update-cmd": [ - "([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility)" ] } } diff --git a/view/adminhtml/templates/config/applepay_button.phtml b/view/adminhtml/templates/config/applepay_button.phtml index 6ba754cd0..e57195c9f 100644 --- a/view/adminhtml/templates/config/applepay_button.phtml +++ b/view/adminhtml/templates/config/applepay_button.phtml @@ -1,3 +1,3 @@ - + diff --git a/view/adminhtml/templates/config/configuration_wizard.phtml b/view/adminhtml/templates/config/configuration_wizard.phtml index 813b1e4c7..999768131 100644 --- a/view/adminhtml/templates/config/configuration_wizard.phtml +++ b/view/adminhtml/templates/config/configuration_wizard.phtml @@ -1,8 +1,8 @@ getNextButtonHtml() ?>