Ejemplo n.º 1
0
 /**
  * This Action loads the loggingdata from the datebase into the backendview
  */
 public function loadStoreAction()
 {
     $start = intval($this->Request()->getParam("start"));
     $limit = intval($this->Request()->getParam("limit"));
     $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
     $store = $helper->database()->getLog($start, $limit);
     $total = $helper->database()->getLogCount();
     $this->View()->assign(array("data" => $store, "total" => $total, "success" => true));
 }
Ejemplo n.º 2
0
 /**
  * Persists the log entrie in the database
  *
  * @param String $source String describing the source of this log entry.
  *                       Can be either a classname or the term "Sofort Library"
  * @param String $message
  */
 private function _logIntoDb($source, $message)
 {
     $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
     if ($helper->option()->isLogging()) {
         $moduleVersion = Shopware()->Plugins()->Frontend()->SofortPayment()->getVersion();
         $helper->database()->insertLogEntry($moduleVersion, $source, $message);
     }
 }
Ejemplo n.º 3
0
 /**
  * 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}.");
     }
 }
Ejemplo n.º 4
0
 /**
  * Public method called after the customer returns to the shop
  *
  * @param string $status
  * @param string $reason
  * @param string $transactionId
  */
 public function createOrderAfterRedirect($status, $reason, $transactionId)
 {
     // workaround for missing session after creating order
     $orderVariables = unserialize(Shopware()->Session()->offsetGet('sofortMailVariables'));
     $user = $this->context->getUser();
     $alreadySend = false;
     $result = false;
     if (!Shopware()->Session()->sofortOrderExsist) {
         Shopware()->Session()->sofortSendMail = true;
         //create Order
         $result = $this->saveOrder($transactionId, 0);
         $alreadySend = true;
     } else {
         $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
         $helper->database()->changeTransactionId($this->context->getOrderNumber(), $transactionId);
         $this->setOrderState($transactionId, 0);
     }
     $state = $this->context->convertLibState($status, $reason);
     if ($state !== 0) {
         $row = $this->getOrderInformation($transactionId);
         $order = Shopware()->Modules()->Order();
         $order->setPaymentStatus($row['id'], $state, false);
         $this->logger->logManually(__CLASS__, 'Change PaymentStatus for Order #' . $row['ordernumber'] . '(' . $row['id'] . ') to ' . $state);
     }
     if (!$alreadySend) {
         //send Mail
         $this->sendMail($orderVariables, $user);
     }
 }
Ejemplo n.º 5
0
 /**
  * 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));
 }
Ejemplo n.º 6
0
 /**
  * Translates the payment description
  */
 private function _translatePayments($languages)
 {
     $translator = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Translator();
     $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
     $suKey = $helper->database()->getPaymentKey("sofortbanking");
     $idealKey = $helper->database()->getPaymentKey("sofortideal");
     //Add Translation
     foreach ($languages as $language) {
         $translator->setLanguage($language);
         $suDescription = $translator->getSnippetByNumber("1001");
         $idealDescription = $translator->getSnippetByNumber("2001");
         $translator->addPaymentTranslation($suKey, $suDescription);
         $translator->addPaymentTranslation($idealKey, $idealDescription);
     }
 }
Ejemplo n.º 7
0
 /**
  * Adds a translation set for the payment with the given key
  *
  * @param String $key                   Key of the payment (numeric)
  * @param String $description
  * @param String $additionalDescription (optional)
  */
 public function addPaymentTranslation($key, $description, $additionalDescription = "")
 {
     $translationObject = new Shopware_Components_Translation();
     $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
     $data = array();
     $data['description'] = $description;
     $data['additionalDescription'] = $additionalDescription;
     $languages = $helper->database()->getShopIds($this->_language);
     foreach ($languages as $language) {
         $translationObject->write($language['id'], "config_payment", $key, $data, 1);
     }
 }
Ejemplo n.º 8
0
 /**
  * This action handles the asynchronous callbacks
  * The sofortLib is used to obtain data about
  */
 public function notifyAction()
 {
     Shopware()->Plugins()->Controller()->ViewRenderer()->setNoRender();
     $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
     $configKey = $helper->option()->getConfigKey("sofortbanking");
     //Step 3: Handling Notifications about status changes
     $notification = $helper->library()->getNotificationInstance();
     $notification->setLogger(new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger());
     $notification->setLogEnabled();
     $notification->getNotification();
     $transactionId = $notification->getTransactionId();
     //Step 4: Inquire changed Transactiondata
     $transactionData = new SofortLib_TransactionData($configKey);
     $transactionData->setTransaction($transactionId);
     $transactionData->sendRequest();
     //Step 5: Handling the Response to the Inquiry for changed Transaction Data
     $orderId = $helper->database()->getOrderByTransactionId($transactionId);
     $state = $this->convertLibState($transactionData->getStatus(), $transactionData->getStatusReason());
     $order = Shopware()->Modules()->Order();
     if ($state != 0) {
         $order->setPaymentStatus($orderId, $state, false);
         $order->setOrderStatus($orderId, 0, false);
     }
 }
Ejemplo n.º 9
0
 /**
  * Updates the plugin
  *
  * @param string $oldVersion
  *
  * @return bool
  */
 public function update($oldVersion)
 {
     try {
         $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
         switch ($oldVersion) {
             case "2.0.0":
             case "2.0.1":
                 $helper->database()->updateBasketTable();
             case "2.0.2":
             case "2.0.3":
             case "2.0.4":
                 $helper->database()->updatePaymentDescription();
             case "2.0.5":
             case "2.1.0":
             case "2.2.0":
             default:
                 $this->uninstall();
                 $this->install();
         }
     } catch (Exception $exception) {
         return false;
     }
     return true;
 }