I have a custom extension that uses sales_order_save_after
basically i want to create an invoice after the customer put a payment data , the problem is the order seems not been created at so i got an error like this:
Call to a member function getAdditionalInformation() on null in vendor/magento/module-sales/Model/OrderRepository.php:172
then i remove the create invoice function from my observer, then it does not got any error.
After i successfully place an order , i try this create invoice function again using the success order , the create invoice function run smoothly.
It seems the function is triggered before the payment has been placed, is there a way to detect if the payment has been placed using this observer or order?