Skip to content

Commit

Permalink
Merge pull request #2220 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 8.22.0
  • Loading branch information
candemiralp authored Sep 25, 2023
2 parents 24f94fa + 8111d41 commit 6608569
Show file tree
Hide file tree
Showing 30 changed files with 601 additions and 433 deletions.
8 changes: 8 additions & 0 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ configure: n98-magerun2.phar
flush:
bin/magento cache:flush

# Setup upgrade
enable-express:
bin/magento module:enable Adyen_ExpressCheckout
bin/magento setup:upgrade
bin/magento config:set payment/adyen_hpp/show_google_pay_on "1,2,3"
bin/magento config:set payment/adyen_hpp/show_apple_pay_on "1,2,3"
bin/magento cache:clean

# Full plugin setup
plugin: install configure flush

Expand Down
5 changes: 5 additions & 0 deletions .github/docker-compose.e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ services:
- ADYEN_API_KEY
- ADYEN_CLIENT_KEY
- ADYEN_MERCHANT
- GOOGLE_USERNAME
- GOOGLE_PASSWORD
- WEBHOOK_USERNAME
- WEBHOOK_PASSWORD

volumes:
- ../../scripts/e2e.sh:/e2e.sh
- ../../scripts/e2e-all.sh:/e2e-all.sh
- ../../../test-report:/tmp/test-report
15 changes: 15 additions & 0 deletions .github/scripts/e2e-all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/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
17 changes: 13 additions & 4 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
name: E2E Test
run-name: Headless E2E tests for Adyen Magento2 Plugin
name: Magento 2 E2E Pipeline
run-name: E2E tests for Adyen Magento2 Plugin

on: [pull_request]
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches-ignore: [main]

jobs:
build:
if: ${{ github.actor != 'renovate[bot]' || github.actor != 'lgtm-com[bot]' }}
if: |
${{
github.event.pull_request.draft == false &&
(github.actor != 'renovate' || github.actor != 'lgtm-com')
}}
runs-on:
group: larger-runners
labels: ubuntu-latest-8-cores
Expand Down Expand Up @@ -58,6 +65,8 @@ jobs:
ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}}
ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
WEBHOOK_USERNAME: ${{secrets.WEBHOOK_USERNAME}}
WEBHOOK_PASSWORD: ${{secrets.WEBHOOK_PASSWORD}}

- name: Archive test result artifacts
if: always()
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/templates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ services:
- ADYEN_API_KEY
- ADYEN_CLIENT_KEY
- ADYEN_MERCHANT
- GOOGLE_USERNAME
- GOOGLE_PASSWORD
- WEBHOOK_USERNAME
- WEBHOOK_PASSWORD
volumes:
- ../../scripts/e2e.sh:/e2e.sh
- ../../scripts/e2e-all.sh:/e2e-all.sh
- ../../../test-report:/tmp/test-report
networks:
backend:
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/test-repo-e2e-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Magento 2 Release E2E Pipeline
run-name: E2E tests against Test Repository with Express Checkout

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [main]

jobs:
build:
runs-on:
group: larger-runners
labels: ubuntu-latest-8-cores
timeout-minutes: 20
env:
PHP_VERSION: "8.1"
MAGENTO_VERSION: "2.4.5"
ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
steps:
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento

- name: Start web server in background
run: docker-compose -f .github/workflows/templates/docker-compose.yml up -d web
env:
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}}
ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}}

- name: Setup permissions
run: docker exec magento2-container make fs

- name: Check install
run: docker exec magento2-container make sys-check

- name: Install plugin
run: docker exec -u www-data magento2-container make plugin

- name: Install Express module
run: docker exec -u www-data magento2-container composer require adyen/adyen-magento2-expresscheckout

- name: Enable Express module
run: docker exec -u www-data magento2-container make enable-express

- name: Switch to production mode
run: docker exec -u www-data magento2-container make production

- name: Setup permissions
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
env:
INTEGRATION_TESTS_BRANCH: develop
MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
MAGENTO_ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
MAGENTO_BASE_URL: ${{secrets.MAGENTO_BASE_URL}}
PAYPAL_USERNAME: ${{secrets.PLAYWRIGHT_PAYPAL_USERNAME}}
PAYPAL_PASSWORD: ${{secrets.PLAYWRIGHT_PAYPAL_PASSWORD}}
ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}}
ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}}
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}}

