amazonCustomerFactory = $amazonCustomerFactory; $this->clientFactory = $clientFactory; $this->amazonCoreHelper = $amazonCoreHelper; $this->customerUrl = $customerUrl; $this->accessTokenRequestValidator = $accessTokenRequestValidator; $this->accountRedirect = $accountRedirect; $this->matcher = $matcher; $this->customerLinkManagement = $customerLinkManagement; $this->customerSession = $customerSession; $this->session = $session; $this->logger = $logger; parent::__construct($context); } /** * Load userinfo from access token * * @return AmazonCustomerInterface */ protected function getAmazonCustomer() { try { $userInfo = $this->clientFactory ->create() ->getUserInfo($this->getRequest()->getParam('access_token')); if (is_array($userInfo) && isset($userInfo['user_id'])) { $data = [ 'id' => $userInfo['user_id'], 'email' => $userInfo['email'], 'name' => $userInfo['name'], 'country' => $this->amazonCoreHelper->getRegion(), ]; $amazonCustomer = $this->amazonCustomerFactory->create($data); return $amazonCustomer; } } catch (\Exception $e) { $this->logger->error($e); $this->messageManager->addErrorMessage(__('Error processing Amazon Login')); } return false; } /** * @return bool */ protected function isValidToken() { return $this->accessTokenRequestValidator->isValid($this->getRequest()); } /** * @return string */ protected function getRedirectLogin() { return $this->_redirect($this->customerUrl->getLoginUrl()); } /** * @return string */ protected function getRedirectAccount() { return $this->accountRedirect->getRedirect(); } }