customerSession = $customerSession; $this->checkoutSession = $checkoutSession; } /** * {@inheritdoc} */ public function getConfig() { $config = []; /** @var \Amazon\Core\Api\Data\AmazonCustomerInterface $amazonCustomer */ if ($amazonCustomer = $this->customerSession->getAmazonCustomer()) { $config['amazon_customer_email'] = $amazonCustomer->getEmail(); } if (!isset($config['amazon_customer_email'])) { $quote = $this->checkoutSession->getQuote(); $config['amazon_customer_email'] = $quote->getCustomerEmail(); } // return a stdClass so that the resulting JSON is an empty object, not an empty array return ['amazonLogin' => empty($config) ? new \stdClass : $config]; } }