Example #1
0
 public function dispatch(\Magento\Framework\App\RequestInterface $request)
 {
     foreach ($this->_routerList as $router) {
         $this->_logger->addDebug(get_class($router));
     }
     return parent::dispatch($request);
 }
Example #2
0
 /**
  *
  * @param $message
  * @param bool|false $useSeparator
  */
 public function log($message, $useSeparator = false)
 {
     if ($this->getDebugStatus()) {
         if ($useSeparator) {
             $this->_logger->addDebug(str_repeat('=', 100));
         }
         $this->_logger->addDebug($message);
     }
 }
Example #3
0
 /**
  * Returns the the path to the processed image 
  * 
  * @param string $sFilter
  * @param string $sOptions
  * @param string $sFile
  * 
  * @return string
  * 
  * @throws \Exception
  */
 public function process($sFilter, $sOptions, $sFile)
 {
     $this->oLogger->addInfo("filter=" . $sFilter . "; file=" . $sFile);
     // check if filter exists
     $sFilterClass = "\\Pids\\Filter\\" . ucfirst(strtolower($sFilter));
     if (!class_exists($sFilterClass)) {
         throw new \Exception("Filter " . $sFilterClass . " does not exist.");
     }
     $oFilter = new $sFilterClass();
     // check if image exists else use default image
     if (!file_exists('data' . DIRECTORY_SEPARATOR . $sFile)) {
         $sFile = $this->aConfig["image"]["default"];
         $this->oLogger->addDebug("using default image");
     }
     $this->sSourceImage = 'data' . DIRECTORY_SEPARATOR . $sFile;
     // check if cache is up to date
     $this->sCacheImage = $this->getCachePath($sFilter, $sOptions, $sFile);
     if (file_exists($this->sCacheImage) && filemtime($this->sSourceImage) < filemtime($this->sCacheImage)) {
         $this->oLogger->addDebug("cache file was up to date");
         return $this->sCacheImage;
     }
     //TODO separate method
     $rFinfo = finfo_open(FILEINFO_MIME_TYPE);
     $sMime = finfo_file($rFinfo, $this->sSourceImage, FILEINFO_MIME_TYPE);
     switch ($sMime) {
         case 'image/jpeg':
         case 'image/jpg':
             $rImage = imagecreatefromjpeg($this->sSourceImage);
             break;
         case 'image/png':
             $rImage = imagecreatefrompng($this->sSourceImage);
             break;
         default:
             throw new \Exception('Unsupported mime type ' . $sMime);
     }
     // create cache file
     $rImage = $oFilter->apply($rImage, $sOptions, $this->aConfig["filters"][strtolower($sFilter)]);
     if ($this->aConfig["image"]["watermark"]) {
         $rImage = $oFilter->addWatermark($rImage);
     }
     //TODO separate method
     switch ($sMime) {
         case 'image/jpeg':
         case 'image/jpg':
             imagejpeg($rImage, $this->sCacheImage, $this->aConfig["image"]["quality"]);
             break;
         case 'image/png':
             imagepng($rImage, $this->sCacheImage, ceil($this->aConfig["image"]["quality"] / 10));
             break;
     }
     $this->oLogger->addDebug("cache file created:" . $this->sCacheImage);
     return $this->sCacheImage;
 }
Example #4
0
 /**
  * Receives webhook events from Roadrunner
  */
 public function execute()
 {
     $this->_logger->addDebug('paystandmagento/webhook/paystand endpoint was hit');
     $body = @file_get_contents('php://input');
     $json = json_decode($body);
     $this->_logger->addDebug(">>>>> body=" . print_r($body, TRUE));
     if (isset($json->resource->meta->source) && $json->resource->meta->source == "magento 2") {
         $quoteId = $json->resource->meta->quote;
         $this->_logger->addDebug('magento 2 webhook identified with quote id = ' . $quoteId);
         $this->_order->loadByAttribute('quote_id', $quoteId);
         if (!empty($this->_order->getIncrementId())) {
             $this->_logger->addDebug('current order increment id = ' . $this->_order->getIncrementId());
             $state = $this->_order->getState();
             $this->_logger->addDebug('current order state = ' . $state);
             $status = $this->_order->getStatus();
             $this->_logger->addDebug('current order status = ' . $status);
             $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
             if ($this->scopeConfig->getValue(self::USE_SANDBOX, $storeScope)) {
                 $base_url = 'https://api.paystand.co/v3';
             } else {
                 $base_url = 'https://api.paystand.com/v3';
             }
             $url = $base_url . "/events/" . $json->id . "/verify";
             $auth_header = array("x-publishable-key: " . $this->scopeConfig->getValue(self::PUBLISHABLE_KEY, $storeScope));
             $curl = $this->buildCurl("POST", $url, json_encode($json), $auth_header);
             $response = $this->runCurl($curl);
             $this->_logger->addDebug("http_response_code is " . $this->http_response_code);
             if (FALSE !== $response && $this->http_response_code == 200) {
                 if ($json->resource->object = "payment") {
                     switch ($json->resource->status) {
                         case 'posted':
                             $state = 'pending';
                             $status = 'pending';
                             break;
                         case 'paid':
                             $state = 'processing';
                             $status = 'processing';
                             break;
                         case 'failed':
                             $state = 'closed';
                             $status = 'closed';
                             break;
                         case 'canceled':
                             $state = 'canceled';
                             $status = 'canceled';
                             break;
                     }
                 }
                 $this->_order->setState($state);
                 $this->_order->setStatus($status);
                 $this->_order->save();
                 $this->_logger->addDebug('new order state = ' . $state);
                 $this->_logger->addDebug('new order status = ' . $status);
             } else {
                 $this->_logger->addDebug('event verify failed');
             }
         }
     }
 }
Example #5
0
 /**
  * @param \Magento\Framework\Event\Observer $observer
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $response = $observer->getResponse();
     $body = $response->getBody();
     $this->_logger->addDebug("Flushed output: " . PHP_EOL . $body);
 }