src/Payum/Core/CoreGatewayFactory.php
public function createConfig(array $config = [])
    {
        $config = ArrayObject::ensureArrayObject($config);
        $config->defaults($this->defaultConfig);

        $config->defaults([
            'httplug.message_factory'=>function (ArrayObject $config) {
                if (class_exists(MessageFactoryDiscovery::class)) {
                    return MessageFactoryDiscovery::find();
                }

                if (class_exists(\GuzzleHttp\Psr7\Request::class)) {
                    return new GuzzleMessageFactory();
                }

                if (class_exists(\Zend\Diactoros\Request::class)) {
                    return new DiactorosMessageFactory();
                }

                throw new \LogicException('The httplug.message_factory could not be guessed. Install one of the following packages: php-http/guzzle6-adapter, zendframework/zend-diactoros. You can also overwrite the config option with your implementation.');
            },
            'httplug.stream_factory'=>function (ArrayObject $config) {
                if (class_exists(StreamFactoryDiscovery::class)) {
                    return StreamFactoryDiscovery::find();
                }

                if (class_exists(\GuzzleHttp\Psr7\Request::class)) {
                    return new GuzzleStreamFactory();
                }

                if (class_exists(\Zend\Diactoros\Request::class)) {
                    return new DiactorosStreamFactory();
                }

                throw new \LogicException('The httplug.stream_factory could not be guessed. Install one of the following packages: php-http/guzzle6-adapter, zendframework/zend-diactoros. You can also overwrite the config option with your implementation.');
            },
            'httplug.client'=>function (ArrayObject $config) {
                if (class_exists(HttpClientDiscovery::class)) {
                    return HttpClientDiscovery::find();
                }

                if (class_exists(HttpGuzzle6Client::class)) {
                    return new HttpGuzzle6Client();
                }

                if (class_exists(HttpGuzzle5Client::class)) {
                    return new HttpGuzzle5Client();
                }

                if (class_exists(HttpSocketClient::class)) {
                    return new HttpSocketClient();
                }

                if (class_exists(HttpCurlClient::class)) {
                    return new HttpCurlClient($config['httplug.message_factory'], $config['httplug.stream_factory']);
                }

                if (class_exists(HttpBuzzClient::class)) {
                    return new HttpBuzzClient();
                }

                throw new \LogicException('The httplug.client could not be guessed. Install one of the following packages: php-http/guzzle6-adapter. You can also overwrite the config option with your implementation.');
            },
            'payum.http_client'=>function (ArrayObject $config) {
                return new HttplugClient($config['httplug.client']);
            },
            'payum.template.layout' => '@PayumCore/layout.html.twig',

            'twig.env' => function () {
                return new \Twig_Environment(new \Twig_Loader_Chain());
            },
            'twig.register_paths' => function (ArrayObject $config) {
                $twig = $config['twig.env'];
                if (false == $twig instanceof \Twig_Environment) {
                    throw new \LogicException(sprintf(
                        'The `twig.env config option must contains instance of Twig_Environment but got %s`',
                        is_object($twig) ? get_class($twig) : gettype($twig)
                    ));
                }

                TwigUtil::registerPaths($twig, $config['payum.paths']);

                return null;
            },
            'payum.action.get_http_request' => new GetHttpRequestAction(),
            'payum.action.capture_payment' => new CapturePaymentAction(),
            'payum.action.authorize_payment' => new AuthorizePaymentAction(),
            'payum.action.payout_payout' => new PayoutPayoutAction(),
            'payum.action.execute_same_request_with_model_details' => new ExecuteSameRequestWithModelDetailsAction(),
            'payum.action.render_template' => function (ArrayObject $config) {
                return new RenderTemplateAction($config['twig.env'], $config['payum.template.layout']);
            },
            'payum.extension.endless_cycle_detector' => new EndlessCycleDetectorExtension(),
            'payum.action.get_currency' => function (ArrayObject $config) {
                return new GetCurrencyAction($config['payum.iso4217']);
            },
            'payum.prepend_actions' => [],
            'payum.prepend_extensions' => [],
            'payum.prepend_apis' => [],
            'payum.default_options' => [],
            'payum.required_options' => [],

            'payum.api.http_client' => function (ArrayObject $config) {
                return $config['payum.http_client'];
            },

            'payum.security.token_storage' => null,
        ]);

        if ($config['payum.security.token_storage']) {
            $config['payum.action.get_token'] = function (ArrayObject $config) {
                return new GetTokenAction($config['payum.security.token_storage']);
            };
        }

        $config['payum.paths'] = array_replace([
            'PayumCore' => __DIR__.'/Resources/views',
        ], $config['payum.paths'] ?: []);

        return (array) $config;
    }
