loginSessionHelper = $loginSessionHelper; $this->orderRepository = $orderRepository; $this->customerLinkManagement = $customerLinkManagement; $this->coreHelper = $coreHelper; } /** * @param OrderCustomerManagementInterface $subject * @param CustomerInterface $result * @param int $orderId * @return CustomerInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterCreate(OrderCustomerManagementInterface $subject, $result, $orderId) { if ($this->coreHelper->isLwaEnabled()) { $paymentMethodName = $this->orderRepository->get($orderId)->getPayment()->getMethod(); $isAmazonPayment = $paymentMethodName === Config::CODE; $amazonCustomer = $this->loginSessionHelper->getAmazonCustomer(); if ($isAmazonPayment && $amazonCustomer) { $this->customerLinkManagement->updateLink($result->getId(), $amazonCustomer->getId()); } } return $result; } }