PrepareMerchantUrls.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * This file is part of the Klarna Order Management module
  4. *
  5. * (c) Klarna Bank AB (publ)
  6. *
  7. * For the full copyright and license information, please view the NOTICE
  8. * and LICENSE files that were distributed with this source code.
  9. */
  10. namespace Klarna\Ordermanagement\Observer;
  11. use Magento\Framework\Event\Observer;
  12. use Magento\Framework\Event\ObserverInterface;
  13. use Magento\Framework\Url;
  14. /**
  15. * Class PrepareMerchantUrls
  16. *
  17. * @package Klarna\Ordermanagement\Observer
  18. */
  19. class PrepareMerchantUrls implements ObserverInterface
  20. {
  21. /**
  22. * @var Url
  23. */
  24. private $url;
  25. /**
  26. * PrepareMerchantUrls constructor.
  27. *
  28. * @param Url $url
  29. */
  30. public function __construct(Url $url)
  31. {
  32. $this->url = $url;
  33. }
  34. /**
  35. * @param Observer $observer
  36. * @return void
  37. */
  38. public function execute(\Magento\Framework\Event\Observer $observer)
  39. {
  40. $urls = $observer->getUrls();
  41. if ($urls->hasPushUri()) { // Ignore for Kred
  42. return;
  43. }
  44. $urlParams = $observer->getUrlParams()->toArray();
  45. $urls->setPush($this->url->getDirectUrl('klarna/api/push/id/{checkout.order.id}', $urlParams));
  46. $urls->setNotification($this->url->getDirectUrl('klarna/api/notification/id/{checkout.order.id}', $urlParams));
  47. }
  48. }