I am building payment gateway extension and i am facing small issue to get the quote object after control return from payment Gateway.

Let me explain you in detail.

I am using below funtion to redirect to payment gateway.

public function getCheckoutRedirectUrl()
return Mage::getUrl('custom/index/start');

Above method works fine. I am redirecting to payment gateway and payment processed successful with success message and redirect back to our store with captured status on below controller action.

public function returnAction()
$quote = Mage::getSingleton('checkout/session')->getQuote();
$payment = $quote->getPayment();
$service = Mage::getModel('sales/service_quote', $quote);
$order = $service->getOrder();

Mage_Sales_Model_Order::STATE_PENDING_PAYMENT: break; case Mage_Sales_Model_Order::STATE_PROCESSING: case Mage_Sales_Model_Order::STATE_COMPLETE: case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW: $order->sendNewOrderEmail(); break; } $this->getResponse()->setRedirect(Mage::getUrl('checkout/onepage/success')); return; }

But in the above function i get the quote object as blank and due to that i am unable to place an order. This means that after returning from payment gateway it clears the checkout session.

How can i get the quote object and what is the problem ?

Please help


After click on place order button at final step of checkout ,you can not get quote object from $quote = Mage::getSingleton('checkout/session')->getQuote();

As per as magento,whenever a customer is click on place order button then a quote is convert to order object and unlink the session quote object from session. and just assign:

  • last quote id to checkout session variable to last_quote_id
  • Newly created order increment id to session variable last_real_order_id

If you want to get order increment id & quote id then use $OrderIncrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); and $quote=Mage::getSingleton('checkout/session')->getLastQuoteId() respectively at returnAction

$OrderObject=$order = Mage::getModel('sales/order');


$QuoteObject = Mage::getModel('sales/quote');
  • Thanks for your answer but i am using below function means public function getCheckoutRedirectUrl() { return Mage::getUrl('custom/index/start'); } when i click on save payment then i am redirected to payment gateway. Same function as paypal standard payment Gateway. I have tried code but its not working and redirect back to return action and redirected to shopping cart page with blank cart. I got quote object as blank value. Let me know – Sanjay Jethva Oct 19 '15 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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