- name: Archive test result artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: html-report
path: test-report
26 changes: 23 additions & 3 deletions .github/workflows/test-repo-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Integration Test Repository Pipeline
run-name: Headless E2E test run triggered by adyen-integration-tools-tests ${{inputs.testBranch}}
name: Integration Test Repository Dispatch Pipeline
run-name: E2E tests against Test Repository ${{inputs.testBranch}} with Express Checkout ${{inputs.expressBranch}}

on:
workflow_dispatch:
Expand All @@ -8,12 +8,22 @@ on:
description: "Integration Test Repository Pipeline"
required: true
default: "develop"
expressBranch:
description: "Express Checkout Repository Pipeline"
required: true
default: "develop"

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
timeout-minutes: 20
env:
PHP_VERSION: "8.1"
MAGENTO_VERSION: "2.4.5"
Expand Down Expand Up @@ -42,14 +52,20 @@ jobs:
- name: Install plugin
run: docker exec -u www-data magento2-container make plugin

- name: Install Express module
run: docker exec -u www-data magento2-container composer require adyen/adyen-magento2-expresscheckout:dev-${{inputs.expressBranch}}

- name: Enable Express module
run: docker exec -u www-data magento2-container make enable-express

- name: Switch to production mode
run: docker exec -u www-data magento2-container make production

- name: Setup permissions
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-all.sh
env:
INTEGRATION_TESTS_BRANCH: ${{inputs.testBranch}}
MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
Expand All @@ -60,6 +76,10 @@ jobs:
ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}}
ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}}
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}}

- name: Archive test result artifacts
if: always()
Expand Down
12 changes: 5 additions & 7 deletions Gateway/Http/Client/TransactionCancel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Adyen\Client;
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Helper\Idempotency;
use Adyen\Service\Modification;
use Adyen\Service\Checkout\ModificationsApi;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Payment\Gateway\Http\ClientInterface;
use Magento\Payment\Gateway\Http\TransferInterface;
Expand Down Expand Up @@ -59,9 +59,8 @@ public function placeRequest(TransferInterface $transferObject): array
$request = $transferObject->getBody();
$headers = $transferObject->getHeaders();

$service = new Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
$client = $this->adyenHelper->initializeAdyenClient();
$service = $this->adyenHelper->createAdyenCheckoutService($client);

