Skip to content

Commit e3f27bb

Browse files
committed
Merge remote-tracking branch 'mpi/MC-19650' into Chaika-PR-2019-09-13-1
2 parents f537c81 + a8fbb7c commit e3f27bb

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

app/code/Magento/Paypal/Controller/Express/AbstractExpress.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Magento\Framework\App\Action\Action as AppAction;
1010
use Magento\Framework\App\Action\HttpGetActionInterface;
1111
use Magento\Framework\App\Action\HttpPostActionInterface;
12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Quote\Api\CartRepositoryInterface;
1214
use Magento\Quote\Api\Data\CartInterface;
1315

1416
/**
@@ -98,6 +100,11 @@ abstract class AbstractExpress extends AppAction implements
98100
*/
99101
protected $_customerUrl;
100102

103+
/**
104+
* @var CartRepositoryInterface
105+
*/
106+
private $quoteRepository;
107+
101108
/**
102109
* @param \Magento\Framework\App\Action\Context $context
103110
* @param \Magento\Customer\Model\Session $customerSession
@@ -107,6 +114,7 @@ abstract class AbstractExpress extends AppAction implements
107114
* @param \Magento\Framework\Session\Generic $paypalSession
108115
* @param \Magento\Framework\Url\Helper\Data $urlHelper
109116
* @param \Magento\Customer\Model\Url $customerUrl
117+
* @param CartRepositoryInterface $quoteRepository
110118
*/
111119
public function __construct(
112120
\Magento\Framework\App\Action\Context $context,
@@ -116,7 +124,8 @@ public function __construct(
116124
\Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory,
117125
\Magento\Framework\Session\Generic $paypalSession,
118126
\Magento\Framework\Url\Helper\Data $urlHelper,
119-
\Magento\Customer\Model\Url $customerUrl
127+
\Magento\Customer\Model\Url $customerUrl,
128+
CartRepositoryInterface $quoteRepository = null
120129
) {
121130
$this->_customerSession = $customerSession;
122131
$this->_checkoutSession = $checkoutSession;
@@ -128,6 +137,7 @@ public function __construct(
128137
parent::__construct($context);
129138
$parameters = ['params' => [$this->_configMethod]];
130139
$this->_config = $this->_objectManager->create($this->_configType, $parameters);
140+
$this->quoteRepository = $quoteRepository ?: ObjectManager::getInstance()->get(CartRepositoryInterface::class);
131141
}
132142

133143
/**
@@ -233,7 +243,12 @@ protected function _getCheckoutSession()
233243
protected function _getQuote()
234244
{
235245
if (!$this->_quote) {
236-
$this->_quote = $this->_getCheckoutSession()->getQuote();
246+
if ($this->_getSession()->getQuoteId()) {
247+
$this->_quote = $this->quoteRepository->get($this->_getSession()->getQuoteId());
248+
$this->_getCheckoutSession()->replaceQuote($this->_quote);
249+
} else {
250+
$this->_quote = $this->_getCheckoutSession()->getQuote();
251+
}
237252
}
238253
return $this->_quote;
239254
}
@@ -243,7 +258,7 @@ protected function _getQuote()
243258
*/
244259
public function getCustomerBeforeAuthUrl()
245260
{
246-
return;
261+
return null;
247262
}
248263

249264
/**

app/code/Magento/Paypal/Controller/Express/OnAuthorization.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public function execute(): ResultInterface
155155
} else {
156156
$responseContent['redirectUrl'] = $this->urlBuilder->getUrl('paypal/express/review');
157157
$this->_checkoutSession->setQuoteId($quote->getId());
158+
$this->_getSession()->setQuoteId($quote->getId());
158159
}
159160
} catch (ApiProcessableException $e) {
160161
$responseContent['success'] = false;

0 commit comments

Comments
 (0)