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

Version 3 #545

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Changelog

## 3.0.0 (2022-09-xx)

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

## 2.5.0 (2022-07-xx)

* Support for Symfony 5.0 - 5.3 dropped
* Support for Symfony 4.0 - 4.3 dropped
Chris53897 marked this conversation as resolved.
Show resolved Hide resolved
* Added support for Symfony 6.0
* Minimum Payum Core dependency updated to 1.7.2

Expand Down
2 changes: 1 addition & 1 deletion Command/CreateCaptureTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,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 Down
2 changes: 1 addition & 1 deletion Command/CreateNotifyTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,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 Down
13 changes: 12 additions & 1 deletion 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 Down Expand Up @@ -55,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 @@ -123,6 +124,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return Command::SUCCESS;
}

/**
* @return array<int, string>
Chris53897 marked this conversation as resolved.
Show resolved Hide resolved
*/
protected function getMethodCode(\ReflectionMethod $reflectionMethod): array
{
$file = file($reflectionMethod->getFileName());
Expand All @@ -135,6 +139,9 @@ protected function getMethodCode(\ReflectionMethod $reflectionMethod): array
return array_values($methodCodeLines);
}

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

/**
* @param array<string, GatewayInterface> $gateways
* @return array<int, string>
Chris53897 marked this conversation as resolved.
Show resolved Hide resolved
*/
private function findGatewaysContaining(array $gateways, string $name): array
{
$threshold = 1e3;
Expand Down
2 changes: 1 addition & 1 deletion Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,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 Down
3 changes: 3 additions & 0 deletions DependencyInjection/Compiler/BuildConfigsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function process(ContainerBuilder $container): void
}
}

/**
* @return array[]
Chris53897 marked this conversation as resolved.
Show resolved Hide resolved
*/
protected function processTagData(array $tagData, string $namePrefix, string $prependKey): array
{
$coreGatewayFactoryConfig = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ public function addConfiguration(ArrayNodeDefinition $builder): void
{
}

/**
* @param array<string, mixed> $config
*/
abstract protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): Definition;
}
3 changes: 3 additions & 0 deletions DependencyInjection/Factory/Storage/CustomStorageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public function getName(): string
return 'custom';
}

/**
* @param array<string, mixed> $config
*/
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
return new ChildDefinition($config['service']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public function addConfiguration(ArrayNodeDefinition $builder): void
->end();
}

/**
* @param array<string, mixed> $config
*/
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function addConfiguration(ArrayNodeDefinition $builder): void
->end();
}

/**
* @param array<string, mixed> $config
*/
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
Expand Down
3 changes: 3 additions & 0 deletions DependencyInjection/Factory/Storage/Propel1StorageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public function getName(): string
return "propel1";
}

/**
* @param array<string, mixed> $config
*/
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
Expand Down
3 changes: 3 additions & 0 deletions DependencyInjection/Factory/Storage/Propel2StorageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ public function getName(): string
return "propel2";
}

/**
* @param array<string, mixed> $config
*/
protected function createStorage(ContainerBuilder $container, string $modelClass, array $config): ChildDefinition
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config/storage'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
interface StorageFactoryInterface
{
/**
* @param array<string, mixed> $config
* @return string The payment serviceId
*/
public function create(ContainerBuilder $container, string $modelClass, array $config): string;
Expand All @@ -15,7 +16,7 @@ public function create(ContainerBuilder $container, string $modelClass, array $c
* The storage name,
* For example filesystem, doctrine, propel etc.
*/
public function getName();
public function getName(): string;

public function addConfiguration(ArrayNodeDefinition $builder): void;
}
9 changes: 9 additions & 0 deletions DependencyInjection/PayumExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ protected function loadStorages(array $config, ContainerBuilder $container): voi
}
}

