Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 8.15.0 #1950

Merged
merged 15 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/docker-compose.mftf.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
selenium:
image: selenium/standalone-chrome-debug:3.8.1
image: selenium/standalone-chrome-debug:3.141.59
ports:
- "5900:5900"
networks:
Expand Down
2 changes: 1 addition & 1 deletion .github/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
MARIADB_USER: magento
MARIADB_PASSWORD: magento
elastic:
image: elasticsearch:7.16.2
image: elasticsearch:7.17.8
container_name: elasticsearch
networks:
- backend
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "CodeQL"

on:
push:
branches: [ "develop", "develop-6", "develop-7", "main", "main-6", "main-7", "rc-v9" ]
pull_request:
branches: [ "develop", "main" ]
paths-ignore:
- 'view/base/web/js/*'
schedule:
- cron: "6 1 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ javascript ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/graphql-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
php-version: [7.3, 7.4, 8.1]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mftf-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
ADMIN_USERNAME: ${{ secrets.MAGENTO_ADMIN_USERNAME }}
ADMIN_PASSWORD: ${{ secrets.MAGENTO_ADMIN_PASSWORD }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Start services
run: docker-compose -f .github/docker-compose.yml -f .github/docker-compose.mftf.yml up -d
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/templates/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
networks:
- backend
elastic:
image: elasticsearch:7.16.2
image: elasticsearch:7.17.8
container_name: elasticsearch
ports:
- 9200:9200
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-repo-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
Expand Down
12 changes: 6 additions & 6 deletions Api/Data/NotificationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ public function setEventCode($eventCode);
/**
* Gets the success for the notification.
*
* @return int|null Success.
* @return string|null Success.
*/
public function getSuccess();

/**
* Sets Success.
*
* @param boolean $success
* @param string $success
* @return $this
*/
public function setSuccess($success);
Expand All @@ -198,7 +198,7 @@ public function setPaymentMethod($paymentMethod);
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
* @return string|null AmountValue.
*/
public function getAmountValue();

Expand Down Expand Up @@ -228,7 +228,7 @@ public function setAmountCurrency($amountCurrency);
/**
* Gets the Reason for the notification.
*
* @return int|null Reason.
* @return string|null Reason.
*/
public function getReason();

Expand All @@ -243,7 +243,7 @@ public function setReason($reason);
/**
* Gets the AdditionalData for the notification.
*
* @return int|null AdditionalData.
* @return string|null AdditionalData.
*/
public function getAdditionalData();

Expand All @@ -265,7 +265,7 @@ public function getDone();
/**
* Sets Done.
*
* @param string $done
* @param int $done
* @return $this
*/
public function setDone($done);
Expand Down
85 changes: 85 additions & 0 deletions Block/Adminhtml/System/Config/Fieldset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
namespace Adyen\Payment\Block\Adminhtml\System\Config;

class Fieldset extends \Magento\Config\Block\System\Config\Form\Fieldset
{
protected function _getFrontendClass($element)
{
return parent::_getFrontendClass($element) . ' with-button enabled';
}

protected function _getHeaderTitleHtml($element)
{
$html = '<div class="config-heading" >';

$groupConfig = $element->getGroup();

$htmlId = $element->getHtmlId();
$html .= '<div class="button-container"><button type="button"' .
' class="button action-configure' .
'" id="' .
$htmlId .
'-head" onclick="toggleSolution.call(this, \'' .
$htmlId .
"', '" .
$this->getUrl(
'adminhtml/*/state'
) . '\'); return false;"><span class="state-closed">' . __(
'Configure'
) . '</span><span class="state-opened">' . __(
'Close'
) . '</span></button>';

$html .= '</div>';
$html .= '<div class="heading"><strong>' . $element->getLegend() . '</strong>';

if ($element->getComment()) {
$html .= '<span class="heading-intro">' . $element->getComment() . '</span>';
}
$html .= '<div class="config-alt"></div>';
$html .= '</div></div>';

return $html;
}

/**
* Get collapsed state on-load
*
* @param \Magento\Framework\Data\Form\Element\AbstractElement $element
* @return false
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
protected function _isCollapseState($element)
{
return false;
}

protected function _getHeaderCommentHtml($element)
{
return '';
}

protected function _getExtraJs($element)
{
$script = "require(['jquery', 'prototype'], function(jQuery){
window.toggleSolution = function (id, url) {
var doScroll = false;
Fieldset.toggleCollapse(id, url);
if ($(this).hasClassName(\"open\")) {
$$(\".with-button button.button\").each(function(anotherButton) {
if (anotherButton != this && $(anotherButton).hasClassName(\"open\")) {
$(anotherButton).click();
doScroll = true;
}
}.bind(this));
}
if (doScroll) {
var pos = Element.cumulativeOffset($(this));
window.scrollTo(pos[0], pos[1] - 45);
}
}
});";

return $this->_jsHelper->getScript($script);
}
}
4 changes: 3 additions & 1 deletion Controller/Adminhtml/Configuration/MerchantAccounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public function execute()
if (!empty($apiKey) && preg_match('/^\*+$/', $apiKey)) {
$apiKey = '';
}
$response = $this->managementHelper->getMerchantAccountsAndClientKey($apiKey, (bool) $demoMode);

$managementApiService = $this->managementHelper->getManagementApiService($apiKey, $demoMode);
$response = $this->managementHelper->getMerchantAccountsAndClientKey($managementApiService);

$resultJson->setData($response);
return $resultJson;
Expand Down
56 changes: 46 additions & 10 deletions Controller/Adminhtml/Configuration/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@

namespace Adyen\Payment\Controller\Adminhtml\Configuration;

use Adyen\Payment\Helper\Data;
use Adyen\AdyenException;
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Helper\ManagementHelper;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\StoreManager;

class WebhookTest extends Action
{
Expand All @@ -27,42 +31,74 @@ class WebhookTest extends Action
private $managementApiHelper;

/**
* @var Data
* @var Config
*/
protected $dataHelper;
protected $configHelper;

/**
* @var JsonFactory
*/
protected $resultJsonFactory;

/**
* @var Context
*/
protected $context;

/**
* @var StoreManager
*/
protected $storeManager;

/**
* @param Context $context
* @param ManagementHelper $managementApiHelper
* @param JsonFactory $resultJsonFactory
* @param StoreManager $storeManager
* @param Config $configHelper
*/
public function __construct(
Context $context,
ManagementHelper $managementApiHelper,
Data $dataHelper,
JsonFactory $resultJsonFactory
JsonFactory $resultJsonFactory,
StoreManager $storeManager,
Config $configHelper
) {
parent::__construct($context);
$this->managementApiHelper = $managementApiHelper;
$this->dataHelper = $dataHelper;
$this->resultJsonFactory = $resultJsonFactory;
$this->context = $context;
$this->storeManager = $storeManager;
$this->configHelper = $configHelper;
}

/**
* @return ResultInterface
* @return ResponseInterface|Json|ResultInterface
* @throws AdyenException
* @throws NoSuchEntityException
*/
public function execute()
{
$merchantAccount = $this->dataHelper->getAdyenMerchantAccount('adyen_cc');
$response = $this->managementApiHelper->webhookTest($merchantAccount);
$success = isset($response['data']) &&
$storeId = $this->storeManager->getStore()->getId();

$merchantAccount = $this->configHelper->getMerchantAccount($storeId);
$webhookId = $this->configHelper->getWebhookId($storeId);
$isDemoMode = $this->configHelper->isDemoMode($storeId);
$environment = $isDemoMode ? 'test' : 'live';
$apiKey = $this->configHelper->getApiKey($environment, $storeId);

$managementApiService = $this->managementApiHelper->getManagementApiService($apiKey, $isDemoMode);
$response = $this->managementApiHelper->webhookTest($merchantAccount, $webhookId, $managementApiService);

$success = isset($response['data']) &&
in_array('success', array_column($response['data'], 'status'), true);

$resultJson = $this->resultJsonFactory->create();
$resultJson->setData([
'messages' => $response,
'statusCode' => $success ? 'Success' : 'Failed'
]);

return $resultJson;
}
}
Loading