/** * First Action to be accessed during checkout */ public function indexAction() { Shopware()->Plugins()->Controller()->ViewRenderer()->setNoRender(); Shopware()->Session()->sofortUniqueId = null; Shopware()->Session()->sofortSendMail = false; if ($this->getPaymentShortName() !== 'sofortideal' && $this->getPaymentShortName() !== 'sofortbanking') { $this->redirect(array("action" => "error", "forceSecure" => 1)); return; } $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper(); //Backup Basket $user = $this->getUser(); $sessionId = $user["additional"]["user"]["sessionID"]; $helper->database()->saveBasket($sessionId); //Create Order $paymentUniqueId = $this->createPaymentUniqueId(); Shopware()->Session()->sofortUniqueId = $paymentUniqueId; $paymentState = $helper->option()->getStateTranslation($this->getPaymentShortName(), "temporary"); $this->orderProcessHelper->createOrderBeforeRedirect($paymentState, $paymentUniqueId); $logger = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger(); $logger->logManually($this->_loggingSource, "Saved order with ordernumber " . $this->getOrderNumber() . " and temporary transaction id " . $paymentUniqueId); //Restore Basket $helper->database()->restoreBasket($sessionId); $this->redirect(array("action" => "gateway", "forceSecure" => 1)); }
/** * 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); } }
/** * Displays either banner or logo with text for a payment description. * * @param Enlight_Event_EventArgs $arguments * @param Shopware_Plugins_Frontend_SofortPayment_Bootstrap $bootstrap */ public function designPaymentMeanSelection(Enlight_Event_EventArgs $arguments, Shopware_Plugins_Frontend_SofortPayment_Bootstrap $bootstrap) { $view = $arguments->getSubject()->View(); $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper(); $translator = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Translator(); $languageShortName = $translator->getLanguageShortName(); //Assign Sofortbanking template variables $view->sofortSofortbankingIsCustomerProtectionEnabled = $helper->option()->isCustomerProtectionEnabled(); $view->sofortSofortBankingLinkBannerLogo = "https://images.sofort.com/" . $languageShortName . "/su/landing.php"; $view->sofortSofortBankingLinkBannerCustomerProtection = $languageShortName === "de" ? "https://www.handelsbank.com/de/deutsche-handelsbank-kaeuferschutz/deutsche-handelsbank-kaeuferschutz.html" : "https://www.handelsbank.com/en/buyer-protection/information-for-buyers.html"; $view->sofortSofortbankingIsRecommended = $helper->option()->isRecommendedPayment("sofortbanking"); $view->sofortSofortbankingIsShowingBanner = $helper->option()->getFrontendDisplayType("sofortbanking") == 1; $view->sofortSofortbankingIsShowingLogo = $helper->option()->getFrontendDisplayType("sofortbanking") == 2; $view->sofortSofortbankingLogo = $translator->getSofortbankingLogo(); $view->sofortSofortbankingBanner = $translator->getSofortbankingBanner($customerProtection = false); $view->sofortSofortbankingBannerCp = $translator->getSofortbankingBanner($customerProtection = true); $view->sofortSofortbankingRecommendedText = $translator->getSnippetByNumber("1003", "(empfohlene Zahlart)"); $view->sofortSofortbankingAlt = $translator->getSnippetByNumber("1001", "SOFORT Überweisung"); $view->sofortSofortbankingLogoText = $translator->getSnippetByNumber("1004", "* Zahlungssystem mit TÜV-geprüftem Datenschutz <br />" . "* Keine Registrierung notwendig <br />" . "* Ware/Dienstleistung wird bei Verfügbarkeit SOFORT versendet <br />" . "* Bitte halten Sie Ihre Online-Banking-Daten (PIN/TAN) bereit"); $view->sofortSofortbankingLogoTextCp = $translator->getSnippetByNumber("1005", "* Bei Bezahlung mit SOFORT Überweisung genießen Sie Käuferschutz!" . " <a href='https://www.handelsbank.com/de/deutsche-handelsbank-kaeuferschutz/deutsche-handelsbank-kaeuferschutz.html'>" . "Mehr Informationen</a><br />"); //Assign Ideal template variables $configKey = $helper->option()->getConfigKey("ideal"); $password = $helper->option()->getPassword(); $sofort = $helper->library()->getIdealClassic($configKey, $password); $view->sofortIdealAlt = $translator->getSnippetByNumber("2001", "iDEAL"); $view->sofortIdealRecommendedText = $translator->getSnippetByNumber("1003", "(empfohlene Zahlart)"); $view->sofortIdealWelcomeMessage = $translator->getSnippetByNumber("2002", "Bitte wählen Sie Ihre Bank:"); $view->sofortIdealBanks = $sofort->getRelatedBanks(); //get all iDEAL-Banks $view->sofortIdealIsRecommended = $helper->option()->isRecommendedPayment("ideal"); $view->sofortIdealIsShowingBanner = $helper->option()->getFrontendDisplayType("ideal") == 1; $view->sofortIdealIsShowingLogo = $helper->option()->getFrontendDisplayType("ideal") == 2; $view->sofortIdealBanner = $translator->getIdealBanner(); $view->sofortIdealLogo = $translator->getIdealLogo(); $view->sofortIdealLink = "https://images.sofort.com/" . $languageShortName . "/ideal/landing.php"; }
/** * 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}."); } }
/** * 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); } }