1
My online store is presenting the following problem when sending:
Exception 'Zend_http_client_exception' with message 'Unable to read Response, or Response is Empty' in D: wamp www santaines lib Zend Http Client.php:1081 Stack trace: #0 D: wamp www santaines lib Varien Http Client.php(61): Zend_http_client->request(NULL) #1 D:\wamp\www\santaines\app\code\local\Envato\Custompaymentmethod\controllers\PaymentController.php(56): Varien_Http_Client->request() #2 D:\wamp\www\santaines\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Envato_Custompaymentmethod_PaymentController->gatewayAction() #3 D: wamp www santaines app code core Mage Core Controller Varien Router Standard.php(250): Mage_core_controller_varien_action->Dispatch('gateway') #4 D: wamp www santaines app code core Mage Core Controller Varien Front.php(172): Mage_core_controller_varien_router_standard-match>(Object(Mage_core_controller_request_http)) #5 D: wamp www santaines app code core Mage Core Model App.php(354): Mage_core_controller_varien_front->Dispatch() #6 D: wamp www santaines app Mage.php(684): Mage_core_model_app->run(Array) #7 D: wamp www santaines index.php(87): Mage::(', 'store') #8 {main}
Requisition code:
$arr_querystring = array(
'numero' => $orderId,
'nome' => Mage::helper('customer')->getCustomerName(),
'valor' => $totalPedido,
'cpf' => $cpfComprador,
'email' => Mage::helper('customer')->getCustomer()->getData('email'),
'celular' => $celularComprador,
'dtNascimento' => $dataNascimentoComprador,
'envioSMS' => 'N' );
$jsonData = Mage::helper('core')->jsonEncode( $arr_querystring );
$headers = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData),
'lgn:xxx',
'pwd:xxx');
$client = new Varien_Http_Client();
$client->setUri('https://nameOfServerRest')
->setMethod('POST')
->setHeaders($headers)
->setRawData($jsonData);
try{
$response = $client->request();
if ($response->isSuccessful()){
$statusJson = $response->getBody();
$json = Mage::helper('core')->jsonDecode($statusJson);
if ($json['Status'] == "001"){
$link = $json['Message'];
$this->_redirectUrl($link);
Mage_Core_Controller_Varien_Action::_redirect('custompaymentmethod/payment/response', array('_secure' => false, '_query'=> $arr_querystring));
}else{
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/error', array('_secure'=> false));
}
}
}catch (Exception $e){
echo $e;
}
I did the test with another store and the server to which sending is working normally. What may be happening?