/**
* @param array<string, mixed> $securityConfig
*/
protected function loadSecurity(array $securityConfig, ContainerBuilder $container): void
{
foreach ($securityConfig['token_storage'] as $tokenClass => $tokenStorageConfig) {
Expand All @@ -183,6 +186,9 @@ protected function loadSecurity(array $securityConfig, ContainerBuilder $contain
}
}

/**
* @param array<string, mixed> $dynamicGatewaysConfig
*/
protected function loadDynamicGateways(array $dynamicGatewaysConfig, ContainerBuilder $container): void
{
$configClass = null;
Expand Down Expand Up @@ -278,6 +284,9 @@ public function getConfiguration(array $config, ContainerBuilder $container): Ma
return new MainConfiguration($this->storagesFactories);
}

/**
* @param array<string, mixed> $storageConfig
*/
protected function findSelectedStorageFactoryNameInStorageConfig(array $storageConfig): string
{
foreach ($storageConfig as $name => $value) {
Expand Down
2 changes: 1 addition & 1 deletion EventListener/ReplyToHttpResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function onKernelException(ExceptionEvent $event): void
return;
}

/** @var $throwable ReplyInterface */
/** @var ReplyInterface $throwable */
$throwable = $event->getThrowable();
$response = $this->replyToSymfonyResponseConverter->convert($throwable);

Expand Down
12 changes: 12 additions & 0 deletions Profiler/PayumCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ public function reset(): void
$this->data = [];
}

/**
* @param array<string, mixed> $contextData
*/
protected function formatAction(array $contextData): string
{
return sprintf(
Expand All @@ -151,6 +154,9 @@ protected function formatAction(array $contextData): string
);
}

/**
* @param array<string, mixed> $contextData
*/
protected function formatReply(array $contextData): string
{
return sprintf(
Expand All @@ -160,6 +166,9 @@ protected function formatReply(array $contextData): string
);
}

/**
* @param array<string, mixed> $contextData
*/
protected function formatException(array $contextData): string
{
return sprintf(
Expand All @@ -169,6 +178,9 @@ protected function formatException(array $contextData): string
);
}

/**
* @param array<string, mixed> $contextData
*/
protected function formatRequest(array $contextData): string
{
return sprintf(
Expand Down
14 changes: 5 additions & 9 deletions Resources/doc/configure-payment-in-backend.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,13 @@ namespace Acme\PaymentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\GatewayConfig as BaseGatewayConfig;

/**
* @ORM\Table
* @ORM\Entity
*/
#[ORM\Table]
#[ORM\Entity]
class GatewayConfig extends BaseGatewayConfig
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
#[ORM\Column]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
protected int $id;
}
```
Expand Down
14 changes: 5 additions & 9 deletions Resources/doc/custom_purchase_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ namespace Acme\PaymentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\ArrayObject;

/**
* @ORM\Table
* @ORM\Entity
*/
#[ORM\Table]
#[ORM\Entity]
class PaymentDetails extends ArrayObject
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
#[ORM\Column]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: "IDENTITY")]
protected int $id;
}
```
Expand Down
6 changes: 3 additions & 3 deletions Resources/doc/custom_purchase_examples/authorize_net_aim.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ use Symfony\Component\HttpFoundation\Request;

class PaymentController extends Controller
{
public function prepareAuthorizeNetPaymentAction(Request $request)
public function prepareAuthorizeNetPaymentAction(Request $request, Payum $payum)
{
$gatewayName = 'your_gateway_name';

$storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails');
$storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails');

/** @var \Acme\PaymentBundle\Entity\PaymentDetails $details */
$details = $storage->create();
Expand All @@ -59,7 +59,7 @@ class PaymentController extends Controller
$details['clientemail'] = 'user@email.com';
$storage->update($details);

$captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken(
$captureToken = $payum->getTokenFactory()->createCaptureToken(
$gatewayName,
$details,
'acme_gateway_done' // the route to redirect after capture
Expand Down
6 changes: 3 additions & 3 deletions Resources/doc/custom_purchase_examples/be2bill.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ use Symfony\Component\HttpFoundation\Request;

class PaymentController extends Controller
{
public function prepareBe2BillPaymentAction(Request $request)
public function prepareBe2BillPaymentAction(Request $request, Payum $payum)
{
$gatewayName = 'your_gateway_name';

$storage = $this->get('payum')->getStorage('Acme\PaymentBundle\Entity\PaymentDetails');
$storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails');

/** @var \Acme\PaymentBundle\Entity\PaymentDetails */
$details = $storage->create();
Expand All @@ -65,7 +65,7 @@ class PaymentController extends Controller
$details['ORDERID'] = 'orderId';
$storage->update($details);

$captureToken = $this->get('payum')->getTokenFactory()->createCaptureToken(
$captureToken = $payum->getTokenFactory()->createCaptureToken(
$gatewayName,
$details,
'acme_payment_done' // the route to redirect after capture;
Expand Down
8 changes: 4 additions & 4 deletions Resources/doc/custom_purchase_examples/be2bill_onsite.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ use Symfony\Component\HttpFoundation\Request;

class PaymentController extends Controller
{
public function prepareBe2BillPaymentAction(Request $request)
public function prepareBe2BillPaymentAction(Request $request, Payum $payum)
{
$gatewayName = 'your_gateway_name';

$storage = $this->getPayum()->getStorage('Acme\PaymentBundle\Entity\PaymentDetails');
$storage = $payum->getStorage('Acme\PaymentBundle\Entity\PaymentDetails');

/** @var PaymentDetails */
/** @var PaymentDetails $details */
$details = $storage->create();
//be2bill amount format is cents: for example: 100.05 (EUR). will be 10005.
$details['AMOUNT'] = 10005;
Expand All @@ -63,7 +63,7 @@ class PaymentController extends Controller
$details['ORDERID'] = 'orderId'.uniqid();
$storage->update($details);

$captureToken = $this->getTokenFactory()->createCaptureToken(
$captureToken = $payum->getTokenFactory()->createCaptureToken(
$gatewayName,
$details,
'acme_payment_done' // the route to redirect after capture;
Expand Down
Loading