I am developing a custom payment gateway. It uses OrderIncrementID to identify which Order was the payment made for. I have every functionality running after the Order has been placed, i.e. after checkout, except one in the checkout page itself.

In the checkout page, Order was not created, getting an OrderIncrementID seems very difficult. We have to overwrite the order creation in the checkout such that it will be created after the payment method selection which sounds very complicated and dangerous to overwrite the flow. An alternative is to use QuoteID, but the tradeoff is that I have to implement a convertion from QuoteID to OrderIncrementID.

What can I do in this case to get an OrderIncrementID in the checkout page? especially after the payment method selection


Thanks for @AmitBera answer, I will now emphasis that consistency and integrity on overlapping request is very important in this payment system. User A load the checkout page first, followed by user B. But User B complete the checkout first, followed by User A. The correct payment for correct users should be made.


You could get the reserved order id for the quote if that helps. Try this:

$incrementId = $quote->getReservedOrderId();

Or you can get an order increment id like this:


Acording to the comments of the method this will:

 * Generate new increment order id and associate it with current quote
 * @return Mage_Sales_Model_Quote
public function reserveOrderId()

Also if you want you can hook to the event: sales_model_service_quote_submit_before

And then get the incrementId in the event handler like this:

public function doSomething($observer){//observer for the event
    $quote = $observer->getEvent()->getQuote();
    $incrementId = $quote->getReservedOrderId();
    //do stuff

For this last part credit goes to @Marius, Where is order ID generated?

  • 2
    Originally the Quote has NULL reserved order id, thus calling $quote->reserveOrderId()->save() solve my problem. And now we can get the reserved id. Thanks :) – Yeo Jun 1 '15 at 21:59
  • How to get order id when I click on make payment button – Jitendra prajapat Nov 5 '20 at 12:17

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.