1

The Clearing module prints the exception. This module is a third-party module.

Do you know where the cause lies in the source code? Please tell me.

    bool(false)
    1 exception(s):
    Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/html/primary/vendor/veriteworks/paygent-connect/src/PaygentConnect/Response/Parser.php on line 27

    Exception #0 (Exception): Warning: Invalid argument supplied for foreach() in /var/www/html/primary/vendor/veriteworks/paygent-connect/src/PaygentConnect/Response/Parser.php on line 27
    #0 /var/www/html/primary/vendor/veriteworks/paygent-connect/src/PaygentConnect/Response/Parser.php(27): Magento\Framework\App\ErrorHandler->handler(2, 'Invalid argumen...', '/var/www/html/p...', 27, Array)
    #1 /var/www/html/primary/vendor/veriteworks/paygent-connect/src/PaygentConnect/Client/Curl.php(109): PaygentConnect\Response\Parser->parse()
    #2 /var/www/html/primary/vendor/veriteworks/paygent-connect/src/PaygentConnect/PaygentConnect.php(93): PaygentConnect\Client\Curl->execute()
    #3 /var/www/html/primary/vendor/veriteworks/paygent/Model/Card/Lists.php(66): PaygentConnect\PaygentConnect->post()
    #4 /var/www/html/primary/vendor/veriteworks/paygent/Model/Config/CcProvider.php(174): Veriteworks\Paygent\Model\Card\Lists->loadRegisteredCards()
    #5 /var/www/html/primary/vendor/veriteworks/paygent/Model/Config/CcProvider.php(78): Veriteworks\Paygent\Model\Config\CcProvider->loadCardInfo()
    #6 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(111): Veriteworks\Paygent\Model\Config\CcProvider->__construct(Object(Magento\Payment\Model\CcConfig), Object(Magento\Payment\Helper\Data\Interceptor), Object(Veriteworks\Paygent\Gateway\Config\Cc), Object(Veriteworks\Paygent\Helper\Data), Object(Veriteworks\Paygent\Model\Source\PaymentClass), Object(Veriteworks\Paygent\Model\Source\SplitCount), Object(Veriteworks\Paygent\Model\Card\Lists))
    #7 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(66): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Veriteworks\\Pay...', Array)
    #8 /var/www/html/primary/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Veriteworks\\Pay...')
    #9 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(180): Magento\Framework\ObjectManager\ObjectManager->get('Veriteworks\\Pay...')
    #10 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(156): Magento\Framework\ObjectManager\Factory\AbstractFactory->parseArray(Array)
    #11 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(230): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, NULL, NULL, 'configProviders', 'Magento\\Checkou...')
    #12 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Checkou...', Array, Array)
    #13 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Checkou...', Array, Array)
    #14 /var/www/html/primary/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Checkou...')
    #15 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(144): Magento\Framework\ObjectManager\ObjectManager->get('Magento\\Checkou...')
    #16 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(230): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgument(Array, 'Magento\\Checkou...', NULL, 'configProvider', 'Magento\\Checkou...')
    #17 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(34): Magento\Framework\ObjectManager\Factory\AbstractFactory->resolveArgumentsInRuntime('Magento\\Checkou...', Array, Array)
    #18 /var/www/html/primary/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(59): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->_resolveArguments('Magento\\Checkou...', Array, Array)
    #19 /var/www/html/primary/vendor/magento/framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create('Magento\\Checkou...', Array)
    #20 /var/www/html/primary/vendor/magento/framework/View/Element/BlockFactory.php(45): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Checkou...', Array)
    #21 /var/www/html/primary/vendor/magento/framework/View/Layout/Generator/Block.php(269): Magento\Framework\View\Element\BlockFactory->createBlock('Magento\\Checkou...', Array)
    #22 /var/www/html/primary/vendor/magento/framework/View/Layout/Generator/Block.php(249): Magento\Framework\View\Layout\Generator\Block->getBlockInstance('Magento\\Checkou...', Array)
    #23 /var/www/html/primary/vendor/magento/framework/View/Layout/Generator/Block.php(227): Magento\Framework\View\Layout\Generator\Block->createBlock('Magento\\Checkou...', 'checkout.cart.s...', Array)
    #24 /var/www/html/primary/vendor/magento/framework/View/Layout/Generator/Block.php(135): Magento\Framework\View\Layout\Generator\Block->generateBlock(Object(Magento\Framework\View\Layout\ScheduledStructure), Object(Magento\Framework\View\Layout\Data\Structure), 'checkout.cart.s...')
    #25 /var/www/html/primary/vendor/magento/framework/View/Layout/GeneratorPool.php(80): Magento\Framework\View\Layout\Generator\Block->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
    #26 /var/www/html/primary/vendor/magento/framework/View/Layout.php(343): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
    #27 /var/www/html/primary/generated/code/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements()
    #28 /var/www/html/primary/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
    #29 /var/www/html/primary/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
    #30 /var/www/html/primary/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
    #31 /var/www/html/primary/vendor/magento/framework/View/Page/Config.php(208): Magento\Framework\View\Layout\Builder->build()
    #32 /var/www/html/primary/vendor/magento/framework/View/Page/Config.php(228): Magento\Framework\View\Page\Config->build()
    #33 /var/www/html/primary/vendor/magento/module-checkout/Controller/Cart/Index.php(55): Magento\Framework\View\Page\Config->getTitle()
    #34 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Checkout\Controller\Cart\Index->execute()
    #35 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Controller\Cart\Index\Interceptor->___callParent('execute', Array)
    #36 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Controller\Cart\Index\Interceptor->Magento\Framework\Interception\{closure}()
    #37 /var/www/html/primary/generated/code/Magento/Checkout/Controller/Cart/Index/Interceptor.php(26): Magento\Checkout\Controller\Cart\Index\Interceptor->___callPlugins('execute', Array, Array)
    #38 /var/www/html/primary/vendor/magento/framework/App/Action/Action.php(107): Magento\Checkout\Controller\Cart\Index\Interceptor->execute()
    #39 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
    #40 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Checkout\Controller\Cart\Index\Interceptor->___callParent('dispatch', Array)
    #41 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Checkout\Controller\Cart\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
    #42 /var/www/html/primary/generated/code/Magento/Checkout/Controller/Cart/Index/Interceptor.php(39): Magento\Checkout\Controller\Cart\Index\Interceptor->___callPlugins('dispatch', Array, Array)
    #43 /var/www/html/primary/vendor/magento/framework/App/FrontController.php(55): Magento\Checkout\Controller\Cart\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
    #44 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
    #45 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
    #46 /var/www/html/primary/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
    #47 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
    #48 /var/www/html/primary/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
    #49 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
    #50 /var/www/html/primary/app/code/Infortis/Cgen/Plugin/Magento/Framework/App/FrontController.php(32): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
    #51 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(135): Infortis\Cgen\Plugin\Magento\Framework\App\FrontController->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
    #52 /var/www/html/primary/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
    #53 /var/www/html/primary/generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
    #54 /var/www/html/primary/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
    #55 /var/www/html/primary/generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
    #56 /var/www/html/primary/vendor/magento/framework/App/Bootstrap.php(257): Magento\Framework\App\Http\Interceptor->launch()
    #57 /var/www/html/primary/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
    #58 {main}

