amazonRefundDetailsFactory = $amazonRefundDetailsFactory; $this->queuedRefundUpdater = $queuedRefundUpdater; $this->collectionFactory = $collectionFactory; $this->storeManager = $storeManager; } /** * {@inheritDoc} */ public function supports(array $ipnData) { return (isset($ipnData['NotificationType']) && 'PaymentRefund' === $ipnData['NotificationType']); } /** * {@inheritDoc} */ public function process(array $ipnData) { $details = $this->amazonRefundDetailsFactory->create([ 'details' => $ipnData['RefundDetails'] ]); $collection = $this->collectionFactory ->create() ->addFieldToFilter(PendingRefundInterface::REFUND_ID, ['eq' => $details->getRefundId()]) ->setPageSize(1) ->setCurPage(1); $collection->getSelect() ->join(['so' => $collection->getTable('sales_order')], 'main_table.order_id = so.entity_id', []) ->where('so.store_id = ?', $this->storeManager->getStore()->getId()); if (count($items = $collection->getItems())) { $pendingRefund = current($items); $this->queuedRefundUpdater->setThrowExceptions(true); $this->queuedRefundUpdater->checkAndUpdateRefund($pendingRefund->getId(), $details); } } }