$idempotencyKey = $this->idempotencyHelper->generateIdempotencyKey(
$request,
Expand All @@ -70,10 +69,9 @@ public function placeRequest(TransferInterface $transferObject): array

$requestOptions['idempotencyKey'] = $idempotencyKey;

$this->adyenHelper
->logRequest($request, Client::API_PAYMENT_VERSION, '/pal/servlet/Payment/{version}/cancel');
$this->adyenHelper->logRequest($request, Client::API_CHECKOUT_VERSION, '/cancels');
try {
$response = $service->cancel($request, $requestOptions);
$response = $service->cancels($request, $requestOptions);
} catch (AdyenException $e) {
$response['error'] = $e->getMessage();
}
Expand Down
34 changes: 17 additions & 17 deletions Gateway/Http/Client/TransactionCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Adyen\Payment\Helper\Idempotency;
use Adyen\Payment\Helper\Requests;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Service\Modification;
use Adyen\Service\Checkout\ModificationsApi;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Payment\Gateway\Http\ClientInterface;
use Magento\Payment\Gateway\Http\TransferInterface;
Expand All @@ -31,8 +31,8 @@ class TransactionCapture implements ClientInterface
const MULTIPLE_AUTHORIZATIONS = 'multiple_authorizations';
const FORMATTED_CAPTURE_AMOUNT = 'formatted_capture_amount';
const CAPTURE_AMOUNT = 'capture_amount';
const ORIGINAL_REFERENCE = 'original_reference';
const CAPTURE_RECEIVED = '[capture-received]';
const ORIGINAL_REFERENCE = 'paymentPspReference';
const CAPTURE_RECEIVED = 'received';

/**
* @var Data
Expand Down Expand Up @@ -76,9 +76,9 @@ public function placeRequest(TransferInterface $transferObject): array
$request = $transferObject->getBody();
$headers = $transferObject->getHeaders();

$service = new Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);
$client = $this->adyenHelper->initializeAdyenClient();
$service = $this->adyenHelper->createAdyenCheckoutService($client);


$idempotencyKey = $this->idempotencyHelper->generateIdempotencyKey(
$request,
Expand All @@ -91,10 +91,10 @@ public function placeRequest(TransferInterface $transferObject): array
return $this->placeMultipleCaptureRequests($service, $request, $requestOptions);
}

$this->adyenHelper
->logRequest($request, Client::API_PAYMENT_VERSION, '/pal/servlet/Payment/{version}/capture');
$this->adyenHelper->logRequest($request, Client::API_CHECKOUT_VERSION, '/captures');

try {
$response = $service->capture($request, $requestOptions);
$response = $service->captures($request, $requestOptions);
$response = $this->copyParamsToResponse($response, $request);
} catch (AdyenException $e) {
$response['error'] = $e->getMessage();
Expand All @@ -105,22 +105,22 @@ public function placeRequest(TransferInterface $transferObject): array
}

/**
* @param Modification $service
* @param $service
* @param $requestContainer
* @return array
*/
private function placeMultipleCaptureRequests(Modification $service, $requestContainer, $requestOptions)
private function placeMultipleCaptureRequests($service, $requestContainer, $requestOptions): array
{
$response = [];
foreach ($requestContainer[self::MULTIPLE_AUTHORIZATIONS] as $request) {
try {
// Copy merchant account from parent array to every request array
$request[Requests::MERCHANT_ACCOUNT] = $requestContainer[Requests::MERCHANT_ACCOUNT];
$singleResponse = $service->capture($request, $requestOptions);
$singleResponse[self::FORMATTED_CAPTURE_AMOUNT] = $request['modificationAmount']['currency'] . ' ' .
$singleResponse = $service->captures($request, $requestOptions);
$singleResponse[self::FORMATTED_CAPTURE_AMOUNT] = $request['amount']['currency'] . ' ' .
$this->adyenHelper->originalAmount(
$request['modificationAmount']['value'],
$request['modificationAmount']['currency']
$request['amount']['value'],
$request['amount']['currency']
);
$singleResponse = $this->copyParamsToResponse($singleResponse, $request);
$response[self::MULTIPLE_AUTHORIZATIONS][] = $singleResponse;
Expand Down Expand Up @@ -149,8 +149,8 @@ private function placeMultipleCaptureRequests(Modification $service, $requestCon
*/
private function copyParamsToResponse(array $response, array $request): array
{
$response[self::CAPTURE_AMOUNT] = $request['modificationAmount']['value'];
$response[self::ORIGINAL_REFERENCE] = $request['originalReference'];
$response[self::CAPTURE_AMOUNT] = $request['amount']['value'];
$response[self::ORIGINAL_REFERENCE] = $request[self::ORIGINAL_REFERENCE];

return $response;
}
Expand Down
17 changes: 8 additions & 9 deletions Gateway/Http/Client/TransactionRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ public function placeRequest(TransferInterface $transferObject): array
$headers = $transferObject->getHeaders();

foreach ($requests as $request) {
// call lib
$service = new \Adyen\Service\Modification(
$this->adyenHelper->initializeAdyenClient($transferObject->getClientConfig()['storeId'])
);

$client = $this->adyenHelper->initializeAdyenClient();
$service = $this->adyenHelper->createAdyenCheckoutService($client);

$idempotencyKey = $this->idempotencyHelper->generateIdempotencyKey(
$request,
Expand All @@ -73,15 +72,15 @@ public function placeRequest(TransferInterface $transferObject): array
$requestOptions['idempotencyKey'] = $idempotencyKey;

$this->adyenHelper
->logRequest($request, Client::API_PAYMENT_VERSION, '/pal/servlet/Payment/{version}/refund');
->logRequest($request, Client::API_CHECKOUT_VERSION, '/refunds');
try {
$response = $service->refund($request, $requestOptions);
$response = $service->refunds($request, $requestOptions);

// Add amount original reference and amount information to response
$response[self::REFUND_AMOUNT] = $request['modificationAmount']['value'];
$response[self::REFUND_CURRENCY] = $request['modificationAmount']['currency'];
$response[self::REFUND_AMOUNT] = $request['amount']['value'];
$response[self::REFUND_CURRENCY] = $request['amount']['currency'];

$response[self::ORIGINAL_REFERENCE] = $request['originalReference'];
$response[self::ORIGINAL_REFERENCE] = $request['paymentPspReference'];
} catch (AdyenException $e) {
$response = ['error' => $e->getMessage()];
}
Expand Down
2 changes: 1 addition & 1 deletion Gateway/Request/CancelDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function build(array $buildSubject): array
$pspReference = $payment->getCcTransId();

$request['body'] = [
"paymentPspReference" => $pspReference,
"reference" => $order->getOrderIncrementId(),
"originalReference" => $pspReference
];

$request['clientConfig'] = ["storeId" => $order->getStoreId()];
Expand Down
Loading

0 comments on commit 6608569

Please sign in to comment.