Skip to content

Commit

Permalink
Merge pull request #502 from Adyen/develop
Browse files Browse the repository at this point in the history
Release v4.0.0-rc1
  • Loading branch information
candemiralp authored May 23, 2024
2 parents 7a032a2 + 562275c commit 573e355
Show file tree
Hide file tree
Showing 55 changed files with 719 additions and 768 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:

- name: Initiate Dockware
run: |
docker pull dockware/dev:6.5.2.1
docker pull dockware/dev:latest
docker run --rm -p 443:443 --name shopware6 \
--mount type=bind,source="$(pwd)",target=/data/extensions/workdir \
--env PHP_VERSION=8.2 -d dockware/dev:6.5.2.1
--env PHP_VERSION=8.2 -d dockware/dev:latest
sleep 30
docker logs shopware6
docker exec shopware6 bash -c "sudo mysql -u root -proot shopware -e \"UPDATE sales_channel_domain SET url='https://local.shopware.shop' WHERE url NOT LIKE 'default.%';\""
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Install/Configure Plugin
run: |
docker exec shopware6 bash -c "composer config --json repositories.local '{\"type\": \"path\", \"url\": \"/data/extensions/workdir\", \"options\": { \"symlink\": false } }'"
docker exec shopware6 bash -c 'composer require adyen/adyen-shopware6:*'
docker exec shopware6 bash -c 'composer require adyen/adyen-shopware6:*@RC'
docker exec shopware6 bash -c 'php bin/console plugin:refresh'
docker exec shopware6 bash -c 'php bin/console plugin:install AdyenPaymentShopware6 --activate'
docker exec shopware6 bash -c 'php bin/console cache:clear'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ 7.4, 8.0, 8.1, 8.2 ]
php-version: [ 8.2, 8.3 ]

steps:
- name: Setup PHP
Expand All @@ -16,7 +16,7 @@ jobs:
php-version: ${{ matrix.php-version }}

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

- name: Validate composer.json and composer.lock
run: composer validate
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/scripts/prepare-release-asset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Create a copy of the plugin directory
cd ..
cp -r adyen-shopware6 AdyenPaymentShopware6

# Remove Shopware dependencies
composer remove shopware/core --working-dir=./AdyenPaymentShopware6
composer remove shopware/storefront --working-dir=./AdyenPaymentShopware6

# Remove composer.lock again and vendor directory
rm AdyenPaymentShopware6/composer.lock
rm -rf AdyenPaymentShopware6/vendor

# Install dependencies
composer install --no-dev --working-dir=./AdyenPaymentShopware6

# Copy original the composer.json file
cp adyen-shopware6/composer.json AdyenPaymentShopware6/.

# Zip the plugin directory
zip -r AdyenPaymentShopware6.zip AdyenPaymentShopware6/ ;

# Cleanup the zip installation
zip -d AdyenPaymentShopware6.zip __MACOSX/\* ; zip -d AdyenPaymentShopware6.zip *.git*

# Move the zip file to plugin folder
mv AdyenPaymentShopware6.zip adyen-shopware6

# Go back to workflow's root directory
cd adyen-shopware6
22 changes: 22 additions & 0 deletions .github/workflows/upload-release-asset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
release:
types: [published]

name: Upload Shopware 6 Marketplace asset

jobs:
run:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Prepare release artifact
run: .github/workflows/scripts/prepare-release-asset.sh

