Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetResponseAfterSaveOrderObserver.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
21  protected $_coreRegistry;
22 
28  protected $_paypalHss;
29 
34 
38  protected $_view;
39 
47  public function __construct(
48  \Magento\Paypal\Helper\Hss $paypalHss,
49  \Magento\Framework\Registry $coreRegistry,
50  \Magento\Framework\App\ViewInterface $view
51  ) {
52  $this->_paypalHss = $paypalHss;
53  $this->_coreRegistry = $coreRegistry;
54  $this->_view = $view;
55  }
56 
63  public function execute(EventObserver $observer)
64  {
65  /* @var $order \Magento\Sales\Model\Order */
66  $order = $this->_coreRegistry->registry('hss_order');
67 
68  if ($order && $order->getId()) {
69  $payment = $order->getPayment();
70  if ($payment && in_array($payment->getMethod(), $this->_paypalHss->getHssMethods())) {
71  $result = $observer->getData('result')->getData();
72  if (empty($result['error'])) {
73  $this->_view->loadLayout('checkout_onepage_review', true, true, false);
74  $html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml();
75  $result['update_section'] = ['name' => 'paypaliframe', 'html' => $html];
76  $result['redirect'] = false;
77  $result['success'] = false;
78  $observer->getData('result')->setData($result);
79  }
80  }
81  }
82  }
83 }
$order
Definition: order.php:55
$payment
Definition: order.php:17
__construct(\Magento\Paypal\Helper\Hss $paypalHss, \Magento\Framework\Registry $coreRegistry, \Magento\Framework\App\ViewInterface $view)