Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
AbstractExpress Class Reference
Inheritance diagram for AbstractExpress:
Action RedirectLoginInterface AbstractAction ActionInterface Cancel Edit PlaceOrder ReturnAction Review SaveShippingMethod ShippingOptionsCallback UpdateShippingMethods GetToken

Public Member Functions

 __construct (\Magento\Framework\App\Action\Context $context, \Magento\Customer\Model\Session $customerSession, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory, \Magento\Framework\Session\Generic $paypalSession, \Magento\Framework\Url\Helper\Data $urlHelper, \Magento\Customer\Model\Url $customerUrl)
 
 getCustomerBeforeAuthUrl ()
 
 getActionFlagList ()
 
 getLoginUrl ()
 
 getRedirectActionName ()
 
 redirectLogin ()
 
- Public Member Functions inherited from Action
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getActionFlag ()
 
- Public Member Functions inherited from AbstractAction
 __construct (Context $context)
 
 dispatch (RequestInterface $request)
 
 getRequest ()
 
 getResponse ()
 
- Public Member Functions inherited from ActionInterface
 execute ()
 

Protected Member Functions

 _initCheckout ()
 
 _initToken ($setToken=null)
 
 _getSession ()
 
 _getCheckoutSession ()
 
 _getQuote ()
 
- Protected Member Functions inherited from Action
 _forward ($action, $controller=null, $module=null, array $params=null)
 
 _redirect ($path, $arguments=[])
 

Protected Attributes

 $_checkout
 
 $_checkoutTypes = []
 
 $_config
 
 $_quote = false
 
 $_configType
 
 $_configMethod
 
 $_checkoutType
 
 $_customerSession
 
 $_checkoutSession
 
 $_orderFactory
 
 $_checkoutFactory
 
 $_paypalSession
 
 $_urlHelper
 
 $_customerUrl
 
- Protected Attributes inherited from Action
 $_objectManager
 
 $_sessionNamespace
 
 $_eventManager
 
 $_actionFlag
 
 $_redirect
 
 $_view
 
 $_url
 
 $messageManager
 
- Protected Attributes inherited from AbstractAction
 $_request
 
 $_response
 
 $resultRedirectFactory
 
 $resultFactory
 

Additional Inherited Members

- Data Fields inherited from ActionInterface
const FLAG_NO_DISPATCH = 'no-dispatch'
 
const FLAG_NO_POST_DISPATCH = 'no-postDispatch'
 
const FLAG_NO_DISPATCH_BLOCK_EVENT = 'no-beforeGenerateLayoutBlocksDispatch'
 
const PARAM_NAME_BASE64_URL = 'r64'
 
const PARAM_NAME_URL_ENCODED = 'uenc'
 

Detailed Description

Abstract Express Checkout Controller @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 15 of file AbstractExpress.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\App\Action\Context  $context,
\Magento\Customer\Model\Session  $customerSession,
\Magento\Checkout\Model\Session  $checkoutSession,
\Magento\Sales\Model\OrderFactory  $orderFactory,
\Magento\Paypal\Model\Express\Checkout\Factory  $checkoutFactory,
\Magento\Framework\Session\Generic  $paypalSession,
\Magento\Framework\Url\Helper\Data  $urlHelper,
\Magento\Customer\Model\Url  $customerUrl 
)
Parameters
\Magento\Framework\App\Action\Context$context
\Magento\Customer\Model\Session$customerSession
\Magento\Checkout\Model\Session$checkoutSession
\Magento\Sales\Model\OrderFactory$orderFactory
\Magento\Paypal\Model\Express\Checkout\Factory$checkoutFactory
\Magento\Framework\Session\Generic$paypalSession
\Magento\Framework\Url\Helper\Data$urlHelper
\Magento\Customer\Model\Url$customerUrl

Definition at line 105 of file AbstractExpress.php.

114  {
115  $this->_customerSession = $customerSession;
116  $this->_checkoutSession = $checkoutSession;
117  $this->_orderFactory = $orderFactory;
118  $this->_checkoutFactory = $checkoutFactory;
119  $this->_paypalSession = $paypalSession;
120  $this->_urlHelper = $urlHelper;
121  $this->_customerUrl = $customerUrl;
122  parent::__construct($context);
123  $parameters = ['params' => [$this->_configMethod]];
124  $this->_config = $this->_objectManager->create($this->_configType, $parameters);
125  }
$customerUrl
Definition: info.phtml:28

Member Function Documentation

◆ _getCheckoutSession()

_getCheckoutSession ( )
protected

Return checkout session object

Returns
\Magento\Checkout\Model\Session

Definition at line 205 of file AbstractExpress.php.

◆ _getQuote()

_getQuote ( )
protected

Return checkout quote object

Returns
\Magento\Quote\Model\Quote

Definition at line 215 of file AbstractExpress.php.

216  {
217  if (!$this->_quote) {
218  $this->_quote = $this->_getCheckoutSession()->getQuote();
219  }
220  return $this->_quote;
221  }

◆ _getSession()

_getSession ( )
protected

PayPal session instance getter

Returns
\Magento\Framework\Session\Generic

Definition at line 195 of file AbstractExpress.php.

◆ _initCheckout()

_initCheckout ( )
protected

Instantiate quote and checkout

