From 870aebe6fe22af970c6df28ea9cd89aa7ce4d9bf Mon Sep 17 00:00:00 2001 From: Frederik Rommel Date: Tue, 9 Jul 2024 19:33:23 +0200 Subject: [PATCH] PAYOSWXP-150: apple pay: add proxy controller for apple-pay routes --- .../Controller/CheckoutController.php | 41 +++++++++++++++++++ .../StoreApi/Route/AbstractApplePayRoute.php | 2 +- .../StoreApi/Route/ApplePayRoute.php | 2 +- src/Controller/SettingsController.php | 2 +- src/DependencyInjection/controllers.xml | 4 ++ src/DependencyInjection/store_api.xml | 5 ++- .../CheckoutConfirmApplePayEventListener.php | 2 +- src/Resources/config/routes.xml | 1 + .../checkout/apple-pay-button.html.twig | 4 +- 9 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 src/Components/ApplePay/Controller/CheckoutController.php rename src/{ => Components/ApplePay}/StoreApi/Route/AbstractApplePayRoute.php (89%) rename src/{ => Components/ApplePay}/StoreApi/Route/ApplePayRoute.php (98%) diff --git a/src/Components/ApplePay/Controller/CheckoutController.php b/src/Components/ApplePay/Controller/CheckoutController.php new file mode 100644 index 000000000..d7bc30858 --- /dev/null +++ b/src/Components/ApplePay/Controller/CheckoutController.php @@ -0,0 +1,41 @@ + false], + defaults: [ + 'XmlHttpRequest' => true, + '_routeScope' => ['storefront'], + '_loginRequired' => true, + '_loginRequiredAllowGuest' => true, + ], +)] +class CheckoutController +{ + public function __construct( + private readonly AbstractApplePayRoute $route + ) { + } + + #[Route(path: 'validate-merchant', name: 'frontend.payone.apple-pay.validate-merchant', methods: ['POST'])] + public function validateMerchant(Request $request, SalesChannelContext $salesChannelContext): Response + { + return $this->route->validateMerchant($request, $salesChannelContext); + } + + #[Route(path: 'process-payment', name: 'frontend.payone.apple-pay.process-payment', methods: ['POST'])] + public function processPayment(Request $request, SalesChannelContext $salesChannelContext): Response + { + return $this->route->process($request, $salesChannelContext); + } +} diff --git a/src/StoreApi/Route/AbstractApplePayRoute.php b/src/Components/ApplePay/StoreApi/Route/AbstractApplePayRoute.php similarity index 89% rename from src/StoreApi/Route/AbstractApplePayRoute.php rename to src/Components/ApplePay/StoreApi/Route/AbstractApplePayRoute.php index 9e7d69497..c729324f7 100644 --- a/src/StoreApi/Route/AbstractApplePayRoute.php +++ b/src/Components/ApplePay/StoreApi/Route/AbstractApplePayRoute.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PayonePayment\StoreApi\Route; +namespace PayonePayment\Components\ApplePay\StoreApi\Route; use Shopware\Core\System\SalesChannel\SalesChannelContext; use Symfony\Component\HttpFoundation\Request; diff --git a/src/StoreApi/Route/ApplePayRoute.php b/src/Components/ApplePay/StoreApi/Route/ApplePayRoute.php similarity index 98% rename from src/StoreApi/Route/ApplePayRoute.php rename to src/Components/ApplePay/StoreApi/Route/ApplePayRoute.php index 307c8b321..568e163cd 100644 --- a/src/StoreApi/Route/ApplePayRoute.php +++ b/src/Components/ApplePay/StoreApi/Route/ApplePayRoute.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PayonePayment\StoreApi\Route; +namespace PayonePayment\Components\ApplePay\StoreApi\Route; use GuzzleHttp\Client; use PayonePayment\Components\ConfigReader\ConfigReaderInterface; diff --git a/src/Controller/SettingsController.php b/src/Controller/SettingsController.php index c414b4bcf..745021a28 100644 --- a/src/Controller/SettingsController.php +++ b/src/Controller/SettingsController.php @@ -4,6 +4,7 @@ namespace PayonePayment\Controller; +use PayonePayment\Components\ApplePay\StoreApi\Route\ApplePayRoute; use PayonePayment\Configuration\ConfigurationPrefixes; use PayonePayment\PaymentHandler as Handler; use PayonePayment\Payone\Client\Exception\PayoneRequestException; @@ -12,7 +13,6 @@ use PayonePayment\Payone\RequestParameter\Builder\Amazon\AbstractAmazonRequestParameterBuilder; use PayonePayment\Payone\RequestParameter\RequestParameterFactory; use PayonePayment\Payone\RequestParameter\Struct\TestCredentialsStruct; -use PayonePayment\StoreApi\Route\ApplePayRoute; use Psr\Log\LoggerInterface; use Shopware\Core\Checkout\Payment\PaymentMethodEntity; use Shopware\Core\Framework\Context; diff --git a/src/DependencyInjection/controllers.xml b/src/DependencyInjection/controllers.xml index 8b7d5d0e2..1d6e0d712 100644 --- a/src/DependencyInjection/controllers.xml +++ b/src/DependencyInjection/controllers.xml @@ -149,5 +149,9 @@ + + + + diff --git a/src/DependencyInjection/store_api.xml b/src/DependencyInjection/store_api.xml index 75c790516..0725fc64f 100644 --- a/src/DependencyInjection/store_api.xml +++ b/src/DependencyInjection/store_api.xml @@ -10,7 +10,10 @@ - + + + diff --git a/src/EventListener/CheckoutConfirmApplePayEventListener.php b/src/EventListener/CheckoutConfirmApplePayEventListener.php index d50261b86..bb176e661 100644 --- a/src/EventListener/CheckoutConfirmApplePayEventListener.php +++ b/src/EventListener/CheckoutConfirmApplePayEventListener.php @@ -4,9 +4,9 @@ namespace PayonePayment\EventListener; +use PayonePayment\Components\ApplePay\StoreApi\Route\ApplePayRoute; use PayonePayment\Core\Utils\PayoneClassLoader; use PayonePayment\PaymentMethod\PayoneApplePay; -use PayonePayment\StoreApi\Route\ApplePayRoute; use Shopware\Storefront\Page\Account\Order\AccountEditOrderPageLoadedEvent; use Shopware\Storefront\Page\Account\PaymentMethod\AccountPaymentMethodPageLoadedEvent; use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent; diff --git a/src/Resources/config/routes.xml b/src/Resources/config/routes.xml index d3427f02e..d37633a98 100644 --- a/src/Resources/config/routes.xml +++ b/src/Resources/config/routes.xml @@ -3,5 +3,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> + diff --git a/src/Resources/views/storefront/component/checkout/apple-pay-button.html.twig b/src/Resources/views/storefront/component/checkout/apple-pay-button.html.twig index f2e38f0f6..e26071145 100644 --- a/src/Resources/views/storefront/component/checkout/apple-pay-button.html.twig +++ b/src/Resources/views/storefront/component/checkout/apple-pay-button.html.twig @@ -9,8 +9,8 @@