title: Get current orderId in magento payment module during checkout
body: <p>I am implementing my own payment module for Magento, where I implemented getCheckoutRedirectUrl() method in my payment model.</p>
  
  <pre><code>class My_Module_Model_Payment extends Mage_Payment_Model_Method_Abstract {}
  </code></pre>
  
  <p>This method is supposed to just return URL of payment gateway where user is redirected to, but I should also append current orderId to this URL.</p>
  
  <p>The problem is am not able to get orderId. I tried solution as already <a href="https://stackoverflow.com/questions/2195743/get-order-increment-id-in-magento">accepted here</a></p>
  
  <pre><code>$orderId = Mage::getSingleton('checkout/session')-&gt;getLastRealOrderId();
  </code></pre>
  
  <p>but I get empty $orderId. So this doesn't seem to work in my method. The call doesn't produce error, so I get an object (for example Mage::getSingleton('checkout/session')->getQuote()->getSubtotal() returns order amount), but orderId is empty.</p>
  
  <p>I also tried:</p>
  
  <pre><code>$order = Mage::getModel('sales/order');
  $order-&gt;load(Mage::getSingleton('sales/order')-&gt;getLastOrderId());
  $orderId = $order-&gt;getIncrementId();
  </code></pre>
  
  <p>which again returns empty $orderId.</p>
  
  <p>Any Ideas?</p>