public function postProcess()
 {
     $validate = new PagSeguroValidateOrderPrestashop($this->pagSeguro);
     try {
         $validate->validate();
         if ($this->checkout) {
             die($validate->request($this->checkout));
         }
         try {
             Tools::redirectLink($validate->request($this->checkout));
         } catch (Exception $e) {
             $this->displayErroPage();
         }
     } catch (PagSeguroServiceException $exc) {
         canceledOrderForErro();
         displayErroPage();
     } catch (Exception $e) {
         displayErroPage();
     }
 }
include_once dirname(__FILE__) . '/../../backward_compatibility/backward.php';
include_once dirname(__FILE__) . '/../../features/validation/pagsegurovalidateorderprestashop.php';
$pag_seguro = new PagSeguro();
$validate = new PagSeguroValidateOrderPrestashop($pag_seguro);
try {
    $validate->validate();
    if ($checkout) {
        die($validate->request($checkout));
    }
    Tools::redirectLink($validate->request($checkout));
} catch (PagSeguroServiceException $exc) {
    canceledOrderForErro($pag_seguro);
    if ($checkout) {
        throw new Exception($exc->getMessage(), 1);
    } else {
        displayErroPage();
    }
}
function displayErroPage()
{
    $showView = new BWDisplay();
    $showView->setTemplate(_PS_MODULE_DIR_ . 'pagseguro/views/templates/front/error.tpl');
    $showView->run();
}
function canceledOrderForErro($pag_seguro)
{
    $currentOrder = (int) $pag_seguro->currentOrder;
    $history = new OrderHistory();
    $history->id_order = $currentOrder;
    $history->changeIdOrderState(6, $currentOrder);
    $history->save();