Пример #1
0
 /**
  * Forced fetch reports action
  *
  * @return void
  * @throws \Magento\Framework\Model\Exception
  */
 public function execute()
 {
     try {
         $reports = $this->_settlementFactory->create();
         /* @var $reports \Magento\Paypal\Model\Report\Settlement */
         $credentials = $reports->getSftpCredentials();
         if (empty($credentials)) {
             throw new \Magento\Framework\Model\Exception(__('We found nothing to fetch because of an empty configuration.'));
         }
         foreach ($credentials as $config) {
             try {
                 $fetched = $reports->fetchAndSave(\Magento\Paypal\Model\Report\Settlement::createConnection($config));
                 $this->messageManager->addSuccess(__("We fetched %1 report rows from '%2@%3'.", $fetched, $config['username'], $config['hostname']));
             } catch (\Exception $e) {
                 $this->messageManager->addError(__("We couldn't fetch reports from '%1@%2'.", $config['username'], $config['hostname']));
                 $this->_logger->logException($e);
             }
         }
     } catch (\Magento\Framework\Model\Exception $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->_logger->logException($e);
     }
     $this->_redirect('*/*/index');
 }
Пример #2
0
 /**
  * Forced fetch reports action
  *
  * @return \Magento\Backend\Model\View\Result\Redirect
  */
 public function execute()
 {
     try {
         $reports = $this->_settlementFactory->create();
         /* @var $reports \Magento\Paypal\Model\Report\Settlement */
         $credentials = $reports->getSftpCredentials();
         if (empty($credentials)) {
             throw new \Magento\Framework\Exception\LocalizedException(__('We found nothing to fetch because of an empty configuration.'));
         }
         foreach ($credentials as $config) {
             try {
                 $fetched = $reports->fetchAndSave(\Magento\Paypal\Model\Report\Settlement::createConnection($config));
                 $this->messageManager->addSuccess(__('We fetched %1 report rows from "%2@%3."', $fetched, $config['username'], $config['hostname']));
             } catch (\Exception $e) {
                 $this->messageManager->addError(__('We can\'t fetch reports from "%1@%2."', $config['username'], $config['hostname']));
                 $this->_logger->critical($e);
             }
         }
     } catch (\Magento\Framework\Exception\LocalizedException $e) {
         $this->messageManager->addError($e->getMessage());
     } catch (\Exception $e) {
         $this->_logger->critical($e);
     }
     /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
     $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
     return $resultRedirect->setPath('*/*/index');
 }
Пример #3
0
 /**
  * Goes to reports.paypal.com and fetches Settlement reports.
  *
  * @return void
  */
 public function execute()
 {
     try {
         /** @var \Magento\Paypal\Model\Report\Settlement $reports */
         $reports = $this->_settlementFactory->create();
         /* @var $reports \Magento\Paypal\Model\Report\Settlement */
         $credentials = $reports->getSftpCredentials(true);
         foreach ($credentials as $config) {
             try {
                 $reports->fetchAndSave(\Magento\Paypal\Model\Report\Settlement::createConnection($config));
             } catch (\Exception $e) {
                 $this->_logger->critical($e);
             }
         }
     } catch (\Exception $e) {
         $this->_logger->critical($e);
     }
 }
 /**
  * @param array $config
  * @expectedException \InvalidArgumentException
  * @dataProvider createConnectionExceptionDataProvider
  */
 public function testCreateConnectionException($config)
 {
     \Magento\Paypal\Model\Report\Settlement::createConnection($config);
 }