diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 8cf65d5c..b336ae18 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -14,24 +14,14 @@ jobs:
fail-fast: false
matrix:
include:
- - php: 7.4
- symfony: 4.4.*
- - php: 7.4
- symfony: 5.4.*
- - php: 8.0
- symfony: 4.4.*
- php: 8.0
symfony: 5.4.*
- - php: 8.0
- symfony: 6.0.*
- - php: 8.1
- symfony: 4.4.*
- php: 8.1
symfony: 5.4.*
- - php: 8.1
- symfony: 6.0.*
- php: 8.1
symfony: 6.4.*
+ - php: 8.2
+ symfony: 5.4.*
- php: 8.2
symfony: 6.4.*
- php: 8.2
@@ -40,8 +30,12 @@ jobs:
symfony: 7.0.*
- php: 8.4
symfony: 7.0.*
+ - php: 8.4
+ symfony: 8.0.*
- php: 8.5
symfony: 7.0.*
+ - php: 8.5
+ symfony: 8.0.*
steps:
- name: Checkout
@@ -73,7 +67,7 @@ jobs:
composer require symfony/flex:"^1|^2" --no-update
- name: Install dependencies
- run: composer update
+ run: composer update --prefer-source
- name: Run unit tests
run: bin/phpunit
diff --git a/Controller/NotifyController.php b/Controller/NotifyController.php
index 15a4870c..69cc1850 100644
--- a/Controller/NotifyController.php
+++ b/Controller/NotifyController.php
@@ -9,7 +9,7 @@ class NotifyController extends PayumController
{
public function doUnsafeAction(Request $request): Response
{
- $gateway = $this->getPayum()->getGateway($request->get('gateway'));
+ $gateway = $this->getPayum()->getGateway($request->attributes->getString('gateway'));
$gateway->execute(new Notify(null));
diff --git a/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php b/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php
index 50264a1f..c57cf7a9 100644
--- a/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php
+++ b/DependencyInjection/Factory/Storage/DoctrineStorageFactory.php
@@ -4,7 +4,7 @@
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\Config\FileLocator;
class DoctrineStorageFactory extends AbstractStorageFactory
@@ -32,8 +32,8 @@ public function addConfiguration(ArrayNodeDefinition $builder): void
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
- $loader->load('doctrine.'.$config['driver'].'.xml');
+ $loader = new PhpFileLoader($container, new FileLocator(dirname(__DIR__, 3).'/Resources/config/storage'));
+ $loader->load('doctrine.'.$config['driver'].'.php');
$storage = new ChildDefinition(sprintf('payum.storage.doctrine.%s', $config['driver']));
$storage->setPublic(true);
diff --git a/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php b/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php
index 1ec38e2a..6c278c3e 100644
--- a/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php
+++ b/DependencyInjection/Factory/Storage/FilesystemStorageFactory.php
@@ -4,7 +4,7 @@
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\Config\FileLocator;
class FilesystemStorageFactory extends AbstractStorageFactory
@@ -29,8 +29,8 @@ public function addConfiguration(ArrayNodeDefinition $builder): void
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
- $loader->load('filesystem.xml');
+ $loader = new PhpFileLoader($container, new FileLocator(dirname(__DIR__, 3).'/Resources/config/storage'));
+ $loader->load('filesystem.php');
$storage = new ChildDefinition('payum.storage.filesystem.prototype');
$storage->setPublic(true);
diff --git a/DependencyInjection/Factory/Storage/Propel1StorageFactory.php b/DependencyInjection/Factory/Storage/Propel1StorageFactory.php
index 6cd9fb21..98808f8f 100644
--- a/DependencyInjection/Factory/Storage/Propel1StorageFactory.php
+++ b/DependencyInjection/Factory/Storage/Propel1StorageFactory.php
@@ -3,7 +3,7 @@
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\Config\FileLocator;
class Propel1StorageFactory extends AbstractStorageFactory
@@ -18,8 +18,8 @@ public function getName(): string
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
- $loader->load('propel1.xml');
+ $loader = new PhpFileLoader($container, new FileLocator(dirname(__DIR__, 3).'/Resources/config/storage'));
+ $loader->load('propel1.php');
$storage = new ChildDefinition('payum.storage.propel1');
$storage->setPublic(true);
diff --git a/DependencyInjection/Factory/Storage/Propel2StorageFactory.php b/DependencyInjection/Factory/Storage/Propel2StorageFactory.php
index ca29b406..caaec331 100644
--- a/DependencyInjection/Factory/Storage/Propel2StorageFactory.php
+++ b/DependencyInjection/Factory/Storage/Propel2StorageFactory.php
@@ -3,7 +3,7 @@
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\Config\FileLocator;
class Propel2StorageFactory extends AbstractStorageFactory
@@ -18,8 +18,8 @@ public function getName(): string
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
- $loader->load('propel2.xml');
+ $loader = new PhpFileLoader($container, new FileLocator(dirname(__DIR__, 3).'/Resources/config/storage'));
+ $loader->load('propel2.php');
$storage = new ChildDefinition('payum.storage.propel2');
$storage->setPublic(true);
diff --git a/DependencyInjection/PayumExtension.php b/DependencyInjection/PayumExtension.php
index ab21c178..749a3468 100644
--- a/DependencyInjection/PayumExtension.php
+++ b/DependencyInjection/PayumExtension.php
@@ -16,7 +16,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
-use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
+use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;
@@ -52,14 +52,14 @@ public function load(array $configs, ContainerBuilder $container): void
$config = $this->processConfiguration($mainConfig, $configs);
// load services
- $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
- $loader->load('payum.xml');
- $loader->load('commands.xml');
- $loader->load('controller.xml');
- $loader->load('form.xml');
+ $loader = new PhpFileLoader($container, new FileLocator(dirname(__DIR__).'/Resources/config'));
+ $loader->load('payum.php');
+ $loader->load('commands.php');
+ $loader->load('controller.php');
+ $loader->load('form.php');
if ($container->getParameter('kernel.debug')) {
- $loader->load('debug.xml');
+ $loader->load('debug.php');
}
$this->loadStorages($config['storages'], $container);
diff --git a/Form/Type/CreditCardExpirationDateType.php b/Form/Type/CreditCardExpirationDateType.php
index 136eca0a..329f6797 100644
--- a/Form/Type/CreditCardExpirationDateType.php
+++ b/Form/Type/CreditCardExpirationDateType.php
@@ -36,10 +36,7 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * @return ?string
- */
- public function getParent()
+ public function getParent(): ?string
{
return DateType::class;
}
diff --git a/Form/Type/GatewayChoiceType.php b/Form/Type/GatewayChoiceType.php
index b1b504cb..97461f02 100644
--- a/Form/Type/GatewayChoiceType.php
+++ b/Form/Type/GatewayChoiceType.php
@@ -28,10 +28,7 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * @return ?string
- */
- public function getParent()
+ public function getParent(): ?string
{
return ChoiceType::class;
}
diff --git a/Form/Type/GatewayFactoriesChoiceType.php b/Form/Type/GatewayFactoriesChoiceType.php
index 1b064607..d0f64a8f 100644
--- a/Form/Type/GatewayFactoriesChoiceType.php
+++ b/Form/Type/GatewayFactoriesChoiceType.php
@@ -28,10 +28,7 @@ public function configureOptions(OptionsResolver $resolver): void
]);
}
- /**
- * @return ?string
- */
- public function getParent()
+ public function getParent(): ?string
{
return ChoiceType::class;
}
diff --git a/Resources/config/commands.php b/Resources/config/commands.php
new file mode 100644
index 00000000..26193955
--- /dev/null
+++ b/Resources/config/commands.php
@@ -0,0 +1,32 @@
+register('payum.command.create_capture_token', CreateCaptureTokenCommand::class)
+ ->setArguments([new Reference('payum')])
+ ->addTag('console.command')
+ ;
+
+ $container->register('payum.command.create_notify_token', CreateNotifyTokenCommand::class)
+ ->setArguments([new Reference('payum')])
+ ->addTag('console.command')
+ ;
+
+ $container->register('payum.command.debug_gateway', DebugGatewayCommand::class)
+ ->setArguments([new Reference('payum')])
+ ->addTag('console.command')
+ ;
+
+ $container->register('payum.command.status', StatusCommand::class)
+ ->setArguments([new Reference('payum')])
+ ->addTag('console.command')
+ ;
+};
diff --git a/Resources/config/controller.php b/Resources/config/controller.php
new file mode 100644
index 00000000..356bcb05
--- /dev/null
+++ b/Resources/config/controller.php
@@ -0,0 +1,64 @@
+register(PayumController::class)
+ ->setAbstract(true)
+ ->setArguments([new Reference('payum')])
+ ;
+
+ $container->setDefinition(AuthorizeController::class, new ChildDefinition(PayumController::class))
+ ->setPublic(true)
+ ->setAutowired(true)
+ ->addTag('container.service_subscriber')
+ ;
+
+ $container->setDefinition(CancelController::class, new ChildDefinition(PayumController::class))
+ ->setPublic(true)
+ ->setAutowired(true)
+ ->addTag('container.service_subscriber')
+ ;
+
+ $container->setDefinition(CaptureController::class, new ChildDefinition(PayumController::class))
+ ->setPublic(true)
+ ->setAutowired(true)
+ ->addTag('container.service_subscriber')
+ ;
+
+ $container->setDefinition(NotifyController::class, new ChildDefinition(PayumController::class))
+ ->setPublic(true)
+ ->setAutowired(true)
+ ->addTag('container.service_subscriber')
+ ;
+
+ $container->setDefinition(PayoutController::class, new ChildDefinition(PayumController::class))
+ ->setPublic(true)
+ ->setAutowired(true)
+ ->addTag('container.service_subscriber')
+ ;
+
+ $container->setDefinition(RefundController::class, new ChildDefinition(PayumController::class))
+ ->setPublic(true)
+ ->setAutowired(true)
+ ->addTag('container.service_subscriber')
+ ;
+
+ $container->setDefinition(SyncController::class, new ChildDefinition(PayumController::class))
+ ->setPublic(true)
+ ->setAutowired(true)
+ ->addTag('container.service_subscriber')
+ ;
+};
diff --git a/Resources/config/debug.php b/Resources/config/debug.php
new file mode 100644
index 00000000..4dd0ad33
--- /dev/null
+++ b/Resources/config/debug.php
@@ -0,0 +1,23 @@
+register('payum.extension.log_executed_actions', LogExecutedActionsExtension::class)
+ ->setPublic(true)
+ ->setArguments([new Reference('logger', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE)])
+ ->addTag('monolog.logger', ['channel' => 'payum'])
+ ->addTag('payum.extension', ['all' => true, 'alias' => 'log_executed_actions'])
+ ;
+
+ $container->register('payum.profiler.payum_collector', PayumCollector::class)
+ ->setPublic(true)
+ ->addTag('payum.extension', ['all' => true, 'alias' => 'profile_collector', 'prepend' => true])
+ ->addTag('data_collector', ['template' => '@Payum/Profiler/payum.html.twig', 'id' => 'payum'])
+ ;
+};
diff --git a/Resources/config/form.php b/Resources/config/form.php
new file mode 100644
index 00000000..357dbb43
--- /dev/null
+++ b/Resources/config/form.php
@@ -0,0 +1,43 @@
+setParameter('payum.available_gateway_factories', []);
+
+ $container->register('payum.form.type.credit_card_expiration_date', CreditCardExpirationDateType::class)
+ ->setPublic(true)
+ ->addTag('form.type')
+ ;
+
+ $container->register('payum.form.type.credit_card', CreditCardType::class)
+ ->setPublic(true)
+ ->addTag('form.type')
+ ;
+
+ $container->register('payum.form.type.gateway_config', GatewayConfigType::class)
+ ->setPublic(true)
+ ->setArguments([new Reference('payum')])
+ ->addTag('form.type')
+ ;
+
+ $container->register('payum.form.type.gateway_factories_choice', GatewayFactoriesChoiceType::class)
+ ->setPublic(true)
+ ->setArguments(['%payum.available_gateway_factories%'])
+ ->addTag('form.type')
+ ;
+
+ $container->register('payum.form.extension.gateway_factories_choice', GatewayFactoriesChoiceTypeExtension::class)
+ ->setPublic(true)
+ ->setArguments([new Reference('payum')])
+ ->addTag('form.type_extension', ['extended_type' => GatewayFactoriesChoiceType::class])
+ ;
+};
diff --git a/Resources/config/payum.php b/Resources/config/payum.php
new file mode 100644
index 00000000..8566fd6c
--- /dev/null
+++ b/Resources/config/payum.php
@@ -0,0 +1,118 @@
+setParameter('payum.capture_path', 'payum_capture_do');
+ $container->setParameter('payum.notify_path', 'payum_notify_do');
+ $container->setParameter('payum.authorize_path', 'payum_authorize_do');
+ $container->setParameter('payum.refund_path', 'payum_refund_do');
+ $container->setParameter('payum.cancel_path', 'payum_cancel_do');
+ $container->setParameter('payum.payout_path', 'payum_payout_do');
+
+ $container->register('payum.builder', PayumBuilder::class)
+ ->setPublic(false)
+ ->addMethodCall('setMainRegistry', [new Reference('payum.static_registry')])
+ ->addMethodCall('setHttpRequestVerifier', [new Reference('payum.http_request_verifier_builder')])
+ ->addMethodCall('setTokenFactory', [new Reference('payum.token_factory_builder')])
+ ->addMethodCall('setTokenStorage', [new Reference('payum.security.token_storage')])
+ ->addMethodCall('setGenericTokenFactoryPaths', [[
+ 'capture' => '%payum.capture_path%',
+ 'notify' => '%payum.notify_path%',
+ 'authorize' => '%payum.authorize_path%',
+ 'refund' => '%payum.refund_path%',
+ 'cancel' => '%payum.cancel_path%',
+ 'payout' => '%payum.payout_path%',
+ ]])
+ ->addMethodCall('setCoreGatewayFactory', [new Reference('payum.core_gateway_factory_builder')])
+ ;
+
+ $container->register('payum', Payum::class)
+ ->setPublic(true)
+ ->setLazy(true)
+ ->setFactory([new Reference('payum.builder'), 'getPayum'])
+ ;
+
+ $container->setAlias(Payum::class, 'payum')->setPublic(true);
+
+ $container->register('payum.static_registry', ContainerAwareRegistry::class)
+ ->setPublic(true)
+ ->setArguments([
+ [], // gateways services - replaced while container is built
+ [], // storages services - replaced while container is built
+ [], // gateways factories services - replaced while container is built
+ new Reference('service_container'),
+ ])
+ ;
+
+ $container->register('payum.converter.reply_to_http_response', ReplyToSymfonyResponseConverter::class)
+ ->setPublic(true)
+ ;
+
+ $container->register('payum.listener.reply_to_http_response', ReplyToHttpResponseListener::class)
+ ->setPublic(true)
+ ->setArguments([new Reference('payum.converter.reply_to_http_response')])
+ ->addTag('kernel.event_listener', ['event' => 'kernel.exception', 'method' => 'onKernelException', 'priority' => 128])
+ ;
+
+ $container->register('payum.security.token_storage')
+ ->setAbstract(true)
+ ;
+
+ // Extensions
+ $container->register('payum.extension.storage.prototype', StorageExtension::class)
+ ->setAbstract(true)
+ ->setPublic(false)
+ ->setArguments([null]) // replaced with real storage service
+ ;
+
+ $container->register('payum.extension.logger', LoggerExtension::class)
+ ->setPublic(true)
+ ->setArguments([new Reference('logger', ContainerBuilder::IGNORE_ON_INVALID_REFERENCE)])
+ ->addTag('monolog.logger', ['channel' => 'payum'])
+ ->addTag('payum.extension', ['all' => true, 'alias' => 'psr_logger'])
+ ;
+
+ // Builders
+ $container->register('payum.token_factory_builder', TokenFactoryBuilder::class)
+ ->setPublic(false)
+ ->setArguments([new Reference('router')])
+ ;
+
+ $container->register('payum.http_request_verifier_builder', HttpRequestVerifierBuilder::class)
+ ->setPublic(false)
+ ;
+
+ $container->register('payum.core_gateway_factory_builder', CoreGatewayFactoryBuilder::class)
+ ->setPublic(false)
+ ->setArguments([new Reference('service_container')])
+ ;
+
+ $container->register('payum.action.obtain_credit_card_builder', ObtainCreditCardActionBuilder::class)
+ ->setPublic(true)
+ ->setArguments([
+ new Reference('form.factory'),
+ new Reference('request_stack'),
+ ])
+ ;
+
+ $container->register('payum.action.get_http_request', GetHttpRequestAction::class)
+ ->setPublic(true)
+ ->addMethodCall('setHttpRequestStack', [new Reference('request_stack')])
+ ;
+};
diff --git a/Resources/config/routing/all.xml b/Resources/config/routing/all.xml
deleted file mode 100644
index 408e4b42..00000000
--- a/Resources/config/routing/all.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/all.yaml b/Resources/config/routing/all.yaml
new file mode 100644
index 00000000..4260f3e3
--- /dev/null
+++ b/Resources/config/routing/all.yaml
@@ -0,0 +1,20 @@
+_payum_capture:
+ resource: "@PayumBundle/Resources/config/routing/capture.yaml"
+
+_payum_authorize:
+ resource: "@PayumBundle/Resources/config/routing/authorize.yaml"
+
+_payum_notify:
+ resource: "@PayumBundle/Resources/config/routing/notify.yaml"
+
+_payum_payout:
+ resource: "@PayumBundle/Resources/config/routing/payout.yaml"
+
+_payum_refund:
+ resource: "@PayumBundle/Resources/config/routing/refund.yaml"
+
+_payum_sync:
+ resource: "@PayumBundle/Resources/config/routing/sync.yaml"
+
+_payum_cancel:
+ resource: "@PayumBundle/Resources/config/routing/cancel.yaml"
diff --git a/Resources/config/routing/authorize.xml b/Resources/config/routing/authorize.xml
deleted file mode 100644
index 5ffa0952..00000000
--- a/Resources/config/routing/authorize.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- Payum\Bundle\PayumBundle\Controller\AuthorizeController::doAction
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/authorize.yaml b/Resources/config/routing/authorize.yaml
new file mode 100644
index 00000000..a39b910f
--- /dev/null
+++ b/Resources/config/routing/authorize.yaml
@@ -0,0 +1,4 @@
+payum_authorize_do:
+ path: /payment/authorize/{payum_token}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\AuthorizeController::doAction
diff --git a/Resources/config/routing/cancel.xml b/Resources/config/routing/cancel.xml
deleted file mode 100644
index c02e946c..00000000
--- a/Resources/config/routing/cancel.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- Payum\Bundle\PayumBundle\Controller\CancelController::doAction
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/cancel.yaml b/Resources/config/routing/cancel.yaml
new file mode 100644
index 00000000..df5a61ed
--- /dev/null
+++ b/Resources/config/routing/cancel.yaml
@@ -0,0 +1,4 @@
+payum_cancel_do:
+ path: /payment/cancel/{payum_token}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\CancelController::doAction
diff --git a/Resources/config/routing/capture.xml b/Resources/config/routing/capture.xml
deleted file mode 100644
index a79fdd88..00000000
--- a/Resources/config/routing/capture.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- Payum\Bundle\PayumBundle\Controller\CaptureController::doSessionTokenAction
-
-
-
- Payum\Bundle\PayumBundle\Controller\CaptureController::doAction
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/capture.yaml b/Resources/config/routing/capture.yaml
new file mode 100644
index 00000000..c15894a1
--- /dev/null
+++ b/Resources/config/routing/capture.yaml
@@ -0,0 +1,9 @@
+payum_capture_do_session:
+ path: /payment/capture/session-token
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\CaptureController::doSessionTokenAction
+
+payum_capture_do:
+ path: /payment/capture/{payum_token}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\CaptureController::doAction
diff --git a/Resources/config/routing/notify.xml b/Resources/config/routing/notify.xml
deleted file mode 100644
index aea2818a..00000000
--- a/Resources/config/routing/notify.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- Payum\Bundle\PayumBundle\Controller\NotifyController::doUnsafeAction
-
-
-
- Payum\Bundle\PayumBundle\Controller\NotifyController::doAction
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/notify.yaml b/Resources/config/routing/notify.yaml
new file mode 100644
index 00000000..c379bd40
--- /dev/null
+++ b/Resources/config/routing/notify.yaml
@@ -0,0 +1,9 @@
+payum_notify_do_unsafe:
+ path: /payment/notify/unsafe/{gateway}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\NotifyController::doUnsafeAction
+
+payum_notify_do:
+ path: /payment/notify/{payum_token}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\NotifyController::doAction
diff --git a/Resources/config/routing/payout.xml b/Resources/config/routing/payout.xml
deleted file mode 100644
index 9a82facb..00000000
--- a/Resources/config/routing/payout.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- Payum\Bundle\PayumBundle\Controller\PayoutController::doAction
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/payout.yaml b/Resources/config/routing/payout.yaml
new file mode 100644
index 00000000..ff5a6ccd
--- /dev/null
+++ b/Resources/config/routing/payout.yaml
@@ -0,0 +1,4 @@
+payum_payout_do:
+ path: /payment/payout/{payum_token}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\PayoutController::doAction
diff --git a/Resources/config/routing/refund.xml b/Resources/config/routing/refund.xml
deleted file mode 100644
index 5ad10966..00000000
--- a/Resources/config/routing/refund.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- Payum\Bundle\PayumBundle\Controller\RefundController::doAction
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/refund.yaml b/Resources/config/routing/refund.yaml
new file mode 100644
index 00000000..3b1f0bab
--- /dev/null
+++ b/Resources/config/routing/refund.yaml
@@ -0,0 +1,4 @@
+payum_refund_do:
+ path: /payment/refund/{payum_token}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\RefundController::doAction
diff --git a/Resources/config/routing/sync.xml b/Resources/config/routing/sync.xml
deleted file mode 100644
index 402ac937..00000000
--- a/Resources/config/routing/sync.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
- Payum\Bundle\PayumBundle\Controller\SyncController::doAction
-
-
\ No newline at end of file
diff --git a/Resources/config/routing/sync.yaml b/Resources/config/routing/sync.yaml
new file mode 100644
index 00000000..fdcaff40
--- /dev/null
+++ b/Resources/config/routing/sync.yaml
@@ -0,0 +1,4 @@
+payum_sync_do:
+ path: /payment/sync/{payum_token}
+ defaults:
+ _controller: Payum\Bundle\PayumBundle\Controller\SyncController::doAction
diff --git a/Resources/config/storage/doctrine.mongodb.php b/Resources/config/storage/doctrine.mongodb.php
new file mode 100644
index 00000000..6a78f38f
--- /dev/null
+++ b/Resources/config/storage/doctrine.mongodb.php
@@ -0,0 +1,30 @@
+parameters()
+ ->set('payum.storage.doctrine.mongodb.class', DoctrineStorage::class)
+ ;
+
+ $services = $container->services();
+
+ $services->set('payum.storage.doctrine.mongodb', '%payum.storage.doctrine.mongodb.class%')
+ ->public(false)
+ ->abstract()
+ ->args([
+ ref('payum.document_manager'),
+ null, // should be set in DoctrineStorageFactory
+ ])
+ ;
+
+ $services->set('payum.document_manager', DocumentManager::class)
+ ->public(false)
+ ->factory([ref('doctrine_mongodb'), 'getManager'])
+ ;
+};
diff --git a/Resources/config/storage/doctrine.orm.php b/Resources/config/storage/doctrine.orm.php
new file mode 100644
index 00000000..4f8216c3
--- /dev/null
+++ b/Resources/config/storage/doctrine.orm.php
@@ -0,0 +1,24 @@
+setParameter('payum.storage.doctrine.orm.class', DoctrineStorage::class);
+
+ $container->register('payum.storage.doctrine.orm', '%payum.storage.doctrine.orm.class%')
+ ->setPublic(false)
+ ->setAbstract(true)
+ ->setArguments([
+ new Reference('payum.entity_manager'),
+ null, // should be set in DoctrineStorageFactory
+ ])
+ ;
+
+ $container->setAlias('payum.entity_manager', 'doctrine.orm.default_entity_manager')
+ ->setPublic(false)
+ ;
+};
diff --git a/Resources/config/storage/filesystem.php b/Resources/config/storage/filesystem.php
new file mode 100644
index 00000000..73b5e6c8
--- /dev/null
+++ b/Resources/config/storage/filesystem.php
@@ -0,0 +1,24 @@
+parameters()
+ ->set('payum.storage.filesystem.class', FilesystemStorage::class)
+ ;
+
+ $services = $container->services();
+
+ $services->set('payum.storage.filesystem.prototype', '%payum.storage.filesystem.class%')
+ ->public(false)
+ ->abstract()
+ ->args([
+ null, // should be set in FilesystemStorageFactory
+ null, // should be set in FilesystemStorageFactory
+ null, // should be set in FilesystemStorageFactory
+ ])
+ ;
+};
diff --git a/Resources/config/storage/propel1.php b/Resources/config/storage/propel1.php
new file mode 100644
index 00000000..7b1154bb
--- /dev/null
+++ b/Resources/config/storage/propel1.php
@@ -0,0 +1,16 @@
+services();
+
+ $services->set('payum.storage.propel1', Propel1Storage::class)
+ ->public(false)
+ ->abstract()
+ ->args([null]) // should be set in Propel1StorageFactory
+ ;
+};
diff --git a/Resources/config/storage/propel2.php b/Resources/config/storage/propel2.php
new file mode 100644
index 00000000..e7284e65
--- /dev/null
+++ b/Resources/config/storage/propel2.php
@@ -0,0 +1,16 @@
+services();
+
+ $services->set('payum.storage.propel2', Propel2Storage::class)
+ ->public(false)
+ ->abstract()
+ ->args([null]) // should be set in Propel2StorageFactory
+ ;
+};
diff --git a/Security/HttpRequestVerifier.php b/Security/HttpRequestVerifier.php
index 635fe764..189d4f87 100644
--- a/Security/HttpRequestVerifier.php
+++ b/Security/HttpRequestVerifier.php
@@ -36,7 +36,7 @@ public function verify($httpRequest)
));
}
- if (! $hash = $httpRequest->attributes->get('payum_token', $httpRequest->get('payum_token', false))) {
+ if (! $hash = $httpRequest->attributes->getString('payum_token', $httpRequest->query->getString('payum_token', $httpRequest->request->getString('payum_token')))) {
throw new NotFoundHttpException('Token parameter not set in request');
}
diff --git a/Tests/Controller/NotifyControllerTest.php b/Tests/Controller/NotifyControllerTest.php
index e8f7db3e..4f5efd89 100644
--- a/Tests/Controller/NotifyControllerTest.php
+++ b/Tests/Controller/NotifyControllerTest.php
@@ -6,12 +6,8 @@
use Payum\Core\GatewayInterface;
use Payum\Core\Payum;
use Payum\Core\Request\Notify;
-use Payum\Core\Security\GenericTokenFactoryInterface;
-use Payum\Core\Security\HttpRequestVerifierInterface;
-use Payum\Core\Storage\StorageInterface;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
-use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -33,31 +29,20 @@ public function shouldBeSubClassOfController(): void
public function shouldExecuteNotifyRequestOnDoUnsafe(): void
{
$request = Request::create('/');
- $request->query->set('gateway', 'theGatewayName');
+ $request->attributes->set('gateway', 'theGatewayName');
$gatewayMock = $this->createMock(GatewayInterface::class);
$gatewayMock
->method('execute')
->with($this->isInstanceOf(Notify::class));
- $registryMock = $this->createMock(Payum::class);
- $registryMock
+ $payumMock = $this->createMock(Payum::class);
+ $payumMock
->method('getGateway')
->with('theGatewayName')
->willReturn($gatewayMock);
- $this->httpRequestVerifierMock = $this->createMock(
- HttpRequestVerifierInterface::class
- );
-
- $this->payum = new Payum(
- $registryMock,
- $this->httpRequestVerifierMock,
- $this->createMock(GenericTokenFactoryInterface::class),
- $this->createMock(StorageInterface::class)
- );
-
- $controller = new NotifyController($this->payum);
+ $controller = new NotifyController($payumMock);
$response = $controller->doUnsafeAction($request);
diff --git a/Tests/DependencyInjection/PayumExtensionTest.php b/Tests/DependencyInjection/PayumExtensionTest.php
index 2a74d43a..60adcc6d 100644
--- a/Tests/DependencyInjection/PayumExtensionTest.php
+++ b/Tests/DependencyInjection/PayumExtensionTest.php
@@ -66,8 +66,8 @@ public function shouldAllowAddStorageFactory(): void
*/
public function throwIfTryToAddStorageFactoryWithEmptyName(): void
{
- $this->expectExceptionMessage("The storage factory Mock_StorageFactoryInterface_");
$this->expectException(\Payum\Core\Exception\InvalidArgumentException::class);
+ $this->expectExceptionMessageMatches('/The storage factory (Mock|MockObject)_StorageFactoryInterface_/');
$factoryWithEmptyName = $this->createMock(StorageFactoryInterface::class);
$factoryWithEmptyName
->expects($this->once())
diff --git a/Tests/Functional/app/config/config_sf8.yml b/Tests/Functional/app/config/config_sf8.yml
new file mode 100644
index 00000000..70454b36
--- /dev/null
+++ b/Tests/Functional/app/config/config_sf8.yml
@@ -0,0 +1,6 @@
+framework:
+ session:
+ handler_id: null
+ cookie_secure: auto
+ cookie_samesite: lax
+ storage_factory_id: session.storage.factory.mock_file
diff --git a/Tests/Functional/app/config/routing.yml b/Tests/Functional/app/config/routing.yml
index 827711c9..a08aab11 100644
--- a/Tests/Functional/app/config/routing.yml
+++ b/Tests/Functional/app/config/routing.yml
@@ -1,5 +1,5 @@
payum_all:
- resource: "@PayumBundle/Resources/config/routing/all.xml"
+ resource: "@PayumBundle/Resources/config/routing/all.yaml"
prefix: /
foo:
diff --git a/Tests/ReplyToSymfonyResponseConverterTest.php b/Tests/ReplyToSymfonyResponseConverterTest.php
index 4e8e4912..7d84e9ea 100644
--- a/Tests/ReplyToSymfonyResponseConverterTest.php
+++ b/Tests/ReplyToSymfonyResponseConverterTest.php
@@ -96,7 +96,7 @@ public function testShouldReturnResponseIfSymfonyHttpResponseReply(): void
public function testShouldChangeReplyToLogicExceptionIfNotSupported(): void
{
$this->expectException(LogicException::class);
- $this->expectExceptionMessage('Cannot convert reply Mock_Base_');
+ $this->expectExceptionMessageMatches('/Cannot convert reply (Mock|MockObject)_Base_/');
$notSupportedReply = $this->createMock(Base::class);
$listener = new ReplyToSymfonyResponseConverter();
diff --git a/Validator/Constraints/CreditCardDate.php b/Validator/Constraints/CreditCardDate.php
index 58b186fd..a48e6b99 100644
--- a/Validator/Constraints/CreditCardDate.php
+++ b/Validator/Constraints/CreditCardDate.php
@@ -20,17 +20,40 @@ class CreditCardDate extends Constraint
public $min;
- public function __construct($options = null)
- {
- parent::__construct($options);
+ public function __construct(
+ string|array|null $min = null,
+ ?string $minMessage = null,
+ ?string $invalidMessage = null,
+ ?array $groups = null,
+ mixed $payload = null,
+ ) {
+ // Handle BC: if $min is an array, it's old-style options
+ if (is_array($min)) {
+ $options = $min;
+ $minValue = $options['min'] ?? null;
+ $minMessage = $options['minMessage'] ?? $minMessage;
+ $invalidMessage = $options['invalidMessage'] ?? $invalidMessage;
+ parent::__construct($options, $groups, $payload);
+ } else {
+ $minValue = $min;
+ parent::__construct([], $groups, $payload);
+ }
+
+ if ($minValue !== null) {
+ $this->min = $minValue;
+ }
+ if ($minMessage !== null) {
+ $this->minMessage = $minMessage;
+ }
+ if ($invalidMessage !== null) {
+ $this->invalidMessage = $invalidMessage;
+ }
if (null === $this->min) {
throw new MissingOptionsException('Either option "min" must be given for constraint ' . self::class, ['min']);
}
- if (null !== $this->min) {
- $this->min = new DateTime($this->min);
- $this->min->modify('last day of this month');
- }
+ $this->min = new DateTime($this->min);
+ $this->min->modify('last day of this month');
}
}
diff --git a/composer.json b/composer.json
index cfa2fa0b..e885dc86 100644
--- a/composer.json
+++ b/composer.json
@@ -37,14 +37,13 @@
}
],
"require": {
- "php": "^7.4 || ^8.0",
+ "php": "^8.0",
"payum/core": "^1.7.2",
- "symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/form": "^4.4.20 || ^5.4 || ^6.0 || ^7.0",
- "symfony/validator": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/security-csrf": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/dependency-injection": "^4.4 || ^5.4 || ^6.4 || ^7.0",
- "symfony/polyfill-php80": "^1.26"
+ "symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/form": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/validator": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/security-csrf": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0 || ^8.0"
},
"require-dev": {
"defuse/php-encryption": "^2",
@@ -57,16 +56,19 @@
"payum/stripe": "^1.7",
"payum/omnipay-v3-bridge": "dev-master",
"php-http/guzzle7-adapter": "^1.0",
- "phpunit/phpunit": "^9.5",
+ "symfony/http-client": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "nyholm/psr7": "^1.5",
+ "php-http/message-factory": "^1.1",
+ "phpunit/phpunit": "^9.5 || ^10.0",
"psr/log": "^1 || ^2 || ^3",
"stripe/stripe-php": "~7.0",
- "symfony/browser-kit": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/expression-language": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/phpunit-bridge": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/templating": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/twig-bundle": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/web-profiler-bundle": "^4.4 || ^5.4 || ^6.0 || ^7.0",
- "symfony/yaml": "^4.4 || ^5.4 || ^6.0 || ^7.0",
+ "symfony/browser-kit": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/expression-language": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/phpunit-bridge": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/templating": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/web-profiler-bundle": "^5.4 || ^6.0 || ^7.0 || ^8.0",
+ "symfony/yaml": "^5.4 || ^6.0 || ^7.0 || ^8.0",
"twig/twig": "^2.0 || ^3.0"
},
"suggest": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 4aa666be..9a0f9edc 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,19 +1,16 @@
./Tests
+ ./Tests/Controller/AbstractControllerTest.php