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

Fixes to install and run the plugin with Sylius Standard #167

Merged
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
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
"firebase/php-jwt": "^6.10",
"payum/core": "^1.7",
"sylius/core-bundle": "^1.12",
"sylius/refund-plugin": "^1.5",
"sylius/resource-bundle": "^1.10",
"symfony/config": "5.4.* || ^6.0",
"symfony/dependency-injection": "5.4.* || ^6.0",
"symfony/form": "5.4.* || ^6.0",
"symfony/http-foundation": "5.4.* || ^6.0",
"symfony/http-kernel": "5.4.* || ^6.0",
"symfony/routing": "5.4.* || ^6.0",
"symfony/uid": "5.4.*",
"symfony/uid": "5.4.* || ^6.0",
"tpay-com/tpay-openapi-php": "^1.8"
},
"conflict": {
Expand All @@ -50,7 +51,6 @@
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"shipmonk/composer-dependency-analyser": "^1.7",
"sylius-labs/coding-standard": "^4.2",
"sylius/refund-plugin": "^1.5",
"sylius/sylius": "^1.12",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
Expand Down
17 changes: 17 additions & 0 deletions src/DependencyInjection/CommerceWeaversSyliusTpayExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Tpay\OpenApi\Utilities\Logger;

final class CommerceWeaversSyliusTpayExtension extends AbstractResourceExtension implements PrependExtensionInterface
{
Expand Down Expand Up @@ -43,6 +44,7 @@ public function prepend(ContainerBuilder $container): void
$container,
);

$this->setUpTpayLogger($container);
$this->prependDoctrineMigrations($container);
$this->prependDoctrineMapping($container);
}
Expand Down Expand Up @@ -105,4 +107,19 @@ private function getCurrentConfiguration(ContainerBuilder $container): array

return $this->processConfiguration($configuration, $configs);
}

private function setUpTpayLogger(ContainerBuilder $container): void
{
if (!$container->hasParameter('kernel.logs_dir')) {
return;
}

$logsDir = $container->getParameter('kernel.logs_dir');

if (!is_string($logsDir)) {
return;
}

Logger::setLogPath(sprintf('%s/tpay_open_api_', $logsDir));
}
}
2 changes: 0 additions & 2 deletions src/Payum/Action/Api/BaseApiAwareAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Payum\Core\Action\ActionInterface;
use Payum\Core\ApiAwareInterface;
use Payum\Core\ApiAwareTrait;
use Tpay\OpenApi\Utilities\Logger;
use Tpay\OpenApi\Utilities\TpayException;

/**
Expand All @@ -21,7 +20,6 @@ abstract class BaseApiAwareAction implements ActionInterface, ApiAwareInterface
public function __construct()
{
$this->apiClass = TpayApi::class;
Logger::setLogPath(dirname(__DIR__, 4) . '/tests/Application/var/log/');
}

protected function do(callable $func, callable $onSuccess, callable $onFailure): void
Expand Down
13 changes: 0 additions & 13 deletions src/Repository/FindByChannelWithGatewayConfigTraitInterface.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace App\Repository;
declare(strict_types=1);

namespace CommerceWeavers\SyliusTpayPlugin\Repository;

use Sylius\Component\Channel\Model\ChannelInterface;
use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface as BasePaymentMethodRepositoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* @mixin EntityRepository
*/
trait FindByChannelWithGatewayConfigTrait
trait PaymentMethodTrait
{
public function findByChannelAndGatewayConfigNameWithGatewayConfig(ChannelInterface $channel, string $gatewayConfigName): array
{
Expand Down
6 changes: 5 additions & 1 deletion src/Tpay/Provider/ValidTpayChannelListProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@

namespace CommerceWeavers\SyliusTpayPlugin\Tpay\Provider;

use App\Repository\PaymentMethodRepositoryInterface;
use CommerceWeavers\SyliusTpayPlugin\Payum\Exception\UnableToGetBankListException;
use CommerceWeavers\SyliusTpayPlugin\Repository\PaymentMethodRepositoryInterface;
use CommerceWeavers\SyliusTpayPlugin\Tpay\PayGroup;
use CommerceWeavers\SyliusTpayPlugin\Tpay\PaymentType;
use Payum\Core\Security\CryptedInterface;
use Payum\Core\Security\CypherInterface;
use Sylius\Bundle\PayumBundle\Model\GatewayConfigInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Core\Model\PaymentMethodInterface;
use Sylius\Component\Core\Repository\PaymentMethodRepositoryInterface as BasePaymentMethodRepositoryInterface;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this typhint if CommerceWeavers\SyliusTpayPlugin\Repository\PaymentMethodRepositoryInterface already extends it?

use Webmozart\Assert\Assert;

final class ValidTpayChannelListProvider implements ValidTpayChannelListProviderInterface
{
/**
* @param BasePaymentMethodRepositoryInterface&PaymentMethodRepositoryInterface $paymentMethodRepository
*/
public function __construct(
private readonly AvailableTpayChannelListProviderInterface $availableTpayApiBankListProvider,
private readonly PaymentMethodRepositoryInterface $paymentMethodRepository,
Expand Down
5 changes: 3 additions & 2 deletions tests/Application/src/Repository/PaymentMethodRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace App\Repository;

use CommerceWeavers\SyliusTpayPlugin\Repository\FindByChannelWithGatewayConfigTrait;
use CommerceWeavers\SyliusTpayPlugin\Repository\PaymentMethodTrait;
use CommerceWeavers\SyliusTpayPlugin\Repository\PaymentMethodRepositoryInterface;
use Sylius\Bundle\CoreBundle\Doctrine\ORM\PaymentMethodRepository as BasePaymentMethodRepository;

final class PaymentMethodRepository extends BasePaymentMethodRepository implements PaymentMethodRepositoryInterface
{
use FindByChannelWithGatewayConfigTrait;
use PaymentMethodTrait;
lchrusciel marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Tests\CommerceWeavers\SyliusTpayPlugin\Unit\Tpay\Provider;

use App\Repository\PaymentMethodRepositoryInterface;
use CommerceWeavers\SyliusTpayPlugin\Payum\Exception\UnableToGetBankListException;
use CommerceWeavers\SyliusTpayPlugin\Repository\PaymentMethodRepositoryInterface;
use CommerceWeavers\SyliusTpayPlugin\Tpay\Provider\AvailableTpayChannelListProviderInterface;
use CommerceWeavers\SyliusTpayPlugin\Tpay\Provider\ValidTpayChannelListProvider;
use Payum\Core\Security\CypherInterface;
Expand Down
Loading