PrepareCapture.php 835 B

123456789101112131415161718192021222324252627282930313233343536
  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. /**
  14. * Generate item list for payment capture
  15. */
  16. class PrepareCapture implements ObserverInterface
  17. {
  18. /**
  19. * @param Observer $observer
  20. * @return void
  21. */
  22. public function execute(\Magento\Framework\Event\Observer $observer)
  23. {
  24. $payment = $observer->getPayment();
  25. if (false === strpos($payment->getMethod(), 'klarna_')) {
  26. return;
  27. }
  28. $payment->setInvoice($observer->getInvoice());
  29. }
  30. }