diff --git a/.github/scripts/e2e-all.sh b/.github/scripts/e2e-all.sh deleted file mode 100755 index b1c6c36f7..000000000 --- a/.github/scripts/e2e-all.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Checkout E2E tests -cd /tmp; -git clone https://github.com/Adyen/adyen-integration-tools-tests.git; -cd adyen-integration-tools-tests; -git checkout $INTEGRATION_TESTS_BRANCH; - -# Setup environment -rm -rf package-lock.json; -npm i; - -# Run tests -npm run test:ci:magento:all diff --git a/.github/scripts/e2e.sh b/.github/scripts/e2e.sh index c940deb07..55c97f69c 100755 --- a/.github/scripts/e2e.sh +++ b/.github/scripts/e2e.sh @@ -1,15 +1,28 @@ #!/bin/bash -set -euo pipefail -# Checkout E2E tests -cd /tmp; -git clone https://github.com/Adyen/adyen-integration-tools-tests.git; -cd adyen-integration-tools-tests; -git checkout $INTEGRATION_TESTS_BRANCH; +# Base configuration and installation +set -euo pipefail +cd /tmp +git clone https://github.com/Adyen/adyen-integration-tools-tests.git +cd adyen-integration-tools-tests +git checkout $INTEGRATION_TESTS_BRANCH +rm -rf package-lock.json +npm i -# Setup environment -rm -rf package-lock.json; -npm i; +option="$1" -# Run tests -npm run test:ci:magento +# Run the desired group of tests +case $option in + "standard") + echo "Running Standard Set of E2E Tests." + npm run test:ci:magento + ;; + "express-checkout") + echo "Running Express Checkout E2E Tests." + npm run test:ci:magento:express-checkout + ;; + "all") + echo "Running All Magento E2E Tests" + npm run test:ci:magento:all + ;; +esac diff --git a/.github/workflows/test-repo-e2e.yml b/.github/workflows/e2e-test-dispatch.yml similarity index 66% rename from .github/workflows/test-repo-e2e.yml rename to .github/workflows/e2e-test-dispatch.yml index 1c92a60f0..5dd704acf 100644 --- a/.github/workflows/test-repo-e2e.yml +++ b/.github/workflows/e2e-test-dispatch.yml @@ -1,5 +1,5 @@ -name: Adyen Payment Plugin V8 Integration Test Dispatch Pipeline -run-name: --V8-- E2E tests against Test Repository ${{inputs.testBranch}} with Express Checkout ${{inputs.expressBranch}} +name: Integration Test Repository Dispatch Pipeline for V8 +run-name: --V8-- E2E tests against Test Repository ${{inputs.testBranch}} with Express Checkout ${{inputs.expressBranch}} with test group ${{inputs.testGroup}} on: workflow_dispatch: @@ -12,14 +12,18 @@ on: description: "Express Checkout Repository Pipeline" required: true default: "develop-1" + testGroup: + description: "Test group" + required: true + default: "all" + type: choice + options: + - all + - standard + - express-checkout jobs: build: - if: | - ${{ - github.event.pull_request.draft == false && - (github.actor != 'renovate' || github.actor != 'lgtm-com') - }} runs-on: group: larger-runners labels: ubuntu-latest-8-cores @@ -52,10 +56,35 @@ 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 + + - name: Checkout developer module + uses: actions/checkout@v3 + with: + repository: Adyen/adyen-magento2-dev + ref: 'main' + token: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }} + path: Developer + + - name: Make the folder for dev module + run: docker exec -u www-data magento2-container mkdir -p /var/www/html/app/code/Adyen + + - name: Copy dev module into Docker container + run: docker cp ./Developer magento2-container:/var/www/html/app/code/Adyen + + - name: Change ownership of developer module folder + run: docker exec magento2-container chown -R www-data:www-data /var/www/html/app/code/Adyen/Developer + + - name: Enable developer module + run: docker exec -u www-data magento2-container make dev-module + - name: Install Express module + if: ${{inputs.expressBranch != 'disable'}} run: docker exec -u www-data magento2-container composer require adyen/adyen-magento2-expresscheckout:dev-${{inputs.expressBranch}} - name: Enable Express module + if: ${{inputs.expressBranch != 'disable'}} run: docker exec -u www-data magento2-container make enable-express - name: Switch to production mode @@ -65,7 +94,7 @@ jobs: run: docker exec magento2-container make fs - name: Run E2E tests - run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e-all.sh + run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e.sh ${{inputs.testGroup}} env: INTEGRATION_TESTS_BRANCH: ${{inputs.testBranch}} MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}} @@ -78,8 +107,8 @@ jobs: ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}} GOOGLE_USERNAME: ${{secrets.GOOGLE_USERNAME}} GOOGLE_PASSWORD: ${{secrets.GOOGLE_PASSWORD}} - WEBHOOK_USERNAME: ${{secrets.WEBHOOK_USERNAME}} - WEBHOOK_PASSWORD: ${{secrets.WEBHOOK_PASSWORD}} + WEBHOOK_USERNAME: admin + WEBHOOK_PASSWORD: 1234 - name: Archive test result artifacts if: always() diff --git a/.github/workflows/test-repo-e2e-release.yml b/.github/workflows/e2e-test-express-checkout.yml similarity index 94% rename from .github/workflows/test-repo-e2e-release.yml rename to .github/workflows/e2e-test-express-checkout.yml index 379754e9c..b3a22dc8e 100644 --- a/.github/workflows/test-repo-e2e-release.yml +++ b/.github/workflows/e2e-test-express-checkout.yml @@ -1,5 +1,5 @@ -name: Magento 2 V8 Release E2E Pipeline -run-name: --V8-- E2E tests against Test Repository with Express Checkout +name: Magento 2 V8 Express Checkout E2E Pipeline +run-name: --V8-- Adyen Magento 2 Express Checkout Plugin E2E tests on: pull_request: @@ -54,7 +54,7 @@ jobs: run: docker exec magento2-container make fs - name: Run E2E tests - run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e-all.sh + run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e.sh express-checkout env: INTEGRATION_TESTS_BRANCH: develop-8 MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}} diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 81ae5f2ad..2b234b864 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -4,7 +4,6 @@ run-name: --V8-- E2E tests for Adyen Magento2 Plugin on: pull_request: types: [opened, synchronize] - branches-ignore: [main, main-8] jobs: build: @@ -54,7 +53,7 @@ jobs: run: docker exec magento2-container make fs - name: Run E2E tests - run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e.sh + run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e.sh standard env: INTEGRATION_TESTS_BRANCH: develop-8 MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}} diff --git a/Gateway/Request/RecurringVaultDataBuilder.php b/Gateway/Request/RecurringVaultDataBuilder.php index 2e36a9def..9e5571b27 100644 --- a/Gateway/Request/RecurringVaultDataBuilder.php +++ b/Gateway/Request/RecurringVaultDataBuilder.php @@ -11,10 +11,13 @@ namespace Adyen\Payment\Gateway\Request; +use Adyen\Payment\Helper\Config; use Adyen\Payment\Helper\StateData; use Adyen\Payment\Helper\Vault; use Adyen\Payment\Model\Ui\AdyenCcConfigProvider; +use Adyen\Payment\Model\Ui\AdyenHppConfigProvider; use Adyen\Payment\Model\Ui\AdyenOneclickConfigProvider; +use Magento\Framework\Exception\LocalizedException; use Magento\Payment\Gateway\Data\PaymentDataObject; use Magento\Payment\Gateway\Helper\SubjectReader; use Magento\Payment\Gateway\Request\BuilderInterface; @@ -26,18 +29,26 @@ class RecurringVaultDataBuilder implements BuilderInterface */ private $stateData; - public function __construct(StateData $stateData) - { + /** + * @var Config + */ + private $configHelper; + + public function __construct( + StateData $stateData, + Config $configHelper + ) { $this->stateData = $stateData; + $this->configHelper = $configHelper; } /** * @param array $buildSubject * @return array + * @throws LocalizedException */ public function build(array $buildSubject) { - $requestBody = []; /** @var PaymentDataObject $paymentDataObject */ $paymentDataObject = SubjectReader::readPayment($buildSubject); $payment = $paymentDataObject->getPayment(); @@ -53,6 +64,15 @@ public function build(array $buildSubject) // For now this will only be used by tokens created trough adyen_hpp payment methods if (array_key_exists(Vault::TOKEN_TYPE, $details)) { $requestBody['recurringProcessingModel'] = $details[Vault::TOKEN_TYPE]; + } else if ($paymentMethod->getCode() === AdyenCcConfigProvider::CC_VAULT_CODE || + $paymentMethod->getCode() === AdyenOneclickConfigProvider::CODE) { + $requestBody['recurringProcessingModel'] = $this->configHelper->getCardRecurringType( + $order->getStoreId() + ); + } else if ($paymentMethod->getCode() === AdyenHppConfigProvider::class ) { + $requestBody['recurringProcessingModel'] = $this->configHelper->getAlternativePaymentMethodTokenType( + $order->getStoreId() + ); } /* diff --git a/Helper/Creditmemo.php b/Helper/Creditmemo.php index fd69d2d28..709ca30fe 100644 --- a/Helper/Creditmemo.php +++ b/Helper/Creditmemo.php @@ -136,8 +136,16 @@ public function linkAndUpdateAdyenCreditmemos( $adyenCreditmemo[CreditmemoInterface::ENTITY_ID], CreditmemoInterface::ENTITY_ID ); - $currAdyenCreditmemo->setCreditmemoId($magentoCreditmemo->getEntityId()); - $this->adyenCreditmemoResourceModel->save($currAdyenCreditmemo); + + if ($currAdyenCreditmemo->getCreditmemoId() !== null) { + continue; + } + + if ($currAdyenCreditmemo->getAmount() == $magentoCreditmemo->getGrandTotal()) { + $currAdyenCreditmemo->setCreditmemoId($magentoCreditmemo->getEntityId()); + $this->adyenCreditmemoResourceModel->save($currAdyenCreditmemo); + break; + } } } } diff --git a/composer.json b/composer.json index 3679ea0ba..32a26c246 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "adyen/module-payment", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "type": "magento2-module", - "version": "8.22.6", + "version": "8.22.7", "license": "MIT", "repositories": [ { diff --git a/etc/module.xml b/etc/module.xml index b66f34857..10123ab18 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -11,7 +11,7 @@ */ --> - +