Skip to content

Commit

Permalink
Merge branch 'main' into feature/log-invoice-creation-as-info
Browse files Browse the repository at this point in the history
  • Loading branch information
candemiralp authored Feb 21, 2025
2 parents 783d9d7 + 12c5c93 commit ae51513
Show file tree
Hide file tree
Showing 67 changed files with 2,313 additions and 376 deletions.
2 changes: 1 addition & 1 deletion .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ magento:
install:
composer config --json repositories.local '{"type": "path", "url": "/data/extensions/workdir", "options": { "symlink": false } }'
composer require "adyen/module-payment:*"
vendor/bin/phpcs --standard=Magento2 --extensions=php,phtml --error-severity=10 --ignore-annotations -n -p vendor/adyen/module-payment
vendor/bin/phpcs --standard=Magento2 --extensions=php,phtml --error-severity=10 -n -p vendor/adyen/module-payment
bin/magento module:enable Adyen_Payment
bin/magento setup:upgrade
bin/magento setup:di:compile
Expand Down
2 changes: 2 additions & 0 deletions .github/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
paths-ignore:
- 'view/base/web/js'
12 changes: 5 additions & 7 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ name: "CodeQL"

on:
pull_request:
paths-ignore:
- 'view/base/web/js/**'
workflow_dispatch:

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
timeout-minutes: 25
permissions:
actions: read
contents: read
Expand All @@ -24,15 +24,13 @@ jobs:
uses: actions/checkout@v3

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

- name: Autobuild
uses: github/codeql-action/autobuild@v2
config-file: ./.github/codeql-config.yml

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
1 change: 1 addition & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
contents: write
pull-requests: write
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- name: Prepare the next main release
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ jobs:
WEBHOOK_PASSWORD: 1234
CI: TRUE

- name: Delete Webhook
run: |
echo "Running DeleteWebhook command after E2E tests for clean-up"
docker exec -u www-data magento2-container php bin/magento adyen:management:delete-webhook
- name: Archive test result artifacts
if: always()
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/graphql-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
php-version: ["8.2"]
magento-version: ["2.4.6-p7"]
runs-on: ubuntu-latest
timeout-minutes: 25
env:
PHP_VERSION: ${{ matrix.php-version }}
MAGENTO_VERSION: ${{ matrix.magento-version }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
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) || (github.event_name == 'workflow_dispatch')
environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }}
runs-on: ubuntu-latest

timeout-minutes: 25
strategy:
matrix:
php-version: [8.2,8.3]
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:

- name: SonarCloud Scan
if: ${{ env.SONAR_TOKEN }}
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/marketplace-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
marketplace-automation:
runs-on: ubuntu-latest
# environment: internal
timeout-minutes: 25

steps:
- name: Checkout repository
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/mftf-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- php-version: '8.3'
magento-version: '2.4.7-p2'
runs-on: ubuntu-latest
timeout-minutes: 25
env:
PHP_VERSION: ${{ matrix.php-version }}
MAGENTO_VERSION: ${{ matrix.magento-version }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/restapi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
php-version: [8.3]
magento-version: [2.4.7-p2]
runs-on: ubuntu-latest
timeout-minutes: 25
env:
PHP_VERSION: ${{ matrix.php-version }}
MAGENTO_VERSION: ${{ matrix.magento-version }}
Expand Down
2 changes: 2 additions & 0 deletions Api/Data/NotificationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ interface NotificationInterface
/**
* Constants for keys of data array. Identical to the name of the getter in snake case.
*/
const TABLE_NAME = 'adyen_notification';
const TABLE_NAME_ALIAS = 'notification';
const ENTITY_ID = 'entity_id';
const PSPREFRENCE = 'pspreference';
const ORIGINAL_REFERENCE = 'original_reference';
Expand Down
22 changes: 22 additions & 0 deletions Api/Repository/AdyenNotificationRepositoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
/**
*
* Adyen Payment Module
*
* Copyright (c) 2025 Adyen N.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/

namespace Adyen\Payment\Api\Repository;

interface AdyenNotificationRepositoryInterface
{
/**
* @param array $entityIds
* @return void
*/
public function deleteByIds(array $entityIds): void;
}
45 changes: 45 additions & 0 deletions Block/Adminhtml/Notification/WebhookRemovalJobNotice.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/

namespace Adyen\Payment\Block\Adminhtml\Notification;

use Adyen\Payment\Helper\Config;
use Magento\Framework\View\Element\Template\Context;
use Magento\Theme\Block\Html\Notices;

class WebhookRemovalJobNotice extends Notices
{
public function __construct(
Context $context,
private readonly Config $configHelper,
array $data = []
) {
parent::__construct($context, $data);
}

/**
* @return bool
*/
public function isProcessedWebhookRemovalEnabled(): bool
{
return $this->configHelper->getIsProcessedWebhookRemovalEnabled();
}

/**
* Returns the number of days after which the notifications will be cleaned-up.
*
* @return int
*/
public function getNumberOfDays(): int
{
return $this->configHelper->getProcessedWebhookRemovalTime();
}
}
18 changes: 13 additions & 5 deletions Controller/Adminhtml/Notifications/Overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@

namespace Adyen\Payment\Controller\Adminhtml\Notifications;

class Overview extends \Magento\Backend\App\Action
use Magento\Backend\App\Action;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\View\Result\Page;

class Overview extends Action
{
/**
* Load the page defined in corresponding layout XML
*
* @return \Magento\Framework\View\Result\Page
* @return Page
*/
public function execute()
public function execute(): Page
{
$resultPage = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
/** @var Page $resultPage */
$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$resultPage->setActiveMenu('Adyen_Payment::notifications_overview')
->getConfig()->getTitle()->prepend(__('Adyen Notifications Overview'));
->getConfig()
->getTitle()
->prepend(__('Adyen Webhooks Overview'));

return $resultPage;
}
}
59 changes: 59 additions & 0 deletions Cron/Providers/ProcessedWebhooksProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/

namespace Adyen\Payment\Cron\Providers;

use Adyen\Payment\Api\Data\NotificationInterface;
use Adyen\Payment\Helper\Config;
use Adyen\Payment\Model\ResourceModel\Notification\Collection;
use Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory;

class ProcessedWebhooksProvider implements WebhooksProviderInterface
{
/**
* @param CollectionFactory $notificationCollectionFactory
* @param Config $configHelper
*/
public function __construct(
private readonly CollectionFactory $notificationCollectionFactory,
private readonly Config $configHelper
) { }

/**
* Provides the `entity_id`s of the processed webhooks limited by the removal time
*
* @return array
*/
public function provide(): array
{
$numberOfDays = $this->configHelper->getProcessedWebhookRemovalTime();

/** @var Collection $notificationCollection */
$notificationCollection = $this->notificationCollectionFactory->create();
$notificationCollection->getProcessedWebhookIdsByTimeLimit($numberOfDays, self::BATCH_SIZE);

if ($notificationCollection->getSize() > 0) {
return $notificationCollection->getColumnValues(NotificationInterface::ENTITY_ID);
} else {
return [];
}
}

/**
* Returns the provider name
*
* @return string
*/
public function getProviderName(): string
{
return "Adyen processed webhooks provider";
}
}
27 changes: 27 additions & 0 deletions Cron/Providers/WebhooksProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/

namespace Adyen\Payment\Cron\Providers;

interface WebhooksProviderInterface
{
const BATCH_SIZE = 1000;

/**
* @return array
*/
public function provide(): array;

/**
* @return string
*/
public function getProviderName(): string;
}
Loading

0 comments on commit ae51513

Please sign in to comment.