-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
- Loading branch information
There are no files selected for viewing
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> |
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
|
||
'merchant_id' => '', | ||
'service_id' => '', | ||
'service_key' => '', | ||
'authorization_token' => '', | ||
]; | ||
$config->defaults($config['payum.default_options']); | ||
Check failure on line 30 in src/ImojeGatewayFactory.php
|
||
|
||
$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
|
||
|
||
return [ | ||
'environment' => $config['environment'], | ||
'merchant_id' => $config['merchant_id'], | ||
'service_id' => $config['service_id'], | ||
'service_key' => $config['service_key'], | ||
'authorization_token' => $config['authorization_token'], | ||
]; | ||
}; | ||
} | ||
} | ||
} |