app/code/community/Adyen/Payment/Model/Api.php
protected function doRequestJson(array $request, $requestUrl, $apiKey, $storeId, $timeout = null)
    {
        $ch = curl_init();
        $headers = array(
            'Content-Type: application/json'
        );

        if (empty($apiKey)) {
            $username = $this->_helper()->getConfigDataWsUserName($storeId);
            $password = $this->_helper()->getConfigDataWsPassword($storeId);
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
            curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
        } else {
            $headers[] = 'x-api-key: ' . $apiKey;
        }

        if (!empty($timeout)) {
            curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        }

        Mage::log($request, null, 'adyen_api.log');

        curl_setopt($ch, CURLOPT_URL, $requestUrl);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        $error = curl_error($ch);
        $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $errorCode = curl_errno($ch);
        curl_close($ch);
        if ($result === false) {
            Adyen_Payment_Exception::throwCurlException($error, $errorCode);
        }

        if ($httpStatus == 401 || $httpStatus == 403) {
            Adyen_Payment_Exception::throwException(
                Mage::helper('adyen')->__(
                    'Received Status code %s, please make sure your Checkout API key is correct.',
                    $httpStatus
                )
            );
        } elseif ($httpStatus != 200) {
            Adyen_Payment_Exception::throwException(
                Mage::helper('adyen')->__(
                    'HTTP Status code %s received, data %s',
                    $httpStatus, $result
                )
            );
        }

        return $result;
    }
protected function doRequestJson(array $request, $requestUrl, $apiKey, $storeId, $timeout = null)
    {
        $ch = curl_init();
        $headers = array(
            'Content-Type: application/json'
        );

        if (empty($apiKey)) {
            $username = $this->_helper()->getConfigDataWsUserName($storeId);
            $password = $this->_helper()->getConfigDataWsPassword($storeId);
            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
            curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
        } else {
            $headers[] = 'x-api-key: ' . $apiKey;
        }

        if (!empty($timeout)) {
            curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
        }

        Mage::log($request, null, 'adyen_api.log');

        curl_setopt($ch, CURLOPT_URL, $requestUrl);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $result = curl_exec($ch);
        $error = curl_error($ch);
        $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $errorCode = curl_errno($ch);
        curl_close($ch);
        if ($result === false) {
            Adyen_Payment_Exception::throwCurlException($error, $errorCode);
        }

        if ($httpStatus == 401 || $httpStatus == 403) {
            Adyen_Payment_Exception::throwException(
                Mage::helper('adyen')->__(
                    'Received Status code %s, please make sure your Checkout API key is correct.',
                    $httpStatus
                )
            );
        } elseif ($httpStatus != 200) {
            Adyen_Payment_Exception::throwException(
                Mage::helper('adyen')->__(
                    'HTTP Status code %s received, data %s',
                    $httpStatus, $result
                )
            );
        }

        return $result;
    }
protected function doRequestJson ( array $ request , $ requestUrl , $ apiKey , $ storeId , $ timeout = null ) { $ ch = curl_init ( ) ; $ headers = array ( 'Content-Type: application/json' ) ; if ( empty ( $ apiKey ) ) { $ username = $ this -> _helper ( ) -> getConfigDataWsUserName ( $ storeId ) ; $ password = $ this -> _helper ( ) -> getConfigDataWsPassword ( $ storeId ) ; curl_setopt ( $ ch , CURLOPT_HTTPAUTH , CURLAUTH_BASIC ) ; curl_setopt ( $ ch , CURLOPT_USERPWD , $ username . ":" . $ password ) ; } else { $ headers [ ] = 'x-api-key: ' . $ apiKey ; } if ( ! empty ( $ timeout ) ) { curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ timeout ) ; } Mage :: log ( $ request , null , 'adyen_api.log' ) ; curl_setopt ( $ ch , CURLOPT_URL , $ requestUrl ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ ch , CURLOPT_POST , 1 ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , json_encode ( $ request ) ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; $ result = curl_exec ( $ ch ) ; $ error = curl_error ( $ ch ) ; $ httpStatus = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; $ errorCode = curl_errno ( $ ch ) ; curl_close ( $ ch ) ; if ( $ result === false ) { Adyen_Payment_Exception :: throwCurlException ( $ error , $ errorCode ) ; } if ( $ httpStatus == 401 || $ httpStatus == 403 ) { Adyen_Payment_Exception :: throwException ( Mage :: helper ( 'adyen' ) -> __ ( 'Received Status code %s, please make sure your Checkout API key is correct.' , $ httpStatus ) ) ; } elseif ( $ httpStatus != 200 ) { Adyen_Payment_Exception :: throwException ( Mage :: helper ( 'adyen' ) -> __ ( 'HTTP Status code %s received, data %s' , $ httpStatus , $ result ) ) ; } return $ result ; }
Do the API request in json format

@param array $request
@param $requestUrl
@param $apiKey
@param $storeId
@param null $timeout
@return mixed
Do the API request in json format