From 6b91f999fe5ed45773a62bd672a3b71ff3adc370 Mon Sep 17 00:00:00 2001 From: Jacob Tobiasz Date: Tue, 26 Nov 2024 19:59:27 +0100 Subject: [PATCH] Move all `Google Pay`-related services under the `GooglePayPayment` namespace --- .../services/google_pay_payment/payum/action.php | 11 +++++++++++ .../services/google_pay_payment/payum/factory.php | 2 +- config/services/google_pay_payment/validator.php | 15 +++++++++++++++ config/services/payum/action.php | 9 --------- config/services/validator.php | 2 +- config/validation/Pay.xml | 6 +++--- src/Form/Type/TpayPaymentDetailsType.php | 2 +- .../Action}/CreateGooglePayTransactionAction.php | 3 ++- .../Constraint/EncodedGooglePayToken.php | 2 +- .../Constraint/EncodedGooglePayTokenValidator.php | 2 +- .../Checkout/Complete/_navigation.html.twig | 6 ++---- .../shop/cart/complete/_google_pay.html.twig | 4 +--- .../order/pay/_apple_pay_regulations.html.twig | 5 +---- .../order/pay/_google_pay_regulations.html.twig | 5 +---- tests/Api/Shop/PayingForOrdersByGooglePayTest.php | 2 +- .../CreateGooglePayTransactionActionTest.php | 4 ++-- .../EncodedGooglePayTokenValidatorTest.php | 6 +++--- 17 files changed, 47 insertions(+), 39 deletions(-) create mode 100644 config/services/google_pay_payment/validator.php rename src/{Payum/Action/Api => GooglePayPayment/Payum/Action}/CreateGooglePayTransactionAction.php (95%) rename src/{ => GooglePayPayment}/Validator/Constraint/EncodedGooglePayToken.php (90%) rename src/{ => GooglePayPayment}/Validator/Constraint/EncodedGooglePayTokenValidator.php (95%) rename tests/Unit/{Payum/Action/Api => GooglePayPayment/Payum/Action}/CreateGooglePayTransactionActionTest.php (98%) rename tests/Unit/{ => GooglePayPayment}/Validator/Constraint/EncodedGooglePayTokenValidatorTest.php (89%) diff --git a/config/services/google_pay_payment/payum/action.php b/config/services/google_pay_payment/payum/action.php index b787579d..0e63a468 100644 --- a/config/services/google_pay_payment/payum/action.php +++ b/config/services/google_pay_payment/payum/action.php @@ -4,10 +4,21 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; +use CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Payum\Action\CreateGooglePayTransactionAction; +use CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Payum\Factory\GatewayFactory as GooglePayGatewayFactory; + return function(ContainerConfigurator $container): void { $services = $container->services(); $services->defaults() ->public() ; + + $services->set(CreateGooglePayTransactionAction::class) + ->args([ + service('commerce_weavers_sylius_tpay.tpay.factory.create_google_pay_payment_payload'), + service('commerce_weavers_sylius_tpay.payum.factory.token.notify'), + ]) + ->tag('payum.action', ['factory' => GooglePayGatewayFactory::NAME, 'alias' => 'cw.tpay_google_pay.create_google_pay_transaction']) + ; }; diff --git a/config/services/google_pay_payment/payum/factory.php b/config/services/google_pay_payment/payum/factory.php index e4c94687..c6f3204c 100644 --- a/config/services/google_pay_payment/payum/factory.php +++ b/config/services/google_pay_payment/payum/factory.php @@ -10,7 +10,7 @@ return function(ContainerConfigurator $container): void { $services = $container->services(); - $services->set('commerce_weavers_sylius_tpay.apple_pay_payment.payum.factory.gateway', GatewayFactoryBuilder::class) + $services->set('commerce_weavers_sylius_tpay.google_pay_payment.payum.factory.gateway', GatewayFactoryBuilder::class) ->args([ GatewayFactory::class, ]) diff --git a/config/services/google_pay_payment/validator.php b/config/services/google_pay_payment/validator.php new file mode 100644 index 00000000..3b17c409 --- /dev/null +++ b/config/services/google_pay_payment/validator.php @@ -0,0 +1,15 @@ +services(); + + $services->set('commerce_weavers_sylius_tpay.google_pay_payment.validator.constraint.encoded_google_pay_token', EncodedGooglePayTokenValidator::class) + ->tag('validator.constraint_validator') + ; +}; diff --git a/config/services/payum/action.php b/config/services/payum/action.php index a885c0db..3b364288 100644 --- a/config/services/payum/action.php +++ b/config/services/payum/action.php @@ -9,7 +9,6 @@ use CommerceWeavers\SyliusTpayPlugin\CardPayment\Payum\Factory\GatewayFactory as CardGatewayFactory; use CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Payum\Factory\GatewayFactory as GooglePayGatewayFactory; use CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Payum\Factory\GatewayFactory as PayByLinkGatewayFactory; -use CommerceWeavers\SyliusTpayPlugin\Payum\Action\Api\CreateGooglePayTransactionAction; use CommerceWeavers\SyliusTpayPlugin\Payum\Action\Api\CreateVisaMobileTransactionAction; use CommerceWeavers\SyliusTpayPlugin\Payum\Action\Api\NotifyAction; use CommerceWeavers\SyliusTpayPlugin\Payum\Action\CaptureAction; @@ -39,14 +38,6 @@ ->tag('payum.action', ['factory' => TpayGatewayFactory::NAME, 'alias' => 'cw.tpay.capture']) ; - $services->set(CreateGooglePayTransactionAction::class) - ->args([ - service('commerce_weavers_sylius_tpay.tpay.factory.create_google_pay_payment_payload'), - service('commerce_weavers_sylius_tpay.payum.factory.token.notify'), - ]) - ->tag('payum.action', ['factory' => GooglePayGatewayFactory::NAME, 'alias' => 'cw.tpay_google_pay.create_google_pay_transaction']) - ; - $services->set(CreateVisaMobileTransactionAction::class) ->args([ service('commerce_weavers_sylius_tpay.tpay.factory.create_visa_mobile_payment_payload'), diff --git a/config/services/validator.php b/config/services/validator.php index c0f3dbfd..43c23b78 100644 --- a/config/services/validator.php +++ b/config/services/validator.php @@ -4,8 +4,8 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; +use CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Validator\Constraint\EncodedGooglePayTokenValidator; use CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Validator\Constraint\ValidTpayChannelValidator; -use CommerceWeavers\SyliusTpayPlugin\Validator\Constraint\EncodedGooglePayTokenValidator; use CommerceWeavers\SyliusTpayPlugin\Validator\Constraint\ForAuthorizedUserOnlyValidator; return static function(ContainerConfigurator $container): void { diff --git a/config/validation/Pay.xml b/config/validation/Pay.xml index 4c96a100..0c97e2bf 100644 --- a/config/validation/Pay.xml +++ b/config/validation/Pay.xml @@ -56,14 +56,14 @@ - - + + - + diff --git a/src/Form/Type/TpayPaymentDetailsType.php b/src/Form/Type/TpayPaymentDetailsType.php index fbfc0c72..c8dac912 100644 --- a/src/Form/Type/TpayPaymentDetailsType.php +++ b/src/Form/Type/TpayPaymentDetailsType.php @@ -6,8 +6,8 @@ use CommerceWeavers\SyliusTpayPlugin\CardPayment\Form\Type\TpayCardType; use CommerceWeavers\SyliusTpayPlugin\CardPayment\Form\Type\TpayCreditCardChoiceType; +use CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Validator\Constraint\EncodedGooglePayToken; use CommerceWeavers\SyliusTpayPlugin\PayByLinkPayment\Validator\Constraint\ValidTpayChannel; -use CommerceWeavers\SyliusTpayPlugin\Validator\Constraint\EncodedGooglePayToken; use Sylius\Component\Core\Model\ShopUserInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; diff --git a/src/Payum/Action/Api/CreateGooglePayTransactionAction.php b/src/GooglePayPayment/Payum/Action/CreateGooglePayTransactionAction.php similarity index 95% rename from src/Payum/Action/Api/CreateGooglePayTransactionAction.php rename to src/GooglePayPayment/Payum/Action/CreateGooglePayTransactionAction.php index 931f2e8f..66c7b8a6 100644 --- a/src/Payum/Action/Api/CreateGooglePayTransactionAction.php +++ b/src/GooglePayPayment/Payum/Action/CreateGooglePayTransactionAction.php @@ -2,9 +2,10 @@ declare(strict_types=1); -namespace CommerceWeavers\SyliusTpayPlugin\Payum\Action\Api; +namespace CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Payum\Action; use CommerceWeavers\SyliusTpayPlugin\Model\PaymentDetails; +use CommerceWeavers\SyliusTpayPlugin\Payum\Action\Api\BasePaymentAwareAction; use CommerceWeavers\SyliusTpayPlugin\Payum\Factory\Token\NotifyTokenFactoryInterface; use CommerceWeavers\SyliusTpayPlugin\Payum\Request\Api\CreateTransaction; use CommerceWeavers\SyliusTpayPlugin\Tpay\Factory\CreateGooglePayPaymentPayloadFactoryInterface; diff --git a/src/Validator/Constraint/EncodedGooglePayToken.php b/src/GooglePayPayment/Validator/Constraint/EncodedGooglePayToken.php similarity index 90% rename from src/Validator/Constraint/EncodedGooglePayToken.php rename to src/GooglePayPayment/Validator/Constraint/EncodedGooglePayToken.php index 621b7ba1..726ac554 100644 --- a/src/Validator/Constraint/EncodedGooglePayToken.php +++ b/src/GooglePayPayment/Validator/Constraint/EncodedGooglePayToken.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace CommerceWeavers\SyliusTpayPlugin\Validator\Constraint; +namespace CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Validator\Constraint; use Symfony\Component\Validator\Constraint; diff --git a/src/Validator/Constraint/EncodedGooglePayTokenValidator.php b/src/GooglePayPayment/Validator/Constraint/EncodedGooglePayTokenValidator.php similarity index 95% rename from src/Validator/Constraint/EncodedGooglePayTokenValidator.php rename to src/GooglePayPayment/Validator/Constraint/EncodedGooglePayTokenValidator.php index 0d489a58..2e2cd83d 100644 --- a/src/Validator/Constraint/EncodedGooglePayTokenValidator.php +++ b/src/GooglePayPayment/Validator/Constraint/EncodedGooglePayTokenValidator.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace CommerceWeavers\SyliusTpayPlugin\Validator\Constraint; +namespace CommerceWeavers\SyliusTpayPlugin\GooglePayPayment\Validator\Constraint; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; diff --git a/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig b/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig index 462ca589..24cb0caf 100644 --- a/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig +++ b/templates/bundles/SyliusShopBundle/Checkout/Complete/_navigation.html.twig @@ -2,14 +2,12 @@ {# >>> SyliusTpayPlugin customization #} {% if payment is null %} - {% set gateway_name = null %} - {% set payment_type = null %} + {% set gateway_name = null %} {% else %} {% set gateway_name = payment.method.gatewayConfig.gatewayName %} - {% set payment_type = cw_tpay_get_gateway_config_value(payment.method.gatewayConfig, 'type') %} {% endif %} -{% if payment_type in ['google_pay'] or gateway_name in ['tpay_apple_pay'] %} +{% if gateway_name in ['tpay_apple_pay', 'tpay_google_pay'] %} {{ sylius_template_event('cw.tpay.shop.checkout.complete.navigation', { form, order, payment }) }} {% else %}