We are currently having a issue with the Observer, most likely we did something wrong, but I have no clue what I've did wrong.
Basically, we created a module with an observer:
namespace Vendor\Customer\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
use Vendor\Customer\Model\Customer;
use Vendor;
class SalesOrderSaveAfter implements ObserverInterface {
/** @var \Magento\Framework\Logger\Monolog */
protected $logger;
protected $_customer;
public function __construct(\Psr\Log\LoggerInterface $loggerInterface,
\Vendor\Customer\Model\Customer $customer) {
$this->logger = $loggerInterface;
$this->_customer = $customer;
}
/**
* fires when sales_order_save_after is dispatched
*
* @param Observer $observer
*/
public function execute(Observer $observer) {
$order = $observer->getEvent()->getOrder();
$result = (array) $this->_customer->getOrderData($order);
}
}
The problem is, that the module fires the action when the customer clicks on "Place order" in the frontend.
When the customer clicks on "Place order" he will be redirected to a third party payment provider, and after the customer is finishing his payment there, he comes back to the Success-Page, where this Observer triggeres AGAIN.
The result of this is that the observer is triggered twice in one payment process. This seems buggy.
So the question is: how can I tell the Observer to only fire once and only if the payment is successfully done (= when reaching the Success-Page)?