checkout_onepage_controller_success_action event get order magento 2

Get complete order array in observer with event checkout_onepage_controller_success_action.

Create file events.xml in folder “Bluethink/Hello/etc”


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

<event name="checkout_onepage_controller_success_action">
<observer name="checkout_controller_success_action" instance="Bluethink\Hello\Observer\Successorder" />
</event>
</config>

Get order at obeserver file.Create file Successorder.php in folder “Bluethink\Hello\Observer”


namespace Bluethink\Hello\Observer;

use Magento\Framework\Event\ObserverInterface;

class Successorder implements ObserverInterface
{

public function execute(\Magento\Framework\Event\Observer $observer)
{

$order = $observer->getOrder();
echo "===><pre>";
print_r($order->getData());
exit();

}
}

get order array using print_r(); method