Skip to content

Commit

Permalink
Merge branch 'develop' into ECP-8891
Browse files Browse the repository at this point in the history
  • Loading branch information
candemiralp authored Jan 23, 2024
2 parents f10957b + 99df86d commit 8a7a1e4
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 69 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -43,15 +42,15 @@ 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'
ref: "main"
token: ${{ secrets.ADYEN_AUTOMATION_BOT_TEST_ACCESS_TOKEN }}
path: Developer

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/graphql-test.yml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
76 changes: 39 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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 }}
4 changes: 3 additions & 1 deletion .github/workflows/restapi-test.yml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
16 changes: 8 additions & 8 deletions Block/Checkout/Multishipping/Success.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Gateway/Response/PaymentPosCloudHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions Model/Api/PaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'));
Expand Down Expand Up @@ -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;
Expand All @@ -200,16 +200,16 @@ 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,
"recurringDetailReference" => $recurringDetailReference
];

// 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);
Expand Down
2 changes: 1 addition & 1 deletion Model/Config/Backend/WebhookCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 1 addition & 3 deletions view/frontend/templates/checkout/multishipping/success.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 8a7a1e4

Please sign in to comment.