/**
  * Método para cancelamento de transação de pagamento
  *
  * @param $transactionId
  * @return mixed
  */
 public function cancellation($transactionId)
 {
     // Instância de classe de cancelamento
     $cancellation = new Cancellation($this->email, $this->token);
     $cancellation->enableSandBox($this->sandbox);
     $response = null;
     try {
         if (!is_null($transactionId) && !empty($transactionId)) {
             // Envia cancelamento da transação para API
             $response = $cancellation->execute($transactionId);
         }
     } catch (ValidationException $e) {
         Mage::getSingleton('adminhtml/session')->addError('Erro: ' . $e->getMessage());
         Mage::helper("bcash")->saveLog("ValidationException - Model_Order->cancellation: " . $e->getMessage(), $e->getErrors());
     } catch (ConnectionException $e) {
         Mage::getSingleton('adminhtml/session')->addError($e->getMessage() . ' (Confirme se o serviço de cancelamento está habilitado para sua conta Bcash)');
         Mage::helper("bcash")->saveLog("ConnectionException - Model_Order->cancellation: " . $e->getMessage(), $e->getErrors());
     }
     return $response;
 }
include_once dirname(__FILE__) . '/bcash-php-sdk/autoloader.php';
include_once dirname(__FILE__) . '/domain/History.php';
use Bcash\Service\Cancellation;
use Bcash\Exception\ValidationException;
use Bcash\Exception\ConnectionException;
$error = 'error';
$prefix = 'BCASH_';
$id_transacao = Tools::getValue('id_transacao');
$id_pedido = Tools::getValue('id_pedido');
if (empty($id_transacao) || empty($id_pedido)) {
    echo http_response_code(404);
    exit;
}
$email = Configuration::get($prefix . 'EMAIL');
$token = Configuration::get($prefix . 'TOKEN');
$cancellation = new Cancellation($email, $token);
$cancellation->enableSandBox(Configuration::get($prefix . 'SANDBOX'));
try {
    $response = $cancellation->execute($id_transacao);
    if ($response->transactionStatusId == 7 || $response->transactionStatusId == 6) {
        updateOrder($id_pedido, $response);
        writeHistory($id_pedido, $response);
    }
} catch (ValidationException $e) {
    die(errorResponse($e));
} catch (ConnectionException $e) {
    die(errorResponse($e));
}
echo json_encode($response);
exit;
function errorResponse($e)