- name: Upload asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.ref_name }} AdyenPaymentShopware6.zip --clobber
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
}
],
"description": "Official Shopware 6 Plugin to connect to Payment Service Provider Adyen",
"version": "3.15.0",
"version": "4.0.0-rc1",
"type": "shopware-platform-plugin",
"license": "MIT",
"require": {
"shopware/core": "~6.4.0 || ~6.5.0",
"shopware/storefront": "~6.4.0 || ~6.5.0",
"shopware/core": "~6.6.0",
"shopware/storefront": "~6.6.0",
"adyen/php-api-library": "^17.5.0",
"adyen/php-webhook-module": "0.8.0",
"adyen/php-webhook-module": "^1",
"ext-json": "*"
},
"extra": {
Expand Down Expand Up @@ -41,8 +41,8 @@
}
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
"phpunit/phpunit": "^9"
"squizlabs/php_codesniffer": "^3.7",
"phpunit/phpunit": "^10.4"
},
"config": {
"allow-plugins": {
Expand Down
51 changes: 1 addition & 50 deletions src/AdyenPaymentShopware6.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,54 +47,15 @@

class AdyenPaymentShopware6 extends Plugin
{
public function installJsAssets($shopwareVersion)
{
$storefrontAssetPath = __DIR__ . '/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware6.js';
$adminAssetPath = __DIR__ . '/Resources/public/administration/js/adyen-payment-shopware6.js';
if (\version_compare($shopwareVersion, '6.5.0.0', '<')) {
$resultStorefront = $this->safeCopyAsset(
__DIR__ . '/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware64.js.dist',
$storefrontAssetPath
);
$resultAdmin = $this->safeCopyAsset(
__DIR__ . '/Resources/public/administration/js/adyen-payment-shopware64.js.dist',
$adminAssetPath
);
} else {
$resultStorefront = $this->safeCopyAsset(
__DIR__ . '/Resources/app/storefront/dist/storefront/js/adyen-payment-shopware65.js.dist',
$storefrontAssetPath
);
$resultAdmin = $this->safeCopyAsset(
__DIR__ . '/Resources/public/administration/js/adyen-payment-shopware64.js.dist',
$adminAssetPath
);
}

if (!$resultStorefront) {
// @todo: add notice:
// Unable to install your storefront javascript assets, please run the command `bin/build-storefront.sh`
// from your Shopware web directory
}

if (!$resultAdmin) {
// @todo: add notice:
// Unable to install your admin javascript assets, please run the command `bin/build-administration.sh`
// from your Shopware web directory
}
}

public function install(InstallContext $installContext): void
{
$this->installJsAssets($installContext->getCurrentShopwareVersion());
foreach (PaymentMethods\PaymentMethods::PAYMENT_METHODS as $paymentMethod) {
$this->addPaymentMethod(new $paymentMethod(), $installContext->getContext());
}
}

public function activate(ActivateContext $activateContext): void
{
$this->installJsAssets($activateContext->getCurrentShopwareVersion());
foreach (PaymentMethods\PaymentMethods::PAYMENT_METHODS as $paymentMethod) {
$this->setPaymentMethodIsActive(true, $activateContext->getContext(), new $paymentMethod());
}
Expand Down Expand Up @@ -128,7 +89,6 @@ public function uninstall(UninstallContext $uninstallContext): void

public function update(UpdateContext $updateContext): void
{
$this->installJsAssets($updateContext->getCurrentShopwareVersion());
$currentVersion = $updateContext->getCurrentPluginVersion();

if (\version_compare($currentVersion, '1.2.0', '<')) {
Expand Down Expand Up @@ -253,7 +213,7 @@ private function setPaymentMethodIsActive(
$paymentRepository->update([$paymentMethodData], $context);
}

private function removePluginData()
private function removePluginData(): void
{
//Search for config keys that contain the bundle's name
/** @var EntityRepository $systemConfigRepository */
Expand Down Expand Up @@ -501,15 +461,6 @@ private function updateTo3150(UpdateContext $updateContext): void
}
}

private function safeCopyAsset($source, $destination): bool
{
try {
return copy($source, $destination);
} catch (\Exception $e) {
return false;
}
}

/**
* @param UpdateContext $updateContext
* @param string $paymentMethodHandler
Expand Down
15 changes: 10 additions & 5 deletions src/Command/DisablePaymentMethodCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@
namespace Adyen\Shopware\Command;

use Adyen\Shopware\Handlers\Command\PaymentMethodStatusHandler;
use Exception;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'adyen:payment-method:disable', description: 'Disables Adyen payment methods')]
class DisablePaymentMethodCommand extends Command
{
protected static $defaultName = 'adyen:payment-method:disable';

/**
* @var PaymentMethodStatusHandler
*/
protected PaymentMethodStatusHandler $handler;

/**
* @param PaymentMethodStatusHandler $handler
*/
public function __construct(PaymentMethodStatusHandler $handler)
{
parent::__construct();
Expand Down Expand Up @@ -73,14 +77,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($isAllSelected xor isset($paymentMethodHandlerIdentifier)) {
$this->handler->run($isAllSelected, false, $paymentMethodHandlerIdentifier);
$message = 'Payment method is disabled successfully.';
$output->writeln($message);
} else {
throw new \Exception('Invalid parameter! For usage please check manual --help.');
}
} catch (\Exception $e) {
$message = $e->getMessage();
} catch (Exception $e) {
$output->writeln($e->getMessage());
return Command::FAILURE;
}

$output->writeln($message);
return Command::SUCCESS;
}
}
12 changes: 8 additions & 4 deletions src/Command/EnablePaymentMethodCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@
namespace Adyen\Shopware\Command;

use Adyen\Shopware\Handlers\Command\PaymentMethodStatusHandler;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'adyen:payment-method:enable', description: 'Enables Adyen payment methods')]
class EnablePaymentMethodCommand extends Command
{
protected static $defaultName = 'adyen:payment-method:enable';

/**
* @var PaymentMethodStatusHandler
*/
protected PaymentMethodStatusHandler $handler;

/**
* @param PaymentMethodStatusHandler $handler
*/
public function __construct(PaymentMethodStatusHandler $handler)
{
parent::__construct();
Expand Down Expand Up @@ -73,14 +76,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($isAllSelected xor isset($paymentMethodHandlerIdentifier)) {
$this->handler->run($isAllSelected, true, $paymentMethodHandlerIdentifier);
$message = 'Payment method is enabled successfully.';
$output->writeln($message);
} else {
throw new \Exception('Invalid parameter! For usage please check manual --help.');
}
} catch (\Exception $e) {
$message = $e->getMessage();
$output->writeln($e->getMessage());
return Command::FAILURE;
}

$output->writeln($message);
return Command::SUCCESS;
}
}
9 changes: 6 additions & 3 deletions src/Command/FetchPaymentMethodLogosCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@
namespace Adyen\Shopware\Command;

