ShippingOptionsCallback.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Paypal\Controller\Express\AbstractExpress;
  8. class ShippingOptionsCallback extends \Magento\Paypal\Controller\Express\AbstractExpress
  9. {
  10. /**
  11. * @var \Magento\Quote\Api\CartRepositoryInterface
  12. */
  13. protected $quoteRepository;
  14. /**
  15. * @param \Magento\Framework\App\Action\Context $context
  16. * @param \Magento\Customer\Model\Session $customerSession
  17. * @param \Magento\Checkout\Model\Session $checkoutSession
  18. * @param \Magento\Sales\Model\OrderFactory $orderFactory
  19. * @param \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory
  20. * @param \Magento\Framework\Session\Generic $paypalSession
  21. * @param \Magento\Framework\Url\Helper\Data $urlHelper
  22. * @param \Magento\Customer\Model\Url $customerUrl
  23. * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
  24. */
  25. public function __construct(
  26. \Magento\Framework\App\Action\Context $context,
  27. \Magento\Customer\Model\Session $customerSession,
  28. \Magento\Checkout\Model\Session $checkoutSession,
  29. \Magento\Sales\Model\OrderFactory $orderFactory,
  30. \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory,
  31. \Magento\Framework\Session\Generic $paypalSession,
  32. \Magento\Framework\Url\Helper\Data $urlHelper,
  33. \Magento\Customer\Model\Url $customerUrl,
  34. \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
  35. ) {
  36. $this->quoteRepository = $quoteRepository;
  37. parent::__construct(
  38. $context,
  39. $customerSession,
  40. $checkoutSession,
  41. $orderFactory,
  42. $checkoutFactory,
  43. $paypalSession,
  44. $urlHelper,
  45. $customerUrl
  46. );
  47. }
  48. /**
  49. * Return shipping options items for shipping address from request
  50. *
  51. * @return void
  52. */
  53. public function execute()
  54. {
  55. try {
  56. $quoteId = $this->getRequest()->getParam('quote_id');
  57. $this->_quote = $this->quoteRepository->get($quoteId);
  58. $this->_initCheckout();
  59. $response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams());
  60. $this->getResponse()->setBody($response);
  61. } catch (\Exception $e) {
  62. $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
  63. }
  64. }
  65. }