public function createConfig(array $config = [])
    {
        $config = ArrayObject::ensureArrayObject($config);
        $config->defaults($this->defaultConfig);

        $config->defaults([
            'httplug.message_factory'=>function (ArrayObject $config) {
                if (class_exists(MessageFactoryDiscovery::class)) {
                    return MessageFactoryDiscovery::find();
                }

                if (class_exists(\GuzzleHttp\Psr7\Request::class)) {
                    return new GuzzleMessageFactory();
                }

                if (class_exists(\Zend\Diactoros\Request::class)) {
                    return new DiactorosMessageFactory();
                }

                throw new \LogicException('The httplug.message_factory could not be guessed. Install one of the following packages: php-http/guzzle6-adapter, zendframework/zend-diactoros. You can also overwrite the config option with your implementation.');
            },
            'httplug.stream_factory'=>function (ArrayObject $config) {
                if (class_exists(StreamFactoryDiscovery::class)) {
                    return StreamFactoryDiscovery::find();
                }

                if (class_exists(\GuzzleHttp\Psr7\Request::class)) {
                    return new GuzzleStreamFactory();
                }

                if (class_exists(\Zend\Diactoros\Request::class)) {
                    return new DiactorosStreamFactory();
                }

                throw new \LogicException('The httplug.stream_factory could not be guessed. Install one of the following packages: php-http/guzzle6-adapter, zendframework/zend-diactoros. You can also overwrite the config option with your implementation.');
            },
            'httplug.client'=>function (ArrayObject $config) {
                if (class_exists(HttpClientDiscovery::class)) {
                    return HttpClientDiscovery::find();
                }

                if (class_exists(HttpGuzzle6Client::class)) {
                    return new HttpGuzzle6Client();
                }

                if (class_exists(HttpGuzzle5Client::class)) {
                    return new HttpGuzzle5Client();
                }

                if (class_exists(HttpSocketClient::class)) {
                    return new HttpSocketClient();
                }

                if (class_exists(HttpCurlClient::class)) {
                    return new HttpCurlClient($config['httplug.message_factory'], $config['httplug.stream_factory']);
                }

                if (class_exists(HttpBuzzClient::class)) {
                    return new HttpBuzzClient();
                }

                throw new \LogicException('The httplug.client could not be guessed. Install one of the following packages: php-http/guzzle6-adapter. You can also overwrite the config option with your implementation.');
            },
            'payum.http_client'=>function (ArrayObject $config) {
                return new HttplugClient($config['httplug.client']);
            },
            'payum.template.layout' => '@PayumCore/layout.html.twig',

            'twig.env' => function () {
                return new \Twig_Environment(new \Twig_Loader_Chain());
            },
            'twig.register_paths' => function (ArrayObject $config) {
                $twig = $config['twig.env'];
                if (false == $twig instanceof \Twig_Environment) {
                    throw new \LogicException(sprintf(
                        'The `twig.env config option must contains instance of Twig_Environment but got %s`',
                        is_object($twig) ? get_class($twig) : gettype($twig)
                    ));
                }

                TwigUtil::registerPaths($twig, $config['payum.paths']);

                return null;
            },
            'payum.action.get_http_request' => new GetHttpRequestAction(),
            'payum.action.capture_payment' => new CapturePaymentAction(),
            'payum.action.authorize_payment' => new AuthorizePaymentAction(),
            'payum.action.payout_payout' => new PayoutPayoutAction(),
            'payum.action.execute_same_request_with_model_details' => new ExecuteSameRequestWithModelDetailsAction(),
            'payum.action.render_template' => function (ArrayObject $config) {
                return new RenderTemplateAction($config['twig.env'], $config['payum.template.layout']);
            },
            'payum.extension.endless_cycle_detector' => new EndlessCycleDetectorExtension(),
            'payum.action.get_currency' => function (ArrayObject $config) {
                return new GetCurrencyAction($config['payum.iso4217']);
            },
            'payum.prepend_actions' => [],
            'payum.prepend_extensions' => [],
            'payum.prepend_apis' => [],
            'payum.default_options' => [],
            'payum.required_options' => [],

            'payum.api.http_client' => function (ArrayObject $config) {
                return $config['payum.http_client'];
            },

            'payum.security.token_storage' => null,
        ]);

        if ($config['payum.security.token_storage']) {
            $config['payum.action.get_token'] = function (ArrayObject $config) {
                return new GetTokenAction($config['payum.security.token_storage']);
            };
        }

        $config['payum.paths'] = array_replace([
            'PayumCore' => __DIR__.'/Resources/views',
        ], $config['payum.paths'] ?: []);

        return (array) $config;
    }
{@inheritDoc}