I'm trying to solve the problem with session validation on the page /checkout/onepage/success/ with example https://gielberkers.com/style-checkoutonepagesuccess-page-magento-2/
But the example does not work if there is no order. How get increment_id for order, if does not orders exist?
To do this you must place an order first. So what you should do is, undo all the changes that this article is proposing, place an order, and do it again.
This code is taking the last order placed on your platform to build the success page, so if has no order, will not work.