diff --git a/README.md b/README.md
new file mode 100644
index 0000000..cf515f7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+# SOFORT Banking by ![alt text](src/copy_this/modules/tronet/tronet.gif)
+
+## functional description
+
+The OXID eShop interface for SOFORT Banking (further references as SOFORT
+Überweisung) extends an existing installation of the software OXID eShop by the
+payment method SOFORT Überweisung.
+
+OXID eShop is a software by OXID eSales GmbH, Freiburg, Germany. It is
+available at [www.oxid-esales.com](http://www.oxid-esales.com).
+
+SOFORT Überweisung is an online payment service of SOFORT AG, Gauting. The
+registration / establishment of the service is done at [www.sofort.com](http://www.sofort.com).
+The SOFORT AG charges transaction fees for using the service.
\ No newline at end of file
diff --git a/build/Changelog.txt b/build/Changelog.txt
new file mode 100644
index 0000000..bfcba3d
--- /dev/null
+++ b/build/Changelog.txt
@@ -0,0 +1,85 @@
+==1.0.0==
+*Initial release of module for Sofortueberweisung.
+
+==4.0.0==
+*ADDED: compatibility for Oxid 4.0
+
+==4.0.1==
+*FIXED: minor bugs
+
+==4.5.0==
+*ADDED: compatibility for Oxid 4.5
+
+==4.5.1==
+*FIXED: minor bugs
+
+==4.6.0==
+*ADDED: compatibility for Oxid 4.6
+
+==4.7.0==
+*ADDED: compatibility for Oxid 4.7/5.0
+
+==4.8.0==
+*ADDED: compatibility for Oxid 4.8/5.1
+*FIXED: saving wrong SSL-shop-URL during Setup
+*FIXED: shop-session sometimes lost during payment-process
+
+==5.0.0==
+*Internal release of module using new sofortgateway-API by sofort AG.
+
+==6.0.0==
+*Initial release of certified module using new sofortgateway-API by sofort AG.
+
+==6.0.1==
+*FIXED: minor bugs
+
+==6.0.2==
+*FIXED: minor bugs
+
+==6.1.0==
+*ADDED: compatibility for currency CHF
+
+==6.1.1==
+*ADDED: reason for the bank transfer can be edited
+
+==6.1.2==
+*FIXED: minor bugs
+
+==6.2.0==
+*ADDED: compatibility for Oxid 4.9
+
+==6.2.1==
+*FIXED: minor bugs
+
+==6.2.2==
+*FIXED: minor bugs
+
+==6.2.3==
+*ADDED: transaction second reason now editable
+*ADDED: Logfile /log/SOFORTGATEWAY_LOG.txt
+
+==6.2.4==
+*ADDED: support for standard OXID mobile theme
+*ADDED: functionality to chose what should happen with canceled orders
+*FIXED: Bug which resulted in having no order-no passed
+*UPDATED: readme-files
+
+==6.2.5==
+*FIXED: Bug, which hasn't called the finalizeOrder properly, which lead to some unexpected results
+*FIXED: Bug, which didn't refresh the varstock after cancelling an order
+
+==6.2.6==
+*FIXED: Bug, consider oxorderarticles on deleting an unfinished order
+*FIXED: When an order has been canceled during a step at sofortüberweisung article stock has not been updated again.
+
+==7.0.0==
+*CHANGED: Removed dependency to ZendGuard
+*CHANGED: Module is not longer encrypted
+*ADDED: an auto-update feature as well as an manual-update feature
+*ADDED: functionality to show if files were manually changed in this shop
+*ADDED: a new Site for feedback, FAQ's and more (http://www.sofort.tro.net)
+*ADDED: Made Source available in Git
+*ADDED: Menu item in the admin-navigation for diverse features
+*UPDATED: Updated the manual
+*ADDED: an option to disable the auto-update notification
+*ADDED: Logo in order step 3 can be toggled via module settings now
\ No newline at end of file
diff --git a/build/Install.sql b/build/Install.sql
new file mode 100644
index 0000000..fd12402
--- /dev/null
+++ b/build/Install.sql
@@ -0,0 +1,42 @@
+INSERT IGNORE INTO `oxpayments` SET
+ `OXID` = 'trosofortgateway_su',
+ `OXACTIVE` = 1,
+ `OXDESC` = 'SOFORT Überweisung',
+ `OXDESC_1` = 'SOFORT Banking',
+ `OXADDSUM` = 0,
+ `OXADDSUMTYPE` = 'abs',
+ `OXADDSUMRULES` = 15,
+ `OXFROMBONI` = 0,
+ `OXFROMAMOUNT` = 0,
+ `OXTOAMOUNT` = 999999,
+ `OXCHECKED` = 1,
+ `OXSORT` = 1,
+ `OXLONGDESC` = '
+ ',
+ `OXLONGDESC_1` = '
+ ';
+
+CREATE TABLE IF NOT EXISTS `trogatewaylog` (
+ `OXID` varchar(32) collate latin1_general_ci NOT NULL,
+ `TRANSACTIONID` varchar(255) collate latin1_general_ci NOT NULL,
+ `TRANSACTION` varchar(255) collate latin1_general_ci NOT NULL,
+ `STATUS` varchar(255) collate latin1_general_ci NOT NULL,
+ `STATUSREASON` varchar(255) collate latin1_general_ci NOT NULL,
+ `TIMESTAMP` timestamp NOT NULL default CURRENT_TIMESTAMP,
+ PRIMARY KEY (`OXID`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
+
\ No newline at end of file
diff --git a/build/LICENSE b/build/LICENSE
new file mode 100644
index 0000000..1d45fae
--- /dev/null
+++ b/build/LICENSE
@@ -0,0 +1,6 @@
+This is a license agreement between you and the Tronet GmbH.
+By installation and use of the software, you confirm that you have read the license agreement and agree with her.
+If you do not agree with one or more points, you are not authorized to install this software, distribute or use them.
+The license agreement legitimates you to install and use the software on one or more computers.
+The license for the software is free.
+You are not entitled to technical support of any kind, the Tronet GmbH is not obliged to provide maintenance or revision of the software.
\ No newline at end of file
diff --git a/build/Readme.txt b/build/Readme.txt
new file mode 100644
index 0000000..37a9a9b
--- /dev/null
+++ b/build/Readme.txt
@@ -0,0 +1,53 @@
+==Title==
+trosofortueberweisung
+
+==Author==
+tronet GmbH
+
+==Prefix==
+tro
+
+==Version==
+7.0.0
+
+==Link==
+http://www.tronet.media
+
+==Mail==
+info@tro.net
+
+==Description==
+Module for integration of Sofortueberweisung-payment in Oxid.
+
+==Extend==
+*oxpaymentgateway
+--executePayment
+*oxorder
+--finalizeOrder
+--_executePayment
+*payment
+--validatePayment
+
+==Requirements==
+1. Oxid eshop in Version from 4.7.x /5.0.x
+3. An active "Sofortgateway-project" at Sofort.com
+
+==Installation==
+1. Copy contents of folder "/copy_this/" into your shop-root
+2. Activate module "trosofortueberweisung" in your oxid-backend
+3. Enter your Configuration-Key at Extensions->Modules->tronet SOFORT Überweisung
+4. Configure new payment "Sofortüberweisung" in your oxid backend (Payment-methods, Shipping-methods)
+
+==Modules==
+oxpaymentgateway => tronet/trosofortueberweisung/application/models/trosofortueberweisungoxpaymentgateway
+oxorder => tronet/trosofortueberweisung/application/models/trosofortueberweisungoxorder
+order => tronet/trosofortueberweisung/application/controllers/trosofortueberweisungorder
+order_overview => tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisungorder_overview
+payment => tronet/trosofortueberweisung/application/controllers/trosofortueberweisungpayment
+oxbasket => tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasket
+oxbasketitem => tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasketitem
+navigation => tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_navigation
+oxlist => tronet/trosofortueberweisung/application/models/trosofortueberweisungreleaseoxlist
+
+==Libraries==
+SofortLib-PHP-Payment-2.1.2 (/copy_this/tronet/trosofortueberweisung/library/)
diff --git a/build/readme_en.pdf b/build/readme_en.pdf
new file mode 100644
index 0000000..157fafe
Binary files /dev/null and b/build/readme_en.pdf differ
diff --git a/docs/readme_en.docx b/docs/readme_en.docx
new file mode 100644
index 0000000..4ae9e1b
Binary files /dev/null and b/docs/readme_en.docx differ
diff --git a/src/copy_this/modules/tronet/logo_tronet.media.png b/src/copy_this/modules/tronet/logo_tronet.media.png
new file mode 100644
index 0000000..a0b0eae
Binary files /dev/null and b/src/copy_this/modules/tronet/logo_tronet.media.png differ
diff --git a/src/copy_this/modules/tronet/tronet.gif b/src/copy_this/modules/tronet/tronet.gif
new file mode 100644
index 0000000..63108a3
Binary files /dev/null and b/src/copy_this/modules/tronet/tronet.gif differ
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung.php
new file mode 100644
index 0000000..0f2aa28
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung.php
@@ -0,0 +1,27 @@
+getVariable('currentadminshop');
+
+ if ( !$sCurrentAdminShop ) {
+ if ( oxRegistry::getSession()->getVariable('malladmin') ) {
+ $sCurrentAdminShop = 'oxbaseshop';
+ } else {
+ $sCurrentAdminShop = oxRegistry::getSession()->getVariable('actshop');
+ }
+ }
+
+ $this->_aViewData['linkFix'] = "?";
+ $aVersion = explode( '.', $this->getConfig()->getActiveShop()->oxshops__oxversion->value );
+ if( 4 == $aVersion[0] && 3 <= $aVersion[1] ) $this->_aViewData['linkFix'] = "";
+
+ $this->_aViewData['currentadminshop'] = $sCurrentAdminShop;
+ oxRegistry::getSession()->setVariable('currentadminshop', $sCurrentAdminShop);
+
+ return 'trosofortueberweisung.tpl';
+ }
+}
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_list.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_list.php
new file mode 100644
index 0000000..75e3ec8
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_list.php
@@ -0,0 +1,33 @@
+_checkSOFORTUpdates();
+ $this->addTplParam('blTroCheckedForUpdates', true);
+ }
+
+ /**
+ * Function to lookup the newest version of SOFORT stored in an XML-file.
+ * The function compares the installed shop-version with the newest version available.
+ * If there is a newer version available, a message for the frontend is added.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ private function _checkSOFORTUpdates()
+ {
+ try
+ {
+ $oSOFORTReleaseList = oxNew('trosofortueberweisungreleaseoxlist');
+ $oSOFORTReleaseList->troSelectXmlUri($this->getSOFORTConfig()->getReleaseListUrl());
+
+ $sModuleVersion = $this->getCurrentModuleVersion();
+ $sOxidEdition = $this->getConfig()->getEdition();
+ $sOxidVersion = $this->getConfig()->getVersion();
+
+ $oSOFORTRelease = $oSOFORTReleaseList->troGetLatestRelease($sModuleVersion, $sOxidEdition, $sOxidVersion, PHP_VERSION);
+
+ if ($oSOFORTRelease != null)
+ {
+ $aViewData['aMessage']['trosofortueberweisung_update_notification'] = $this->_renderUpdateNotificationMessage($oSOFORTRelease);
+ $this->addTplParam('aTroMessage', $aViewData);
+ }
+ else
+ {
+ $aViewData['aMessage']['trosofortueberweisung_update_notification'] = $this->_renderUpdateNotificationMessageLatestVersionInstalled();
+ $this->addTplParam('aTroMessage', $aViewData);
+ }
+ }
+ catch (Exception $oException)
+ {
+ $aViewData['aMessage']['trosofortueberweisung_update_notification'] = $this->_renderUpdateNotificationFailedMessage($oException);
+ $this->addTplParam('aTroMessage', $aViewData);
+ }
+ }
+
+ /**
+ * @return trosofortueberweisungconfig
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getSOFORTConfig()
+ {
+ if ($this->_oSOFORTConfig == null)
+ {
+ $this->_oSOFORTConfig = oxNew('trosofortueberweisungconfig');
+ }
+
+ return $this->_oSOFORTConfig;
+ }
+
+ /**
+ * Simple getter function to retrieve the currently installed Module-Version.
+ *
+ * @return string The current version of SOFORT Überweisung
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getCurrentModuleVersion()
+ {
+ $aModuleVersions = $this->getConfig()->getConfigParam('aModuleVersions');
+
+ return $aModuleVersions["trosofortueberweisung"];
+ }
+
+ /**
+ * Renders notification message for passed release.
+ *
+ * @param trosofortueberweisungrelease $oSOFORTRelease
+ *
+ * @return mixed|string|void
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function _renderUpdateNotificationMessage($oSOFORTRelease)
+ {
+ $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
+ $oSmarty->assign('oView', $this);
+ $oSmarty->assign('oViewConf', $this->getViewConfig());
+
+ $oSmarty->assign('sTroDownloadLink', $oSOFORTRelease->getDownload());
+ $oSmarty->assign('sTroAutomaticInstallationLink', 'index.php?cl=trosofortueberweisung_update&stoken=' . $this->getSession()->getSessionChallengeToken() . '&trosofortueberweisung_version=' . $oSOFORTRelease->getVersion('_'));
+ $oSmarty->assign('sTroChangeLogLink', $this->getSOFORTConfig()->getChangeLogUrl());
+ $oSmarty->assign('aTroNewVersion', array($oSOFORTRelease->getVersion()));
+
+ return $oSmarty->fetch('trosofortueberweisung_updateavailable.tpl');
+ }
+
+ /**
+ * Renders notification message for passed release.
+ *
+ * @return mixed|string|void
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function _renderUpdateNotificationMessageLatestVersionInstalled()
+ {
+ $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
+ $oSmarty->assign('oView', $this);
+ $oSmarty->assign('oViewConf', $this->getViewConfig());
+
+ return $oSmarty->fetch('trosofortueberweisung_noupdateavailable.tpl');
+ }
+
+ /**
+ * Renders notification message for passed release.
+ *
+ * @param Exception $oException
+ *
+ * @return mixed|string|void
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function _renderUpdateNotificationFailedMessage($oException)
+ {
+ $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
+ $oSmarty->assign('oView', $this);
+ $oSmarty->assign('oViewConf', $this->getViewConfig());
+
+ return $oSmarty->fetch('trosofortueberweisung_updateavailable_failed.tpl');
+ }
+
+ /**
+ * Action function that checks for module changes.
+ *
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troCheckForChanges()
+ {
+ $oSOFORTConfig = oxNew('trosofortueberweisungconfig');
+ $sDownloadLinkRaw = $oSOFORTConfig->getTroMetaHashLinkRaw();
+ $sDownloadFile = sprintf($sDownloadLinkRaw, $this->getCurrentVersion());
+
+ if ($this->_troUrlExists($sDownloadFile))
+ {
+ $oXML = file_get_contents($sDownloadFile);
+ if ($oXML)
+ {
+ $oXml = new \SimpleXMLElement($oXML);
+ $sModulePath = getShopBasePath() . 'modules/';
+ $aChangedFiles = $this->getSOFORTDirectoryUtility()->getChangedFilesFromDirectory($sModulePath, $oXml);
+ $blTroCheckedChangesFailed = false;
+ }
+ else
+ {
+ $aChangedFiles = array('changedCoreFiles' => 0);
+ $blTroCheckedChangesFailed = true;
+ }
+ }
+ else
+ {
+ $aChangedFiles = array('changedCoreFiles' => 0);
+ $blTroCheckedChangesFailed = true;
+ }
+
+ $this->addTplParam('aTroChangedFiles', $aChangedFiles);
+ $this->addTplParam('blTroCheckedChanges', true);
+ $this->addTplParam('blTroCheckedChangesFailed', $blTroCheckedChangesFailed);
+ }
+
+ /**
+ * Check whether $sUrl is exists.
+ *
+ * @param string $sUrl Url to check
+ * @return bool $blUrlExists
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function _troUrlExists($sUrl)
+ {
+ $aFileHeaders = @get_headers($sUrl);
+ if($aFileHeaders[0] == 'HTTP/1.1 404 Not Found') {
+ $blUrlExists = false;
+ }
+ else {
+ $blUrlExists = true;
+ }
+
+ return $blUrlExists;
+ }
+
+ /**
+ * Simple getter function to retrieve the currently installed Module-Version.
+ *
+ * @return string Current version of SOFORT Überweisung
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getCurrentVersion()
+ {
+ $aModuleVersions = $this->getConfig()->getConfigParam('aModuleVersions');
+
+ return $aModuleVersions["trosofortueberweisung"];
+ }
+
+ /**
+ * @return object|trosofortueberweisungdirectoryutility
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getSOFORTDirectoryUtility()
+ {
+ if ($this->_oSOFORTDirectoryUtility == null)
+ {
+ $this->_oSOFORTDirectoryUtility = oxNew('trosofortueberweisungdirectoryutility');
+ }
+
+ return $this->_oSOFORTDirectoryUtility;
+ }
+
+ /**
+ * @param trosofortueberweisungconfig $oSOFORTConfig
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setSOFORTConfig($oSOFORTConfig)
+ {
+ $this->_oSOFORTConfig = $oSOFORTConfig;
+ }
+
+ /**
+ * @param $oSOFORTDirectoryUtility
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setSOFORTDirectoryUtility($oSOFORTDirectoryUtility)
+ {
+ $this->_oSOFORTDirectoryUtility = $oSOFORTDirectoryUtility;
+ }
+ }
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_navigation.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_navigation.php
new file mode 100644
index 0000000..9333914
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_navigation.php
@@ -0,0 +1,146 @@
+getConfig()->getRequestParameter('item');
+ $sItem = ($sItem ? basename($sItem) : false);
+
+ if (!$this->getConfig()->getRequestParameter("navReload") && $sItem == 'home.tpl')
+ {
+ $this->_checkSOFORTUpdates();
+ }
+ else
+ {
+ $this->getSession()->deleteVariable('navReload');
+ }
+
+ return $sReturn;
+ }
+
+ /**
+ * Function to lookup the newest version of SOFORT stored in an XML-file.
+ * The function compares the installed shop-version with the newest version available.
+ * If there is a newer version available, a message for the frontend is added.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ private function _checkSOFORTUpdates()
+ {
+ if ($this->getConfig()->getConfigParam('blTroGateWayUpdateCheck'))
+ {
+ try
+ {
+ $oSOFORTReleaseList = oxNew('trosofortueberweisungreleaseoxlist');
+ $oSOFORTReleaseList->troSelectXmlUri($this->getSOFORTConfig()->getReleaseListUrl());
+
+ $sModuleVersion = $this->getCurrentModuleVersion();
+ $sOxidEdition = $this->getConfig()->getEdition();
+ $sOxidVersion = $this->getConfig()->getVersion();
+
+ $oSOFORTRelease = $oSOFORTReleaseList->troGetLatestRelease($sModuleVersion, $sOxidEdition, $sOxidVersion, PHP_VERSION);
+
+ if ($oSOFORTRelease != null)
+ {
+ $this->_aViewData['aMessage']['trosofortueberweisung_update_notification'] = $this->_renderUpdateNotificationMessage($oSOFORTRelease);
+ }
+ }
+ catch (Exception $oException)
+ {
+ // silently ignore as no error messages shall be displayed on the OXID eShop dashboard.
+ }
+ }
+ }
+
+ /**
+ * @return trosofortueberweisungconfig
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getSOFORTConfig()
+ {
+ if ($this->_oSOFORTConfig == null)
+ {
+ $this->_oSOFORTConfig = oxNew('trosofortueberweisungconfig');
+ }
+
+ return $this->_oSOFORTConfig;
+ }
+
+ /**
+ * Simple getter function to retrieve the currently installed Module-Version.
+ *
+ * @return string The current version of SOFORT Überweisung
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getCurrentModuleVersion()
+ {
+ $aModuleVersions = $this->getConfig()->getConfigParam('aModuleVersions');
+
+ return $aModuleVersions["trosofortueberweisung"];
+ }
+
+ /**
+ * Renders notification message for passed release.
+ *
+ * @param trosofortueberweisungrelease $oSOFORTRelease
+ *
+ * @return mixed|string|void
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function _renderUpdateNotificationMessage($oSOFORTRelease)
+ {
+ $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
+ $oSmarty->assign('oView', $this);
+ $oSmarty->assign('oViewConf', $this->getViewConfig());
+
+ $oSmarty->assign('sTroDownloadLink', $oSOFORTRelease->getDownload());
+ $oSmarty->assign('sTroAutomaticInstallationLink', 'index.php?cl=trosofortueberweisung_update&stoken=' . $this->getSession()->getSessionChallengeToken() . '&trosofortueberweisung_version=' . $oSOFORTRelease->getVersion('_'));
+ $oSmarty->assign('sTroChangeLogLink', $this->getSOFORTConfig()->getChangeLogUrl());
+ $oSmarty->assign('aTroNewVersion', array($oSOFORTRelease->getVersion()));
+
+ return $oSmarty->fetch('trosofortueberweisung_updateavailable.tpl');
+ }
+
+ /**
+ * @param trosofortueberweisungconfig $oSOFORTConfig
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setSOFORTConfig($oSOFORTConfig)
+ {
+ $this->_oSOFORTConfig = $oSOFORTConfig;
+ }
+ }
+
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_update.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_update.php
new file mode 100644
index 0000000..4b5b4f5
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisung_update.php
@@ -0,0 +1,353 @@
+addTplParam('sTroShopMainUrl', $this->getConfig()->getShopMainUrl());
+
+ $this->addTplParam('sTroSessionToken', $this->getSession()->getSessionChallengeToken());
+
+ $sReleaseVersionRaw = $this->getConfig()->getRequestParameter('trosofortueberweisung_version');
+ $this->addTplParam('sTroNewVersionRaw', $sReleaseVersionRaw);
+
+ $sReleaseVersionForDisplay = str_replace('_', '.', $sReleaseVersionRaw);
+ $this->addTplParam('sTroNewVersion', $sReleaseVersionForDisplay);
+
+ $this->addTplParam('aTroNewVersion', array($sReleaseVersionForDisplay));
+ $sTroTemplate = 'trosofortueberweisung_update.tpl';
+
+ return $sTroTemplate;
+ }
+
+ /**
+ * Action method checking whether core files has been modified by anyone but
+ * module developer.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troChangedModuleCoreFiles()
+ {
+ $oSOFORTConfig = oxNew('trosofortueberweisungconfig');
+ $sDownloadLinkRaw = $oSOFORTConfig->getTroMetaHashLinkRaw();
+ $sDownloadFile = sprintf($sDownloadLinkRaw, $this->getCurrentVersion());
+
+ $oXML = file_get_contents($sDownloadFile);
+ if ($oXML)
+ {
+ $oXml = new \SimpleXMLElement($oXML);
+ $sModulePath = getShopBasePath() . 'modules/';
+ $aChangedFiles = $this->getSOFORTDirectoryUtility()->getChangedFilesFromDirectory($sModulePath, $oXml);
+ $this->_troRenderJson(json_encode($aChangedFiles, JSON_FORCE_OBJECT));
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_couldNotFetchXml');
+ $this->_troRenderJson('{"couldNotFetchXml":"' . $sErrorMessage . '"}');
+ }
+ }
+
+ /**
+ * Simple getter function to retrieve the currently installed Module-Version.
+ *
+ * @return string Current version of SOFORT Überweisung
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getCurrentVersion()
+ {
+ $aModuleVersions = $this->getConfig()->getConfigParam('aModuleVersions');
+
+ return $aModuleVersions["trosofortueberweisung"];
+ }
+
+ public function getSOFORTDirectoryUtility()
+ {
+ if ($this->_oSOFORTDirectoryUtility == null)
+ {
+ $this->_oSOFORTDirectoryUtility = oxNew('trosofortueberweisungdirectoryutility');
+ }
+
+ return $this->_oSOFORTDirectoryUtility;
+ }
+
+ /**
+ * Outputs json data and terminates the script afterwards.
+ *
+ * @param string $sJson Valid json data
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function _troRenderJson($sJson)
+ {
+ header("Expires: Mon, 3 May 2000 01:00:00 GMT");
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
+ header("Cache-Control: no-cache, must-revalidate");
+ header("Pragma: no-cache");
+ header("Content-type: json");
+ echo json_encode($sJson);
+ exit;
+ }
+
+ /**
+ * Action method downloading latest release for current OXID eShop. Latest release
+ * is defined by the get parameter "trosofortueberweisung_version".
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troDownloadLatestModuleRelease()
+ {
+ $oSOFORTRelease = $this->getSOFORTReleaseList()->troGetRelease($this->getConfig()->getRequestParameter('trosofortueberweisung_version'), '_');
+
+ if ($oSOFORTRelease != null)
+ {
+ $oSOFORTUpdateUtility = oxNew('trosofortueberweisungupdateutility');
+
+ if ($oSOFORTUpdateUtility->downloadRelease($oSOFORTRelease) != false)
+ {
+ $this->_troRenderJson('{}');
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_fileNotDownloaded');
+ $this->_troRenderJson('{"fileNotDownloaded":"' . $sErrorMessage . '"}');
+ }
+ }
+ else
+ {
+ $sVersion = str_replace('_', '.', $this->getConfig()->getRequestParameter('trosofortueberweisung_version'));
+ $sErrorMessageRaw = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_releaseNotFound');
+ $sErrorMessage = sprintf($sErrorMessageRaw, $sVersion);
+ $this->_troRenderJson('{"releaseNotFound":"' . $sErrorMessage . '"}');
+ }
+ }
+
+ /**
+ * Getter for _oSOFORTReleaseList.
+ *
+ * @return trosofortueberweisungreleaseoxlist
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getSOFORTReleaseList()
+ {
+ if ($this->_oSOFORTReleaseList == null)
+ {
+ $oSOFORTConfig = oxNew('trosofortueberweisungconfig');
+ $this->_oSOFORTReleaseList = $oSOFORTReleaseList = oxNew('trosofortueberweisungreleaseoxlist');
+ $this->_oSOFORTReleaseList->troSelectXmlUri($oSOFORTConfig->getReleaseListUrl());
+ }
+
+ return $this->_oSOFORTReleaseList;
+ }
+
+ /**
+ * Action method extracting latest module release. Latest release
+ * is defined by the get parameter "trosofortueberweisung_version".
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troExtractLatestModuleRelease()
+ {
+ $oSOFORTRelease = $this->getSOFORTReleaseList()->troGetRelease($this->getConfig()->getRequestParameter('trosofortueberweisung_version'), '_');
+
+ if ($oSOFORTRelease != null)
+ {
+ $oSOFORTUpdateUtility = oxNew('trosofortueberweisungupdateutility');
+
+ $sExtractDirectory = $this->getConfig()->getConfigParam('sShopDir') . 'tmp/' . $oSOFORTRelease->getArchiveName();
+ $sExtractIntoDirectory = $this->getConfig()->getConfigParam('sShopDir') . 'tmp/';
+
+ $blSuccess = $oSOFORTUpdateUtility->extractArchive($sExtractDirectory, $sExtractIntoDirectory, false);
+ if ($blSuccess)
+ {
+ $this->_troRenderJson('{}');
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_unknownResult');
+ $this->_troRenderJson('{"unknownResult":"' . $sErrorMessage . '"}');
+ }
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_unknownResult');
+ $this->_troRenderJson('{"unknownResult":"' . $sErrorMessage . '"}');
+ }
+ }
+
+ /**
+ * Action method creating a module backup of current module tronet/trosofortueberweisung.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troCreateModuleBackup()
+ {
+ $oSOFORTUpdateUtility = oxNew('trosofortueberweisungupdateutility');
+ $sFile = $oSOFORTUpdateUtility->createModuleBackup();
+ $blFileExists = file_exists($sFile);
+
+ if ($blFileExists)
+ {
+ $this->_troRenderJson('{"couldNotCreateBackup":"0"}');
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_unknownResult');
+ $this->_troRenderJson('{"couldNotCreateBackup":"1","unknownResult":"' . $sErrorMessage . '"}');
+ }
+ }
+
+ /**
+ * Action method performing the actual update by replacing the current module directory
+ * with the recently downloaded release.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troPerformUpdate()
+ {
+ $oSOFORTRelease = $this->getSOFORTReleaseList()->troGetRelease($this->getConfig()->getRequestParameter('trosofortueberweisung_version'), '_');
+
+ if ($oSOFORTRelease != null)
+ {
+ $oSOFORTUpdateUtility = oxNew('trosofortueberweisungupdateutility');
+ $sShopHomeDir = $this->getConfig()->getConfigParam('sShopDir');
+ $sSourceDirectory = $sShopHomeDir . 'tmp/' . $oSOFORTRelease->getExtractDirectoryInZip();
+ if ($oSOFORTUpdateUtility->copyDirectory($sSourceDirectory, $sShopHomeDir))
+ {
+ $this->_troRenderJson('{}');
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_copyFailed');
+ $this->_troRenderJson('{"copyFailed":"' . $sErrorMessage . '"}');
+ }
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_unknownResult');
+ $this->_troRenderJson('{"unknownResult":"' . $sErrorMessage . '"}');
+ }
+ }
+
+ /**
+ * Action method that reactivates the module so that changes of the new module version are applied.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troRefreshModule()
+ {
+ if ($this->_refreshModule())
+ {
+ $this->_troRenderJson('{}');
+ }
+ else
+ {
+ $sErrorMessage = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_JSON_RETURN_unknownResult');
+ $this->_troRenderJson('{"unknownResult":"' . $sErrorMessage . '"}');
+ }
+ }
+
+ /**
+ * Function to (de)activate the module to apply changes from the metadata.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ private function _refreshModule()
+ {
+ $oModule = oxNew('oxModule');
+ $oModule->load("trosofortueberweisung");
+
+ $sEdition = oxRegistry::getConfig()->getEdition();
+ $sMinVersion = (($sEdition == "EE") ? "5.2" : "4.9.0");
+
+ // check if we are at least 4.9 (or 5.2 in EE), otherwise we need another routine
+ if (version_compare(oxRegistry::getConfig()->getVersion(), $sMinVersion, ">="))
+ {
+ $oModuleCache = oxNew('oxModuleCache', $oModule);
+ $oModuleInstaller = oxNew('oxModuleInstaller', $oModuleCache);
+ $blRefreshingSuccessful = ($oModuleInstaller->deactivate($oModule) && $oModuleInstaller->activate($oModule));
+ }
+ else
+ {
+ $blRefreshingSuccessful = ($oModule->deactivate() && $oModule->activate());
+ }
+
+ $this->_aViewData["updatenav"] = "1";
+ return $blRefreshingSuccessful;
+ }
+
+ /**
+ * Action method clearing the OXID tmp/* directory.
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troClearOxidTmpDirectory()
+ {
+ $oSOFORTUpdateUtility = oxNew('trosofortueberweisungupdateutility');
+ $oSOFORTUpdateUtility->clearOxidTmpDirectory();
+ $this->_troRenderJson('{}');
+ }
+
+ /**
+ * Setter for _oSOFORTReleaseList.
+ *
+ * @param $oSOFORTReleaseList
+ *
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setSOFORTReleaseList($oSOFORTReleaseList)
+ {
+ $this->_oSOFORTReleaseList = $oSOFORTReleaseList;
+ }
+
+ public function setSOFORTDirectoryUtility($oSOFORTDirectoryUtility)
+ {
+ $this->_oSOFORTDirectoryUtility = $oSOFORTDirectoryUtility;
+ }
+ }
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisungorder_notifications.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisungorder_notifications.php
new file mode 100644
index 0000000..2204b1a
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisungorder_notifications.php
@@ -0,0 +1,132 @@
+ Display Orders -> log.
+ *
+ * @file trosofortueberweisungorder_notifications.php
+ * @link http://www.tro.net
+ * @copyright (C) tronet GmbH 2016
+ * @package modules
+ * @addtogroup application/controllers/admin
+ * @extend oxAdminDetails
+ * @author tronet GmbH
+ * @extend oxAdminDetails
+ */
+ class trosofortueberweisungorder_notifications extends oxAdminDetails
+ {
+ /**
+ * Executes parent method parent::render(), creates oxOrder and
+ * oxList objects, passes it's data to Smarty engine and returns
+ * name of template file "troorder_notifications.tpl".
+ *
+ * @return string
+ * @author tronet GmbH
+ */
+ public function render()
+ {
+ parent::render();
+
+ return 'trosofortueberweisungorder_notifications.tpl';
+ }
+
+ /**
+ * Loads trogatewaylog-entry from DB
+ *
+ * @return trosofortueberweisunggatewaylog|bool
+ * @author tronet GmbH
+ */
+ public function getLog()
+ {
+ $sLogOxid = $this->getLogOxid();
+ $mReturn = false;
+ if (isset($sLogOxid))
+ {
+ $mReturn = oxNew('trosofortueberweisunggatewaylog');
+ $mReturn->load($sLogOxid);
+ }
+
+ return $mReturn;
+ }
+
+ public function getFLogData()
+ {
+ $oLog = $this->getLog();
+ if ($oLog)
+ {
+ $s = 'Timestamp: '.$oLog->trogatewaylog__timestamp->value."\n";
+ $s .= 'Status: '.$oLog->trogatewaylog__status->value."\n";
+ $s .= 'Status-Reason: '.$oLog->trogatewaylog__statusreason->value."\n";
+ $s .= 'Transaction-ID: '.$oLog->trogatewaylog__transactionid->value."\n";
+ return $s;
+ }
+ }
+
+ /**
+ * Loads trogatewaylog-entry from DB
+ *
+ * @return object
+ * @author tronet GmbH
+ */
+ public function getLogOxid()
+ {
+ return $this->getConfig()->getRequestParameter('log_oxid');
+ }
+
+ /**
+ * Loads trogatewaylog-entries from DB
+ *
+ * @return oxList $oLogs
+ * @author tronet GmbH
+ */
+ public function getAllLogs()
+ {
+ $oLogs = oxNew('oxlist');
+ $oLogs->init('trosofortueberweisunggatewaylog');
+ $sOxid = $this->getEditObjectId();
+ if (isset($sOxid) && '1' !== $sOxid)
+ {
+ $oOrder = oxNew('oxorder');
+ $oOrder->load($sOxid);
+ $sSelect = "select * from trogatewaylog where transactionid='" . $oOrder->oxorder__oxtransid->value . "' order by timestamp DESC";
+ $oLogs->selectString($sSelect);
+ }
+
+ return $oLogs;
+ }
+
+ /**
+ * Extends method by our needs.
+ *
+ * Saves trogatewaylog-entry text changes.
+ * @author tronet GmbH
+ */
+ public function save()
+ {
+ parent::save();
+
+ $oOrder = oxNew('oxOrder');
+ if ($oOrder->load($this->getEditObjectId()))
+ {
+ $sTroGatewayLogTransactionId = $this->getConfig()->getRequestParameter('trogatewaylog__transactionid');
+
+ $oTroGatewayLog = oxNew('trosofortueberweisunggatewaylog');
+ $oTroGatewayLog->load($this->getLogOxid());
+ $oTroGatewayLog->trogatewaylog__transactionid = new oxField($sTroGatewayLogTransactionId);
+ $oTroGatewayLog->save();
+ }
+ }
+
+ /**
+ * Extends method by our needs.
+ *
+ * Deletes trogatewaylog-entry from DB
+ * @author tronet GmbH
+ */
+ public function delete()
+ {
+ $oTroGatewayLog = oxNew('trosofortueberweisunggatewaylog');
+ $oTroGatewayLog->delete($this->getLogOxid());
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisungorder_overview.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisungorder_overview.php
new file mode 100644
index 0000000..14c222a
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/admin/trosofortueberweisungorder_overview.php
@@ -0,0 +1,47 @@
+ Display Orders -> Overview.
+ *
+ * NEW: shows paymentstatus via DB-table trogatewaylog
+ *
+ * @file trosofortueberweisungorder_overview.php
+ * @link http://www.tro.net
+ * @copyright (C) tronet GmbH 2013
+ * @package modules
+ * @addtogroup controllers
+ * @extend order_overview
+ */
+class trosofortueberweisungorder_overview extends trosofortueberweisungorder_overview_parent
+{
+ private $_sStatus = null;
+
+ /**
+ * returns current paymentstatus from DB-table trogatewaylog
+ *
+ * @return string
+ * @author tronet GmbH
+ */
+ public function troGetPaymentStatus()
+ {
+ if ($this->_sStatus === null)
+ {
+ $sOxId = $this->getEditObjectId();
+ $oOrder = oxNew('oxOrder');
+ if ($oOrder->load($sOxId))
+ {
+ if ($oOrder->getPaymentType()->oxuserpayments__oxpaymentsid->rawValue == 'trosofortgateway_su')
+ {
+ $oDB = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
+
+ $sSelect = "SELECT status FROM trogatewaylog WHERE transactionid='" . $oOrder->oxorder__oxtransid->value . "' ORDER BY timestamp DESC LIMIT 1";
+ $this->_sStatus = $oDB->getOne($sSelect);
+ };
+ };
+ }
+
+ return $this->_sStatus;
+ }
+}
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisung_notification.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisung_notification.php
new file mode 100644
index 0000000..fd67fbb
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisung_notification.php
@@ -0,0 +1,172 @@
+_getTroTransactionData();
+
+ $this->_troStoreGatewayLog($oTransactionData);
+ switch($oTransactionData->getStatus())
+ {
+ // Deutsche Handelsbank account - waiting for another status
+ case 'pending':
+ break;
+
+ // Deutsche Handelsbank account - money not received
+ case 'loss':
+ $this->_troCancelOrder($oTransactionData);
+ break;
+
+ // Deutsche Handelsbank account - money received
+ case 'received':
+ $this->_troSetOrderPaid($oTransactionData);
+ break;
+
+ // no Deutsche Handelsbank account
+ case 'untraceable':
+ $this->_troSetOrderPaid($oTransactionData);
+ break;
+
+ // money refunded
+ case 'refunded':
+ $this->_troCancelOrder($oTransactionData);
+ break;
+ }
+
+ // just exit, as we are not in frontend here
+ oxRegistry::getUtils()->showMessageAndExit('No info received');
+ }
+
+ /**
+ * get the transaction data
+ *
+ * @return $oTransactionData
+ */
+ private function _getTroTransactionData()
+ {
+ $sModuleDirectory = oxRegistry::getConfig()->getModulesDir();
+ $sSOFORTLibraryCoreDirectory = $sModuleDirectory . 'tronet/trosofortueberweisung/library/core/';
+
+ require_once($sSOFORTLibraryCoreDirectory . 'sofortLibNotification.inc.php');
+ require_once($sSOFORTLibraryCoreDirectory . 'sofortLibTransactionData.inc.php');
+
+ // create SofortLib_Notification-object and fetch transaction-id
+ $oNotification = $this->getSofortLibNotificationObject();
+ $oNotification->getNotification(file_get_contents('php://input'));
+ $sTransactionId = $oNotification->getTransactionId();
+
+ if ($sTransactionId == '')
+ {
+ oxRegistry::getUtils()->showMessageAndExit('No info received');
+ }
+
+ // create SofortLib_TransactionData-object and fetch some information for the transaction-id retrieved above
+ $oTransactionData = $this->getSofortLibTransactionDataObject();
+ $oTransactionData->addTransaction($sTransactionId);
+ $oTransactionData->sendRequest();
+ return $oTransactionData;
+ }
+
+ public function getSofortLibNotificationObject()
+ {
+ return new SofortLibNotification();
+ }
+
+ public function getSofortLibTransactionDataObject()
+ {
+ return new SofortLibTransactionData(oxRegistry::getConfig()->getConfigParam('sTroGatewayConfKey'));
+ }
+
+ /**
+ * stores received information to log-table trogatewaylog
+ *
+ * @param string $oTransactionData
+ */
+ private function _troStoreGatewayLog($oTransactionData)
+ {
+ $oTroGatewayLog = oxNew('trosofortueberweisunggatewaylog');
+ $oTroGatewayLog->trogatewaylog__transactionid = new oxField($oTransactionData->getTransaction());
+ $oTroGatewayLog->trogatewaylog__status = new oxField($oTransactionData->getStatus());
+ $oTroGatewayLog->trogatewaylog__statusreason = new oxField($oTransactionData->getStatusReason());
+ $oTroGatewayLog->trogatewaylog__timestamp = new oxField($oTransactionData->getStatusModifiedTime());
+ $oTroGatewayLog->save();
+ }
+
+ /**
+ * gets oxorder.oxid for the current transaction-id
+ *
+ * @param string $oTransactionData
+ * @return string
+ */
+ private function _getTroOrderID($oTransactionData)
+ {
+ $sTransactionId = $oTransactionData->getTransaction();
+
+ $sSelect = "SELECT OXID FROM oxorder where oxtransid='" . $sTransactionId . "' ";
+ $oDB = oxDb::getDb();
+ $sOrderId = $oDB->getOne($sSelect);
+ return $sOrderId;
+ }
+
+ /**
+ * sets order as paid
+ *
+ * @param string $oTransactionData
+ */
+ private function _troSetOrderPaid($oTransactionData)
+ {
+ $sOrderId = $this->_getTroOrderID($oTransactionData);
+
+ if ($sOrderId)
+ {
+ $sDate = $oTransactionData->getStatusModifiedTime();
+
+ $sUpdate = "UPDATE oxorder SET oxpaid='$sDate' where oxid='$sOrderId'";
+ $oDB = oxDb::getDb();
+ $oDB->execute($sUpdate);
+ oxRegistry::getUtils()->showMessageAndExit('Order updated');
+ }
+ oxRegistry::getUtils()->showMessageAndExit('Order not found');
+ }
+
+ /**
+ * cancels order
+ *
+ * @param string $oTransactionData
+ */
+ private function _troCancelOrder($oTransactionData)
+ {
+ $sOrderId = $this->_getTroOrderID($oTransactionData);
+
+ if ($sOrderId)
+ {
+ $oOrder = oxNew('oxorder');
+ $oOrder->load($sOrderId);
+ $oOrder->cancelOrder();
+
+ $sUpdate = "UPDATE oxorder SET oxpaid='' where oxid='$sOrderId'";
+ $oDB = oxDb::getDb();
+ $oDB->execute($sUpdate);
+
+ oxRegistry::getUtils()->showMessageAndExit('Order canceled');
+ }
+ oxRegistry::getUtils()->showMessageAndExit('Order not found');
+ }
+}
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisungorder.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisungorder.php
new file mode 100644
index 0000000..48f71a1
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisungorder.php
@@ -0,0 +1,167 @@
+_continueExecuteSUOrder())
+ {
+ return 'payment';
+ }
+
+ /*
+ * As this function is triggered due to external processes variables $oUser, $oBasket, $oOrder have
+ * to be initialized.
+ */
+
+ // additional check if we really really have a user now
+ if (!$oUser = $this->getUser())
+ {
+ return 'user';
+ }
+
+ // get basket contents
+ $oBasket = $oSession->getVariable('trosubasket');
+ $oBasket->troGetFromSession();
+ if ($oBasket->getProductsCount())
+ {
+
+ try
+ {
+ $oOrder = $oSession->getVariable('trosuoxorder');
+
+ // Finish oxOrder::finalizeOrder
+ $iSuccess = $oOrder->continueFinalizeOrder($oBasket, $oUser);
+
+ ////////////////////////////////////////////////////////////
+ //// Following is the rest of oxOrder::execute
+
+ // performing special actions after user finishes order (assignment to special user groups)
+ $oUser->onOrderExecute($oBasket, $iSuccess);
+
+ // proceeding to next view
+ return $this->_getNextStep($iSuccess);
+ }
+ catch (oxOutOfStockException $oEx)
+ {
+ oxRegistry::get("oxUtilsView")->addErrorToDisplay($oEx, false, true, 'basket');
+ }
+ catch (oxNoArticleException $oEx)
+ {
+ oxRegistry::get("oxUtilsView")->addErrorToDisplay($oEx);
+ }
+ catch (oxArticleInputException $oEx)
+ {
+ oxRegistry::get("oxUtilsView")->addErrorToDisplay($oEx);
+ }
+ }
+ }
+
+ /**
+ * _continueExecuteSUOrder
+ *
+ * Verifies previously initiated order has been payed.
+ *
+ * The success link contains the Transaction-ID.
+ *
+ * This function sends a new request to SOFORT AG regarding the current transaction status.
+ *
+ * If the current transaction status is either "pending", "received" or "untraceable" plus table oxOrder
+ * contains a record with the Transaction-ID which has not been finished yet (status: NOT_FINISHED) plus
+ * the defined payment method is "trosofortgateway_su" the order processing will be continued.
+ *
+ * We assume order should not be continued. If everything is ok the return var $blContinueExecuteSUOrder is
+ * set to true.
+ *
+ * @return boolean
+ * @author tronet GmbH
+ */
+ private function _continueExecuteSUOrder()
+ {
+ $blContinueExecuteSUOrder = false;
+
+ $oConfig = $this->getConfig();
+ require_once($oConfig->getModulesDir() . 'tronet/trosofortueberweisung/library/core/sofortLibTransactionData.inc.php');
+
+ // initialize
+ $sOrderId = $oConfig->getRequestParameter('orderid');
+ $sTransactionId = $oConfig->getRequestParameter('transactionid');
+ $sConfigKey = $oConfig->getConfigParam('sTroGatewayConfKey');
+
+ // Request the current transaction-status.
+ $oSofort = new SofortLibTransactionData($sConfigKey);
+ $oSofort->addTransaction($sTransactionId);
+ $oSofort->sendRequest();
+ $sStatus = $oSofort->getStatus();
+
+ if ($this->troSOFORTOrderHasBeenPayed($sStatus) && $this->troSOFORTOrderIsNotFinishedYet($sTransactionId, $sOrderId))
+ {
+ $blContinueExecuteSUOrder = true;
+ }
+
+ return $blContinueExecuteSUOrder;
+ }
+
+ /**
+ * Status "pending": Data have been recorded by SOFORT AG but the SOFORT AG did not written off yet.
+ * The order is counted as payed anyway.
+ *
+ * Status: "received": SOFORT AG has written off and received the money.
+ *
+ * @param $sPaymentStatus
+ *
+ * @return bool
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function troSOFORTOrderHasBeenPayed($sPaymentStatus)
+ {
+ $aValidPaymentStatus = array('pending', 'received', 'untraceable');
+
+ return (in_array($sPaymentStatus, $aValidPaymentStatus));
+ }
+
+ /**
+ * Determine whether current order with the present Transaction-ID is opened (status: NOT_FINISHED)
+ *
+ * @param $sTransactionId
+ * @param $sOrderId
+ *
+ * @return string
+ * @author tronet GmbH
+ */
+ protected function troSOFORTOrderIsNotFinishedYet($sTransactionId, $sOrderId)
+ {
+ $oDb = oxDb::getDb();
+
+ $sSql = "select oxid from oxorder where oxpaymenttype = 'trosofortgateway_su'
+ and oxtransstatus = 'NOT_FINISHED'
+ and oxtransid = " . $oDb->quote($sTransactionId) . "
+ and oxid = " . $oDb->quote($sOrderId);
+
+ return $oDb->getOne($sSql);
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisungpayment.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisungpayment.php
new file mode 100644
index 0000000..9c49f68
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/controllers/trosofortueberweisungpayment.php
@@ -0,0 +1,76 @@
+getConfig()->getRequestParameter('paymentid');
+ if ($sPaymentId == 'trosofortgateway_su')
+ {
+ // Determine current currency
+ $sCurrency = $this->getConfig()->getActShopCurrencyObject()->name;
+ if (!in_array($sCurrency, $this->_aCurrencies))
+ {
+ // Show order step 3, so that the customer can switch payment type.
+ $oEx = oxNew('oxException');
+ $oEx->setMessage('ERROR_MESSAGE_CURRENCY');
+ oxRegistry::get("oxUtilsView")->addErrorToDisplay($oEx);
+
+ return 'payment';
+ }
+ }
+
+ return parent::validatePayment();
+ }
+
+ /**
+ * deleteOldOrder
+ *
+ * If a customer cancels payment process on SOFORT AG page or has been inactive for too long this method
+ * will be triggered. The previous inserted order with the status "NOT_FINISHED" will be deleted.
+ *
+ * @author tronet GmbH
+ */
+ public function deleteOldOrder()
+ {
+ $sOrderId = $this->getSession()->getVariable('sess_challenge');
+ $oOrder = oxNew('oxorder');
+ $oOrder->load($sOrderId);
+ $oOrder->troDeleteOldOrder();
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisunggatewaylog.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisunggatewaylog.php
new file mode 100644
index 0000000..cafadda
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisunggatewaylog.php
@@ -0,0 +1,49 @@
+init($this->_sCoreTbl);
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasket.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasket.php
new file mode 100644
index 0000000..b6452c5
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasket.php
@@ -0,0 +1,34 @@
+_aBasketContents as $sItemKey => $oBasketItem )
+ {
+ $oSession->setVariable('trosubasket'.$sItemKey, $oBasketItem);
+ $oBasketItem->troStoreInSession($sItemKey);
+ }
+ }
+
+ public function troGetFromSession()
+ {
+ $oSession = new oxSession();
+ /** @var trosofortueberweisungoxbasketitem $oBasketItem */
+ foreach ( $this->_aBasketContents as $sItemKey => $oBasketItem )
+ {
+ $oBasketItem = $oSession->getVariable('trosubasket'.$sItemKey);
+ $oBasketItem->troGetFromSession($sItemKey);
+ }
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasketitem.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasketitem.php
new file mode 100644
index 0000000..505a358
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxbasketitem.php
@@ -0,0 +1,24 @@
+setVariable('trosubasketitem'.$sItemKey, $this->_oArticle);
+ }
+
+ public function troGetFromSession($sItemKey)
+ {
+ $oSession = new oxSession();
+ $this->_oArticle = $oSession->getVariable('trosubasketitem'.$sItemKey);
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxorder.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxorder.php
new file mode 100644
index 0000000..6fda8fd
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxorder.php
@@ -0,0 +1,220 @@
+getVariable('sess_challenge');
+
+ if ($sOrderId)
+ {
+ $oDb = oxDb::getDb();
+ $sSql = "select oxid from oxorder
+ where oxpaymenttype = 'trosofortgateway_su'
+ and oxtransstatus = 'NOT_FINISHED'
+ and oxid = " . $oDb->quote($sOrderId);
+
+ if ($oDb->getOne($sSql))
+ {
+ // check what should happen, depending on the users choice. Delete or cancel the old order
+ // 0 => cancel order
+ // 1 => delete order#
+ $iMode = $this->getConfig()->getConfigParam('iTroGatewayCanceledOrders');
+
+ if ($iMode == 0)
+ {
+ $this->load($sOrderId);
+ $this->cancelOrder();
+ $this->oxorder__oxordernr = null;
+ $this->oxorder__oxstorno = null;
+ $this->getSession()->setVariable('sess_challenge', oxUtilsObject::getInstance()->generateUID());
+ }
+ elseif ($iMode == 1)
+ {
+ $this->delete($sOrderId);
+ $this->getSession()->setVariable('sess_challenge', oxUtilsObject::getInstance()->generateUID());
+ }
+ }
+ }
+ }
+
+ /**
+ * Order checking, processing and saving method.
+ * Before saving performed checking if order is still not executed (checks in
+ * database oxorder table for order with know ID), if yes - returns error code 3,
+ * if not - loads payment data, assigns all info from basket to new oxorder object
+ * and saves full order with error status. Then executes payment. On failure -
+ * deletes order and returns error code 2. On success - saves order (oxorder::save()),
+ * removes article from wishlist (oxorder::_updateWishlist()), updates voucher data
+ * (oxorder::_markVouchers()). Finally sends order confirmation email to customer
+ * (oxemail::SendOrderEMailToUser()) and shop owner (oxemail::SendOrderEMailToOwner()).
+ * If this is order recalculation, skipping payment execution, marking vouchers as used
+ * and sending order by email to shop owner and user
+ * Mailing status (1 if OK, 0 on error) is returned.
+ *
+ * @param oxBasket $oBasket Shopping basket object
+ * @param oxUser $oUser Current user object
+ * @param bool $blRecalculatingOrder Order recalculation
+ *
+ * @return integer
+ */
+ public function finalizeOrder(oxBasket $oBasket, $oUser, $blRecalculatingOrder = false)
+ {
+ $this->troDeleteOldOrder();
+
+ return parent::finalizeOrder($oBasket, $oUser, $blRecalculatingOrder);
+ }
+
+ /**
+ * Executes payment. Additionally loads oxPaymentGateway object, initiates
+ * it by adding payment parameters (oxPaymentGateway::setPaymentParams())
+ * and finally executes it (oxPaymentGateway::executePayment()). On failure -
+ * deletes order and returns * error code 2.
+ *
+ * @param oxBasket|trosofortueberweisungoxbasket $oBasket basket object
+ * @param object $oUserPayment user payment object
+ *
+ * @return integer 2 or an error code
+ */
+ protected function _executePayment(oxBasket $oBasket, $oUserPayment)
+ {
+ $sPaymentId = $oBasket->getPaymentId();
+ if ($sPaymentId == 'trosofortgateway_su')
+ {
+ // Safe current order only ($this) and the current basket ($oBasket) in the session,
+ // so that the info are available when the user returns from the SOFORT AG.
+ $oSession = new oxSession();
+
+ if (!$this->oxorder__oxordernr->value)
+ {
+ $this->_setNumber();
+ }
+
+ $oOrder = clone $this;
+ $oSession->setVariable('trosuoxorder', $oOrder);
+ $oSession->setVariable('trosubasket', $oBasket);
+ $oBasket->troStoreInSession();
+ }
+
+ return parent::_executePayment($oBasket, $oUserPayment);
+ }
+
+ /**
+ * continueFinalizeOrder
+ *
+ * On return from SOFORT AG OXIDs core method finalizeOrder is continued.
+ *
+ * @param oxBasket $oBasket Shopping basket object
+ * @param object $oUser Current user object
+ * @param bool $blRecalculatingOrder Order recalculation
+ *
+ * @return string
+ */
+ public function continueFinalizeOrder(oxBasket $oBasket, $oUser, $blRecalculatingOrder = false)
+ {
+ $oSession = new oxSession();
+ // payment information
+ $oUserPayment = $this->_setPayment($oBasket->getPaymentId());
+
+ //// Rest of finalizeOrder
+ // executing TS protection
+ if (!$blRecalculatingOrder && $oBasket->getTsProductId()) {
+ $blRet = $this->_executeTsProtection($oBasket);
+ if ($blRet !== true) {
+ return $blRet;
+ }
+ }
+
+ // deleting remark info only when order is finished
+ $oSession->deleteVariable('ordrem');
+ $oSession->deleteVariable('stsprotection');
+
+ if (!$this->oxorder__oxordernr->value) {
+ $this->_setNumber();
+ } else {
+ oxNew('oxCounter')->update($this->_getCounterIdent(), $this->oxorder__oxordernr->value);
+ }
+
+ //#4005: Order creation time is not updated when order processing is complete
+ if (!$blRecalculatingOrder) {
+ $this->_updateOrderDate();
+ }
+
+ // updating order trans status (success status)
+ $this->_setOrderStatus('OK');
+
+ // store orderid
+ $oBasket->setOrderId($this->getId());
+
+ // updating wish lists
+ $this->_updateWishlist($oBasket->getContents(), $oUser);
+
+ // updating users notice list
+ $this->_updateNoticeList($oBasket->getContents(), $oUser);
+
+ // marking vouchers as used and sets them to $this->_aVoucherList (will be used in order email)
+ // skipping this action in case of order recalculation
+ if (!$blRecalculatingOrder) {
+ $this->_markVouchers($oBasket, $oUser);
+ }
+
+ // send order by email to shop owner and current user
+ // skipping this action in case of order recalculation
+ if (!$blRecalculatingOrder) {
+ $iRet = $this->_sendOrderByEmail($oUser, $oBasket, $oUserPayment);
+ } else {
+ $iRet = self::ORDER_STATE_OK;
+ }
+
+ // Call the original finalizeOrder method. In case the method is extended by other modules,
+ // this makes sure those features are executed as well.
+ $iRet2 = $this->finalizeOrder($oBasket, $oUser, $blRecalculatingOrder);
+
+ // Return value of the original finalizeOrder should be self::ORDER_STATE_ORDEREXISTS in any case,
+ // as the order has been created before the redirection to SOFORT AG.
+ // In case a different value is returned, we pass this return value.
+ if ($iRet2 == self::ORDER_STATE_ORDEREXISTS)
+ {
+ return $iRet;
+ }
+ return $iRet2;
+ }
+
+ /**
+ * Sets OrderNumber.
+ *
+ * This method is triggered before we execute payment via SOFORT.
+ *
+ * @author tronet GmbH
+ */
+ public function troSetOrderNr()
+ {
+ if (is_null($this->getFieldData('oxordernr')))
+ {
+ $this->_setNumber();
+ }
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxpaymentgateway.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxpaymentgateway.php
new file mode 100644
index 0000000..1e4722c
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungoxpaymentgateway.php
@@ -0,0 +1,245 @@
+getSession()->getBasket();
+ $sPaymentId = $oBasket->getPaymentId();
+
+ if ($sPaymentId == 'trosofortgateway_su')
+ {
+ $mReturn = $this->troExecutePayment($oOrder);
+ }
+ else
+ {
+ $mReturn = parent::executePayment($dAmount, $oOrder);
+ }
+
+ return $mReturn;
+ }
+
+ /**
+ * _replaceUmlauts
+ *
+ * Replaces umlaut as not every bank supports them in transferal reasons.
+ *
+ * @param string $sString The string to process.
+ *
+ * @return string
+ */
+ private function _replaceUmlauts($sString)
+ {
+ $aSearch = array(
+ chr(192), chr(193), chr(194), chr(195), chr(196), chr(197), #A
+ chr(198), #AE
+ chr(199), #C
+ chr(200), chr(201), chr(202), chr(203), #E
+ chr(204), chr(205), chr(206), chr(207), #I
+ chr(208), #D
+ chr(209),
+ chr(210), chr(211), chr(212), chr(213), chr(214), chr(216), #O
+ chr(217), chr(218), chr(219), chr(220), #U
+ chr(221), #Y
+ chr(223), #ss
+ chr(224), chr(225), chr(226), chr(227), chr(228), chr(229), #a
+ chr(230), #ae
+ chr(231), #c
+ chr(232), chr(233), chr(234), chr(235), #e
+ chr(236), chr(237), chr(238), chr(239), #i
+ chr(240), #d
+ chr(241), #n
+ chr(242), chr(243), chr(244), chr(245), chr(246), chr(248), #o
+ chr(249), chr(250), chr(251), chr(252), #u
+ chr(253), chr(255), #y
+ chr(39), "'", #'
+ );
+ $aReplace = array(
+ 'A', 'A', 'A', 'A', 'Ae', 'A',
+ 'Ae',
+ 'C',
+ 'E', 'E', 'E', 'E',
+ 'I', 'I', 'I', 'I',
+ 'D',
+ 'N',
+ 'O', 'O', 'O', 'O', 'Oe', 'O',
+ 'U', 'U', 'U', 'Ue',
+ 'Y',
+ 'ss',
+ 'a', 'a', 'a', 'a', 'ae', 'a',
+ 'ae',
+ 'c',
+ 'e', 'e', 'e', 'e',
+ 'i', 'i', 'i', 'i',
+ 'd',
+ 'n',
+ 'o', 'o', 'o', 'o', 'oe', 'o',
+ 'u', 'u', 'u', 'ue',
+ 'y', 'y',
+ '', '',
+ );
+ return str_replace($aSearch, $aReplace, $sString);
+ }
+
+ /**
+ * troExecutePayment
+ *
+ * Creates an object of type Sofortueberweisung and stores data in it.
+ *
+ * The in shop configured language is not transmitted as of request by SOFORT AG.
+ *
+ * @param oxOrder $oOrder order object
+ *
+ * @return void
+ */
+ private function troExecutePayment($oOrder)
+ {
+ /*
+ * Initialize
+ */
+ $oUser = $oOrder->getOrderUser();
+ $oConfig = $this->getConfig();
+ $oShop = $oConfig->getActiveShop();
+
+ require_once( $oConfig->getModulesDir() . 'tronet/trosofortueberweisung/library/payment/sofortLibSofortueberweisung.inc.php');
+
+
+ // Prepare data for Sofortueberweisung
+ $aPlaceHolder = array(
+ '[BSTNR]' => $oOrder->oxorder__oxordernr->value,
+ '[KNR]' => $oUser->oxuser__oxcustnr->value,
+ '[KNAME]' => $oUser->oxuser__oxlname->value,
+ '[DATUM]' => date('d.m.Y'),
+ '[PRICE]' => round($oOrder->oxorder__oxtotalordersum->value, 2),
+ '[SHP]' => utf8_decode($oShop->oxshops__oxname->value),
+ );
+
+ $aPlaceHolderKeys = array_keys($aPlaceHolder);
+ $aPlaceHolderValues = array_values($aPlaceHolder);
+
+ $sGatewayReason1 = str_replace($aPlaceHolderKeys, $aPlaceHolderValues, $oConfig->getConfigParam('sTroGatewayReason'));
+ $sGatewayReason2 = str_replace($aPlaceHolderKeys, $aPlaceHolderValues, $oConfig->getConfigParam('sTroGatewayReason2'));
+
+ $aReason[0] = $this->_replaceUmlauts($sGatewayReason1);
+ $aReason[1] = $this->_replaceUmlauts($sGatewayReason2);
+
+ /*
+ * Create new Sofortueberweisung and fill with data
+ */
+ $oSofort = new Sofortueberweisung($oConfig->getConfigParam('sTroGatewayConfKey'));
+ $oSofort->setReason($aReason[0], $aReason[1]);
+
+ $sUserCountryId = $oUser->oxuser__oxcountryid;
+ $oCountry = oxNew('oxCountry');
+ $oCountry->load($sUserCountryId);
+ $oSofort->setSenderCountryCode($oCountry->oxcountry__oxisoalpha2);
+
+ $oSofort->setAmount(round($oOrder->oxorder__oxtotalordersum->value, 2));
+
+ // force_sid
+ $sid = $oConfig->getRequestParameter('force_sid');
+ if (empty($sid))
+ {
+ $sid = $_COOKIE['force_sid'];
+ }
+ if (empty($sid))
+ {
+ $sid = $_SESSION['force_sid'];
+ }
+
+ ########################################
+ // Set urls
+ $oSofort->setSuccessUrl($oConfig->getSslShopUrl().'?cl=order&fnc=continueExecute&transactionid=-TRANSACTION-&orderid='.$oOrder->oxorder__oxid->value.'&force_sid='.$sid);
+ $oSofort->setAbortUrl ($oConfig->getSslShopUrl().'?cl=payment&fnc=deleteOldOrder&force_sid='.$sid);
+ $oSofort->setTimeoutUrl($oConfig->getSslShopUrl().'?cl=payment&fnc=deleteOldOrder&force_sid='.$sid);
+ $oSofort->setNotificationUrl($oConfig->getSslShopUrl() . '?cl=trosofortueberweisung_notification');
+
+ // Determine OXID eShop and trosofortueberweisung-Module-Version
+ $aModuleVersions = $oConfig->getConfigParam('aModuleVersions');
+ $sModuleVersion = 'oxid_' . $oConfig->getVersion() . '; trosu_' . $aModuleVersions['trosofortueberweisung'];
+ $oSofort->setVersion($sModuleVersion);
+
+ $oSofort->setEmailCustomer($oUser->oxuser__oxusername->value);
+
+ $oSofort->setCurrencyCode($oConfig->getActShopCurrencyObject()->name);
+
+ // After setting up an instance of Sofortueberweisung a request is send to the SOFORT API.
+ // SOFORT API responses with a URL to which current customer is redirected to.
+ $oSofort->sendRequest();
+ $this->troRedirect($oSofort, $oOrder);
+ }
+
+ /**
+ * checks for error and redirects to SOFORT or back to payment-view
+ *
+ * @param object $oSofort Sofortlib object
+ * @param object $oOrder order object
+ *
+ * @return void
+ */
+ public function troRedirect($oSofort, $oOrder)
+ {
+ require_once( $this->getConfig()->getModulesDir() . 'tronet/trosofortueberweisung/library/core/sofortLibNotification.inc.php');
+
+ if ($oSofort->isError())
+ {
+ // Data transmitted to SOFORT AG are invalid and cannot be processed by SOFORT AG.
+ $oLang = oxRegistry::getLang();
+ $sBaseLanguage = $oLang->getBaseLanguage();
+ $sErrorMessage = $oLang->translateString('TRO_SOFORTGATEWAY_PAYMENTERROR', $sBaseLanguage);
+ oxRegistry::get('oxutilsview')->addErrorToDisplay(
+ $sErrorMessage, false, true
+ );
+
+ // Add a log entry
+ $aErrors = $oSofort->getErrors();
+ if (is_array($aErrors))
+ {
+ foreach ($aErrors as $aError)
+ {
+ $oEx = oxNew( "trosuexception", $aError['message'], $aError['code'], 'Payment-redirect to Sofort AG', $this->getConfig() );
+ $oEx->debugOut();
+ }
+ }
+
+ // Delete initiated order, show order step 3 (payment) and prompt him to choose an other payment
+ // method.
+ $this->sRedirUrl = $this->getConfig()->getSslShopUrl() . '?cl=payment&fnc=deleteOldOrder';
+ oxRegistry::getUtils()->redirect($this->sRedirUrl);
+ }
+ else
+ {
+ // Data transmitted to SOFORT AG are valid. Save the Transaction-ID and redirect to SOFORT AG.
+ $sTransactionId = $oSofort->getTransactionId();
+ $oOrder->oxorder__oxtransid = new oxField($sTransactionId);
+ $oOrder->save();
+ $this->sRedirUrl = $oSofort->getPaymentUrl();
+ oxRegistry::getUtils()->redirect($this->sRedirUrl);
+ }
+ }
+ }
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungrelease.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungrelease.php
new file mode 100644
index 0000000..ed394a0
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungrelease.php
@@ -0,0 +1,228 @@
+setVersion($sVersion);
+ $this->setDownload($sDownload);
+
+ $oRequirements = oxNew('trosofortueberweisungreleaserequirements', $sMinimumOxidVersionCe, $sMinimumOxidVersionPe, $sMinimumOxidVersionEe, $sMinimumPhpVersion);
+ $this->setSofortgatewayReleaseRequirements($oRequirements);
+
+ $sVersionUnderscored = str_replace('.', '_', $this->getVersion());
+ $this->setExtractDirectoryInZip('Oxid-Sofortueberweisung-' . $sVersionUnderscored . '/copy_this');
+
+ $this->setArchiveName('Oxid-Sofortueberweisung-' . $sVersionUnderscored . '.zip');
+ }
+
+ /**
+ * Set the version.
+ *
+ * @param string $sVersion
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setVersion($sVersion)
+ {
+ $this->_sVersion = $sVersion;
+ }
+
+ /**
+ * Set the download url.
+ *
+ * @param string $sDownload
+ *
+ * @return trosofortueberweisungrelease
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setDownload($sDownload)
+ {
+ $this->_sDownload = $sDownload;
+
+ return $this;
+ }
+
+ /**
+ * @param trosofortueberweisungreleaserequirements $oSOFORTReleaseRequirements
+ *
+ * @return trosofortueberweisungrelease
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setSofortgatewayReleaseRequirements($oSOFORTReleaseRequirements)
+ {
+ $this->_oSofortgatewayReleaseRequirements = $oSOFORTReleaseRequirements;
+
+ return $this;
+ }
+
+ /**
+ * Get the release version. Optionally separator dot can be
+ * adjusted as required. By default a dot is used as separator.
+ *
+ * @param string|null $sSeparator
+ *
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getVersion($sSeparator = null)
+ {
+ if ($sSeparator != null)
+ {
+ $sReturn = str_replace('.', '_', $this->_sVersion);
+ }
+ else
+ {
+ $sReturn = $this->_sVersion;
+ }
+
+ return $sReturn;
+ }
+
+ /**
+ * @param string $sExtractDirectoryInZip
+ *
+ * @return trosofortueberweisungrelease
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setExtractDirectoryInZip($sExtractDirectoryInZip)
+ {
+ $this->_sExtractDirectoryInZip = $sExtractDirectoryInZip;
+
+ return $this;
+ }
+
+ /**
+ * @param mixed $sArchiveName
+ *
+ * @return trosofortueberweisungrelease
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setArchiveName($sArchiveName)
+ {
+ $this->_sArchiveName = $sArchiveName;
+
+ return $this;
+ }
+
+ /**
+ * Checks whether current version is compatible with passed parameters and whether current release version is
+ * higher.
+ *
+ * @param string $sModuleVersion
+ * @param string $sOxidEdition
+ * @param string $sOxidVersion
+ * @param string $sPhpVersion
+ *
+ * @return bool
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function doesModuleVersionSatisfyInstalledVersion($sModuleVersion, $sOxidEdition, $sOxidVersion, $sPhpVersion)
+ {
+ return ($this->getSofortgatewayReleaseRequirements()->doesModuleVersionSatisfyInstalledVersion($sOxidEdition, $sOxidVersion, $sPhpVersion) && version_compare($sModuleVersion, $this->getVersion(), '<'));
+ }
+
+ /**
+ * @return trosofortueberweisungreleaserequirements
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getSofortgatewayReleaseRequirements()
+ {
+ return $this->_oSofortgatewayReleaseRequirements;
+ }
+
+ /**
+ * Get the download url.
+ *
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getDownload()
+ {
+ return $this->_sDownload;
+ }
+
+ /**
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getArchiveName()
+ {
+ return $this->_sArchiveName;
+ }
+
+ /**
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getExtractDirectoryInZip()
+ {
+ return $this->_sExtractDirectoryInZip;
+ }
+ }
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungreleaseoxlist.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungreleaseoxlist.php
new file mode 100644
index 0000000..de1e55c
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungreleaseoxlist.php
@@ -0,0 +1,115 @@
+releases->release as $oSOFORTReleaseXml)
+ {
+ $this->_aArray[] = oxNew($this->_sObjectsInListName, $oSOFORTReleaseXml->version, $oSOFORTReleaseXml->download, $oSOFORTReleaseXml->requirements->minimumOxidVersion->ce, $oSOFORTReleaseXml->requirements->minimumOxidVersion->pe, $oSOFORTReleaseXml->requirements->minimumOxidVersion->ee, $oSOFORTReleaseXml->requirements->minimumPhpVersion);
+ }
+ }
+ catch (Exception $oException)
+ {
+ throw new InvalidArgumentException('Could not process passed xml uri (' . $sXmlUri . ') properly.', 0, $oException);
+ }
+ }
+
+ /**
+ * Finds and returns the latest release for system as defined by the parameters.
+ *
+ * @param string $sModuleVersion
+ * @param string $sOxidEdition
+ * @param string $sOxidVersion
+ * @param string $sPhpVersion
+ *
+ * @return null|trosofortueberweisungrelease
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troGetLatestRelease($sModuleVersion, $sOxidEdition, $sOxidVersion, $sPhpVersion)
+ {
+ $oLatestRelease = null;
+
+ /** @var trosofortueberweisungrelease $oSOFORTRelease */
+ foreach ($this->_aArray as $oSOFORTRelease)
+ {
+ if ($oSOFORTRelease->doesModuleVersionSatisfyInstalledVersion($sModuleVersion, $sOxidEdition, $sOxidVersion, $sPhpVersion))
+ {
+ $oLatestRelease = $oSOFORTRelease;
+ }
+ }
+
+ return $oLatestRelease;
+ }
+
+ /**
+ * Finds and returns specified release. In case the version is in a different
+ * format it can be specified as well.
+ *
+ * @param $sVersion
+ * @param null $sFormat
+ *
+ * @return null|trosofortueberweisungrelease
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function troGetRelease($sVersion, $sFormat = null)
+ {
+ $oRelease = null;
+
+ /** @var trosofortueberweisungrelease $oSOFORTRelease */
+ foreach ($this->_aArray as $oSOFORTRelease)
+ {
+ if ($oSOFORTRelease->getVersion($sFormat) == $sVersion)
+ {
+ $oRelease = $oSOFORTRelease;
+ break;
+ }
+ }
+
+ return $oRelease;
+ }
+ }
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungreleaserequirements.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungreleaserequirements.php
new file mode 100644
index 0000000..54db780
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/models/trosofortueberweisungreleaserequirements.php
@@ -0,0 +1,213 @@
+setMinimumOxidVersionCe($sMinimumOxidVersionCe);
+ $this->setMinimumOxidVersionPe($sMinimumOxidVersionPe);
+ $this->setMinimumOxidVersionEe($sMinimumOxidVersionEe);
+ $this->setMinimumPhpVersion($sMinimumPhpVersion);
+ }
+
+ /**
+ * @param string $sMinimumOxidVersionCe
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setMinimumOxidVersionCe($sMinimumOxidVersionCe)
+ {
+ $this->_sMinimumOxidVersionCe = $sMinimumOxidVersionCe;
+ }
+
+ /**
+ * @param string $sMinimumOxidVersionPe
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setMinimumOxidVersionPe($sMinimumOxidVersionPe)
+ {
+ $this->_sMinimumOxidVersionPe = $sMinimumOxidVersionPe;
+ }
+
+ /**
+ * @param string $sMinimumOxidVersionEe
+ */
+ public function setMinimumOxidVersionEe($sMinimumOxidVersionEe)
+ {
+ $this->_sMinimumOxidVersionEe = $sMinimumOxidVersionEe;
+ }
+
+ /**
+ * @param string $sMinimumPhpVersion
+ *
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function setMinimumPhpVersion($sMinimumPhpVersion)
+ {
+ $this->_sMinimumPhpVersion = $sMinimumPhpVersion;
+ }
+
+ /**
+ * @param $sOxidEdition
+ * @param $sOxidVersion
+ * @param $sPhpVersion
+ *
+ * @return bool
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function doesModuleVersionSatisfyInstalledVersion($sOxidEdition, $sOxidVersion, $sPhpVersion)
+ {
+ $blDoesSatisfy = false;
+
+ switch (strtolower($sOxidEdition))
+ {
+ case "ce":
+ $blDoesSatisfy = $this->doesModuleVersionSatisfyInstalledVersionCe($sOxidVersion, $sPhpVersion);
+ break;
+
+ case "pe":
+ $blDoesSatisfy = $this->doesModuleVersionSatisfyInstalledVersionPe($sOxidVersion, $sPhpVersion);
+ break;
+
+ case "ee":
+ $blDoesSatisfy = $this->doesModuleVersionSatisfyInstalledVersionEe($sOxidVersion, $sPhpVersion);
+ break;
+
+ default:
+ throw new InvalidArgumentException("Unknown oxid edition (" . $sOxidEdition . ")");
+ }
+
+ return $blDoesSatisfy;
+ }
+
+ /**
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getMinimumPhpVersion()
+ {
+ return $this->_sMinimumPhpVersion;
+ }
+
+ /**
+ * @param $sOxidVersion
+ * @param $sPhpVersion
+ *
+ * @return bool
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function doesModuleVersionSatisfyInstalledVersionCe($sOxidVersion, $sPhpVersion)
+ {
+ return (version_compare($sOxidVersion, $this->getMinimumOxidVersionCe(), '>=') && version_compare($sPhpVersion, $this->getMinimumPhpVersion(), '>='));
+ }
+
+ /**
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getMinimumOxidVersionCe()
+ {
+ return $this->_sMinimumOxidVersionCe;
+ }
+
+ /**
+ * @param $sOxidVersion
+ * @param $sPhpVersion
+ *
+ * @return bool
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function doesModuleVersionSatisfyInstalledVersionPe($sOxidVersion, $sPhpVersion)
+ {
+ return (version_compare($sOxidVersion, $this->getMinimumOxidVersionPe(), '>=') && version_compare($sPhpVersion, $this->getMinimumPhpVersion(), '>='));
+ }
+
+ /**
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getMinimumOxidVersionPe()
+ {
+ return $this->_sMinimumOxidVersionPe;
+ }
+
+ /**
+ * @param $sOxidVersion
+ * @param $sPhpVersion
+ *
+ * @return bool
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ protected function doesModuleVersionSatisfyInstalledVersionEe($sOxidVersion, $sPhpVersion)
+ {
+ return (version_compare($sOxidVersion, $this->getMinimumOxidVersionEe(), '>=') && version_compare($sPhpVersion, $this->getMinimumPhpVersion(), '>='));
+ }
+
+ /**
+ * @return string
+ * @author tronet GmbH
+ * @since 7.0.0
+ */
+ public function getMinimumOxidVersionEe()
+ {
+ return $this->_sMinimumOxidVersionEe;
+ }
+ }
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/translations/de/trosofortueberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/translations/de/trosofortueberweisung_lang.php
new file mode 100644
index 0000000..38d14ab
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/translations/de/trosofortueberweisung_lang.php
@@ -0,0 +1,30 @@
+getConfigParam('sShopDir');
+ $sModulePath = oxNew('oxModule')->getModulePath('trosofortueberweisung');
+
+ $sAbsolutePath = $sShopHomeDir . 'modules/' . $sModulePath . '/library/translations/' . $sTheme . '/' . $sLanguageKey . '/trosofortueberweisung_lang.php';
+
+ /*
+ * Include master translation file
+ */
+ include_once($sAbsolutePath);
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/translations/en/trosofortueberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/translations/en/trosofortueberweisung_lang.php
new file mode 100644
index 0000000..ebcbff3
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/translations/en/trosofortueberweisung_lang.php
@@ -0,0 +1,30 @@
+getConfigParam('sShopDir');
+ $sModulePath = oxNew('oxModule')->getModulePath('trosofortueberweisung');
+
+ $sAbsolutePath = $sShopHomeDir . 'modules/' . $sModulePath . '/library/translations/' . $sTheme . '/' . $sLanguageKey . '/trosofortueberweisung_lang.php';
+
+ /*
+ * Include master translation file
+ */
+ include_once($sAbsolutePath);
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/de/trosofortueberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/de/trosofortueberweisung_lang.php
new file mode 100644
index 0000000..f74604b
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/de/trosofortueberweisung_lang.php
@@ -0,0 +1,30 @@
+getConfigParam('sShopDir');
+ $sModulePath = oxNew('oxModule')->getModulePath('trosofortueberweisung');
+
+ $sAbsolutePath = $sShopHomeDir . 'modules/' . $sModulePath . '/library/translations/' . $sTheme . '/' . $sLanguageKey . '/trosofortueberweisung_lang.php';
+
+ /*
+ * Include master translation file
+ */
+ include_once($sAbsolutePath);
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/en/trosofortueberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/en/trosofortueberweisung_lang.php
new file mode 100644
index 0000000..b6229be
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/en/trosofortueberweisung_lang.php
@@ -0,0 +1,30 @@
+getConfigParam('sShopDir');
+ $sModulePath = oxNew('oxModule')->getModulePath('trosofortueberweisung');
+
+ $sAbsolutePath = $sShopHomeDir . 'modules/' . $sModulePath . '/library/translations/' . $sTheme . '/' . $sLanguageKey . '/trosofortueberweisung_lang.php';
+
+ /*
+ * Include master translation file
+ */
+ include_once($sAbsolutePath);
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_noupdateavailable.tpl b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_noupdateavailable.tpl
new file mode 100644
index 0000000..9afc69c
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_noupdateavailable.tpl
@@ -0,0 +1,3 @@
+[{oxstyle include=$oViewConf->getModuleUrl('trosofortueberweisung', 'out/admin/src/css/trosofortueberweisung.css')}]
+
+✔ [{oxmultilang ident="TRO_NEW_VERSION_ALREADY_INSTALLED"}]
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_updateavailable.tpl b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_updateavailable.tpl
new file mode 100644
index 0000000..ec6e36a
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_updateavailable.tpl
@@ -0,0 +1,14 @@
+[{oxstyle include=$oViewConf->getModuleUrl('trosofortueberweisung', 'out/admin/src/css/trosofortueberweisung.css')}]
+
+ [{oxmultilang ident="TRO_NEW_VERSION_AVAILABLE"}]
+
+
+
+ [{oxmultilang ident="TRO_VERSION_DOWNLOAD" args=$aTroNewVersion}]
+
+
+ [{oxmultilang ident="TRO_VERSION_INSTALL" args=$aTroNewVersion}]
+
+
+ [{oxmultilang ident="TRO_CHANGE_LOG_URL_DESCRIPTION"}]
+
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_updateavailable_failed.tpl b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_updateavailable_failed.tpl
new file mode 100644
index 0000000..edb012e
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/messages/trosofortueberweisung_updateavailable_failed.tpl
@@ -0,0 +1,8 @@
+[{oxstyle include=$oViewConf->getModuleUrl('trosofortueberweisung', 'out/admin/src/css/trosofortueberweisung.css')}]
+
+ [{oxmultilang ident="TRO_NEW_VERSION_AVAILABLE_FAILED"}]
+
+
+
+ [{oxmultilang ident="TRO_NEW_VERSION_AVAILABLE_FAILED_MESSAGE"}]
+
\ No newline at end of file
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/trosofortueberweisung.tpl b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/trosofortueberweisung.tpl
new file mode 100644
index 0000000..047964d
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/trosofortueberweisung.tpl
@@ -0,0 +1,13 @@
+
+
+
+ [{oxmultilang ident="GENERAL_ADMIN_TITLE_1"}]
+
+
+
+
+
+
diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/trosofortueberweisung_list.tpl b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/trosofortueberweisung_list.tpl
new file mode 100644
index 0000000..75979a0
--- /dev/null
+++ b/src/copy_this/modules/tronet/trosofortueberweisung/application/views/admin/tpl/trosofortueberweisung_list.tpl
@@ -0,0 +1,96 @@
+[{include file="headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign box="list"}]
+
+[{if $readonly}]
+ [{assign var="readonly" value="readonly disabled"}]
+[{else}]
+ [{assign var="readonly" value=""}]
+[{/if}]
+
+
+
+