Skip to content

Commit

Permalink
Add gateway factory
Browse files Browse the repository at this point in the history
  • Loading branch information
liszkapawel committed Feb 13, 2024
1 parent 6b866f8 commit 0758950
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
13 changes: 13 additions & 0 deletions config/services/gateway_factory.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>

<defaults public="true" autoconfigure="false" autowire="false"/>

<service id="bitbag.imoje_plugin.gateway_factory" class="Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder">
<argument>BitBag\SyliusImojePlugin\ImojeGatewayFactory</argument>
<tag name="payum.gateway_factory_builder" factory="imoje"/>
</service>

</services>
</container>
47 changes: 47 additions & 0 deletions src/ImojeGatewayFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace BitBag\SyliusImojePlugin;

use BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface;
use Payum\Core\Bridge\Spl\ArrayObject;
use Payum\Core\GatewayFactory;

final class ImojeGatewayFactory extends GatewayFactory
{
protected function populateConfig(ArrayObject $config): void
{
$config->defaults(
[
'payum.factory_name' => 'imoje',
'payum.factory_title' => 'Imoje'
]
);

if (false === (bool) $config['payum.api']) {
$config['payum.default_options'] = [
'environment' => ImojeBridgeInterface::SANDBOX_ENVIRONMENT,

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony 5.4.*, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony ^6.0, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony 5.4.*, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.0, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.0, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony 5.4.*, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony 5.4.*, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.

Check failure on line 24 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony ^6.0, MySQL 8.0

Access to constant SANDBOX_ENVIRONMENT on an unknown class BitBag\SyliusImojePlugin\Bridge\ImojeBridgeInterface.
'merchant_id' => '',
'service_id' => '',
'service_key' => '',
'authorization_token' => '',
];
$config->defaults($config['payum.default_options']);

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony 5.4.*, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony ^6.0, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony 5.4.*, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.0, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.0, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony 5.4.*, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony 5.4.*, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

Check failure on line 30 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony ^6.0, MySQL 8.0

Parameter #1 $input of method Payum\Core\Bridge\Spl\ArrayObject::defaults() expects array|Traversable, mixed given.

$config['payum.required_options'] = ['environment', 'merchant_id', 'service_id', 'service_key', 'authorization_token'];

$config['payum.api'] = static function (ArrayObject $config): array {
$config->validateNotEmpty($config['payum.required_options']);

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony 5.4.*, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony ^6.0, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony 5.4.*, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.0, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.0, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony 5.4.*, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony 5.4.*, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

Check failure on line 35 in src/ImojeGatewayFactory.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.0, Symfony ^6.0, MySQL 8.0

Parameter #1 $required of method Payum\Core\Bridge\Spl\ArrayObject::validateNotEmpty() expects array, mixed given.

return [
'environment' => $config['environment'],
'merchant_id' => $config['merchant_id'],
'service_id' => $config['service_id'],
'service_key' => $config['service_key'],
'authorization_token' => $config['authorization_token'],
];
};
}
}
}

0 comments on commit 0758950

Please sign in to comment.