namespace PaygentConnect\Client;

use \PaygentConnect\Response\Validator;
use \PaygentConnect\Config\Config;
use \PaygentConnect\Response\Parser;

class Curl
{
    /**
     *
     */
    const KEYSTORE_PASS = "changeit";
    /**
     * @var resource
     */
    private $client;
    /**
     * @var array
     */
    private $options = [];
    /**
     * @var string
     */
    private $data = '';

    private $config;

    private $result;


    /**
     * Curl constructor.
     * @param Config $config
     * @param Config $const
     * @param array $options
     */
    public function __construct(Config $config, $url, $options)
    {
        $this->config = $config;
        $this->options = $options;
        $result = true;

        $this->client = curl_init($url);

        $result = curl_setopt($this->client, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
        $result = curl_setopt($this->client, CURLOPT_RETURNTRANSFER, true);
        $result = curl_setopt($this->client, CURLOPT_POST, true);
        $result = curl_setopt($this->client, CURLOPT_HEADER, true);
        $result = curl_setopt($this->client, CURLOPT_SSL_VERIFYHOST, false);

        //if(!$this->options['noCert']) {
            $result = curl_setopt($this->client, CURLOPT_SSLCERT, $this->options['clientCertificatePath']);
            $result = curl_setopt($this->client, CURLOPT_SSLKEYPASSWD, self::KEYSTORE_PASS);
        //}

        //if(!$this->options['noCaCert']) {
        //    $result = curl_setopt($this->client, CURLOPT_SSL_VERIFYPEER, false);
        //} else {
            $result = curl_setopt($this->client, CURLOPT_SSL_VERIFYPEER, true);
            $result = curl_setopt($this->client, CURLOPT_CAINFO, $this->options['caCertificatePath']);
        //}

        $result = curl_setopt($this->client, CURLOPT_TIMEOUT, $this->options['timeout']);
        $result = curl_setopt($this->client, CURLOPT_CONNECTTIMEOUT, $this->options['proxyTimeout']);

        if(!$result) {
            throw new \BadFunctionCallException('Connection client initialize error.');
        }
    }

    /**
     * @param $data
     * @return $this
     */
    public function setRequest($data)
    {
        $this->data = $data;
        return $this;
    }

    /**
     * @return mixed
     */
    public function execute()
    {
        $query = $this->data;
        $length = strlen($query);

        $header =[
            $this->options['contentType'],
            $this->options['encoding'],
            $this->options['contentLength'] . ': ' . $length,
            $this->options['userAgent'] . ": curl_php",
        ];

        curl_setopt($this->client, CURLOPT_HTTPHEADER, $header);
        curl_setopt($this->client, CURLOPT_POSTFIELDS, $query);

        $result = curl_exec($this->client);
        $validator = new Validator();
        $returnCode = '0';

        if($result === false && curl_errno($this->client) != 0) {
            $returnCode = $validator->validate($this->client);
        }

        $parser = new Parser($result);
        $parser->parse();
        $this->result = $parser->getBody();

        return $returnCode;
    }

    public function getResult()
    {
        return $this->result;
    }

}

class Parser
{
    private $response;
    private $data;


