Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Fetch.php
Go to the documentation of this file.
1 <?php
8 
12 
14 {
20  const ADMIN_RESOURCE = 'Magento_Sales::transactions_fetch';
21 
27  public function execute()
28  {
29  $txn = $this->_initTransaction();
31  $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
32  if (!$txn) {
33  return $resultRedirect->setPath('sales/*/');
34  }
35  try {
36  $this->orderPaymentRepository
37  ->get($txn->getPaymentId())
38  ->setOrder($txn->getOrder())
39  ->importTransactionInfo($txn);
40  $txn->save();
41  $this->messageManager->addSuccessMessage(__('The transaction details have been updated.'));
42  } catch (\Magento\Framework\Exception\LocalizedException $e) {
43  $this->messageManager->addErrorMessage($e->getMessage());
44  } catch (\Exception $e) {
45  $this->messageManager->addErrorMessage(__('We can\'t update the transaction details.'));
46  $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
47  }
48 
49  return $resultRedirect->setPath('sales/transactions/view', ['_current' => true]);
50  }
51 }
__()
Definition: __.php:13