Skip to content
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
18 changes: 1 addition & 17 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ 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.1.*

Expand Down Expand Up @@ -59,7 +43,7 @@ jobs:

- name: Install Symfony Flex
run: |
composer require symfony/flex:^1 --no-update
composer require symfony/flex:^2 --no-update
composer config --no-plugins allow-plugins.symfony/flex true

- name: Install dependencies
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 3.0.0 (2022-09-xx)

* Support for Symfony < 6.1 dropped
* Support for PHP < 8.1 dropped
* remove deprecated functions getPayum, getHttpRequestVerifier and getTokenFactory in PayumController

## 2.5.0 (2022-07-xx)

* Support for Symfony 5.0 - 5.3 dropped
Expand Down
13 changes: 3 additions & 10 deletions Command/CreateCaptureTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
#[AsCommand(name: 'payum:security:create-capture-token')]
class CreateCaptureTokenCommand extends Command
{
protected static $defaultName = 'payum:security:create-capture-token';

private Payum $payum;

public function __construct(Payum $payum)
public function __construct(private readonly Payum $payum)
{
$this->payum = $payum;

parent::__construct();
}

Expand All @@ -30,7 +24,6 @@ public function __construct(Payum $payum)
protected function configure(): void
{
$this
->setName(static::$defaultName)
->addArgument('gateway-name', InputArgument::REQUIRED, 'The gateway name associated with the token')
->addOption('model-class', null, InputOption::VALUE_OPTIONAL, 'The model class associated with the token')
->addOption('model-id', null, InputOption::VALUE_OPTIONAL, 'The model id associated with the token')
Expand All @@ -50,7 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$model = null;
if ($modelClass && $modelId) {
if (false === $model = $this->payum->getStorage($modelClass)->find($modelId)) {
if (!$model = $this->payum->getStorage($modelClass)->find($modelId)) {
throw new RuntimeException(sprintf(
'Cannot find model with class %s and id %s.',
$modelClass,
Expand All @@ -66,6 +59,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(sprintf('After Url: <info>%s</info>', $token->getAfterUrl() ?: 'null'));
$output->writeln(sprintf('Details: <info>%s</info>', (string) $token->getDetails()));

return 0;
return Command::SUCCESS;
}
}
13 changes: 3 additions & 10 deletions Command/CreateNotifyTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@
#[AsCommand(name: 'payum:security:create-notify-token')]
class CreateNotifyTokenCommand extends Command
{
protected static $defaultName = 'payum:security:create-notify-token';

private Payum $payum;

public function __construct(Payum $payum)
public function __construct(private readonly Payum $payum)
{
$this->payum = $payum;

parent::__construct();
}

Expand All @@ -30,7 +24,6 @@ public function __construct(Payum $payum)
protected function configure(): void
{
$this
->setName(static::$defaultName)
->addArgument('gateway-name', InputArgument::REQUIRED, 'The gateway name associated with the token')
->addOption('model-class', null, InputOption::VALUE_OPTIONAL, 'The model class associated with the token')
->addOption('model-id', null, InputOption::VALUE_OPTIONAL, 'The model id associated with the token')
Expand All @@ -48,7 +41,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$model = null;

if ($modelClass && $modelId) {
if (false === $model = $this->payum->getStorage($modelClass)->find($modelId)) {
if (!$model = $this->payum->getStorage($modelClass)->find($modelId)) {
throw new RuntimeException(sprintf(
'Cannot find model with class %s and id %s.',
$modelClass,
Expand All @@ -63,6 +56,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(sprintf('Url: <info>%s</info>', $token->getTargetUrl()));
$output->writeln(sprintf('Details: <info>%s</info>', (string) $token->getDetails() ?: 'null'));

return 0;
return Command::SUCCESS;
}
}
26 changes: 15 additions & 11 deletions Command/DebugGatewayCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Payum\Core\Extension\StorageExtension;
use Payum\Core\Gateway;
use Payum\Core\GatewayInterface;
use Payum\Core\Payum;
use Payum\Core\Storage\AbstractStorage;
use Symfony\Component\Console\Attribute\AsCommand;
Expand All @@ -16,13 +17,8 @@
#[AsCommand(name: 'debug:payum:gateway', aliases: ['payum:gateway:debug'])]
class DebugGatewayCommand extends Command
{
protected static $defaultName = 'debug:payum:gateway';

protected Payum $payum;

public function __construct(Payum $payum)
public function __construct(protected Payum $payum)
{
$this->payum = $payum;
parent::__construct();
}

Expand All @@ -32,8 +28,6 @@ public function __construct(Payum $payum)
protected function configure(): void
{
$this
->setName(static::$defaultName)
->setAliases(['payum:gateway:debug'])
->addArgument('gateway-name', InputArgument::OPTIONAL, 'The gateway name you want to get information about.')
->addOption('show-supports', null, InputOption::VALUE_NONE, 'Show what actions supports.')
;
Expand Down Expand Up @@ -62,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('');
$output->writeln(sprintf('%s (%s):', $name, get_class($gateway)));

if (false === $gateway instanceof Gateway) {
if (!$gateway instanceof Gateway) {
continue;
}

Expand Down Expand Up @@ -127,9 +121,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

return 0;
return Command::SUCCESS;
}

/**
* @return list<string>
*/
protected function getMethodCode(\ReflectionMethod $reflectionMethod): array
{
$file = file($reflectionMethod->getFileName());
Expand All @@ -142,7 +139,10 @@ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array
return array_values($methodCodeLines);
}

private function findProperGatewayName(InputInterface $input, OutputInterface $output, array $gateways, string $name)
/**
* @param array<string, GatewayInterface> $gateways
*/
private function findProperGatewayName(InputInterface $input, OutputInterface $output, array $gateways, string $name): string
{
$helperSet = $this->getHelperSet();
if (!$helperSet->has('question') || isset($gateways[$name]) || !$input->isInteractive()) {
Expand All @@ -159,6 +159,10 @@ private function findProperGatewayName(InputInterface $input, OutputInterface $o
return $this->getHelper('question')->ask($input, $output, $question);
}

/**
* @param array<string, GatewayInterface> $gateways
* @return list<string>
*/
private function findGatewaysContaining(array $gateways, string $name): array
{
$threshold = 1e3;
Expand Down
12 changes: 3 additions & 9 deletions Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
#[AsCommand(name: 'payum:status', description: 'Allows to get a payment status.')]
class StatusCommand extends Command
{
protected static $defaultName = 'payum:status';

protected Payum $payum;

public function __construct(Payum $payum)
public function __construct(protected Payum $payum)
{
$this->payum = $payum;
parent::__construct();
}

Expand All @@ -30,7 +25,6 @@ public function __construct(Payum $payum)
protected function configure(): void
{
$this
->setName(static::$defaultName)
->setDescription('Allows to get a payment status.')
->addArgument('gateway-name', InputArgument::REQUIRED, 'The gateway name')
->addOption('model-class', null, InputOption::VALUE_REQUIRED, 'The model class')
Expand All @@ -48,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$modelId = $input->getOption('model-id');

$storage = $this->payum->getStorage($modelClass);
if (false === $model = $storage->find($modelId)) {
if (!$model = $storage->find($modelId)) {
throw new RuntimeException(sprintf(
'Cannot find model with class %s and id %s.',
$modelClass,
Expand All @@ -61,6 +55,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$output->writeln(sprintf('Status: %s', $status->getValue()));

return 0;
return Command::SUCCESS;
}
}
6 changes: 3 additions & 3 deletions Controller/AuthorizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class AuthorizeController extends PayumController
{
public function doAction(Request $request): RedirectResponse
{
$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
$token = $this->payum->getHttpRequestVerifier()->verify($request);

$gateway = $this->getPayum()->getGateway($token->getGatewayName());
$gateway = $this->payum->getGateway($token->getGatewayName());
$gateway->execute(new Authorize($token));

$this->getPayum()->getHttpRequestVerifier()->invalidate($token);
$this->payum->getHttpRequestVerifier()->invalidate($token);

return $this->redirect($token->getAfterUrl());
}
Expand Down
6 changes: 3 additions & 3 deletions Controller/CancelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class CancelController extends PayumController
*/
public function doAction(Request $request): Response
{
$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
$token = $this->payum->getHttpRequestVerifier()->verify($request);

$gateway = $this->getPayum()->getGateway($token->getGatewayName());
$gateway = $this->payum->getGateway($token->getGatewayName());
$gateway->execute(new Cancel($token));

$this->getPayum()->getHttpRequestVerifier()->invalidate($token);
$this->payum->getHttpRequestVerifier()->invalidate($token);

return $token->getAfterUrl() ?
$this->redirect($token->getAfterUrl()) :
Expand Down
6 changes: 3 additions & 3 deletions Controller/CaptureController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function doSessionTokenAction(Request $request): RedirectResponse

public function doAction(Request $request): RedirectResponse
{
$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
$token = $this->payum->getHttpRequestVerifier()->verify($request);

$gateway = $this->getPayum()->getGateway($token->getGatewayName());
$gateway = $this->payum->getGateway($token->getGatewayName());
$gateway->execute(new Capture($token));

$this->getPayum()->getHttpRequestVerifier()->invalidate($token);
$this->payum->getHttpRequestVerifier()->invalidate($token);

return $this->redirect($token->getAfterUrl());
}
Expand Down
6 changes: 3 additions & 3 deletions Controller/NotifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class NotifyController extends PayumController
{
public function doUnsafeAction(Request $request): Response
{
$gateway = $this->getPayum()->getGateway($request->get('gateway'));
$gateway = $this->payum->getGateway($request->get('gateway'));

$gateway->execute(new Notify(null));

Expand All @@ -18,9 +18,9 @@ public function doUnsafeAction(Request $request): Response

public function doAction(Request $request): Response
{
$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
$token = $this->payum->getHttpRequestVerifier()->verify($request);

$gateway = $this->getPayum()->getGateway($token->getGatewayName());
$gateway = $this->payum->getGateway($token->getGatewayName());

$gateway->execute(new Notify($token));

Expand Down
6 changes: 3 additions & 3 deletions Controller/PayoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class PayoutController extends PayumController
{
public function doAction(Request $request): RedirectResponse
{
$token = $this->getPayum()->getHttpRequestVerifier()->verify($request);
$token = $this->payum->getHttpRequestVerifier()->verify($request);

$gateway = $this->getPayum()->getGateway($token->getGatewayName());
$gateway = $this->payum->getGateway($token->getGatewayName());
$gateway->execute(new Payout($token));

$this->getPayum()->getHttpRequestVerifier()->invalidate($token);
$this->payum->getHttpRequestVerifier()->invalidate($token);

return $this->redirect($token->getAfterUrl());
}
Expand Down
Loading