src/Klarna.php
protected function xmlrpc_call($method, $array)
    {
        $this->_checkConfig();

        if (!isset($method) || !is_string($method)) {
            throw new Klarna_InvalidTypeException('method', 'string');
        }
        if ($array === null || count($array) === 0) {
            throw new KlarnaException("Parameterlist is empty or null!", 50067);
        }
        if (self::$disableXMLRPC) {
            return true;
        }
        try {
            /*
             * Disable verifypeer for CURL, so below error is avoided.
             * CURL error: SSL certificate problem, verify that the CA
             * cert is OK.
             * Details: error:14090086:SSL
             * routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (#8)
             */
            $this->xmlrpc->verifypeer = false;

            $timestart = microtime(true);

            //Create the XMLRPC message.
            $msg = new xmlrpcmsg($method);
            $params = array_merge(
                array(
                    $this->PROTO, $this->VERSION
                ), $array
            );

            $msg = new xmlrpcmsg($method);
            foreach ($params as $p) {
                if (!$msg->addParam(
                    php_xmlrpc_encode($p, array('extension_api'))
                )
                ) {
                    throw new KlarnaException(
                        "Failed to add parameters to XMLRPC message.",
                        50068
                    );
                }
            }

            $selectDateTime = microtime(true);
            if (self::$xmlrpcDebug) {
                $this->xmlrpc->setDebug(2);
            }
            //Save previous XML RPC client encoding settings.
            $tmp_xmlrpc_defencoding = $GLOBALS['xmlrpc_defencoding'];
            $tmp_xmlrpc_internalencoding = $GLOBALS['xmlrpc_internalencoding'];
            //Set XML RPC client encoding settings.
            $GLOBALS['xmlrpc_defencoding'] = 'ISO-8859-1';
            $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';

            //Send the message.
            $xmlrpcresp = $this->xmlrpc->send($msg);

            //Restore previous XML RPC client encoding settings.
            $GLOBALS['xmlrpc_defencoding'] = $tmp_xmlrpc_defencoding;
            $GLOBALS['xmlrpc_internalencoding'] = $tmp_xmlrpc_internalencoding;

            //Calculate time and selectTime.
            $timeend = microtime(true);
            $time = (int) (($selectDateTime - $timestart) * 1000);
            $selectTime = (int) (($timeend - $timestart) * 1000);

            $status = $xmlrpcresp->faultCode();

            if ($status !== 0) {
                throw new KlarnaException($xmlrpcresp->faultString(), $status);
            }

            return php_xmlrpc_decode($xmlrpcresp->value());
        }
        catch(KlarnaException $e) {
            //Otherwise it is caught below, and rethrown.
            throw $e;
        }
        catch(Exception $e) {
            throw new KlarnaException($e->getMessage(), $e->getCode());
        }
    }
protected function xmlrpc_call($method, $array)
    {
        $this->_checkConfig();

        if (!isset($method) || !is_string($method)) {
            throw new Klarna_InvalidTypeException('method', 'string');
        }
        if ($array === null || count($array) === 0) {
            throw new KlarnaException("Parameterlist is empty or null!", 50067);
        }
        if (self::$disableXMLRPC) {
            return true;
        }
        try {
            /*
             * Disable verifypeer for CURL, so below error is avoided.
             * CURL error: SSL certificate problem, verify that the CA
             * cert is OK.
             * Details: error:14090086:SSL
             * routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (#8)
             */
            $this->xmlrpc->verifypeer = false;

            $timestart = microtime(true);

            //Create the XMLRPC message.
            $msg = new xmlrpcmsg($method);
            $params = array_merge(
                array(
                    $this->PROTO, $this->VERSION
                ), $array
            );

            $msg = new xmlrpcmsg($method);
            foreach ($params as $p) {
                if (!$msg->addParam(
                    php_xmlrpc_encode($p, array('extension_api'))
                )
                ) {
                    throw new KlarnaException(
                        "Failed to add parameters to XMLRPC message.",
                        50068
                    );
                }
            }

            $selectDateTime = microtime(true);
            if (self::$xmlrpcDebug) {
                $this->xmlrpc->setDebug(2);
            }
            //Save previous XML RPC client encoding settings.
            $tmp_xmlrpc_defencoding = $GLOBALS['xmlrpc_defencoding'];
            $tmp_xmlrpc_internalencoding = $GLOBALS['xmlrpc_internalencoding'];
            //Set XML RPC client encoding settings.
            $GLOBALS['xmlrpc_defencoding'] = 'ISO-8859-1';
            $GLOBALS['xmlrpc_internalencoding'] = 'UTF-8';

            //Send the message.
            $xmlrpcresp = $this->xmlrpc->send($msg);

            //Restore previous XML RPC client encoding settings.
            $GLOBALS['xmlrpc_defencoding'] = $tmp_xmlrpc_defencoding;
            $GLOBALS['xmlrpc_internalencoding'] = $tmp_xmlrpc_internalencoding;

            //Calculate time and selectTime.
            $timeend = microtime(true);
            $time = (int) (($selectDateTime - $timestart) * 1000);
            $selectTime = (int) (($timeend - $timestart) * 1000);

            $status = $xmlrpcresp->faultCode();

            if ($status !== 0) {
                throw new KlarnaException($xmlrpcresp->faultString(), $status);
            }

            return php_xmlrpc_decode($xmlrpcresp->value());
        }
        catch(KlarnaException $e) {
            //Otherwise it is caught below, and rethrown.
            throw $e;
        }
        catch(Exception $e) {
            throw new KlarnaException($e->getMessage(), $e->getCode());
        }
    }
