diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 51c3097d..d5f0f1e6 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -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.%';\"" @@ -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' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aa244284..d138e288 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 diff --git a/.github/workflows/scripts/prepare-release-asset.sh b/.github/workflows/scripts/prepare-release-asset.sh new file mode 100755 index 00000000..7be70654 --- /dev/null +++ b/.github/workflows/scripts/prepare-release-asset.sh @@ -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 diff --git a/.github/workflows/upload-release-asset.yml b/.github/workflows/upload-release-asset.yml new file mode 100644 index 00000000..22c45144 --- /dev/null +++ b/.github/workflows/upload-release-asset.yml @@ -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 diff --git a/composer.json b/composer.json index c6b104ff..ca55fd34 100644 --- a/composer.json +++ b/composer.json @@ -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": { @@ -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": { diff --git a/src/AdyenPaymentShopware6.php b/src/AdyenPaymentShopware6.php index 0dae2971..e2d4dd81 100644 --- a/src/AdyenPaymentShopware6.php +++ b/src/AdyenPaymentShopware6.php @@ -47,46 +47,8 @@ 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()); } @@ -94,7 +56,6 @@ public function install(InstallContext $installContext): void public function activate(ActivateContext $activateContext): void { - $this->installJsAssets($activateContext->getCurrentShopwareVersion()); foreach (PaymentMethods\PaymentMethods::PAYMENT_METHODS as $paymentMethod) { $this->setPaymentMethodIsActive(true, $activateContext->getContext(), new $paymentMethod()); } @@ -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', '<')) { @@ -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 */ @@ -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 diff --git a/src/Command/DisablePaymentMethodCommand.php b/src/Command/DisablePaymentMethodCommand.php index 7410752c..d22bd20c 100644 --- a/src/Command/DisablePaymentMethodCommand.php +++ b/src/Command/DisablePaymentMethodCommand.php @@ -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(); @@ -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; } } diff --git a/src/Command/EnablePaymentMethodCommand.php b/src/Command/EnablePaymentMethodCommand.php index 8fd1e458..e5a143a2 100644 --- a/src/Command/EnablePaymentMethodCommand.php +++ b/src/Command/EnablePaymentMethodCommand.php @@ -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(); @@ -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; } } diff --git a/src/Command/FetchPaymentMethodLogosCommand.php b/src/Command/FetchPaymentMethodLogosCommand.php index e31825aa..9107735c 100644 --- a/src/Command/FetchPaymentMethodLogosCommand.php +++ b/src/Command/FetchPaymentMethodLogosCommand.php @@ -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(); diff --git a/src/Command/ProcessWebhooksCommand.php b/src/Command/ProcessWebhooksCommand.php index f959699b..c72484f7 100644 --- a/src/Command/ProcessWebhooksCommand.php +++ b/src/Command/ProcessWebhooksCommand.php @@ -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(); @@ -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; } } diff --git a/src/Command/ScheduleWebhooksCommand.php b/src/Command/ScheduleWebhooksCommand.php index 4323409a..48bb36f4 100644 --- a/src/Command/ScheduleWebhooksCommand.php +++ b/src/Command/ScheduleWebhooksCommand.php @@ -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(); diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 8effab36..e119d694 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -48,53 +48,49 @@ use Shopware\Core\System\Currency\CurrencyFormatter; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Throwable; -/** - * Class AdminController - * @package Adyen\Shopware\Controller - * @Route(defaults={"_routeScope"={"administration"}}) - */ +#[Route(defaults: ['_routeScope' => ['administration']])] class AdminController { const ADMIN_DATETIME_FORMAT = 'Y-m-d H:i (e)'; /** @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; /** @var OrderRepository */ - private $orderRepository; + private OrderRepository $orderRepository; /** @var RefundService */ - private $refundService; + private RefundService $refundService; /** @var AdyenRefundRepository */ - private $adyenRefundRepository; + private AdyenRefundRepository $adyenRefundRepository; /** @var NotificationService */ - private $notificationService; + private NotificationService $notificationService; /** @var CurrencyFormatter */ - private $currencyFormatter; + private CurrencyFormatter $currencyFormatter; /** @var Currency */ - private $currencyUtil; + private Currency $currencyUtil; /** @var CaptureService */ - private $captureService; + private CaptureService $captureService; /** @var AdyenPaymentCaptureRepository */ - private $adyenPaymentCaptureRepository; + private AdyenPaymentCaptureRepository $adyenPaymentCaptureRepository; /** @var ConfigurationService */ - private $configurationService; + private ConfigurationService $configurationService; /** @var AdyenPaymentService */ - private $adyenPaymentService; + private AdyenPaymentService $adyenPaymentService; /** @var OrderTransactionRepository */ - private $orderTransactionRepository; + private OrderTransactionRepository $orderTransactionRepository; /** * AdminController constructor. @@ -141,16 +137,17 @@ public function __construct( } /** - * @Route(path="/api/_action/adyen/verify") - * * @param RequestDataBag $dataBag * @return JsonResponse */ + #[Route('/api/_action/adyen/verify', name: 'api.action.adyen.verify', methods: ['POST', 'GET'])] public function check(RequestDataBag $dataBag): JsonResponse { try { $client = new Client(); - $environment = $dataBag->get(ConfigurationService::BUNDLE_NAME . '.config.environment') ? 'live' : 'test'; + $environment = $dataBag->get(ConfigurationService::BUNDLE_NAME . '.config.environment') ? + 'live' : + 'test'; $client->setXApiKey( $dataBag->get(ConfigurationService::BUNDLE_NAME . '.config.apiKey' . ucfirst($environment)) ); @@ -179,16 +176,11 @@ public function check(RequestDataBag $dataBag): JsonResponse /** * Send a capture request to the Adyen platform * - * @Route( - * "/api/adyen/capture", - * name="api.adyen_payment_capture.post", - * methods={"POST"} - * ) - * * @param Request $request * @return JsonResponse */ - public function sendCaptureRequest(Request $request) + #[Route('/api/adyen/capture', name: 'api.adyen_payment_capture.post', methods: ['POST'])] + public function sendCaptureRequest(Request $request): JsonResponse { $context = Context::createDefaultContext(); $orderId = $request->request->get('orderId'); @@ -236,15 +228,11 @@ public function sendCaptureRequest(Request $request) /** * Get payment capture requests by order * - * @Route( - * "/api/adyen/orders/{orderId}/captures", - * name="api.adyen_payment_capture.get", - * methods={"GET"} - * ) * @param string $orderId * @return JsonResponse */ - public function getCaptureRequests(string $orderId) + #[Route('/api/adyen/orders/{orderId}/captures', name: 'api.adyen_payment_capture.get', methods: ['GET'])] + public function getCaptureRequests(string $orderId): JsonResponse { $captureRequests = $this->adyenPaymentCaptureRepository->getCaptureRequestsByOrderId($orderId); @@ -254,15 +242,15 @@ public function getCaptureRequests(string $orderId) /** * Get payment capture requests by order * - * @Route( - * "/api/adyen/orders/{orderId}/is-capture-allowed", - * name="api.adyen_payment_capture_allowed.get", - * methods={"GET"} - * ) * @param string $orderId * @return JsonResponse */ - public function isCaptureAllowed(string $orderId) + #[Route( + '/api/adyen/orders/{orderId}/is-capture-allowed', + name: 'api.adyen_payment_capture_allowed.get', + methods: ['GET'] + )] + public function isCaptureAllowed(string $orderId): JsonResponse { $orderTransaction = $this->orderTransactionRepository->getFirstAdyenOrderTransactionByStates( $orderId, @@ -289,22 +277,22 @@ public function isCaptureAllowed(string $orderId) } /** - * @Route( - * "/api/adyen/orders/{orderId}/is-manual-capture-enabled", - * name="api.adyen_payment_capture_enabled.get", - * methods={"GET"} - * ) * @param string $orderId * @return JsonResponse */ - public function isManualCaptureEnabled(string $orderId) + #[Route( + '/api/adyen/orders/{orderId}/is-manual-capture-enabled', + name: 'api.adyen_payment_capture_enabled.get', + methods: ['GET'] + )] + public function isManualCaptureEnabled(string $orderId): JsonResponse { try { $orderTransaction = $this->orderTransactionRepository->getFirstAdyenOrderTransaction($orderId); if (is_null($orderTransaction)) { return new JsonResponse(false); } - + $paymentMethodHandlerIdentifier = $orderTransaction->getPaymentMethod()->getHandlerIdentifier(); return new JsonResponse( @@ -318,15 +306,10 @@ public function isManualCaptureEnabled(string $orderId) /** * Send a refund operation to the Adyen platform * - * @Route( - * "/api/adyen/refunds", - * name="api.adyen_refund.post", - * methods={"POST"} - * ) - * * @param Request $request * @return JsonResponse */ + #[Route('/api/adyen/refunds', name: 'api.adyen_refund.post', methods: ['POST'])] public function postRefund(Request $request): JsonResponse { $context = Context::createDefaultContext(); @@ -381,15 +364,10 @@ public function postRefund(Request $request): JsonResponse } /** - * @Route( - * "/api/adyen/orders/{orderId}/refunds", - * name="api.adyen_refund.get", - * methods={"GET"} - * ) - * * @param string $orderId * @return JsonResponse */ + #[Route('/api/adyen/orders/{orderId}/refunds', name: 'api.adyen_refund.get', methods: ['GET'])] public function getRefunds(string $orderId): JsonResponse { $refunds = $this->adyenRefundRepository->getRefundsByOrderId($orderId); @@ -400,13 +378,10 @@ public function getRefunds(string $orderId): JsonResponse /** * Get all the notifications for an order. * - * @Route( - * "/api/adyen/orders/{orderId}/notifications", - * methods={"GET"} - * ) * @param string $orderId * @return JsonResponse */ + #[Route('/api/adyen/orders/{orderId}/notifications', name: 'api.adyen_notifications.get', methods: ['GET'])] public function getOrderNotifications(string $orderId): JsonResponse { $order = $this->orderRepository->getOrder($orderId, Context::createDefaultContext()); @@ -440,13 +415,10 @@ public function getOrderNotifications(string $orderId): JsonResponse /** * Get all the authorised payments of an order from adyen_payment table. * - * @Route( - * "/api/adyen/orders/{orderId}/partial-payments", - * methods={"GET"} - * ) * @param string $orderId * @return JsonResponse */ + #[Route('/api/adyen/orders/{orderId}/partial-payments', name: 'api.adyen_partial_payments.get', methods: ['GET'])] public function getPartialPayments(string $orderId): JsonResponse { $order = $this->orderRepository->getOrder($orderId, Context::createDefaultContext()); @@ -476,7 +448,7 @@ public function getPartialPayments(string $orderId): JsonResponse * @param array $entities * @return array */ - private function buildResponseData(array $entities) + private function buildResponseData(array $entities): array { $context = Context::createDefaultContext(); $result = []; @@ -504,15 +476,14 @@ private function buildResponseData(array $entities) } /** - * @Route( - * "/api/adyen/reschedule-notification/{notificationId}", - * name="admin.action.adyen.reschedule-notification", - * methods={"GET"} - * ) - * * @param string $notificationId * @return JsonResponse */ + #[Route( + '/api/adyen/reschedule-notification/{notificationId}', + name: 'admin.action.adyen.reschedule-notification', + methods: ['GET'] + )] public function rescheduleNotification(string $notificationId): JsonResponse { $notification = $this->notificationService->getNotificationById($notificationId); diff --git a/src/Controller/StoreApi/Donate/DonateController.php b/src/Controller/StoreApi/Donate/DonateController.php index 5f014ec3..e9c7825f 100644 --- a/src/Controller/StoreApi/Donate/DonateController.php +++ b/src/Controller/StoreApi/Donate/DonateController.php @@ -38,41 +38,40 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; -/** - * Class DonateController - * @package Adyen\Shopware\Controller\StoreApi\Donate - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] class DonateController { /** * @var OrderTransactionRepository */ - private $adyenOrderTransactionRepository; + private OrderTransactionRepository $adyenOrderTransactionRepository; + /** * @var EntityRepository */ - private $orderTransactionRepository; + private EntityRepository $orderTransactionRepository; + /** * @var DonationService */ - private $donationService; + private DonationService $donationService; /** * @var ConfigurationService */ - private $configurationService; + private ConfigurationService $configurationService; /** * @var Currency */ - private $currency; + private Currency $currency; + /** * @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; /** * StoreApiController constructor. @@ -81,6 +80,7 @@ class DonateController * @param OrderTransactionRepository $adyenOrderTransactionRepository * @param EntityRepository $orderTransactionRepository * @param ConfigurationService $configurationService + * @param Currency $currency * @param LoggerInterface $logger */ public function __construct( @@ -100,16 +100,11 @@ public function __construct( } /** - * @Route( - * "/store-api/adyen/donate", - * name="store-api.action.adyen.donate", - * methods={"POST"} - * ) - * * @param Request $request * @param SalesChannelContext $salesChannelContext * @return JsonResponse */ + #[Route('/store-api/adyen/donate', name: 'store-api.action.adyen.donate', methods: ['POST'])] public function donate( Request $request, SalesChannelContext $salesChannelContext diff --git a/src/Controller/StoreApi/OrderApi/OrderApiController.php b/src/Controller/StoreApi/OrderApi/OrderApiController.php index 801a23b2..8fe2cc30 100644 --- a/src/Controller/StoreApi/OrderApi/OrderApiController.php +++ b/src/Controller/StoreApi/OrderApi/OrderApiController.php @@ -24,6 +24,7 @@ namespace Adyen\Shopware\Controller\StoreApi\OrderApi; +use Adyen\AdyenException; use Adyen\Shopware\Exception\ValidationException; use Adyen\Shopware\Service\PaymentMethodsBalanceService; use Adyen\Shopware\Service\OrdersService; @@ -36,83 +37,78 @@ use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Psr\Log\LoggerInterface; -use Symfony\Component\Routing\Annotation\Route; use Shopware\Core\Checkout\Cart\SalesChannel\CartService; +use Symfony\Component\Routing\Attribute\Route; -/** - * Class OrderApiController - * @package Adyen\Shopware\Controller\StoreApi\OrderApi - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] class OrderApiController { /** * @var PaymentMethodsBalanceService */ - private $paymentMethodsBalanceService; + private PaymentMethodsBalanceService $paymentMethodsBalanceService; /** - * @var OrdersService + * @var OrdersService|OrdersCancelService */ - private $ordersCancelService; + private OrdersCancelService|OrdersService $ordersCancelService; /** * @var PaymentStateDataService */ - private $paymentStateDataService; + private PaymentStateDataService $paymentStateDataService; /** * @var CartService */ - private $cartService; - private $logger; - private $contextSwitchRoute; - private $paymentMethodsFilterService; + private CartService $cartService; + + /** + * @var AbstractContextSwitchRoute + */ + private AbstractContextSwitchRoute $contextSwitchRoute; + + /** + * @var PaymentMethodsFilterService + */ + private PaymentMethodsFilterService $paymentMethodsFilterService; /** * StoreApiController constructor. * * @param PaymentMethodsBalanceService $paymentMethodsBalanceService - * @param OrdersService $ordersService * @param OrdersCancelService $ordersCancelService * @param PaymentStateDataService $paymentStateDataService * @param CartService $cartService * @param PaymentMethodsFilterService $paymentMethodsFilterService * @param AbstractContextSwitchRoute $contextSwitchRoute - * @param LoggerInterface $logger */ public function __construct( PaymentMethodsBalanceService $paymentMethodsBalanceService, - OrdersService $ordersService, OrdersCancelService $ordersCancelService, PaymentStateDataService $paymentStateDataService, CartService $cartService, PaymentMethodsFilterService $paymentMethodsFilterService, - AbstractContextSwitchRoute $contextSwitchRoute, - LoggerInterface $logger + AbstractContextSwitchRoute $contextSwitchRoute ) { $this->paymentMethodsBalanceService = $paymentMethodsBalanceService; - $this->ordersService = $ordersService; $this->ordersCancelService = $ordersCancelService; $this->paymentStateDataService = $paymentStateDataService; $this->cartService = $cartService; $this->paymentMethodsFilterService = $paymentMethodsFilterService; $this->contextSwitchRoute = $contextSwitchRoute; - $this->logger = $logger; } /** - * @Route( - * "/store-api/adyen/payment-methods/balance", - * name="store-api.action.adyen.payment-methods.balance", - * methods={"POST"} - * ) - * * @param SalesChannelContext $context * @param Request $request * @return JsonResponse */ + #[Route( + '/store-api/adyen/payment-methods/balance', + name: 'store-api.action.adyen.payment-methods.balance', + methods: ['POST'] + )] public function getPaymentMethodsBalance(SalesChannelContext $context, Request $request): JsonResponse { $paymentMethod = json_decode($request->request->get('paymentMethod', ''), true); @@ -123,16 +119,11 @@ public function getPaymentMethodsBalance(SalesChannelContext $context, Request $ } /** - * @Route( - * "/store-api/adyen/orders/cancel", - * name="store-api.action.adyen.orders.cancel", - * methods={"POST"} - * ) - * * @param SalesChannelContext $context * @param Request $request * @return JsonResponse */ + #[Route('/store-api/adyen/orders/cancel', name: 'store-api.action.adyen.orders.cancel', methods: ['POST'])] public function cancelOrder(SalesChannelContext $context, Request $request): JsonResponse { $orderData = $request->request->get('orderData'); @@ -142,17 +133,13 @@ public function cancelOrder(SalesChannelContext $context, Request $request): Jso } /** - * @Route( - * "/store-api/adyen/giftcard", - * name="store-api.action.adyen.giftcard", - * methods={"POST"} - * ) * @param SalesChannelContext $context * @param Request $request * @return JsonResponse * @throws ValidationException - * @throws \Adyen\AdyenException + * @throws AdyenException */ + #[Route('/store-api/adyen/giftcard', name: 'store-api.action.adyen.giftcard', methods: ['POST'])] public function giftcardStateData(SalesChannelContext $context, Request $request): JsonResponse { // store giftcard state data for context @@ -170,15 +157,11 @@ public function giftcardStateData(SalesChannelContext $context, Request $request } /** - * @Route( - * "/store-api/adyen/giftcard/remove", - * name="store-api.action.adyen.giftcard.remove", - * methods={"POST"} - * ) * @param SalesChannelContext $context * @param Request $request * @return JsonResponse */ + #[Route('/store-api/adyen/giftcard/remove', name: 'store-api.action.adyen.giftcard.remove', methods: ['POST'])] public function deleteGiftCardStateData(SalesChannelContext $context, Request $request): JsonResponse { $stateDateId = $request->request->get('stateDataId'); @@ -188,17 +171,10 @@ public function deleteGiftCardStateData(SalesChannelContext $context, Request $r } /** - * @Route( - * "/store-api/adyen/giftcard", - * name="store-api.action.adyen.giftcard.fetch", - * methods={"POST"} - * ) * @param SalesChannelContext $context - * @param Request $request * @return JsonResponse - * @throws ValidationException - * @throws \Adyen\AdyenException */ + #[Route('/store-api/adyen/giftcard', name: 'store-api.action.adyen.giftcard.fetch', methods: ['POST'])] public function fetchRedeemedGiftcards(SalesChannelContext $context): JsonResponse { $fetchedRedeemedGiftcards = $this->paymentStateDataService diff --git a/src/Controller/StoreApi/Payment/PaymentController.php b/src/Controller/StoreApi/Payment/PaymentController.php index 5b2b00f1..1df7a686 100644 --- a/src/Controller/StoreApi/Payment/PaymentController.php +++ b/src/Controller/StoreApi/Payment/PaymentController.php @@ -26,6 +26,7 @@ use Adyen\Model\Checkout\PaymentDetailsRequest; use Adyen\Shopware\Util\CheckoutStateDataValidator; +use Adyen\Exception\MissingDataException; use Adyen\Shopware\Exception\PaymentFailedException; use Adyen\Shopware\Handlers\PaymentResponseHandler; use Adyen\Shopware\Service\ConfigurationService; @@ -34,13 +35,13 @@ use Adyen\Shopware\Service\PaymentResponseService; use Adyen\Shopware\Service\PaymentStatusService; use Adyen\Shopware\Service\Repository\OrderRepository; +use JsonException; use Psr\Log\LoggerInterface; use Shopware\Core\Checkout\Cart\Price\Struct\CalculatedPrice; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionDefinition; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStateHandler; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates; use Shopware\Core\Checkout\Order\OrderEntity; -use Shopware\Core\Checkout\Order\SalesChannel\OrderService; use Shopware\Core\Checkout\Order\SalesChannel\SetPaymentOrderRouteResponse; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; @@ -51,72 +52,75 @@ use Shopware\Core\System\StateMachine\Transition; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Annotation\Route; -use OpenApi\Annotations as OA; +use Symfony\Component\Routing\Attribute\Route; -/** - * Class PaymentController - * @package Adyen\Shopware\Controller\StoreApi\Payment - * @Route(defaults={"_routeScope"={"store-api"}}) - */ +#[Route(defaults: ['_routeScope' => ['store-api']])] class PaymentController { /** * @var PaymentMethodsService */ - private $paymentMethodsService; + private PaymentMethodsService $paymentMethodsService; + /** * @var PaymentDetailsService */ - private $paymentDetailsService; + private PaymentDetailsService $paymentDetailsService; + /** * @var CheckoutStateDataValidator */ - private $checkoutStateDataValidator; + private CheckoutStateDataValidator $checkoutStateDataValidator; + /** * @var PaymentStatusService */ - private $paymentStatusService; + private PaymentStatusService $paymentStatusService; + /** * @var PaymentResponseHandler */ - private $paymentResponseHandler; + private PaymentResponseHandler $paymentResponseHandler; + /** * @var PaymentResponseService */ - private $paymentResponseService; + private PaymentResponseService $paymentResponseService; + /** * @var OrderRepository */ - private $orderRepository; - /** - * @var OrderService - */ - private $orderService; + private OrderRepository $orderRepository; + /** * @var EntityRepository */ private EntityRepository $orderTransactionRepository; + /** * @var StateMachineRegistry */ - private $stateMachineRegistry; + private StateMachineRegistry $stateMachineRegistry; + /** * @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; + /** * @var ConfigurationService */ - private $configurationService; + private ConfigurationService $configurationService; + /** * @var OrderTransactionStateHandler */ - private $orderTransactionStateHandler; + private OrderTransactionStateHandler $orderTransactionStateHandler; + /** * @var InitialStateIdLoader */ - private $initialStateIdLoader; + private InitialStateIdLoader $initialStateIdLoader; /** * StoreApiController constructor. @@ -128,7 +132,6 @@ class PaymentController * @param PaymentResponseHandler $paymentResponseHandler * @param PaymentResponseService $paymentResponseService * @param OrderRepository $orderRepository - * @param OrderService $orderService * @param StateMachineRegistry $stateMachineRegistry * @param InitialStateIdLoader $initialStateIdLoader * @param EntityRepository $orderTransactionRepository @@ -144,7 +147,6 @@ public function __construct( PaymentResponseHandler $paymentResponseHandler, PaymentResponseService $paymentResponseService, OrderRepository $orderRepository, - OrderService $orderService, StateMachineRegistry $stateMachineRegistry, InitialStateIdLoader $initialStateIdLoader, EntityRepository $orderTransactionRepository, @@ -159,7 +161,6 @@ public function __construct( $this->paymentResponseHandler = $paymentResponseHandler; $this->paymentResponseService = $paymentResponseService; $this->orderRepository = $orderRepository; - $this->orderService = $orderService; $this->stateMachineRegistry = $stateMachineRegistry; $this->orderTransactionRepository = $orderTransactionRepository; $this->configurationService = $configurationService; @@ -169,15 +170,10 @@ public function __construct( } /** - * @Route( - * "/store-api/adyen/payment-methods", - * name="store-api.action.adyen.payment-methods", - * methods={"GET"} - * ) - * * @param SalesChannelContext $context * @return JsonResponse */ + #[Route('/store-api/adyen/payment-methods', name: 'store-api.action.adyen.payment-methods', methods: ['GET'])] public function getPaymentMethods(SalesChannelContext $context): JsonResponse { $paymentMethodsResponse = $this->paymentMethodsService->getPaymentMethods($context); @@ -185,16 +181,11 @@ public function getPaymentMethods(SalesChannelContext $context): JsonResponse } /** - * @Route( - * "/store-api/adyen/payment-details", - * name="store-api.action.adyen.payment-details", - * methods={"POST"} - * ) - * * @param Request $request * @param SalesChannelContext $context * @return JsonResponse */ + #[Route('/store-api/adyen/payment-details', name: 'store-api.action.adyen.payment-details', methods: ['POST'])] public function postPaymentDetails( Request $request, SalesChannelContext $context @@ -270,16 +261,11 @@ function (Context $context) use ($orderTransactionId, $customFields) { } /** - * @Route( - * "/store-api/adyen/payment-status", - * name="store-api.action.adyen.payment-status", - * methods={"POST"} - * ) - * * @param Request $request * @param SalesChannelContext $context * @return JsonResponse */ + #[Route('/store-api/adyen/payment-status', name: 'store-api.action.adyen.payment-status', methods: ['POST'])] public function getPaymentStatus(Request $request, SalesChannelContext $context): JsonResponse { $orderId = $request->request->get('orderId'); @@ -298,38 +284,11 @@ public function getPaymentStatus(Request $request, SalesChannelContext $context) } /** - * @OA\Post( - * path="/adyen/set-payment", - * summary="set payment for an order", - * operationId="orderSetPayment", - * tags={"Store API", "Account"}, - * @OA\RequestBody( - * required=true, - * @OA\JsonContent( - * @OA\Property( - * property="paymentMethodId", - * description="The ID of the new paymentMethod", - * type="string" - * ), - * @OA\Property(property="orderId", description="The ID of the order", type="string") - * ) - * ), - * @OA\Response( - * response="200", - * description="Successfully set a payment", - * @OA\JsonContent(ref="#/components/schemas/SuccessResponse") - * ) - * ) - * @Route( - * "/store-api/adyen/set-payment", - * name="store-api.action.adyen.set-payment", - * methods={"POST"} - * ) - * * @param Request $request * @param SalesChannelContext $context * @return SetPaymentOrderRouteResponse */ + #[Route('/store-api/adyen/set-payment', name: 'store-api.action.adyen.set-payment', methods: ['POST'])] public function updatePaymentMethod(Request $request, SalesChannelContext $context): SetPaymentOrderRouteResponse { $this->setPaymentMethod( @@ -356,7 +315,8 @@ private function setPaymentMethod( function () use ($order, $initialStateId, $orderId, $paymentMethodId, $context): void { if ($order->getTransactions() !== null && $order->getTransactions()->count() >= 1) { foreach ($order->getTransactions() as $transaction) { - if ($transaction->getStateMachineState()->getTechnicalName() + $stateMachineState = $transaction->getStateMachineState(); + if (isset($stateMachineState) && $transaction->getStateMachineState()->getTechnicalName() !== OrderTransactionStates::STATE_CANCELLED) { $this->orderTransactionStateHandler->cancel( $transaction->getId(), @@ -387,18 +347,17 @@ function () use ($order, $initialStateId, $orderId, $paymentMethodId, $context): } /** - * @Route( - * "/store-api/adyen/cancel-order-transaction", - * name="store-api.action.adyen.cancel-order-transaction", - * methods={"POST"} - * ) - * * @param Request $request * @param SalesChannelContext $salesChannelContext * @return JsonResponse - * @throws \Adyen\Exception\MissingDataException - * @throws \JsonException + * @throws MissingDataException + * @throws JsonException */ + #[Route( + '/store-api/adyen/cancel-order-transaction', + name: 'store-api.action.adyen.cancel-order-transaction', + methods: ['POST'] + )] public function cancelOrderTransaction( Request $request, SalesChannelContext $salesChannelContext @@ -407,10 +366,17 @@ public function cancelOrderTransaction( $orderId = $request->request->get('orderId'); $order = $this->orderRepository->getOrder($orderId, $context, ['transactions']); - $transaction = $order->getTransactions()->filterByState(OrderTransactionStates::STATE_IN_PROGRESS)->first(); + $transaction = $order->getTransactions() + ->filterByState(OrderTransactionStates::STATE_IN_PROGRESS) + ->first(); $this->stateMachineRegistry->transition( - new Transition(OrderTransactionDefinition::ENTITY_NAME, $transaction->getId(), 'cancel', 'stateId'), + new Transition( + OrderTransactionDefinition::ENTITY_NAME, + $transaction->getId(), + 'cancel', + 'stateId' + ), $context ); diff --git a/src/Handlers/AbstractPaymentMethodHandler.php b/src/Handlers/AbstractPaymentMethodHandler.php index 56389ac4..d5f78b5c 100644 --- a/src/Handlers/AbstractPaymentMethodHandler.php +++ b/src/Handlers/AbstractPaymentMethodHandler.php @@ -50,10 +50,7 @@ use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStateHandler; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; use Shopware\Core\Checkout\Payment\Cart\PaymentHandler\AsynchronousPaymentHandlerInterface; -use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentFinalizeException; -use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException; -use Shopware\Core\Checkout\Payment\Exception\CustomerCanceledAsyncPaymentException; -use Shopware\Core\Checkout\Payment\Exception\PaymentProcessException; +use Shopware\Core\Checkout\Payment\PaymentException; use Shopware\Core\Content\Product\Exception\ProductNotFoundException; use Shopware\Core\Content\Product\ProductCollection; use Shopware\Core\Content\Product\ProductEntity; @@ -94,77 +91,82 @@ abstract class AbstractPaymentMethodHandler implements AsynchronousPaymentHandle /** * @var ClientService */ - protected $clientService; + protected ClientService $clientService; /** * @var Currency */ - protected $currency; + protected Currency $currency; /** * @var ConfigurationService */ - protected $configurationService; + protected ConfigurationService $configurationService; /** * @var CheckoutStateDataValidator */ - protected $checkoutStateDataValidator; + protected CheckoutStateDataValidator $checkoutStateDataValidator; /** * @var PaymentStateDataService */ - protected $paymentStateDataService; + protected PaymentStateDataService $paymentStateDataService; /** * @var LoggerInterface */ - protected $logger; + protected LoggerInterface $logger; /** * @var SalesChannelRepository */ - protected $salesChannelRepository; + protected SalesChannelRepository $salesChannelRepository; /** * @var PaymentResponseHandler */ - protected $paymentResponseHandler; + protected PaymentResponseHandler $paymentResponseHandler; /** * @var ResultHandler */ - protected $resultHandler; + protected ResultHandler $resultHandler; /** * @var OrderTransactionStateHandler */ - protected $orderTransactionStateHandler; + protected OrderTransactionStateHandler $orderTransactionStateHandler; /** * @var RouterInterface */ - protected $symfonyRouter; + protected RouterInterface $symfonyRouter; /** * @var EntityRepository */ - protected $currencyRepository; + protected EntityRepository $currencyRepository; /** * @var EntityRepository */ - protected $productRepository; + protected EntityRepository $productRepository; /** * @var RequestStack */ - protected $requestStack; + protected RequestStack $requestStack; /** * @var AbstractContextSwitchRoute */ - private $contextSwitchRoute; + private AbstractContextSwitchRoute $contextSwitchRoute; + + /** + * @var OrdersService + */ + private OrdersService $ordersService; private $paymentsApiService; @@ -174,8 +176,6 @@ abstract class AbstractPaymentMethodHandler implements AsynchronousPaymentHandle private $remainingAmount = null; - private OrdersService $ordersService; - /** * AbstractPaymentMethodHandler constructor. * @@ -244,7 +244,7 @@ public static function getBrand(): ?string * @param RequestDataBag $dataBag * @param SalesChannelContext $salesChannelContext * @return RedirectResponse - * @throws PaymentProcessException|AdyenException + * @throws AdyenException */ public function pay( AsyncPaymentTransactionStruct $transaction, @@ -305,16 +305,16 @@ public function pay( if (empty($orderNumber)) { $message = 'Order number is missing'; - throw new AsyncPaymentProcessException($transactionId, $message); + throw PaymentException::asyncProcessInterrupted($transactionId, $message); } try { $this->paymentResponseHandler ->handleShopwareApis($transaction, $salesChannelContext, $this->paymentResults); } catch (PaymentCancelledException $exception) { - throw new CustomerCanceledAsyncPaymentException($transactionId, $exception->getMessage()); + throw PaymentException::customerCanceled($transactionId, $exception->getMessage()); } catch (PaymentFailedException $exception) { - throw new AsyncPaymentFinalizeException($transactionId, $exception->getMessage()); + throw PaymentException::asyncFinalizeInterrupted($transactionId, $exception->getMessage()); } /* @@ -334,7 +334,12 @@ public function pay( return new RedirectResponse($transaction->getReturnUrl()); } - private function createAdyenOrder(SalesChannelContext $salesChannelContext, $transaction) + /** + * @param SalesChannelContext $salesChannelContext + * @param $transaction + * @return array + */ + private function createAdyenOrder(SalesChannelContext $salesChannelContext, $transaction): array { $uuid = Uuid::randomHex(); $currency = $salesChannelContext->getCurrency()->getIsoCode(); @@ -349,8 +354,7 @@ private function createAdyenOrder(SalesChannelContext $salesChannelContext, $tra * @param AsyncPaymentTransactionStruct $transaction * @param Request $request * @param SalesChannelContext $salesChannelContext - * @throws AsyncPaymentFinalizeException - * @throws CustomerCanceledAsyncPaymentException + * @return void */ public function finalize( AsyncPaymentTransactionStruct $transaction, @@ -361,9 +365,9 @@ public function finalize( try { $this->resultHandler->processResult($transaction, $request, $salesChannelContext); } catch (PaymentCancelledException $exception) { - throw new CustomerCanceledAsyncPaymentException($transactionId, $exception->getMessage()); + throw PaymentException::customerCanceled($transactionId, $exception->getMessage()); } catch (PaymentFailedException $exception) { - throw new AsyncPaymentFinalizeException($transactionId, $exception->getMessage()); + throw PaymentException::asyncFinalizeInterrupted($transactionId, $exception->getMessage()); } } @@ -704,7 +708,7 @@ private function getPaymentRequest( $orderRequestData ); return $request; - } catch (AsyncPaymentProcessException $exception) { + } catch (PaymentException $exception) { $this->logger->error($exception->getMessage()); throw $exception; } catch (\Exception $exception) { @@ -714,10 +718,16 @@ private function getPaymentRequest( $exception->getMessage() ); $this->logger->error($message); - throw new AsyncPaymentProcessException($transactionId, $message); + throw PaymentException::asyncProcessInterrupted($transactionId, $message); } } + /** + * @param SalesChannelContext $salesChannelContext + * @param PaymentRequest $request + * @param AsyncPaymentTransactionStruct $transaction + * @return void + */ private function paymentsCall( SalesChannelContext $salesChannelContext, PaymentRequest $request, @@ -747,7 +757,7 @@ private function paymentsCall( ); $this->displaySafeErrorMessages($exception); $this->logger->error($message); - throw new AsyncPaymentProcessException($transactionId, $message); + throw PaymentException::asyncProcessInterrupted($transactionId, $message); } $this->paymentResults[] = $this->paymentResponseHandler ->handlePaymentResponse($response, $transaction->getOrderTransaction(), false); @@ -776,7 +786,11 @@ private function getProduct(string $productId, Context $context): ProductEntity return $product; } - private function displaySafeErrorMessages(AdyenException $exception) + /** + * @param AdyenException $exception + * @return void + */ + private function displaySafeErrorMessages(AdyenException $exception): void { if ('validation' === $exception->getErrorType() && in_array($exception->getAdyenErrorCode(), self::SAFE_ERROR_CODES)) { @@ -816,7 +830,7 @@ private function getSplitStreetAddressHouseNumber(string $address): array /** * @param AsyncPaymentTransactionStruct $transaction - * @param RequestDataBag $dataBag + * @param $adyenOrderResponse * @param SalesChannelContext $salesChannelContext * @return void */ @@ -870,7 +884,7 @@ public function handleAdyenOrderPayment( $this->paymentStateDataService->deletePaymentStateDataFromId($statedataArray->getId()); } if (json_last_error() !== JSON_ERROR_NONE) { - throw new AsyncPaymentProcessException( + throw PaymentException::asyncProcessInterrupted( $transactionId, 'Invalid payment state data.' ); diff --git a/src/Handlers/Command/PaymentMethodStatusHandler.php b/src/Handlers/Command/PaymentMethodStatusHandler.php index c68fad9b..d53f5c84 100644 --- a/src/Handlers/Command/PaymentMethodStatusHandler.php +++ b/src/Handlers/Command/PaymentMethodStatusHandler.php @@ -36,23 +36,23 @@ class PaymentMethodStatusHandler /** * @var AdyenPluginProvider */ - private $adyenPluginProvider; + private AdyenPluginProvider $adyenPluginProvider; - private $paymentMethodRepository; + private EntityRepository $paymentMethodRepository; /** * @var EntityRepository */ - private $salesChannelRepository; + private EntityRepository $salesChannelRepository; /** * @var EntityRepository */ - private $salesChannelPaymentMethodRepository; + private EntityRepository $salesChannelPaymentMethodRepository; public function __construct( AdyenPluginProvider $adyenPluginProvider, - $paymentMethodRepository, + EntityRepository $paymentMethodRepository, EntityRepository $salesChannelRepository, EntityRepository $salesChannelPaymentMethodRepository ) { diff --git a/src/Handlers/PaymentResponseHandler.php b/src/Handlers/PaymentResponseHandler.php index 4f8aba92..35982f78 100644 --- a/src/Handlers/PaymentResponseHandler.php +++ b/src/Handlers/PaymentResponseHandler.php @@ -32,6 +32,7 @@ use Adyen\Shopware\Exception\PaymentFailedException; use Adyen\Shopware\Service\CaptureService; use Adyen\Shopware\Service\ConfigurationService; +use Adyen\Shopware\Service\Repository\OrderTransactionRepository as AdyenOrderTransactionRepository; use Psr\Log\LoggerInterface; use Adyen\Shopware\Service\PaymentResponseService; use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionEntity; @@ -39,6 +40,7 @@ use Shopware\Core\Checkout\Order\Aggregate\OrderTransaction\OrderTransactionStates; use Shopware\Core\Checkout\Payment\Cart\AsyncPaymentTransactionStruct; use Shopware\Core\Framework\Context; +use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\System\SalesChannel\SalesChannelContext; class PaymentResponseHandler @@ -65,48 +67,59 @@ class PaymentResponseHandler // Merchant reference key in API response const MERCHANT_REFERENCE = 'merchantReference'; + /** * @var LoggerInterface */ - private $logger; + private LoggerInterface $logger; /** * @var PaymentResponseService */ - private $paymentResponseService; + private PaymentResponseService $paymentResponseService; /** * @var OrderTransactionStateHandler */ - private $transactionStateHandler; + private OrderTransactionStateHandler $transactionStateHandler; - private $orderTransactionRepository; + /** + * @var EntityRepository + */ + private EntityRepository $orderTransactionRepository; + + /** + * @var AdyenOrderTransactionRepository + */ + private AdyenOrderTransactionRepository $adyenOrderTransactionRepository; /** * @var ConfigurationService */ - private $configurationService; + private ConfigurationService $configurationService; /** * @var CaptureService */ - private $captureService; + private CaptureService $captureService; /** * @param LoggerInterface $logger * @param PaymentResponseService $paymentResponseService * @param OrderTransactionStateHandler $transactionStateHandler - * @param $orderTransactionRepository + * @param EntityRepository $orderTransactionRepository * @param CaptureService $captureService * @param ConfigurationService $configurationService + * @param AdyenOrderTransactionRepository $adyenOrderTransactionRepository */ public function __construct( LoggerInterface $logger, PaymentResponseService $paymentResponseService, OrderTransactionStateHandler $transactionStateHandler, - $orderTransactionRepository, + EntityRepository $orderTransactionRepository, CaptureService $captureService, - ConfigurationService $configurationService + ConfigurationService $configurationService, + AdyenOrderTransactionRepository $adyenOrderTransactionRepository ) { $this->logger = $logger; $this->paymentResponseService = $paymentResponseService; @@ -114,6 +127,7 @@ public function __construct( $this->orderTransactionRepository = $orderTransactionRepository; $this->captureService = $captureService; $this->configurationService = $configurationService; + $this->adyenOrderTransactionRepository = $adyenOrderTransactionRepository; } /** @@ -123,7 +137,7 @@ public function __construct( * @return PaymentResponseHandlerResult */ public function handlePaymentResponse( - $response, + PaymentResponse|PaymentDetailsResponse $response, OrderTransactionEntity $orderTransaction, bool $upsertResponse = true ): PaymentResponseHandlerResult { @@ -230,7 +244,14 @@ public function handleShopwareApis( ): void { $orderTransactionId = $transaction->getOrderTransaction()->getId(); $context = $salesChannelContext->getContext(); - $stateTechnicalName = $transaction->getOrderTransaction()->getStateMachineState()->getTechnicalName(); + + $stateMachineState = $transaction->getOrderTransaction()->getStateMachineState(); + if (is_null($stateMachineState)) { + $orderTransaction = $this->adyenOrderTransactionRepository->getWithId($orderTransactionId); + $stateMachineState = $orderTransaction->getStateMachineState(); + } + + $stateTechnicalName = $stateMachineState->getTechnicalName(); $requiresManualCapture = $this->captureService ->isManualCapture($transaction->getOrderTransaction()->getPaymentMethod()->getHandlerIdentifier()); diff --git a/src/Migration/Migration1609373668AdyenMediaFolder.php b/src/Migration/Migration1609373668AdyenMediaFolder.php index a7222b8f..f9f934f2 100644 --- a/src/Migration/Migration1609373668AdyenMediaFolder.php +++ b/src/Migration/Migration1609373668AdyenMediaFolder.php @@ -23,11 +23,10 @@ public function update(Connection $connection): void $defaultFolderId = Uuid::randomBytes(); $configurationId = Uuid::randomBytes(); $connection->executeStatement(' - INSERT INTO `media_default_folder` (`id`, `association_fields`, `entity`, `created_at`) - VALUES (:id, :associationFields, :entity, :createdAt) + INSERT INTO `media_default_folder` (`id`, `entity`, `created_at`) + VALUES (:id, :entity, :createdAt) ', [ 'id' => $defaultFolderId, - 'associationFields' => '[]', 'entity' => 'adyen', 'createdAt' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT) ]); diff --git a/src/Resources/app/administration/src/component/adyen-config-check-button/index.js b/src/Resources/app/administration/src/component/adyen-config-check-button/index.js index 14fa8968..8069c262 100644 --- a/src/Resources/app/administration/src/component/adyen-config-check-button/index.js +++ b/src/Resources/app/administration/src/component/adyen-config-check-button/index.js @@ -45,8 +45,8 @@ Component.register('adyen-config-check-button', { // i.e. from this.$parent.$parent.$parent to this.$parent.$parent.$parent.$parent // @fixme This is a hack to support all versions let systemConfigComponent = this.$parent; - while (!systemConfigComponent.hasOwnProperty('actualConfigData')) { - systemConfigComponent = systemConfigComponent.$parent + while (systemConfigComponent.actualConfigData === undefined) { + systemConfigComponent = systemConfigComponent.$parent; } let selectedSalesChannelId = systemConfigComponent.currentSalesChannelId; let config = systemConfigComponent.actualConfigData; diff --git a/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.html.twig b/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.html.twig index 0f7ed860..711766fb 100644 --- a/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.html.twig +++ b/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.html.twig @@ -1,8 +1,8 @@ {% block adyen_capture %}
-
-
+
+
{{ $tc('adyen.noCaptureRequests') }}
diff --git a/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.scss b/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.scss index cb347982..efeb194c 100644 --- a/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.scss +++ b/src/Resources/app/administration/src/component/adyen-payment-capture/adyen-payment-capture.scss @@ -20,13 +20,13 @@ * */ -.adyen-card-header { +.adyen-capture-card-header { display: flex; height: 30px; margin-bottom: 15px; } -.adyen-card-header-first { +.adyen-capture-card-header-first { margin-top: auto; width: 100%; } diff --git a/src/Resources/app/administration/src/component/adyen-refund/adyen-refund.html.twig b/src/Resources/app/administration/src/component/adyen-refund/adyen-refund.html.twig index 46bc3abd..400dcb94 100644 --- a/src/Resources/app/administration/src/component/adyen-refund/adyen-refund.html.twig +++ b/src/Resources/app/administration/src/component/adyen-refund/adyen-refund.html.twig @@ -1,8 +1,8 @@ {% block adyen_refund %}
-
-
+
+
{{ $tc('adyen.noRefundsCreated') }}
@@ -20,8 +20,12 @@ :title="$tc('adyen.refundConfirm') + ': ' + order.orderNumber" variant="small">
- + +
\n',inject:["adyenService"],mixins:[t.getByName("notification")],data(){return{isLoading:!1,isSaveSuccessful:!1}},computed:{pluginConfig(){let e=this.$parent;for(;void 0===e.actualConfigData;)e=e.$parent;let t=e.currentSalesChannelId,n=e.actualConfigData;return Object.assign({},n.null,n[t])}},methods:{saveFinish(){this.isSaveSuccessful=!1},check(){this.isLoading=!0,this.adyenService.check(this.pluginConfig).then(e=>{e.success?(this.isSaveSuccessful=!0,this.createNotificationSuccess({title:this.$tc("adyen.configTestTitle"),message:this.$tc("adyen.configTestSuccess")})):this.createNotificationError({title:this.$tc("adyen.configTestTitle"),message:this.$tc(e.message?e.message:"adyen.configTestFail")}),this.isLoading=!1})}}}),n(597);let{Component:a,Mixin:s}=Shopware;a.register("adyen-payment-capture",{template:'{% block adyen_capture %}\n \n
\n
\n
\n {{ $tc(\'adyen.noCaptureRequests\') }}\n
\n
\n \n {{ $tc(\'adyen.sendCaptureRequest\') }}\n \n
\n \n \n \n
\n \n \n
\n
\n {{ $tc(\'adyen.error\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService","systemConfigApiService"],mixins:[s.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],showModal:!1,captureRequests:[],allowCapture:!1,captureEnabled:!1,errorOccurred:!1,isLoading:!0,showWidget:!1}},methods:{openModal(){this.showModal=!0},onCloseModal(){this.showModal=!1},onSubmitCapture(){this.isLoading=!0,this.adyenService.capture(this.order.id).then(e=>{e.success?(this.fetchCaptureRequests(),this.createNotificationSuccess({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc("adyen.captureSuccessful")})):this.createNotificationError({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc(e.message?e.message:"adyen.error")})}).catch(()=>{this.createNotificationError({title:this.$tc("adyen.adyenPaymentCaptureTitle"),message:this.$tc("adyen.error")})}).finally(()=>{this.isLoading=!1,this.showModal=!1})},fetchCaptureRequests(){this.isLoading=!0,this.adyenService.getCaptureRequests(this.order.id).then(e=>{this.captureRequests=e,this.isCaptureAllowed()}).catch(()=>{this.errorOccurred=!0,this.captureRequests=[]}).finally(()=>{this.isLoading=!1})},isManualCaptureEnabled(){this.isLoading=!0,this.adyenService.isManualCaptureEnabled(this.order.id).then(e=>{this.captureEnabled=e,this.showWidget=this.adyenService.isAdyenOrder(this.order)&&this.captureEnabled}).catch(()=>{this.errorOccurred=!0,this.captureEnabled=!1}).finally(()=>{this.isLoading=!1})},isCaptureAllowed(){this.isLoading=!0,this.adyenService.isCaptureAllowed(this.order.id).then(e=>{this.allowCapture=e}).catch(()=>{this.errorOccurred=!0,this.allowCapture=!1}).finally(()=>{this.isLoading=!1})}},beforeMount(){this.isManualCaptureEnabled(),this.fetchCaptureRequests()}}),n(842);let{Component:r,Mixin:i}=Shopware;r.register("adyen-refund",{template:'{% block adyen_refund %}\n \n
\n
\n
\n {{ $tc(\'adyen.noRefundsCreated\') }}\n
\n
\n \n {{ $tc(\'sw-order.documentCard.labelCreateNew\') }}\n \n
\n \n
\n \n \n
\n \n
\n
\n \n \n
\n
\n {{ $tc(\'adyen.refundFetchError\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[i.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],refundAmount:0,showModal:!1,refunds:[],allowRefund:!0,isLoadingTable:!0,errorOccurred:!1,isLoadingRefund:!1,showWidget:!1}},methods:{openModal(){this.showModal=!0},onCloseModal(){this.showModal=!1},onRefund(){this.isLoadingRefund=!0,this.adyenService.postRefund(this.order.id,this.refundAmount).then(e=>{e.success?(this.fetchRefunds(),this.createNotificationSuccess({title:this.$tc("adyen.refundTitle"),message:this.$tc("adyen.refundSuccessful")})):this.createNotificationError({title:this.$tc("adyen.refundTitle"),message:this.$tc(e.message?e.message:"adyen.error")})}).catch(()=>{this.createNotificationError({title:this.$tc("adyen.refundTitle"),message:this.$tc("adyen.error")})}).finally(()=>{this.isLoadingRefund=!1,this.showModal=!1})},fetchRefunds(){this.isLoadingTable=!0,this.adyenService.getRefunds(this.order.id).then(e=>{this.refunds=e,this.isRefundAllowed()}).catch(()=>{this.errorOccurred=!0,this.refunds=[]}).finally(()=>{this.isLoadingTable=!1})},isRefundAllowed(){let e=0;for(let t of this.refunds)"Failed"!==t.status&&(e+=t.rawAmount);this.allowRefund=this.order.amountTotal>e/100},isAdyenOrder(){let e=this.order.transactions,t=!1;for(let n=0;n\n \n \n {% block sw_data_grid_body_columns %}\n {% block sw_data_grid_column_actions %}\n \n {% endblock %}\n {% endblock %}\n \n

{{ $tc(\'adyen.noNotificationsReceived\') }}

\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[d.getByName("notification")],props:{order:{type:Object,required:!0}},data(){return{notifications:[],columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"eventCode",label:this.$tc("adyen.columnHeaders.event")},{property:"success",label:this.$tc("adyen.columnHeaders.success")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")},{property:"errorCount",label:this.$tc("adyen.columnHeaders.errorCount")},{property:"errorMessage",label:this.$tc("adyen.columnHeaders.errorMessage")}],showWidget:!1}},methods:{fetchNotifications(){this.adyenService.fetchNotifications(this.order.id).then(e=>{this.notifications=e})},onReschedule(e){this.adyenService.rescheduleNotification(e.notificationId).then(e=>{this.createNotificationSuccess({title:this.$tc("adyen.reprocessNotification"),message:this.$tc("adyen.notificationRescheduleSuccess")}),this.fetchNotifications()})}},beforeMount(){this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchNotifications()}});let c={};c.isVersionOlderThan65=()=>{var e,t;return -1===(t="6.5.0.0",(e=Shopware.Context.app.config.version).startsWith(t+"-")?-1:t.startsWith(e+"-")?1:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"case",caseFirst:"upper"}))};var l=c;let{Component:u}=Shopware;u.register("adyen-partial-payments",{template:'
\n
    \n
    {{ $tc(\'adyen.authorisedPayments\') }}
    \n
    \n {{ payment.pspReference }} -\n {{ payment.method }} -\n {{ payment.amount }}\n
    \n
    {{ errorMessage }}
    \n
\n
    \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n PSP Reference\n
    \n
    \n
    \n Payment Method\n
    \n
    \n
    \n Amount\n
    \n
    \n \n \n
    \n {{ payment.method }}\n
    \n
    \n
    \n {{ payment.amount }}\n
    \n
    \n
    \n
    \n {{ errorMessage }}\n
\n
\n',inject:["adyenService"],props:{order:{type:Object,required:!0}},methods:{fetchAdyenPartialPayments(){this.adyenService.fetchAdyenPartialPayments(this.order.id).then(e=>{e.length>0?this.partialPayments=e:this.errorMessage=this.$tc("adyen.pendingWebhook")})}},data(){return{errorMessage:"",partialPayments:[],showWidget:!1,isVersionOlderThan65:!1}},beforeMount(){this.isVersionOlderThan65=l.isVersionOlderThan65(),this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchAdyenPartialPayments()}}),Shopware.Component.override("sw-order-detail-general",{template:'{% block sw_order_detail_general_line_items_card %}\n {% parent %}\n \n \n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-detail-base",{template:'{% block sw_order_detail_base_custom_fields %}\n {% parent %}\n \n \n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-user-card",{template:'{% block sw_order_detail_base_secondary_info_payment %}\n {% parent %}\n\n \n{% endblock %}\n'}),Shopware.Component.override("sw-order-detail-details",{template:'{% block sw_order_detail_details_payment_method_select %}\n {% parent %}\n\n \n{% endblock %}\n'}),n(465);var h=JSON.parse('{"adyen":{"configTestTitle":"Configuration test","configTestSuccess":"Configuration is successfully tested","configTestFail":"There\'s an issue in your configuration","adyenRefunds":"Adyen Refunds","refundTitle":"Refund","refundSuccessful":"A refund has been successfully submitted.","invalidRefundAmount":"Refund amount exceeds order total","error":"An error has occurred. Please check the logs.","refundFetchError":"An error has occurred while attempting to get linked refunds.","refundConfirm":"Create refund for order","createRefund":"Create Refund","noRefundsCreated":"No refunds created","columnHeaders":{"pspReference":"PSP Reference","amount":"Amount","status":"Status","event":"Event","success":"Success","created":"Created","updated":"Updated","errorCount":"Error Count","errorMessage":"Error Message"},"reprocessNotification":"Reprocess Notification","notificationRescheduleSuccess":"Notification will be processed again.","notificationsTitle":"Adyen Webhook Notifications","noNotificationsReceived":"No webhook notifications received.","adyenPaymentCaptureTitle":"Adyen Capture Requests","noCaptureRequests":"No capture requests have been sent","sendCaptureRequest":"Send Capture Request","captureConfirm":"Capture payment for order","captureSuccessful":"Capture request has been successfully sent","pendingWebhook":"Order is pending webhook.","authorisedPayments":"Authorised Payments"}}');Shopware.Locale.extend("en-GB",h)}()})(); //# sourceMappingURL=adyen-payment-shopware6.js.map \ No newline at end of file diff --git a/src/Resources/public/administration/js/adyen-payment-shopware64.js.dist b/src/Resources/public/administration/js/adyen-payment-shopware64.js.dist deleted file mode 100644 index 29d51134..00000000 --- a/src/Resources/public/administration/js/adyen-payment-shopware64.js.dist +++ /dev/null @@ -1 +0,0 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/bundles/adyenpaymentshopware6/",n(n.s="RgpO")}({"6MJt":function(e,t,n){},Fxip:function(e,t,n){var r=n("xIYV");r.__esModule&&(r=r.default),"string"==typeof r&&(r=[[e.i,r,""]]),r.locals&&(e.exports=r.locals);(0,n("SZ7m").default)("3299a05e",r,!0,{})},MTTW:function(e,t){var n=Shopware.Component,r=Shopware.Data.Criteria;n.extend("sw-entity-single-select-override","sw-entity-single-select",{props:{criteria:{type:Object,required:!1,default:function(){var e=new r(1,this.resultLimit);return e.addFilter(r.equals("stateMachine.technicalName","order_delivery.state")),e}}}})},RgpO:function(e,t,n){"use strict";n.r(t);n("UvA/");var r=Shopware,a=r.Component,i=r.Mixin;a.register("adyen-config-check-button",{template:'\n',inject:["adyenService"],mixins:[i.getByName("notification")],data:function(){return{isLoading:!1,isSaveSuccessful:!1}},computed:{pluginConfig:function(){for(var e=this.$parent;!e.hasOwnProperty("actualConfigData");)e=e.$parent;var t=e.currentSalesChannelId,n=e.actualConfigData;return Object.assign({},n.null,n[t])}},methods:{saveFinish:function(){this.isSaveSuccessful=!1},check:function(){var e=this;this.isLoading=!0,this.adyenService.check(this.pluginConfig).then((function(t){t.success?(e.isSaveSuccessful=!0,e.createNotificationSuccess({title:e.$tc("adyen.configTestTitle"),message:e.$tc("adyen.configTestSuccess")})):e.createNotificationError({title:e.$tc("adyen.configTestTitle"),message:e.$tc(t.message?t.message:"adyen.configTestFail")}),e.isLoading=!1}))}}});n("hnQ+");var o=Shopware,s=o.Component,d=o.Mixin;s.register("adyen-payment-capture",{template:'{% block adyen_capture %}\n \n
\n
\n
\n {{ $tc(\'adyen.noCaptureRequests\') }}\n
\n
\n \n {{ $tc(\'adyen.sendCaptureRequest\') }}\n \n
\n \n \n \n
\n \n \n
\n
\n {{ $tc(\'adyen.error\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService","systemConfigApiService"],mixins:[d.getByName("notification")],props:{order:{type:Object,required:!0}},data:function(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],showModal:!1,captureRequests:[],allowCapture:!1,captureEnabled:!1,errorOccurred:!1,isLoading:!0,showWidget:!1}},methods:{openModal:function(){this.showModal=!0},onCloseModal:function(){this.showModal=!1},onSubmitCapture:function(){var e=this;this.isLoading=!0,this.adyenService.capture(this.order.id).then((function(t){t.success?(e.fetchCaptureRequests(),e.createNotificationSuccess({title:e.$tc("adyen.adyenPaymentCaptureTitle"),message:e.$tc("adyen.captureSuccessful")})):e.createNotificationError({title:e.$tc("adyen.adyenPaymentCaptureTitle"),message:e.$tc(t.message?t.message:"adyen.error")})})).catch((function(){e.createNotificationError({title:e.$tc("adyen.adyenPaymentCaptureTitle"),message:e.$tc("adyen.error")})})).finally((function(){e.isLoading=!1,e.showModal=!1}))},fetchCaptureRequests:function(){var e=this;this.isLoading=!0,this.adyenService.getCaptureRequests(this.order.id).then((function(t){e.captureRequests=t,e.isCaptureAllowed()})).catch((function(){e.errorOccurred=!0,e.captureRequests=[]})).finally((function(){e.isLoading=!1}))},isManualCaptureEnabled:function(){var e=this;this.isLoading=!0,this.adyenService.isManualCaptureEnabled(this.order.id).then((function(t){e.captureEnabled=t,e.showWidget=e.adyenService.isAdyenOrder(e.order)&&e.captureEnabled})).catch((function(){e.errorOccurred=!0,e.captureEnabled=!1})).finally((function(){e.isLoading=!1}))},isCaptureAllowed:function(){var e=this;this.isLoading=!0,this.adyenService.isCaptureAllowed(this.order.id).then((function(t){e.allowCapture=t})).catch((function(){e.errorOccurred=!0,e.allowCapture=!1})).finally((function(){e.isLoading=!1}))}},beforeMount:function(){this.isManualCaptureEnabled(),this.fetchCaptureRequests()}});n("Fxip");function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n\n
\n
\n
\n {{ $tc(\'adyen.noRefundsCreated\') }}\n
\n
\n \n {{ $tc(\'sw-order.documentCard.labelCreateNew\') }}\n \n
\n \n
\n \n
\n \n
\n
\n \n \n
\n
\n {{ $tc(\'adyen.refundFetchError\') }}\n
\n \n{% endblock %}\n',inject:["adyenService"],mixins:[p.getByName("notification")],props:{order:{type:Object,required:!0}},data:function(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],refundAmount:0,showModal:!1,refunds:[],allowRefund:!0,isLoadingTable:!0,errorOccurred:!1,isLoadingRefund:!1,showWidget:!1}},methods:{openModal:function(){this.showModal=!0},onCloseModal:function(){this.showModal=!1},onRefund:function(){var e=this;this.isLoadingRefund=!0,this.adyenService.postRefund(this.order.id,this.refundAmount).then((function(t){t.success?(e.fetchRefunds(),e.createNotificationSuccess({title:e.$tc("adyen.refundTitle"),message:e.$tc("adyen.refundSuccessful")})):e.createNotificationError({title:e.$tc("adyen.refundTitle"),message:e.$tc(t.message?t.message:"adyen.error")})})).catch((function(){e.createNotificationError({title:e.$tc("adyen.refundTitle"),message:e.$tc("adyen.error")})})).finally((function(){e.isLoadingRefund=!1,e.showModal=!1}))},fetchRefunds:function(){var e=this;this.isLoadingTable=!0,this.adyenService.getRefunds(this.order.id).then((function(t){e.refunds=t,e.isRefundAllowed()})).catch((function(){e.errorOccurred=!0,e.refunds=[]})).finally((function(){e.isLoadingTable=!1}))},isRefundAllowed:function(){var e,t=0,n=c(this.refunds);try{for(n.s();!(e=n.n()).done;){var r=e.value;"Failed"!==r.status&&(t+=r.rawAmount)}}catch(e){n.e(e)}finally{n.f()}this.allowRefund=this.order.amountTotal>t/100},isAdyenOrder:function(){for(var e=this.order.transactions,t=!1,n=0;n\n \n \n {% block sw_data_grid_body_columns %}\n {% block sw_data_grid_column_actions %}\n \n {% endblock %}\n {% endblock %}\n \n

{{ $tc(\'adyen.noNotificationsReceived\') }}

\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[m.getByName("notification")],props:{order:{type:Object,required:!0}},data:function(){return{notifications:[],columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"eventCode",label:this.$tc("adyen.columnHeaders.event")},{property:"success",label:this.$tc("adyen.columnHeaders.success")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")},{property:"errorCount",label:this.$tc("adyen.columnHeaders.errorCount")},{property:"errorMessage",label:this.$tc("adyen.columnHeaders.errorMessage")}],showWidget:!1}},methods:{fetchNotifications:function(){var e=this;this.adyenService.fetchNotifications(this.order.id).then((function(t){e.notifications=t}))},onReschedule:function(e){var t=this;this.adyenService.rescheduleNotification(e.notificationId).then((function(e){t.createNotificationSuccess({title:t.$tc("adyen.reprocessNotification"),message:t.$tc("adyen.notificationRescheduleSuccess")}),t.fetchNotifications()}))}},beforeMount:function(){this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchNotifications()}});var g={isVersionOlderThan65:function(){var e,t,n=Shopware.Context.app.config.version;return-1===(t="6.5.0.0",(e=n).startsWith(t+"-")?-1:t.startsWith(e+"-")?1:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"case",caseFirst:"upper"}))}},v=g;Shopware.Component.register("adyen-partial-payments",{template:'
\n
    \n
    {{ $tc(\'adyen.authorisedPayments\') }}
    \n
    \n {{ payment.pspReference }} -\n {{ payment.method }} -\n {{ payment.amount }}\n
    \n
    {{ errorMessage }}
    \n
\n
    \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n PSP Reference\n
    \n
    \n
    \n Payment Method\n
    \n
    \n
    \n Amount\n
    \n
    \n \n \n
    \n {{ payment.method }}\n
    \n
    \n
    \n {{ payment.amount }}\n
    \n
    \n
    \n
    \n {{ errorMessage }}\n
\n
\n',inject:["adyenService"],props:{order:{type:Object,required:!0}},methods:{fetchAdyenPartialPayments:function(){var e=this;this.adyenService.fetchAdyenPartialPayments(this.order.id).then((function(t){t.length>0?e.partialPayments=t:e.errorMessage=e.$tc("adyen.pendingWebhook")}))}},data:function(){return{errorMessage:"",partialPayments:[],showWidget:!1,isVersionOlderThan65:!1}},beforeMount:function(){this.isVersionOlderThan65=v.isVersionOlderThan65(),this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchAdyenPartialPayments()}});Shopware.Component.override("sw-order-detail-general",{template:'{% block sw_order_detail_general_line_items_card %}\n {% parent %}\n \n \n \n{% endblock %}\n'});Shopware.Component.override("sw-order-detail-base",{template:'{% block sw_order_detail_base_custom_fields %}\n {% parent %}\n \n \n \n{% endblock %}\n'});Shopware.Component.override("sw-order-user-card",{template:'{% block sw_order_detail_base_secondary_info_payment %}\n {% parent %}\n\n \n{% endblock %}\n'});Shopware.Component.override("sw-order-detail-details",{template:'{% block sw_order_detail_details_payment_method_select %}\n {% parent %}\n\n \n{% endblock %}\n'});n("MTTW");var w=n("bY4/");Shopware.Locale.extend("en-GB",w)},SZ7m:function(e,t,n){"use strict";function r(e,t){for(var n=[],r={},a=0;an.parts.length&&(r.parts.length=n.parts.length)}else{var o=[];for(a=0;a2&&void 0!==arguments[2]?arguments[2]:"adyen";return r(this,l),(n=d.call(this,e,t,a)).headers=n.getBasicHeaders({}),n}return t=l,(n=[{key:"check",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.post("_action/".concat(this.getApiBasePath(),"/verify"),e,{headers:t}).then((function(e){return c.handleResponse(e)}))}},{key:"capture",value:function(e){return this.httpClient.post(this.getApiBasePath()+"/capture",{orderId:e},{headers:this.headers}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during capture request: "+e.message),e}))}},{key:"getCaptureRequests",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/captures",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during capture request: "+e.message),e}))}},{key:"isCaptureAllowed",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/is-capture-allowed",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during is-capture-allowed request: "+e.message),e}))}},{key:"isManualCaptureEnabled",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/is-manual-capture-enabled",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during is-capture-allowed request: "+e.message),e}))}},{key:"getRefunds",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/refunds",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during refunds request: "+e.message),e}))}},{key:"postRefund",value:function(e,t){var n=this.getBasicHeaders({});return this.httpClient.post(this.getApiBasePath()+"/refunds",{orderId:e,refundAmount:t},{headers:n}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during post refund request: "+e.message),e}))}},{key:"fetchNotifications",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/notifications",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred: "+e.message),e}))}},{key:"rescheduleNotification",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/reschedule-notification/"+e,{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred: "+e.message),e}))}},{key:"isAdyenOrder",value:function(e){for(var t=e.transactions,n=!1,r=0;r\n Test Configuration\n\n',inject:["adyenService"],mixins:[i.getByName("notification")],data:function(){return{isLoading:!1,isSaveSuccessful:!1}},computed:{pluginConfig:function(){for(var e=this.$parent;!e.hasOwnProperty("actualConfigData");)e=e.$parent;var t=e.currentSalesChannelId,n=e.actualConfigData;return Object.assign({},n.null,n[t])}},methods:{saveFinish:function(){this.isSaveSuccessful=!1},check:function(){var e=this;this.isLoading=!0,this.adyenService.check(this.pluginConfig).then((function(t){t.success?(e.isSaveSuccessful=!0,e.createNotificationSuccess({title:e.$tc("adyen.configTestTitle"),message:e.$tc("adyen.configTestSuccess")})):e.createNotificationError({title:e.$tc("adyen.configTestTitle"),message:e.$tc(t.message?t.message:"adyen.configTestFail")}),e.isLoading=!1}))}}});n("H7Mt");var o=Shopware,s=o.Component,d=o.Mixin;s.register("adyen-payment-capture",{template:'{% block adyen_capture %}\n \n
\n
\n
\n {{ $tc(\'adyen.noCaptureRequests\') }}\n
\n
\n \n {{ $tc(\'adyen.sendCaptureRequest\') }}\n \n
\n \n \n \n
\n \n \n
\n
\n {{ $tc(\'adyen.error\') }}\n
\n
\n{% endblock %}\n',inject:["adyenService","systemConfigApiService"],mixins:[d.getByName("notification")],props:{order:{type:Object,required:!0}},data:function(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],showModal:!1,captureRequests:[],allowCapture:!1,captureEnabled:!1,errorOccurred:!1,isLoading:!0,showWidget:!1}},methods:{openModal:function(){this.showModal=!0},onCloseModal:function(){this.showModal=!1},onSubmitCapture:function(){var e=this;this.isLoading=!0,this.adyenService.capture(this.order.id).then((function(t){t.success?(e.fetchCaptureRequests(),e.createNotificationSuccess({title:e.$tc("adyen.adyenPaymentCaptureTitle"),message:e.$tc("adyen.captureSuccessful")})):e.createNotificationError({title:e.$tc("adyen.adyenPaymentCaptureTitle"),message:e.$tc(t.message?t.message:"adyen.error")})})).catch((function(){e.createNotificationError({title:e.$tc("adyen.adyenPaymentCaptureTitle"),message:e.$tc("adyen.error")})})).finally((function(){e.isLoading=!1,e.showModal=!1}))},fetchCaptureRequests:function(){var e=this;this.isLoading=!0,this.adyenService.getCaptureRequests(this.order.id).then((function(t){e.captureRequests=t,e.isCaptureAllowed()})).catch((function(){e.errorOccurred=!0,e.captureRequests=[]})).finally((function(){e.isLoading=!1}))},isManualCaptureEnabled:function(){var e=this;this.isLoading=!0,this.adyenService.isManualCaptureEnabled(this.order.id).then((function(t){e.captureEnabled=t,e.showWidget=e.adyenService.isAdyenOrder(e.order)&&e.captureEnabled})).catch((function(){e.errorOccurred=!0,e.captureEnabled=!1})).finally((function(){e.isLoading=!1}))},isCaptureAllowed:function(){var e=this;this.isLoading=!0,this.adyenService.isCaptureAllowed(this.order.id).then((function(t){e.allowCapture=t})).catch((function(){e.errorOccurred=!0,e.allowCapture=!1})).finally((function(){e.isLoading=!1}))}},beforeMount:function(){this.isManualCaptureEnabled(),this.fetchCaptureRequests()}});n("tG31");function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,i=e},f:function(){try{o||null==n.return||n.return()}finally{if(s)throw i}}}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n\n
\n
\n
\n {{ $tc(\'adyen.noRefundsCreated\') }}\n
\n
\n \n {{ $tc(\'sw-order.documentCard.labelCreateNew\') }}\n \n
\n \n
\n \n
\n \n
\n
\n \n \n
\n
\n {{ $tc(\'adyen.refundFetchError\') }}\n
\n \n{% endblock %}\n',inject:["adyenService"],mixins:[p.getByName("notification")],props:{order:{type:Object,required:!0}},data:function(){return{columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")}],refundAmount:0,showModal:!1,refunds:[],allowRefund:!0,isLoadingTable:!0,errorOccurred:!1,isLoadingRefund:!1,showWidget:!1}},methods:{openModal:function(){this.showModal=!0},onCloseModal:function(){this.showModal=!1},onRefund:function(){var e=this;this.isLoadingRefund=!0,this.adyenService.postRefund(this.order.id,this.refundAmount).then((function(t){t.success?(e.fetchRefunds(),e.createNotificationSuccess({title:e.$tc("adyen.refundTitle"),message:e.$tc("adyen.refundSuccessful")})):e.createNotificationError({title:e.$tc("adyen.refundTitle"),message:e.$tc(t.message?t.message:"adyen.error")})})).catch((function(){e.createNotificationError({title:e.$tc("adyen.refundTitle"),message:e.$tc("adyen.error")})})).finally((function(){e.isLoadingRefund=!1,e.showModal=!1}))},fetchRefunds:function(){var e=this;this.isLoadingTable=!0,this.adyenService.getRefunds(this.order.id).then((function(t){e.refunds=t,e.isRefundAllowed()})).catch((function(){e.errorOccurred=!0,e.refunds=[]})).finally((function(){e.isLoadingTable=!1}))},isRefundAllowed:function(){var e,t=0,n=c(this.refunds);try{for(n.s();!(e=n.n()).done;){var r=e.value;"Failed"!==r.status&&(t+=r.rawAmount)}}catch(e){n.e(e)}finally{n.f()}this.allowRefund=this.order.amountTotal>t/100},isAdyenOrder:function(){for(var e=this.order.transactions,t=!1,n=0;n\n \n \n {% block sw_data_grid_body_columns %}\n {% block sw_data_grid_column_actions %}\n \n {% endblock %}\n {% endblock %}\n \n

{{ $tc(\'adyen.noNotificationsReceived\') }}

\n
\n
\n{% endblock %}\n',inject:["adyenService"],mixins:[m.getByName("notification")],props:{order:{type:Object,required:!0}},data:function(){return{notifications:[],columns:[{property:"pspReference",label:this.$tc("adyen.columnHeaders.pspReference")},{property:"eventCode",label:this.$tc("adyen.columnHeaders.event")},{property:"success",label:this.$tc("adyen.columnHeaders.success")},{property:"amount",label:this.$tc("adyen.columnHeaders.amount")},{property:"status",label:this.$tc("adyen.columnHeaders.status")},{property:"createdAt",label:this.$tc("adyen.columnHeaders.created")},{property:"updatedAt",label:this.$tc("adyen.columnHeaders.updated")},{property:"errorCount",label:this.$tc("adyen.columnHeaders.errorCount")},{property:"errorMessage",label:this.$tc("adyen.columnHeaders.errorMessage")}],showWidget:!1}},methods:{fetchNotifications:function(){var e=this;this.adyenService.fetchNotifications(this.order.id).then((function(t){e.notifications=t}))},onReschedule:function(e){var t=this;this.adyenService.rescheduleNotification(e.notificationId).then((function(e){t.createNotificationSuccess({title:t.$tc("adyen.reprocessNotification"),message:t.$tc("adyen.notificationRescheduleSuccess")}),t.fetchNotifications()}))}},beforeMount:function(){this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchNotifications()}});var g={isVersionOlderThan65:function(){var e,t,n=Shopware.Context.app.config.version;return-1===(t="6.5.0.0",(e=n).startsWith(t+"-")?-1:t.startsWith(e+"-")?1:e.localeCompare(t,void 0,{numeric:!0,sensitivity:"case",caseFirst:"upper"}))}},v=g;Shopware.Component.register("adyen-partial-payments",{template:'
\n
    \n
    {{ $tc(\'adyen.authorisedPayments\') }}
    \n
    \n {{ payment.pspReference }} -\n {{ payment.method }} -\n {{ payment.amount }}\n
    \n
    {{ errorMessage }}
    \n
\n
    \n \n
    \n
    \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
    \n
    \n PSP Reference\n
    \n
    \n
    \n Payment Method\n
    \n
    \n
    \n Amount\n
    \n
    \n \n \n
    \n {{ payment.method }}\n
    \n
    \n
    \n {{ payment.amount }}\n
    \n
    \n
    \n
    \n {{ errorMessage }}\n
\n
\n',inject:["adyenService"],props:{order:{type:Object,required:!0}},methods:{fetchAdyenPartialPayments:function(){var e=this;this.adyenService.fetchAdyenPartialPayments(this.order.id).then((function(t){t.length>0?e.partialPayments=t:e.errorMessage=e.$tc("adyen.pendingWebhook")}))}},data:function(){return{errorMessage:"",partialPayments:[],showWidget:!1,isVersionOlderThan65:!1}},beforeMount:function(){this.isVersionOlderThan65=v.isVersionOlderThan65(),this.showWidget=this.adyenService.isAdyenOrder(this.order),this.showWidget&&this.fetchAdyenPartialPayments()}});Shopware.Component.override("sw-order-detail-general",{template:'{% block sw_order_detail_general_line_items_card %}\n {% parent %}\n \n \n \n{% endblock %}\n'});Shopware.Component.override("sw-order-detail-base",{template:'{% block sw_order_detail_base_custom_fields %}\n {% parent %}\n \n \n \n{% endblock %}\n'});Shopware.Component.override("sw-order-user-card",{template:'{% block sw_order_detail_base_secondary_info_payment %}\n {% parent %}\n\n \n{% endblock %}\n'});Shopware.Component.override("sw-order-detail-details",{template:'{% block sw_order_detail_details_payment_method_select %}\n {% parent %}\n\n \n{% endblock %}\n'});n("vNjL");var w=n("GGYj");Shopware.Locale.extend("en-GB",w)},GGYj:function(e){e.exports=JSON.parse('{"adyen":{"configTestTitle":"Configuration test","configTestSuccess":"Configuration is successfully tested","configTestFail":"There\'s an issue in your configuration","adyenRefunds":"Adyen Refunds","refundTitle":"Refund","refundSuccessful":"A refund has been successfully submitted.","invalidRefundAmount":"Refund amount exceeds order total","error":"An error has occurred. Please check the logs.","refundFetchError":"An error has occurred while attempting to get linked refunds.","refundConfirm":"Create refund for order","createRefund":"Create Refund","noRefundsCreated":"No refunds created","columnHeaders":{"pspReference":"PSP Reference","amount":"Amount","status":"Status","event":"Event","success":"Success","created":"Created","updated":"Updated","errorCount":"Error Count","errorMessage":"Error Message"},"reprocessNotification":"Reprocess Notification","notificationRescheduleSuccess":"Notification will be processed again.","notificationsTitle":"Adyen Webhook Notifications","noNotificationsReceived":"No webhook notifications received.","adyenPaymentCaptureTitle":"Adyen Capture Requests","noCaptureRequests":"No capture requests have been sent","sendCaptureRequest":"Send Capture Request","captureConfirm":"Capture payment for order","captureSuccessful":"Capture request has been successfully sent","pendingWebhook":"Order is pending webhook.","authorisedPayments":"Authorised Payments"}}')},H7Mt:function(e,t,n){var r=n("mH+n");r.__esModule&&(r=r.default),"string"==typeof r&&(r=[[e.i,r,""]]),r.locals&&(e.exports=r.locals);(0,n("P8hj").default)("056a1238",r,!0,{})},P8hj:function(e,t,n){"use strict";function r(e,t){for(var n=[],r={},a=0;an.parts.length&&(r.parts.length=n.parts.length)}else{var o=[];for(a=0;a2&&void 0!==arguments[2]?arguments[2]:"adyen";return r(this,l),(n=d.call(this,e,t,a)).headers=n.getBasicHeaders({}),n}return t=l,(n=[{key:"check",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.post("_action/".concat(this.getApiBasePath(),"/verify"),e,{headers:t}).then((function(e){return c.handleResponse(e)}))}},{key:"capture",value:function(e){return this.httpClient.post(this.getApiBasePath()+"/capture",{orderId:e},{headers:this.headers}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during capture request: "+e.message),e}))}},{key:"getCaptureRequests",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/captures",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during capture request: "+e.message),e}))}},{key:"isCaptureAllowed",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/is-capture-allowed",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during is-capture-allowed request: "+e.message),e}))}},{key:"isManualCaptureEnabled",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/is-manual-capture-enabled",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during is-capture-allowed request: "+e.message),e}))}},{key:"getRefunds",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/refunds",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during refunds request: "+e.message),e}))}},{key:"postRefund",value:function(e,t){var n=this.getBasicHeaders({});return this.httpClient.post(this.getApiBasePath()+"/refunds",{orderId:e,refundAmount:t},{headers:n}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred during post refund request: "+e.message),e}))}},{key:"fetchNotifications",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/orders/"+e+"/notifications",{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred: "+e.message),e}))}},{key:"rescheduleNotification",value:function(e){var t=this.getBasicHeaders({});return this.httpClient.get(this.getApiBasePath()+"/reschedule-notification/"+e,{headers:t}).then((function(e){return c.handleResponse(e)})).catch((function(e){throw console.error("An error occurred: "+e.message),e}))}},{key:"isAdyenOrder",value:function(e){for(var t=e.transactions,n=!1,r=0;r {\n return ApiService.handleResponse(response);\n });\n }\n\n capture(orderId) {\n return this.httpClient.post(\n this.getApiBasePath() + '/capture',\n { orderId },\n { headers: this.headers }\n ).then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred during capture request: ' + error.message);\n throw error;\n });\n }\n\n getCaptureRequests(orderId) {\n const headers = this.getBasicHeaders({});\n\n return this.httpClient\n .get(this.getApiBasePath() + '/orders/' + orderId + '/captures', {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred during capture request: ' + error.message);\n throw error;\n });\n }\n\n isCaptureAllowed(orderId) {\n const headers = this.getBasicHeaders({});\n\n return this.httpClient\n .get(this.getApiBasePath() + '/orders/' + orderId + '/is-capture-allowed', {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred during is-capture-allowed request: ' + error.message);\n throw error;\n });\n }\n\n isManualCaptureEnabled(orderId) {\n const headers = this.getBasicHeaders({});\n\n return this.httpClient\n .get(this.getApiBasePath() + '/orders/' + orderId + '/is-manual-capture-enabled', {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred during is-capture-allowed request: ' + error.message);\n throw error;\n });\n }\n\n getRefunds(orderId) {\n const headers = this.getBasicHeaders({});\n\n return this.httpClient\n .get(this.getApiBasePath() + '/orders/' + orderId + '/refunds', {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred during refunds request: ' + error.message);\n throw error;\n });\n }\n\n postRefund(orderId, refundAmount) {\n const headers = this.getBasicHeaders({});\n return this.httpClient\n .post(this.getApiBasePath() + '/refunds', {orderId: orderId, refundAmount: refundAmount}, {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n\n }).catch((error) => {\n console.error('An error occurred during post refund request: ' + error.message);\n throw error;\n });\n }\n\n fetchNotifications(orderId) {\n const headers = this.getBasicHeaders({});\n\n return this.httpClient\n .get(this.getApiBasePath() + '/orders/' + orderId + '/notifications', {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred: ' + error.message);\n throw error;\n });\n }\n\n rescheduleNotification(notificationId) {\n const headers = this.getBasicHeaders({});\n\n return this.httpClient\n .get(this.getApiBasePath() + '/reschedule-notification/' + notificationId , {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred: ' + error.message);\n throw error;\n });\n }\n\n isAdyenOrder(order) {\n const orderTransactions = order.transactions;\n let isAdyen = false;\n for (let i = 0; i < orderTransactions.length; i++) {\n if (orderTransactions[i].customFields !== undefined) {\n if (orderTransactions[i].customFields.originalPspReference !== undefined) {\n isAdyen = true;\n }\n }\n }\n\n return isAdyen;\n }\n\n fetchAdyenPartialPayments(orderId) {\n const headers = this.getBasicHeaders({});\n\n return this.httpClient\n .get(this.getApiBasePath() + '/orders/' + orderId + '/partial-payments', {\n headers\n })\n .then((response) => {\n return ApiService.handleResponse(response);\n }).catch((error) => {\n console.error('An error occurred: ' + error.message);\n throw error;\n });\n }\n}\n\nApplication.addServiceProvider('adyenService', (container) => {\n const initContainer = Application.getContainer('init');\n return new ApiClient(initContainer.httpClient, container.loginService);\n});\n","// style-loader: Adds some css to the DOM by adding a