I'm using Magento

I'm working on a custom extension which is adding an extra payment method. Everything seems to work with the extension - the payment method is displayed properly but i got this error when i try to "Place order" with my custom method selected.

Here is the error i got:

There has been an error processing your request

Exception printing is disabled by default for security reasons.

Error log record number: 321152034690

Here is the report:

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";}

Here is all what i got in: /home/sportsdi/public_html/beta/app/code/local/Myname/Mygateway/controllers/PaymentController.php:

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

    // 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->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Gateway has authorized the payment.');




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

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

Can you please help me find out the problem and fix it?

Thanks in advance!

closed as off-topic by David Manners, Klettseb, Keyul Shah, Amit Bera, Marius Mar 25 '15 at 11:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about third-party modules are generally off-topic because the scope of functionality and code are not available. For more information, see this meta post/answer." – David Manners, Klettseb, Keyul Shah, Marius
If this question can be reworded to fit the rules in the help center, please edit the question.


Tony Stark,There may be issue in Model class of Payment.It may be var_dump().print_r,echo has been used in Model class Myname_Mygateway_Model_YourPaymentMethod.Please remove those.

Or may space issue controller class Myname_Mygateway_PaymentController>Need to debug.

Also, need to check at all class app/code

Not the answer you're looking for? Browse other questions tagged or ask your own question.