title: Display Getway error message to use Magento
body: <pre><code>&lt;?php class Swetin_Mygateway_PaymentController extends Mage_Core_Controller_Front_Action {
      // The redirect action is triggered when someone places an order
      public function redirectAction() {
          $this-&gt;loadLayout();
          $block = $this-&gt;getLayout()-&gt;createBlock('Mage_Core_Block_Template','swetin',array('template' =&gt; 'swetin/redirect.phtml'));
          $this-&gt;getLayout()-&gt;getBlock('content')-&gt;append($block);
          $this-&gt;renderLayout();
      }
  
  
      public function responseAction() {
  
          if($this-&gt;getRequest()-&gt;isPost()) {
  
  
              $validated = false;
  
              // Generally sent by gateway
              $status_codes = $this-&gt;getRequest()-&gt;getPost('gtpay_tranx_status_code');
              $orderId = $this-&gt;getRequest()-&gt;getPost('gtpay_tranx_id');
              //$orderId = "";
              $orderStatMsg = $this-&gt;getRequest()-&gt;getPost('gtpay_tranx_status_msg');
  
              //echo $status_codes;
  
              if($status_codes == "00" ){ $validated = true; }
  
              //$orderId = $requesting['gtpay_tranx_id']; 
  
              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-&gt;loadByIncrementId($orderId);
                  $order-&gt;setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'Payment authorized!');
  
                  $order-&gt;sendNewOrderEmail();
                  $order-&gt;setEmailSent(true);
  
                  $order-&gt;save();
  
                  Mage::getSingleton('checkout/session')-&gt;unsQuoteId();
  
                  Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure'=&gt;true));
              }
              else {
                  // There is a problem in the response we got
                  $this-&gt;cancelAction($orderStatMsg);
                  Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/failure', array('_secure'=&gt;true));
              }
          }
          else
              Mage_Core_Controller_Varien_Action::_redirect('');
      }
  
      // The cancel action is triggered when an order is to be cancelled
      public function cancelAction($orderStatMsg) {
          if (Mage::getSingleton('checkout/session')-&gt;getLastRealOrderId()) {
              $order = Mage::getModel('sales/order')-&gt;loadByIncrementId(Mage::getSingleton('checkout/session')-&gt;getLastRealOrderId());
              if($order-&gt;getId()) {
  
                          Mage::getSingleton('checkout/session')-&gt;addError($orderStatMsg);
                  session_write_close();
  
                  // Flag the order as 'cancelled' and save it  'Card has declined the payment.'
                  $order-&gt;cancel()-&gt;setState(Mage_Sales_Model_Order::STATE_CANCELED, true, $orderStatMsg)-&gt;save();
              }
          }
      }
  }
  </code></pre>
  
  <p>I get the messages from the gateways.  Is it <code>addSuccess</code>, <code>addError</code>... to collect it in the session?</p>
  
  <p>instead of showing this:
  AN ERROR OCCURRED IN THE PROCESS OF PAYMENT
  Order #100000091</p>
  
  <p>Click here to continue shopping.</p>
  
  <p>i want it to show:</p>
  
  <p>AN ERROR OCCURRED IN THE PROCESS OF PAYMENT
  Error: Insufficient funds or what ever error message gateway returns
  Order #100000091</p>
  
  <p>Click here to continue shopping.</p>