/**
  * Adiciona o Link do meio de pagamento a página de sucesso.
  * @param $observer
  */
 public function orderSuccessEvent($observer)
 {
     try {
         $order = new Mage_Sales_Model_Order();
         $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
         $order->loadByIncrementId($lastOrderId);
         $quoteId = $order->getQuoteId();
         $quote = Mage::getModel("sales/quote")->loadByIdWithoutStore($quoteId);
         $type = null;
         $payment_method_bcash = $quote->getPaymentMethodBcash();
         if ($payment_method_bcash) {
             $helper = new Bcash_Pagamento_Helper_PaymentMethod();
             $type = $helper->getPaymentMethod($payment_method_bcash);
         }
         $layout = Mage::app()->getLayout();
         $block = $layout->createBlock('Mage_Core_Block_Template', 'link_pagamento_bcash', array('template' => 'bcash/pagamento/checkout/success.phtml'));
         $block->setOrder($order);
         $block->setQuote($quote);
         $block->setType($type);
         $layout->getBlock('content')->append($block);
         $bcashTransacation = $order->getTransactionIdBcash();
         Mage::helper("bcash")->saveLog("Pedido '" . $lastOrderId . "' realizado com sucesso. Transacao: " . $bcashTransacation);
     } catch (Exception $e) {
         Mage::helper("bcash")->saveLog($e->getMessage());
     }
 }
 public function successAction()
 {
     $order = new Mage_Sales_Model_Order();
     $lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
     $order->loadByIncrementId($lastOrderId);
     $quoteId = $order->getQuoteId();
     $quote = Mage::getModel("sales/quote")->load($quoteId);
     try {
         $order->setTransactionIdBcash($quote->getTransactionIdBcash())->setStatusBcash($quote->getStatusBcash())->setDescriptionStatusBcash($quote->getDescriptionStatusBcash())->setPaymentLinkBcash($quote->getPaymentLinkBcash())->setPaymentMethodBcash($quote->getPaymentMethodBcash())->setInstallmentsBcash($quote->getInstallmentsBcash());
         $order->save();
         $order->sendNewOrderEmail();
     } catch (Exception $ex) {
     }
     $type = null;
     $payment_method_bcash = $order->getPaymentMethodBcash();
     if ($payment_method_bcash) {
         $helper = new Bcash_Pagamento_Helper_PaymentMethod();
         $type = $helper->getPaymentMethod($payment_method_bcash);
     }
     $this->loadLayout();
     $this->getLayout()->getBlock('root')->setTemplate('page/2columns-right.phtml');
     $block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'link_pagamento_bcash', array('template' => 'bcash/pagamento/checkout/success.phtml'));
     $block->setOrder($order);
     $block->setQuote($quote);
     $block->setType($type);
     $this->getLayout()->getBlock('content')->append($block);
     $this->_initLayoutMessages('checkout/session');
     Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
     $this->renderLayout();
 }
 private function createAllPaymentMethods()
 {
     self::$cards = array($this->createPayment(1, 'Visa', self::CARD_TYPE, 1.0, 12), $this->createPayment(2, 'Master', self::CARD_TYPE, 1.0, 12), $this->createPayment(37, 'American Express', self::CARD_TYPE, 1.0, 12), $this->createPayment(45, 'Aura', self::CARD_TYPE, 1.0, 24), $this->createPayment(55, 'Diners', self::CARD_TYPE, 1.0, 12), $this->createPayment(56, 'HiperCard', self::CARD_TYPE, 1.0, 12), $this->createPayment(63, 'Elo', self::CARD_TYPE, 1.0, 12));
     self::$bankSlip = array($this->createPayment(10, 'Boleto Bancário', self::BANKSLIP_TYPE, 0.01, 1));
     self::$onlineTransfer = array($this->createPayment(58, 'BB', self::ONLINE_TRANSFER_TYPE, 0.01, 1), $this->createPayment(59, 'Bradesco', self::ONLINE_TRANSFER_TYPE, 0.01, 1), $this->createPayment(60, 'Itaú', self::ONLINE_TRANSFER_TYPE, 0.01, 1), $this->createPayment(61, 'Banrisul', self::ONLINE_TRANSFER_TYPE, 0.01, 1), $this->createPayment(62, 'HSBC', self::ONLINE_TRANSFER_TYPE, 0.01, 1));
 }