protected function xmlrpc_call ( $ method , $ array ) { $ this -> _checkConfig ( ) ; if ( ! isset ( $ method ) || ! is_string ( $ method ) ) { throw new Klarna_InvalidTypeException ( 'method' , 'string' ) ; } if ( $ array === null || count ( $ array ) === 0 ) { throw new KlarnaException ( "Parameterlist is empty or null!" , 50067 ) ; } if ( self :: $ disableXMLRPC ) { return true ; } try { /*
             * Disable verifypeer for CURL, so below error is avoided.
             * CURL error: SSL certificate problem, verify that the CA
             * cert is OK.
             * Details: error:14090086:SSL
             * routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed (#8)
             */ $ this -> xmlrpc -> verifypeer = false ; $ timestart = microtime ( true ) ; //Create the XMLRPC message. $ msg = new xmlrpcmsg ( $ method ) ; $ params = array_merge ( array ( $ this -> PROTO , $ this -> VERSION ) , $ array ) ; $ msg = new xmlrpcmsg ( $ method ) ; foreach ( $ params as $ p ) { if ( ! $ msg -> addParam ( php_xmlrpc_encode ( $ p , array ( 'extension_api' ) ) ) ) { throw new KlarnaException ( "Failed to add parameters to XMLRPC message." , 50068 ) ; } } $ selectDateTime = microtime ( true ) ; if ( self :: $ xmlrpcDebug ) { $ this -> xmlrpc -> setDebug ( 2 ) ; } //Save previous XML RPC client encoding settings. $ tmp_xmlrpc_defencoding = $ GLOBALS [ 'xmlrpc_defencoding' ] ; $ tmp_xmlrpc_internalencoding = $ GLOBALS [ 'xmlrpc_internalencoding' ] ; //Set XML RPC client encoding settings. $ GLOBALS [ 'xmlrpc_defencoding' ] = 'ISO-8859-1' ; $ GLOBALS [ 'xmlrpc_internalencoding' ] = 'UTF-8' ; //Send the message. $ xmlrpcresp = $ this -> xmlrpc -> send ( $ msg ) ; //Restore previous XML RPC client encoding settings. $ GLOBALS [ 'xmlrpc_defencoding' ] = $ tmp_xmlrpc_defencoding ; $ GLOBALS [ 'xmlrpc_internalencoding' ] = $ tmp_xmlrpc_internalencoding ; //Calculate time and selectTime. $ timeend = microtime ( true ) ; $ time = ( int ) ( ( $ selectDateTime - $ timestart ) * 1000 ) ; $ selectTime = ( int ) ( ( $ timeend - $ timestart ) * 1000 ) ; $ status = $ xmlrpcresp -> faultCode ( ) ; if ( $ status !== 0 ) { throw new KlarnaException ( $ xmlrpcresp -> faultString ( ) , $ status ) ; } return php_xmlrpc_decode ( $ xmlrpcresp -> value ( ) ) ; } catch ( KlarnaException $ e ) { //Otherwise it is caught below, and rethrown. throw $ e ; } catch ( Exception $ e ) { throw new KlarnaException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } }
Creates a XMLRPC call with specified XMLRPC method and parameters from array.

@param string $method XMLRPC method.
@param array  $array  XMLRPC parameters.

@throws KlarnaException
@return mixed
Creates a XMLRPC call with specified XMLRPC method and parameters from array .