From 3f4c269bb2937613fc5a266ac1cc8c22c26f33f8 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Tue, 26 Nov 2024 18:51:18 +0100 Subject: [PATCH] Move all `Apple Pay`-related services under the `ApplePayPayment` namespace --- config/routes_webhook.php | 2 +- config/services.php | 5 +- config/services/api/command.php | 2 +- .../services/apple_pay_payment/controller.php | 18 +++++ .../apple_pay_payment/payum/action.php | 4 +- .../apple_pay_payment/payum/factory.php | 6 ++ config/services/controller.php | 10 +-- config/services/payum/factory.php | 6 -- config/services/refunding.php | 1 - config/validation/Pay.xml | 4 +- .../InitializeApplePaySessionHandler.php | 2 +- .../Controller/InitApplePayPaymentAction.php | 7 +- .../CreateApplePayTransactionAction.php | 3 +- .../InitializeApplePayPaymentAction.php | 5 +- .../InitializeApplePayPaymentFactory.php | 4 +- ...tializeApplePayPaymentFactoryInterface.php | 4 +- .../Request}/InitializeApplePayPayment.php | 2 +- src/Refunding/Dispatcher/RefundDispatcher.php | 18 ++++- .../InitializeApplePaySessionHandlerTest.php | 4 +- .../CreateApplePayTransactionActionTest.php | 4 +- .../InitializeApplePayPaymentActionTest.php | 6 +- .../InitializeApplePayPaymentFactoryTest.php | 8 +-- .../Dispatcher/RefundDispatcherTest.php | 65 +++++++++++++++---- 23 files changed, 130 insertions(+), 60 deletions(-) create mode 100644 config/services/apple_pay_payment/controller.php rename src/{ => ApplePayPayment}/Controller/InitApplePayPaymentAction.php (84%) rename src/{Payum/Action/Api => ApplePayPayment/Payum/Action}/CreateApplePayTransactionAction.php (95%) rename src/{Payum/Action/Api => ApplePayPayment/Payum/Action}/InitializeApplePayPaymentAction.php (87%) rename src/{ => ApplePayPayment}/Payum/Factory/InitializeApplePayPaymentFactory.php (74%) rename src/{ => ApplePayPayment}/Payum/Factory/InitializeApplePayPaymentFactoryInterface.php (67%) rename src/{Payum/Request/Api => ApplePayPayment/Payum/Request}/InitializeApplePayPayment.php (89%) rename tests/Unit/{Payum/Action/Api => ApplePayPayment/Payum/Action}/CreateApplePayTransactionActionTest.php (98%) rename tests/Unit/{Payum/Action/Api => ApplePayPayment/Payum/Action}/InitializeApplePayPaymentActionTest.php (95%) rename tests/Unit/{ => ApplePayPayment}/Payum/Factory/InitializeApplePayPaymentFactoryTest.php (75%) diff --git a/config/routes_webhook.php b/config/routes_webhook.php index d10a8d86..37f437c7 100644 --- a/config/routes_webhook.php +++ b/config/routes_webhook.php @@ -4,7 +4,7 @@ namespace Symfony\Component\Routing\Loader\Configurator; -use CommerceWeavers\SyliusTpayPlugin\Controller\InitApplePayPaymentAction; +use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Controller\InitApplePayPaymentAction; use CommerceWeavers\SyliusTpayPlugin\Controller\PaymentNotificationAction; use CommerceWeavers\SyliusTpayPlugin\Controller\TpayNotificationAction; use CommerceWeavers\SyliusTpayPlugin\Routing; diff --git a/config/services.php b/config/services.php index b84b43b5..c927c1a8 100644 --- a/config/services.php +++ b/config/services.php @@ -4,6 +4,7 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; +use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Payum\Factory\GatewayFactory; use Payum\Core\Gateway; return function(ContainerConfigurator $container): void { @@ -11,8 +12,8 @@ $services = $container->services(); - $services->set('commerce_weavers_sylius_tpay.gateway', Gateway::class) + $services->set('commerce_weavers_sylius_tpay.apple_pay_gateway', Gateway::class) ->factory([service('payum'), 'getGateway']) - ->args(['tpay']) + ->args([GatewayFactory::NAME]) ; }; diff --git a/config/services/api/command.php b/config/services/api/command.php index 0d6c0047..cfc6c3a9 100644 --- a/config/services/api/command.php +++ b/config/services/api/command.php @@ -50,7 +50,7 @@ ->args([ service('sylius.repository.order'), service('sylius.repository.payment'), - service('commerce_weavers_sylius_tpay.gateway'), + service('commerce_weavers_sylius_tpay.apple_pay_gateway'), service('commerce_weavers_sylius_tpay.payum.factory.initialize_apple_pay_payment'), ]) ->tag('messenger.message_handler') diff --git a/config/services/apple_pay_payment/controller.php b/config/services/apple_pay_payment/controller.php new file mode 100644 index 00000000..c13e3308 --- /dev/null +++ b/config/services/apple_pay_payment/controller.php @@ -0,0 +1,18 @@ +services(); + + $services->set(InitApplePayPaymentAction::class) + ->args([ + service('payum'), + ]) + ->tag('controller.service_arguments') + ; +}; diff --git a/config/services/apple_pay_payment/payum/action.php b/config/services/apple_pay_payment/payum/action.php index 493d52f3..3650e959 100644 --- a/config/services/apple_pay_payment/payum/action.php +++ b/config/services/apple_pay_payment/payum/action.php @@ -4,9 +4,9 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; +use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Payum\Action\CreateApplePayTransactionAction; +use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Payum\Action\InitializeApplePayPaymentAction; use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Payum\Factory\GatewayFactory as ApplePayGatewayFactory; -use CommerceWeavers\SyliusTpayPlugin\Payum\Action\Api\CreateApplePayTransactionAction; -use CommerceWeavers\SyliusTpayPlugin\Payum\Action\Api\InitializeApplePayPaymentAction; return function(ContainerConfigurator $container): void { $services = $container->services(); diff --git a/config/services/apple_pay_payment/payum/factory.php b/config/services/apple_pay_payment/payum/factory.php index 4161992b..3454cb30 100644 --- a/config/services/apple_pay_payment/payum/factory.php +++ b/config/services/apple_pay_payment/payum/factory.php @@ -5,6 +5,8 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Payum\Factory\GatewayFactory; +use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Payum\Factory\InitializeApplePayPaymentFactory; +use CommerceWeavers\SyliusTpayPlugin\ApplePayPayment\Payum\Factory\InitializeApplePayPaymentFactoryInterface; use Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder; return function(ContainerConfigurator $container): void { @@ -16,4 +18,8 @@ ]) ->tag('payum.gateway_factory_builder', ['factory' => GatewayFactory::NAME]) ; + + $services->set('commerce_weavers_sylius_tpay.payum.factory.initialize_apple_pay_payment', InitializeApplePayPaymentFactory::class) + ->alias(InitializeApplePayPaymentFactoryInterface::class, 'commerce_weavers_sylius_tpay.payum.factory.initialize_apple_pay_payment') + ; }; diff --git a/config/services/controller.php b/config/services/controller.php index 66ffaea4..b37f1a80 100644 --- a/config/services/controller.php +++ b/config/services/controller.php @@ -8,9 +8,8 @@ use CommerceWeavers\SyliusTpayPlugin\Controller\DisplayThankYouPageAction; use CommerceWeavers\SyliusTpayPlugin\Controller\DisplayWaitingForPaymentPage; use CommerceWeavers\SyliusTpayPlugin\Controller\PaymentNotificationAction; -use CommerceWeavers\SyliusTpayPlugin\Controller\InitApplePayPaymentAction; -use CommerceWeavers\SyliusTpayPlugin\Controller\TpayNotificationAction; use CommerceWeavers\SyliusTpayPlugin\Controller\RetryPaymentAction; +use CommerceWeavers\SyliusTpayPlugin\Controller\TpayNotificationAction; return function(ContainerConfigurator $container): void { $services = $container->services(); @@ -42,13 +41,6 @@ ->tag('controller.service_arguments') ; - $services->set(InitApplePayPaymentAction::class) - ->args([ - service('payum'), - ]) - ->tag('controller.service_arguments') - ; - $services->set(PaymentNotificationAction::class) ->args([ service('payum'), diff --git a/config/services/payum/factory.php b/config/services/payum/factory.php index 0466c94e..3670d449 100644 --- a/config/services/payum/factory.php +++ b/config/services/payum/factory.php @@ -6,8 +6,6 @@ use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\CreateTransactionFactory; use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\CreateTransactionFactoryInterface; -use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\InitializeApplePayPaymentFactory; -use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\InitializeApplePayPaymentFactoryInterface; use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\NotifyDataFactory; use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\NotifyDataFactoryInterface; use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\NotifyFactory; @@ -35,10 +33,6 @@ ->alias(CreateTransactionFactoryInterface::class, 'commerce_weavers_sylius_tpay.payum.factory.create_transaction') ; - $services->set('commerce_weavers_sylius_tpay.payum.factory.initialize_apple_pay_payment', InitializeApplePayPaymentFactory::class) - ->alias(InitializeApplePayPaymentFactoryInterface::class, 'commerce_weavers_sylius_tpay.payum.factory.initialize_apple_pay_payment') - ; - $services->set('commerce_weavers_sylius_tpay.payum.factory.notify_data', NotifyDataFactory::class) ->alias(NotifyDataFactoryInterface::class, 'commerce_weavers_sylius_tpay.payum.factory.notify_data') ; diff --git a/config/services/refunding.php b/config/services/refunding.php index 6f4032c5..4c68b560 100644 --- a/config/services/refunding.php +++ b/config/services/refunding.php @@ -21,7 +21,6 @@ $services->set('commerce_weavers_sylius_tpay.refunding.dispatcher.refund', RefundDispatcher::class) ->public() ->args([ - service('commerce_weavers_sylius_tpay.gateway'), service('commerce_weavers_sylius_tpay.refunding.checker.refund_plugin_availability'), ]) ->alias(RefundDispatcherInterface::class, 'commerce_weavers_sylius_tpay.refunding.dispatcher.refund') diff --git a/config/validation/Pay.xml b/config/validation/Pay.xml index 2fbf601e..4c96a100 100644 --- a/config/validation/Pay.xml +++ b/config/validation/Pay.xml @@ -24,8 +24,8 @@ - - + +