2015-01-12 36 views
1

我使用的Magento 1.9.0.1Magento的 - 問題創造了新的付款方式模塊

我正在其上增加一個額外的付款方式自定義擴展。 一切似乎與擴展工作 - 付款方式顯示正常,但我得到這個錯誤,當我嘗試「下訂單」與我選擇的自定義方法。

這是我得到的錯誤:

出現了一個錯誤處理您的請求

異常打印默認情況下,出於安全原因關閉。

錯誤日誌記錄編號:321152034690

下面是報告:

a:5:{i:0;s:150:"Cannot send headers; headers already sent in /home/sportsdi/public_html/beta/app/code/local/Myname/Mygateway/controllers/PaymentController.php, line 1";i:1;s:1061:"#0 /home/sportsdi/public_html/beta/lib/Zend/Controller/Response/Abstract.php(115): Zend_Controller_Response_Abstract->canSendHeaders(true) 
#1 /home/sportsdi/public_html/beta/app/code/core/Mage/Core/Model/App.php(1246): Zend_Controller_Response_Abstract->setHeader('Content-Type', 'text/html; char...') 
#2 /home/sportsdi/public_html/beta/app/code/core/Mage/Core/Controller/Varien/Front.php(80): Mage_Core_Model_App->getResponse() 
#3 /home/sportsdi/public_html/beta/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(202): Mage_Core_Controller_Varien_Front->getResponse() 
#4 /home/sportsdi/public_html/beta/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) 
#5 /home/sportsdi/public_html/beta/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() 
#6 /home/sportsdi/public_html/beta/app/Mage.php(684): Mage_Core_Model_App->run(Array) 
#7 /home/sportsdi/public_html/beta/index.php(87): Mage::run('', 'store') 
#8 {main}";s:3:"url";s:28:"/mygateway/payment/redirect/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";} 

這是所有我在得到:/家庭/ sportsdi /的public_html /測試/應用/代碼/本地/Myname/Mygateway/controllers/PaymentController.php:

<?php 
class Myname_Mygateway_PaymentController extends Mage_Core_Controller_Front_Action { 
    // The redirect action is triggered when someone places an order 
    public function redirectAction() { 
     $this->loadLayout(); 
     $block = $this->getLayout()->createBlock('Mage_Core_Block_Template','mygateway',array('template' => 'mygateway/redirect.phtml')); 
     $this->getLayout()->getBlock('content')->append($block); 
     $this->renderLayout(); 
    } 

    // The response action is triggered when your gateway sends back a response after processing the customer's payment 
    public function responseAction() { 
     if($this->getRequest()->isPost()) { 

      /* 
      /* Your gateway's code to make sure the reponse you 
      /* just got is from the gatway and not from some weirdo. 
      /* This generally has some checksum or other checks, 
      /* and is provided by the gateway. 
      /* For now, we assume that the gateway's response is valid 
      */ 

      $validated = true; 
      $orderId = '123'; // Generally sent by gateway 

      if($validated) { 
       // Payment was successful, so update the order's state, send order email and move to the success page 
       $order = Mage::getModel('sales/order'); 
       $order->loadByIncrementId($orderId); 
       $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.'); 

       $order->sendNewOrderEmail(); 
       $order->setEmailSent(true); 

       $order->save(); 

       Mage::getSingleton('checkout/session')->unsQuoteId(); 

       Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=>true)); 
      } 
      else { 
       // There is a problem in the response we got 
       $this->cancelAction(); 
       Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=>true)); 
      } 
     } 
     else 
      Mage_Core_Controller_Varien_Action::_redirect(''); 
    } 

    // The cancel action is triggered when an order is to be cancelled 
    public function cancelAction() { 
     if (Mage::getSingleton('checkout/session')->getLastRealOrderId()) { 
      $order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId()); 
      if($order->getId()) { 
       // Flag the order as 'cancelled' and save it 
       $order->cancel()->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, 'Gateway has declined the payment.')->save(); 
      } 
     } 
    } 
} 

你能幫我找出問題並解決嗎?

在此先感謝!

+0

嗨,嘗試搜索該模塊中「回聲」語句和評論則嘗試下訂單。 – Charlie

回答

0

如果你在你的模塊中有任何echo語句,那麼也會出現這個錯誤,在你的模塊中找到echo,如果你發現然後刪除它。

0

有「回聲」語句會導致這個,除非你打開輸出緩衝。如果您仍然希望看到回波的結果,把線,

ob_start(); 

在有問題的文件的頂部會給你你正在尋找的結果。

更多信息:http://php.net/manual/en/function.ob-start.php