Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Simplify configuring allowed payment methods #139

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions config/admin_routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ commerce_weavers_saferpay_transaction_log:
icon: 'th list'
type: sylius.resource
prefix: saferpay

commerce_weavers_saferpay_admin_transaction_log_show:
path: /saferpay/transaction-logs/{id}
methods: [ GET ]
Expand All @@ -22,6 +22,14 @@ commerce_weavers_saferpay_admin_transaction_log_show:

commerce_weavers_sylius_saferpay_admin_configure_payment_methods:
path: /payment-methods/{id}/configure-saferpay-payment-methods
methods: [GET, POST]
methods: [GET, PATCH]
defaults:
_controller: CommerceWeavers\SyliusSaferpayPlugin\Controller\Action\ConfigurePaymentMethodsAction
_controller: sylius.controller.payment_method::updateAction
_sylius:
template: '@CommerceWeaversSyliusSaferpayPlugin/Admin/PaymentMethod/configurePaymentMethods.html.twig'
redirect: sylius_admin_payment_method_index
form:
type: CommerceWeavers\SyliusSaferpayPlugin\Form\Type\SaferpayPaymentMethodsConfigurationType
options:
paymentMethod: expr:service('sylius.repository.payment_method').find($id)
validation_groups: ['sylius']
Empty file removed config/services/.gitkeep
Empty file.
13 changes: 0 additions & 13 deletions config/services/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use CommerceWeavers\SyliusSaferpayPlugin\Controller\Action\AfterUnsuccessfulPaymentAction;
use CommerceWeavers\SyliusSaferpayPlugin\Controller\Action\AssertAction;
use CommerceWeavers\SyliusSaferpayPlugin\Controller\Action\ConfigurePaymentMethodsAction;
use CommerceWeavers\SyliusSaferpayPlugin\Controller\Action\PrepareAssertAction;
use CommerceWeavers\SyliusSaferpayPlugin\Controller\Action\PrepareCaptureAction;
use CommerceWeavers\SyliusSaferpayPlugin\Controller\Action\WebhookAction;
Expand Down Expand Up @@ -64,18 +63,6 @@
->tag('controller.service_arguments')
;

$services
->set(ConfigurePaymentMethodsAction::class)
->args([
service('sylius.command_bus'),
service('form.factory'),
service('twig'),
service('router'),
service('sylius.repository.payment_method'),
])
->tag('controller.service_arguments')
;

$services
->set(WebhookAction::class)
->args([
Expand Down
11 changes: 0 additions & 11 deletions config/services/command_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,17 @@

declare(strict_types=1);

use CommerceWeavers\SyliusSaferpayPlugin\CommandHandler\ConfigurePaymentMethodsHandler;
use CommerceWeavers\SyliusSaferpayPlugin\Payment\Command\Handler\AssertPaymentHandler;
use CommerceWeavers\SyliusSaferpayPlugin\Payment\Command\Handler\CapturePaymentHandler;
use CommerceWeavers\SyliusSaferpayPlugin\Payum\Factory\AssertFactoryInterface;
use CommerceWeavers\SyliusSaferpayPlugin\Payum\Factory\CaptureFactoryInterface;
use CommerceWeavers\SyliusSaferpayPlugin\Payum\Factory\ResolveNextCommandFactoryInterface;
use CommerceWeavers\SyliusSaferpayPlugin\Processor\SaferpayPaymentProcessor;
use CommerceWeavers\SyliusSaferpayPlugin\Provider\PaymentProviderInterface;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $containerConfigurator) {
$services = $containerConfigurator->services();

$services
->set(ConfigurePaymentMethodsHandler::class)
->args([
service('sylius.repository.payment_method'),
])
->tag('messenger.message_handler', ['bus' => 'sylius.command_bus'])
;

$services
->set(AssertPaymentHandler::class)
->args([
Expand Down
18 changes: 0 additions & 18 deletions spec/Command/ConfigurePaymentMethodsSpec.php

This file was deleted.

57 changes: 0 additions & 57 deletions spec/CommandHandler/ConfigurePaymentMethodsHandlerSpec.php

This file was deleted.

22 changes: 0 additions & 22 deletions src/Command/ConfigurePaymentMethods.php

This file was deleted.

31 changes: 0 additions & 31 deletions src/CommandHandler/ConfigurePaymentMethodsHandler.php

This file was deleted.

100 changes: 0 additions & 100 deletions src/Controller/Action/ConfigurePaymentMethodsAction.php

This file was deleted.

1 change: 1 addition & 0 deletions src/Form/Type/SaferpayPaymentMethodsConfigurationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'choice_label' => function (string $paymentMethodData): string {
return $paymentMethodData;
},
'property_path' => 'gatewayConfig.config[allowed_payment_methods]',
'expanded' => true,
'label' => 'commerce_weavers_saferpay.ui.allowed_payment_methods',
'multiple' => true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% form_theme form '@SyliusAdmin/Form/theme.html.twig' %}

{{ form_start(form, {'attr': {'class': 'ui loadable form', 'novalidate': 'novalidate'}}) }}
<input type="hidden" name="_method" value="PATCH" />
{% include '@SyliusAdmin/Crud/form_validation_errors_checker.html.twig' %}
{{ form_errors(form) }}

Expand Down
Loading