private function writeHistory($orderId, $transactionId)
 {
     $email = Configuration::get(self::prefix . 'EMAIL');
     $token = Configuration::get(self::prefix . 'TOKEN');
     $consultation = new Consultation($email, $token);
     $consultation->enableSandBox(Configuration::get(self::prefix . 'SANDBOX'));
     try {
         $response = $consultation->searchByTransaction($transactionId);
         $id_pedido = $response->transacao->id_pedido;
         $id_transacao = $transactionId;
         $id_status = $this->getStatus($response->transacao->cod_status);
         $status = $response->transacao->status;
         $pagamento_meio = $response->transacao->meio_pagamento;
         $parcelas = $response->transacao->parcelas;
         $valor_original = $response->transacao->valor_original;
         $valor_loja = $response->transacao->valor_loja;
         $taxa = $valor_original - $valor_loja;
         $history = new History($id_pedido, $id_transacao, $id_status, $status, $pagamento_meio, $parcelas, $valor_original, $valor_loja, $taxa);
         $history->write();
     } catch (ValidationException $e) {
         $this->logHistoryFail($orderId, $transactionId, $statusId, $e);
     } catch (ConnectionException $e) {
         $this->logHistoryFail($orderId, $transactionId, $statusId, $e);
     }
 }
 private function getTransaction()
 {
     if (!empty($transaction)) {
         return;
     }
     $consultation = new Consultation($this->email, $this->token);
     $consultation->enableSandBox($this->sandBox);
     $this->transaction = $consultation->searchByTransaction($this->notificationContent->getIdTransaction());
     $this->transaction = $this->transaction->transacao;
 }
 public function getTransaction($transactionId = null, $orderId = null)
 {
     $response = null;
     $consultation = new Consultation($this->email, $this->token);
     $consultation->enableSandBox($this->sandbox);
     try {
         if (!empty($transactionId) && !is_null($transactionId)) {
             //Consulta pelo id da transação
             $response = $consultation->searchByTransaction($transactionId);
         } else {
             if (!empty($orderId) && !is_null($orderId)) {
                 //Consulta pelo id do pedido
                 $response = $consultation->searchByOrder($orderId);
             }
         }
     } catch (ValidationException $e) {
         Mage::getSingleton('adminhtml/session')->addError('Error:' . $e->getMessage());
         Mage::helper("bcash")->saveLog($e->getMessage(), $e->getErrors());
     } catch (ConnectionException $e) {
         Mage::getSingleton('adminhtml/session')->addError('Error:' . $e->getMessage());
         Mage::helper("bcash")->saveLog($e->getMessage(), $e->getErrors());
     }
     return $response;
 }