Returns
void
Exceptions

Definition at line 133 of file AbstractExpress.php.

134  {
135  $quote = $this->_getQuote();
136  if (!$quote->hasItems() || $quote->getHasError()) {
137  $this->getResponse()->setStatusHeader(403, '1.1', 'Forbidden');
138  throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t initialize Express Checkout.'));
139  }
140  if (!isset($this->_checkoutTypes[$this->_checkoutType])) {
141  $parameters = [
142  'params' => [
143  'quote' => $quote,
144  'config' => $this->_config,
145  ],
146  ];
147  $this->_checkoutTypes[$this->_checkoutType] = $this->_checkoutFactory
148  ->create($this->_checkoutType, $parameters);
149  }
150  $this->_checkout = $this->_checkoutTypes[$this->_checkoutType];
151  }
$quote
__()
Definition: __.php:13

◆ _initToken()

_initToken (   $setToken = null)
protected

Search for proper checkout token in request or session or (un)set specified one Combined getter/setter

Parameters
string | null$setToken
Returns
$this|string
Exceptions

Definition at line 161 of file AbstractExpress.php.

162  {
163  if (null !== $setToken) {
164  if (false === $setToken) {
165  // security measure for avoid unsetting token twice
166  if (!$this->_getSession()->getExpressCheckoutToken()) {
167  throw new \Magento\Framework\Exception\LocalizedException(
168  __('PayPal Express Checkout Token does not exist.')
169  );
170  }
171  $this->_getSession()->unsExpressCheckoutToken();
172  } else {
173  $this->_getSession()->setExpressCheckoutToken($setToken);
174  }
175  return $this;
176  }
177  $setToken = $this->getRequest()->getParam('token');
178  if ($setToken) {
179  if ($setToken !== $this->_getSession()->getExpressCheckoutToken()) {
180  throw new \Magento\Framework\Exception\LocalizedException(
181  __('A wrong PayPal Express Checkout Token is specified.')
182  );
183  }
184  } else {
185  $setToken = $this->_getSession()->getExpressCheckoutToken();
186  }
187  return $setToken;
188  }
__()
Definition: __.php:13

◆ getActionFlagList()

getActionFlagList ( )

Returns a list of action flags [flag_key] => boolean

Returns
array

Implements RedirectLoginInterface.

Definition at line 236 of file AbstractExpress.php.

237  {
238  return [];
239  }

◆ getCustomerBeforeAuthUrl()

getCustomerBeforeAuthUrl ( )

Returns before_auth_url redirect parameter for customer session

Returns
null

Implements RedirectLoginInterface.

Definition at line 227 of file AbstractExpress.php.

228  {
229  return;
230  }

◆ getLoginUrl()

getLoginUrl ( )

Returns login url parameter for redirect

Returns
string

Implements RedirectLoginInterface.

Definition at line 245 of file AbstractExpress.php.

246  {
247  return $this->_customerUrl->getLoginUrl();
248  }

◆ getRedirectActionName()

getRedirectActionName ( )

Returns action name which requires redirect

Returns
string

Implements RedirectLoginInterface.

Definition at line 254 of file AbstractExpress.php.

255  {
256  return 'start';
257  }

◆ redirectLogin()

redirectLogin ( )

Redirect to login page

Returns
void

Definition at line 264 of file AbstractExpress.php.

265  {
266  $this->_actionFlag->set('', 'no-dispatch', true);
267  $this->_customerSession->setBeforeAuthUrl($this->_redirect->getRefererUrl());
268  $this->getResponse()->setRedirect(
269  $this->_urlHelper->addRequestParam($this->_customerUrl->getLoginUrl(), ['context' => 'checkout'])
270  );
271  }
_redirect($path, $arguments=[])
Definition: Action.php:167

Field Documentation

◆ $_checkout

$_checkout
protected

Definition at line 20 of file AbstractExpress.php.

◆ $_checkoutFactory

$_checkoutFactory
protected

Definition at line 78 of file AbstractExpress.php.

◆ $_checkoutSession

$_checkoutSession
protected

Definition at line 68 of file AbstractExpress.php.

◆ $_checkoutType

$_checkoutType
protected

Definition at line 58 of file AbstractExpress.php.

◆ $_checkoutTypes

$_checkoutTypes = []
protected

Definition at line 27 of file AbstractExpress.php.

◆ $_config

$_config
protected

Definition at line 32 of file AbstractExpress.php.

◆ $_configMethod

$_configMethod
protected

Definition at line 51 of file AbstractExpress.php.

◆ $_configType

$_configType
protected

Definition at line 44 of file AbstractExpress.php.

◆ $_customerSession

$_customerSession
protected

Definition at line 63 of file AbstractExpress.php.

◆ $_customerUrl

$_customerUrl
protected

Definition at line 93 of file AbstractExpress.php.

◆ $_orderFactory

$_orderFactory
protected

Definition at line 73 of file AbstractExpress.php.

◆ $_paypalSession

$_paypalSession
protected

Definition at line 83 of file AbstractExpress.php.

◆ $_quote

$_quote = false
protected

Definition at line 37 of file AbstractExpress.php.

◆ $_urlHelper

$_urlHelper
protected

Definition at line 88 of file AbstractExpress.php.


The documentation for this class was generated from the following file: