protected function log($level, $message) { if ($this->usePropel) { switch ($level) { case 'debug': $this->logger->debug($message); break; case 'info': $this->logger->info($message); break; case 'notice': $this->logger->notice($message); break; case 'warning': $this->logger->warning($message); break; case 'error': $this->logger->error($message); break; case 'critical': $this->logger->critical($message); break; } } else { $this->logs[] = [$level, $message]; } }
/** * @param $pathToFile * @param $destination * @param $isOnline * @return $this * @throws \ErrorException */ public function copyFile($pathToFile, $destination, $isOnline) { if ($isOnline) { /** * It's an online file */ $this->getFileDownloader()->download($pathToFile, $destination); } else { /** * It's a local file */ if (!is_file($pathToFile)) { $this->throwFileNotFound($pathToFile); } elseif (!is_readable($pathToFile)) { throw new FileNotReadableException($this->translator->trans("The file %file is not readable", ["%file" => $pathToFile])); } if (!copy($pathToFile, $destination)) { $translatedErrorMessage = $this->translator->trans("An error happend while copying %prev to %dest", ["%prev" => $pathToFile, "%dest" => $destination]); $this->logger->error($translatedErrorMessage); throw new \ErrorException($translatedErrorMessage); } } return $this; }
/** * @see : 3.2.(1 & 2) PAYLINE-GUIDE-Descriptif des appels webservices. * @param $token * @return array */ public function getWebPaymentDetails($token) { $reference = ''; try { $results = $this->payline->getWebPaymentDetails(['version' => self::VERSION, 'token' => $token]); $code = $results['result']['code']; $message = $results['result']['longMessage']; $reference = $results['order']['ref']; if (!in_array($code, ['00000', '01001'])) { $this->logger->error("[PAYLINE ERROR][{$code}] : {$message}", ['reference' => $reference]); return false; } return true; } catch (\Exception $e) { $this->logger->error($e->getMessage(), ['reference' => $reference]); } return false; }
public function processUpdateOrders(OrderEvent $event) { if ($event->getOrder()->getPaymentModuleId() == $this->shoppingFluxPaymentModuleId) { $status = $event->getStatus(); $allowedStatus = [$sentStatusId = OrderStatusQuery::getSentStatus()->getId(), OrderStatusQuery::getCancelledStatus()->getId()]; if (in_array($status, $allowedStatus)) { $order = $event->getOrder(); $mode = ShoppingFluxConfigQuery::getProd() ? UpdateOrders::REQUEST_MODE_PRODUCTION : UpdateOrders::REQUEST_MODE_SANDBOX; $api = new UpdateOrders(ShoppingFluxConfigQuery::getToken(), $mode); $request = new Request("UpdateOrders"); $request->addOrder(["IdOrder" => $order->getRef(), "Marketplace" => $order->getTransactionRef(), "Status" => $status === $sentStatusId ? "Shipped" : "Canceled"]); $response = $api->setRequest($request)->getResponse(); if ($response->isInError()) { $this->logger->error($response->getFormattedError()); } if (!$api->compareResponseRequest()) { $errorMessage = "Bad response from ShoppingFlux: " . $response->getGroup("UpdateOrders")->C14N(); $this->logger->error($errorMessage); } } } }