    const LINE_DELIMITER = "\r\n";
    const INITIAL_HTTP_STATUS = '-1';

    public function __construct($response)
    {

        $this->response = $response;
    }

    public function parse()
    {
        $lines = mb_split(self::LINE_DELIMITER, $this->response);
        $bodyStart = 0;
        $returnCode = self::INITIAL_HTTP_STATUS;

        foreach($lines as $i => $line) {

            if (is_null($line) || strlen($line) == 0 || $line === '') {
                break;
            }
            $bodyStart += strlen($line) + strlen(self::LINE_DELIMITER);

            if ($returnCode === self::INITIAL_HTTP_STATUS) {

                $returnCode = $this->parseStatus($line);
                if ($returnCode === true) {
                    continue;
                }
                return $returnCode;
            }

            if (!$this->parseHeader($line)) {
                continue;
            }
        }

        $body = substr($this->response, $bodyStart);
        $this->parseBody($body);
        return $returnCode;
    }

    public function getHeader()
    {
        return $this->data['header'];
    }

    public function getBody()
    {
        return $this->data['body'];
    }

    private function parseStatus($str)
    {
        return true;
    }

    private function parseHeader($str)
    {
        return true;
    }

    private function parseBody($str)
    {
        $str = mb_convert_encoding($str, 'utf-8', 'sjis-win');
        $body = explode("\r\n", $str);
        $headers = [];

        foreach ($body as $line) {
            if(preg_match('/_html/', $line)) {
                $pos = strpos($str, '_html');
                $length  = strlen($str);
                $html = substr($str, $pos, $length);
                list($key, $value) = explode('=', $html, 2);
                list($key2, $value2) = explode('=', $line, 2);
                $this->data['body'][$key2] = $value;
                break;
            } else {
                if(preg_match('/=/', $line)) {
                    list($key, $value) = explode('=', $line, 2);
                    $this->data['body'][$key] = $value;
                } else {
                    $line = preg_replace('/"/', '', $line);
                    $lineArray = explode(',', $line);
                    if(strlen($line) == 0) {
                        continue;
                    }

                    if($lineArray[0] == 2) {
                        $headers = $lineArray;
                        continue;
                    }

                    if($lineArray[0] == 3) {
                        $row = [];
                        foreach($lineArray as $key => $field) {
                            if($key == 0) {
                                continue;
                            }
                            $row[$headers[$key]] = $field;
                        }

                        $this->data['body'][] = $row;
                    }
                }
            }
        }

        return true;
    }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.