/**
  * This Action loads the logging data from the database into the backend view
  */
 public function loadStoreAction()
 {
     $start = intval($this->Request()->getParam('start'));
     $limit = intval($this->Request()->getParam('limit'));
     if ($sort = $this->Request()->getParam('sort')) {
         $sort = current($sort);
     }
     if ($filter = $this->Request()->getParam('filter')) {
         foreach ($filter as $value) {
             if (empty($value['property']) || empty($value['value'])) {
                 continue;
             }
             if ($value['property'] == 'searchTerm') {
                 $this->Request()->setParam('searchTerm', $value['value']);
             }
             if ($value['property'] == 'connectedSearch') {
                 $this->Request()->setParam('connectedSearch', $value['value']);
             }
         }
     }
     if ($searchTerm = $this->Request()->getParam('searchTerm')) {
         $searchTerm = trim($searchTerm);
     }
     $direction = empty($sort['direction']) || $sort['direction'] == 'DESC' ? 'DESC' : 'ASC';
     $property = empty($sort['property']) ? 'id' : $sort['property'];
     $loggingManager = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_LoggingManager();
     //Load Data
     if ($connectedSearch = $this->Request()->getParam('connectedSearch')) {
         $data = $loggingManager->read($start, $limit, $property, $direction, $searchTerm, $connectedSearch);
     } else {
         $data = $loggingManager->read($start, $limit, $property, $direction, $searchTerm);
     }
     $total = $loggingManager->getTotal();
     $this->View()->assign(array("data" => $data, "total" => $total, "success" => true));
 }
 /**
  * Creates an instance of the paymentProcessor class. This class from the paymill lib allows easier access to most
  * calls used during the payment process.
  *
  * @param array $params
  * @param string  $processId
  */
 public function __construct($params, $processId)
 {
     $swConfig = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->Config();
     $privateKey = trim($swConfig->get("privateKey"));
     $apiUrl = "https://api.paymill.com/v2/";
     $source = Shopware()->Plugins()->Frontend()->PaymPaymentCreditcard()->getVersion();
     $source .= "_shopware";
     $source .= "_" . Shopware()->Config()->get('version');
     $this->setSource($source);
     $loggingManager = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_LoggingManager();
     $loggingManager->setProcessId($processId);
     parent::__construct($privateKey, $apiUrl, null, $params, $loggingManager);
 }
 /**
  * Validates the structure of the request
  * @param array $notification
  * @return boolean
  */
 private function isStructureValid($notification)
 {
     $isValid = !empty($notification) && isset($notification['event']['event_type']) && isset($notification['event']['event_resource']['transaction']['id']);
     $this->logging->log('validate structure for request', var_export($isValid, true));
     return $isValid;
 }
 /**
  * Performs the necessary installation steps
  *
  * @throws Exception
  * @return boolean
  */
 public function install()
 {
     try {
         Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_WebhookService::install();
         Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_LoggingManager::install();
         Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_ModelHelper::install($this);
         $this->createPaymentMeans();
         $this->_createForm();
         $this->_registerController();
         $this->_createEvents();
         $this->_updateOrderMail();
         $this->_applyBackendViewModifications();
         $this->_translatePaymentNames();
         $translationHelper = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_TranslationHelper($this->Form());
         $translationHelper->createPluginConfigTranslation();
         $this->solveKnownIssue();
         $this->Plugin()->setActive(true);
     } catch (Exception $exception) {
         $this->uninstall();
         throw new Exception($exception->getMessage());
     }
     $installSuccess = parent::install();
     return $installSuccess;
 }
 /**
  * Validates the response array given by the create call of a refund object
  *
  * @param $refund
  *
  * @return bool
  */
 private function _validateRefundResponse($refund)
 {
     $loggingManager = new Shopware_Plugins_Frontend_PaymPaymentCreditcard_Components_LoggingManager();
     $responseCodeOK = false;
     if (isset($refund['id']) && isset($refund['response_code'])) {
         $responseCodeOK = $refund['response_code'] === 20000;
     }
     if ($responseCodeOK) {
         $loggingManager->log("Refund created.", $refund['id']);
     } else {
         $loggingManager->log("No Refund created.", var_export($refund, true));
     }
     return $responseCodeOK;
 }