I now wanted to get the order id which it has just been placed to know it before sending it to the Payment Gateway

How to get the last order programmatically?