/** * 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(); }