amazonCaptureDetailsFactory = $amazonCaptureDetailsFactory; $this->capture = $capture; $this->collectionFactory = $collectionFactory; $this->storeManager = $storeManager; } /** * {@inheritDoc} */ public function supports(array $ipnData) { return (isset($ipnData['NotificationType']) && 'PaymentCapture' === $ipnData['NotificationType']); } /** * {@inheritDoc} */ public function process(array $ipnData) { $details = $this->amazonCaptureDetailsFactory->create([ 'details' => $ipnData['CaptureDetails'] ]); $collection = $this->collectionFactory ->create() ->addFieldToFilter(PendingCaptureInterface::CAPTURE_ID, ['eq' => $details->getTransactionId()]) ->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())) { $pendingCapture = current($items); $this->capture->setThrowExceptions(true); $this->capture->updateCapture($pendingCapture->getId(), $details); } } }