/** * Displays the errormessages during checkout. */ public function displayErrors($view) { if (isset(Shopware()->Session()->pigmbhErrorMessage)) { $view->sErrorMessages = array(Shopware()->Session()->pigmbhErrorMessage); $logger = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger(); $logger->logManually("Errorhandling:", "Sessionmessage: " . Shopware()->Session()->pigmbhErrorMessage); Shopware()->Session()->pigmbhErrorMessage = null; } }
/** * Load all CSV Files and Translations * If locale Property is set, only that locale is loaded * * @return bool Indicator of success */ public function loadCsvFiles() { try { if ($files = scandir($this->getPath())) { foreach ($files as $file) { if (is_file($this->getPath() . $file)) { $this->loadCsvFileByName($file); } } } } catch (Exception $exc) { $this->_logger->logManually(__CLASS__, $exc->getTraceAsString()); } return false; }
/** * Returns the statenumber of the given state for the given method * * @param String $method Name of the Payment Method * @param String $state * * @throws Exception * @return int Status */ public function getStateTranslation($method, $state) { $logger = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger(); if ($method === "sofortideal") { $method = 'ideal'; } $haystack = ''; if ($method === "ideal") { $haystack = array("temporary", "payment_pending", "payment_received", "payment_canceled", "storno", "refund_partial", "refund_full"); } if ($method === "sofortbanking") { $haystack = array("temporary", "payment_confirmed", "payment_received", "payment_canceled", "investigation_needed", "refund_partial", "refund_full"); } if (in_array($state, $haystack)) { $logger->logManually("Optionhelper, State Translation", "Paymentmean: {$method}, " . "State changing to {$state}, returning " . $this->_getConfigValue($method . "_state_" . $state)); return (int) $this->_getConfigValue($method . "_state_" . $state); } $logger->logManually("Optionhelper, State Translation", "Invalid order state: " . var_export($method) . ", " . var_export($state)); throw new Exception("Invalid order state"); }
/** * This action handles the asynchronous callbacks * The sofortLib is used to obtain data about */ public function notifyAction() { $request = $this->Request()->getParams(); $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper(); $logger = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger(); Shopware()->Plugins()->Controller()->ViewRenderer()->setNoRender(); $notificationPassword = $helper->option()->getNotificationPassword(); //Validate Notification if (!$this->_validateResponse($request, $notificationPassword)) { $logger->logManually("Ideal Notification", "Validationhash missmatch in Notification for Transaction " . $request['transaction']); return; } $logger->logManually("Ideal Notification", "Notification for Transaction " . $request['transaction'] . " received"); //Gather Data $transactionId = $request['transaction']; $status = $request['status']; $reason = $request['status_reason']; $orderId = $helper->database()->getOrderByTransactionId($transactionId); $ordernumber = $helper->database()->getOrdernumberByTransactionId($transactionId); $state = $this->convertLibState($status, $reason); //Change order state if ($state != 0) { $order = Shopware()->Modules()->Order(); $order->setPaymentStatus($orderId, $state, false); $order->setOrderStatus($orderId, 0, false); $logger->logManually("Ideal Notification", "Changing state of order {$ordernumber} to {$state}."); } }
/** * Returns all informations for an specific order * @param string $transactionId * @return array | false */ private function getOrderInformation($transactionId) { $this->logger->logManually(__CLASS__, 'Get informations for TransactionId:' . $transactionId); $select = Shopware()->Db()->select()->from('s_order', array('id', 'ordernumber'))->where('`transactionID` = ?', $transactionId); return Shopware()->Db()->fetchRow($select); }
/** * Deals with timeouts during transactions * * @todo set correct translationname */ public function timeoutAction() { $request = $this->Request()->getParams(); $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper(); $translator = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Translator(); $logger = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger(); Shopware()->Session()->pigmbhErrorMessage = $translator->getSnippetByNumber("1202", "Die Zeit zur Durchführung der Zahlung ist aus Sicherheitsgründen abgelaufen. " . "Es wurde keine Transaktion durchgeführt. Bitte führen Sie die Zahlung erneut aus."); //Condemn order if appropriate $logger->logManually($this->_loggingSource, "Changing Orderstate to mark it as failed"); $order = Shopware()->Modules()->Order(); $helper->database()->changeTransactionId($this->getOrderNumber(), $request['transactionId']); $orderId = $helper->database()->getOrderByTransactionId($request['transactionId']); $order->setPaymentStatus($orderId, $this->convertLibState("payment_canceled", "unknown"), false); $this->restoreArtikleStock($orderId); $this->redirect(array("controller" => "account", "action" => "payment", "sTarget" => "checkout", "errorMessage" => 1, "forceSecure" => 1)); }
/** * Uses the argumented lib state and reason codes to determine the desired * shopware state in accordance with the config * * @param String $state * @param String $reason * * @return int Status */ public function convertLibState($state, $reason) { $status = ''; switch ($state) { case "loss": $status = "investigation_needed"; break; case "pending": $status = "payment_confirmed"; break; case "received": if ($reason == 'consumer_protection') { $status = "payment_confirmed"; } if ($reason == 'credited') { $status = "payment_received"; } break; case "refunded": if ($reason == 'compensation') { $status = "refund_partial"; } if ($reason == 'refunded') { $status = "refund_full"; } break; case "untraceable": if ($reason == 'sofort_bank_account_needed') { $status = "payment_confirmed"; } break; } $haystack = array("temporary", "payment_confirmed", "payment_received", "payment_canceled", "investigation_needed", "refund_partial", "refund_full"); if (in_array($state, $haystack)) { $status = $state; } $logger = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger(); $logger->logManually($this->_loggingSource, "Translated state {$state} to status {$status}."); $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper(); return $helper->option()->getStateTranslation("sofortbanking", $status); }