/** * This action handles the transition to the Sofort AG Payment Form * The sofortLib is used to generate the url to redirect the customer to. * For reference to the Sofort Documentation consider this action to execute step 1 and 2 */ public function gatewayAction() { Shopware()->Plugins()->Controller()->ViewRenderer()->setNoRender(); $user = $this->getUser(); $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper(); $logger = new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger(); //Prepare Parameters $configKey = $helper->option()->getConfigKey("ideal"); $password = $helper->option()->getPassword(); $customerId = $user['additional']['user']['id']; $model = Shopware()->Models()->getRepository('Shopware\\Models\\Customer\\Customer')->findOneById($customerId); $senderBankCode = $model->getAttribute()->getSofortIdealBank(); if ($senderBankCode === null) { $senderBankCode = Shopware()->Session()->sofortIdealBankCode; $logger->logManually($this->_loggingSource, "Error during DB access. Using sender Bank code: " . $senderBankCode); } else { $logger->logManually($this->_loggingSource, "Using sender Bank code: " . $senderBankCode); } $reason = $helper->option()->getReason($this->getOrderNumber(), $user); $senderCountryId = $user['additional']['country']['countryiso']; //Prepare API Call $sofort = $helper->library()->getIdealClassic($configKey, $password); $sofort->getRelatedBanks(); $sofort->setAmount($this->getAmount(), $this->getCurrencyShortName()); $sofort->setSenderBankCode($senderBankCode); $sofort->setReason($reason['1'], $reason['2']); $sofort->setSenderCountryId($senderCountryId); $sofort->setSuccessUrl(Shopware()->Front()->Router()->assemble(array('action' => 'return', 'forceSecure' => 1, 'transactionId' => '-TRANSACTION-', 'status' => '-STATUS-', 'status_reason' => '-STATUS_REASON-'))); $sofort->setAbortUrl(Shopware()->Front()->Router()->assemble(array('action' => 'error', 'forceSecure' => 1, 'transactionId' => '-TRANSACTION-', 'sofortError' => '-ERROR_CODES-'))); $sofort->setNotificationUrl(Shopware()->Front()->Router()->assemble(array('action' => 'notify', 'forceSecure' => 1, 'transactionId' => '-TRANSACTION-', 'modificationTimestamp' => '-STATUS_MODIFIED-'))); //Call API to get PaymentUrl $url = $sofort->getPaymentUrl(); //Validate Data if ($sofort->isError()) { return $this->redirect(Shopware()->Front()->Router()->assemble(array("action" => "error", "forceSecure" => 1))); } //Redirect customer if validation successfull $this->redirect($url, array("forceSecure" => 1)); }
/** * 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() { 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); } }