use Adyen\Shopware\ScheduledTask\FetchPaymentMethodLogosHandler;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'adyen:fetch-logos', description: 'Fetches Adyen payment method logos')]
class FetchPaymentMethodLogosCommand extends Command
{
protected static $defaultName = 'adyen:fetch-logos';

/**
* @var FetchPaymentMethodLogosHandler
*/
protected $handler;
protected FetchPaymentMethodLogosHandler $handler;

/**
* @param FetchPaymentMethodLogosHandler $handler
*/
public function __construct(FetchPaymentMethodLogosHandler $handler)
{
parent::__construct();
Expand Down
13 changes: 8 additions & 5 deletions src/Command/ProcessWebhooksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@
namespace Adyen\Shopware\Command;

use Adyen\Shopware\ScheduledTask\ProcessNotificationsHandler;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'adyen:process-webhooks', description: 'Processes scheduled webhooks')]
class ProcessWebhooksCommand extends Command
{
protected static $defaultName = 'adyen:process-webhooks';

/**
* @var ProcessNotificationsHandler
*/
protected $handler;
protected ProcessNotificationsHandler $handler;

/**
* @param ProcessNotificationsHandler $handler
*/
public function __construct(ProcessNotificationsHandler $handler)
{
parent::__construct();
Expand All @@ -46,13 +49,13 @@ public function __construct(ProcessNotificationsHandler $handler)

protected function configure(): void
{
$this->setDescription('Process webhook notifications');
$this->setDescription('Process webhook notifications.');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->handler->run();
$output->writeln('Webhook notifications have been processed');
$output->writeln('Webhook notifications have been processed.');
return Command::SUCCESS;
}
}
9 changes: 6 additions & 3 deletions src/Command/ScheduleWebhooksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@
namespace Adyen\Shopware\Command;

use Adyen\Shopware\ScheduledTask\ScheduleNotificationsHandler;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'adyen:schedule-webhooks', description: 'Schedules Adyen webhooks')]
class ScheduleWebhooksCommand extends Command
{
protected static $defaultName = 'adyen:schedule-webhooks';

/**
* @var ScheduleNotificationsHandler
*/
protected $handler;
protected ScheduleNotificationsHandler $handler;

/**
* @param ScheduleNotificationsHandler $handler
*/
public function __construct(ScheduleNotificationsHandler $handler)
{
parent::__construct();
Expand Down
Loading

0 comments on commit 573e355

Please sign in to comment.