The infrastructure for handling orders and checkout and payment modules was inherited from osCommerce, and has many flaws in its design insomuch has it has many limitations, one of them being the fact that the order isn't actually created until *after* the payment module finishes handling it. That is on the roadmap for rewriting in a future version.

In the meantime, if you even need to store the order number at all, you'll need to change the query you're using and use the same logic as you found in the linkpoint module.