99use Magento \Framework \App \Action \Action as AppAction ;
1010use Magento \Framework \App \Action \HttpGetActionInterface ;
1111use Magento \Framework \App \Action \HttpPostActionInterface ;
12+ use Magento \Framework \App \ObjectManager ;
13+ use Magento \Quote \Api \CartRepositoryInterface ;
1214use 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 /**
0 commit comments