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}] + + + + + +
+ [{$oViewConf->getHiddenSid()}] + + + + + + + + + + + + + + +
+ + +
+
+ + +
+
+
+ +[{include file="bottomitem.tpl"}] diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/core/exception/trosuexception.php b/src/copy_this/modules/tronet/trosofortueberweisung/core/exception/trosuexception.php new file mode 100644 index 0000000..6098218 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/core/exception/trosuexception.php @@ -0,0 +1,81 @@ +_sTrace = $sTrace; + $this->_oConfig = $oConfig; + parent::__construct($sMessage, $iCode); + } + + /** + * Builds a string representing current trosuexception. + * Overrides oxException::getString() + * + * @return string + * @author tronet GmbH + */ + public function getString() + { + $aModuleVersions = oxRegistry::getConfig()->getConfigParam('aModuleVersions'); + + $sToString = "\n" . 'Module-Version: ' . $aModuleVersions['trosofortueberweisung']; + + if ($this->_oConfig) + { + $sToString .= "\n" . 'Oxid-Version: ' . $this->_oConfig->getVersion() . ' ' . $this->_oConfig->getEdition(); + $sToString .= "\n" . 'Shop-Id: ' . $this->_oConfig->getShopId(); + } + + $sToString .= "\n" . 'Time: ' . date('Y-m-d H:i:s'); + + if ($this->_sTrace) + { + $sToString .= "\n" . 'Trace: ' . $this->_sTrace; + } + + $sToString .= "\n" . 'Code: [' . $this->code . ']'; + $sToString .= "\n" . 'Message from SOFORT AG server: ' . $this->message . "\n"; + + return $sToString; + } + } diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/core/trosofortueberweisungconfig.php b/src/copy_this/modules/tronet/trosofortueberweisung/core/trosofortueberweisungconfig.php new file mode 100644 index 0000000..3794af2 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/core/trosofortueberweisungconfig.php @@ -0,0 +1,160 @@ +_setChangeLogUrl('http://sofort.tro.net/trosofortueberweisung_changelog.txt'); + $this->_setReleaseListUrl('http://sofort.tro.net/Versions/trosofortueberweisung_versions.xml'); + $this->_setTroMetaHashLinkRaw('http://sofort.tro.net/Module-File-Hashes/trometahashes_%1$s.xml'); + $this->_setLogFile('SOFORTGATEWAY_LOG.txt'); + } + + /** + * Set the change log url. + * + * @param string $sChangeLogUrl + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setChangeLogUrl($sChangeLogUrl) + { + $this->_sChangeLogUrl = $sChangeLogUrl; + } + + /** + * Set the release list url. + * + * @param string $sReleaseListUrl + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setReleaseListUrl($sReleaseListUrl) + { + $this->_sReleaseListUrl = $sReleaseListUrl; + } + + /** + * Set the raw trometa-hash-link. + * + * @param string $sTroMetaHashLinkRaw + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setTroMetaHashLinkRaw($sTroMetaHashLinkRaw) + { + $this->_sTroMetaHashLinkRaw = $sTroMetaHashLinkRaw; + } + + /** + * Set the log file + * + * @param string $sLogFile + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setLogFile($sLogFile) + { + $this->_sLogFile = $sLogFile; + } + + /** + * Get the change log url. + * + * @return string $this->_sChangeLogUrl + * @author tronet GmbH + * @since 7.0.0 + */ + public function getChangeLogUrl() + { + return $this->_sChangeLogUrl; + } + + /** + * Get the release list url. + * + * @return string $this->_sReleaseListUrl + * @author tronet GmbH + * @since 7.0.0 + */ + public function getReleaseListUrl() + { + return $this->_sReleaseListUrl; + } + + /** + * Get the raw trometa-hash-link . + * + * @return string $this->_sTroMetaHashLinkRaw + * @author tronet GmbH + * @since 7.0.0 + */ + public function getTroMetaHashLinkRaw() + { + return $this->_sTroMetaHashLinkRaw; + } + + /** + * Get the log file. + * + * @return string $this->_sLogFile + * @author tronet GmbH + * @since 7.0.0 + */ + public function getLogFile() + { + return $this->_sLogFile; + } + } \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/core/trosofortueberweisungevents.php b/src/copy_this/modules/tronet/trosofortueberweisung/core/trosofortueberweisungevents.php new file mode 100644 index 0000000..ec5243f --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/core/trosofortueberweisungevents.php @@ -0,0 +1,97 @@ +execute($sSqlFileContent); + } + + /** + * Inserts SOFORT AG payment method into oxPayment table. + * + * @author tronet GmbH + */ + public static function handleOxPayments() + { + $sSqlFileContent = trosofortueberweisungevents::getSqlFileContent('oxpayments.sql'); + oxDb::getDb()->execute($sSqlFileContent); + } + + /** + * Loads the content of defined sql file and returns the value. + * + * @param $sSqlFile + * + * @return string + * @author tronet GmbH + * @since 7.0.0 + */ + public static function getSqlFileContent($sSqlFile) + { + $sShopBasePath = getShopBasePath(); + + $sDirSep = DIRECTORY_SEPARATOR; + $sPathToModule = $sShopBasePath.'modules'.$sDirSep.'tronet'.$sDirSep.'trosofortueberweisung'.$sDirSep; + $sPathToModuleSqlFiles = $sPathToModule.'library'.$sDirSep.'sql'.$sDirSep; + + return file_get_contents($sPathToModuleSqlFiles.$sSqlFile); + } + + /** + * Performs required actions when deactivating the module. + */ + public static function onDeactivate() + { + trosofortueberweisungevents::setPaymentMethodActiveStatus('trosofortgateway_su', 0); + } + + /** + * Set the active status of a payment method. + * + * @param $sPaymentMethod + * @param $iStatus + * + * @author tronet GmbH + * @since 7.0.0 + */ + public static function setPaymentMethodActiveStatus($sPaymentMethod, $iStatus) + { + $oPayment = oxNew('oxpayment'); + if ($oPayment->load($sPaymentMethod)) + { + $oPayment->oxpayments__oxactive = new oxField($iStatus); + $oPayment->save(); + } + } + } diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungdirectoryutility.php b/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungdirectoryutility.php new file mode 100644 index 0000000..96a0675 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungdirectoryutility.php @@ -0,0 +1,146 @@ +open($sAbsolutePathToZipArchive, ZipArchive::CREATE | ZipArchive::OVERWRITE); + + $aSplFileInfo = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath($sAbsolutePathToDirectoryToArchive)), RecursiveIteratorIterator::LEAVES_ONLY); + + foreach ($aSplFileInfo as $sName => $sFile) + { + if (!$sFile->isdir()) + { + $sFilePath = $sFile->getRealPath(); + $sRelativePath = substr($sFilePath, strlen(realpath($sAbsolutePathToDirectoryToArchive)) + 1); + $oZipArchive->addFile($sFilePath, $sRelativePath); + } + } + + $oZipArchive->close(); + } + else + { + $oLogUtility = $this->getTroLoggingUtility(); + $LogMessage = 'Could not create zip archive because "' . $sAbsolutePathToDirectoryToArchive . '" is not a directory.'; + $oLogUtility->writeToLog('INFO', $LogMessage); + } + + return $oZipArchive; + } + + /** + * @return trosofortueberweisungloggingutility + * @author tronet GmbH + * @since 7.0.0 + */ + public function getTroLoggingUtility() + { + if ($this->_oTroLoggingUtility == null) + { + $this->_oTroLoggingUtility = oxNew('trosofortueberweisungloggingutility'); + } + + return $this->_oTroLoggingUtility; + } + + /** + * Perform a check on a directory for changed files. + * + * @param string $sLookUpDirectory + * @param SimpleXMLElement $oXml + * + * @return array $aChangedFiles + * @author tronet GmbH + * @since 7.0.0 + */ + public function getChangedFilesFromDirectory($sLookUpDirectory, $oXml) + { + $aChangedFiles = array('changedCoreFiles' => 0); + + $aHashNodes = $oXml->hashes->children(); + $sModulePath = $sLookUpDirectory; + + $i = 0; + foreach ($aHashNodes as $key => $value) + { + $sTempFile = str_replace(array( + '\\', + '/', + ), DIRECTORY_SEPARATOR, $sModulePath . $value->file); + + $sFileMessage = null; + + if (file_exists($sTempFile)) + { + $sFileHash = hash_file('md5', $sTempFile); + + if ($sFileHash != $value->hash) + { + $sMessageChanged = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_CORE_FILES_BEEN_MODIFIED_NOTE_CHANGED'); + $sFileMessage = '' . $sMessageChanged . ' "' . $value->file . '"'; + } + } + else + { + $sMessageDeleted = oxRegistry::getLang()->translateString('TRO_SOFORT_UPDATE_CORE_FILES_BEEN_MODIFIED_NOTE_DELETED'); + $sFileMessage = '' . $sMessageDeleted . ' "' . $value->file . '"'; + } + + if ($sFileMessage != null) + { + $aChangedFiles['file_' . $i] = $sFileMessage; + $i++; + } + } + $aChangedFiles['changedCoreFiles'] = count($aChangedFiles) - 1; + + return $aChangedFiles; + } + + /** + * @param trosofortueberweisungloggingutility $oTroLoggingUtility + * + * @author tronet GmbH + * @since 7.0.0 + */ + public function setTroLoggingUtility($oTroLoggingUtility) + { + $this->_oTroLoggingUtility = $oTroLoggingUtility; + } + + + } \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungloggingutility.php b/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungloggingutility.php new file mode 100644 index 0000000..6dcf4fe --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungloggingutility.php @@ -0,0 +1,76 @@ +getLogTemplate(), $sLogTime, $sLevel, $sMessage); + oxRegistry::getUtils()->writeToLog($sFinalLogMessage, $this->getTroSOFORTConfig()->getLogFile()); + } + + /** + * Returns the log template. Where the first placeholder + * is the date, the second the level and the third the + * actual message to log. + * + * @return string + * @author tronet GmbH + * @since 7.0.0 + */ + protected function getLogTemplate() + { + return '[%1$s][%2$s] %3$s' . "\n"; + } + + /** + * @return trosofortueberweisungconfig + * @author tronet GmbH + * @since 7.0.0 + */ + public function getTroSOFORTConfig() + { + if ($this->_oTroSOFORTConfig == null) + { + $this->_oTroSOFORTConfig = oxNew('trosofortueberweisungconfig'); + } + + return $this->_oTroSOFORTConfig; + } + + /** + * @param trosofortueberweisungconfig $oTroSOFORTConfig + * + * @author tronet GmbH + * @since 7.0.0 + */ + public function setTroSOFORTConfig($oTroSOFORTConfig) + { + $this->_oTroSOFORTConfig = $oTroSOFORTConfig; + } + } \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungupdateutility.php b/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungupdateutility.php new file mode 100644 index 0000000..701fce7 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/core/utility/trosofortueberweisungupdateutility.php @@ -0,0 +1,347 @@ +getPathToSOFORTModule(); + $sSaveArchiveInDirectory = $this->getPathToOXIDExportDirectory(); + $sArchiveName = 'trosofortueberweisung__' . date("Ymd_His", time()) . '.zip'; + + $oTroSOFORTDirectoryUtility = oxNew('trosofortueberweisungdirectoryutility'); + $oTroSOFORTDirectoryUtility->createZipArchive($sSaveArchiveInDirectory . $sArchiveName, $sDirectoryToArchive); + + return $sSaveArchiveInDirectory . $sArchiveName; + } + + /** + * @return string + * @author tronet GmbH + * @since 7.0.0 + */ + public function getPathToSOFORTModule() + { + if ($this->_sPathToSOFORTModule == null) + { + $sShopHomeDir = $this->getConfig()->getConfigParam('sShopDir'); + $sPathToSOFORTModule = $sShopHomeDir . 'modules/' . $this->getModule()->getModulePath("trosofortueberweisung"); + $this->_setPathToSOFORTModule($sPathToSOFORTModule); + } + + return $this->_sPathToSOFORTModule; + } + + /** + * @return oxConfig + * @author tronet GmbH + * @since 7.0.0 + */ + public function getConfig() + { + if ($this->_oConfig == null) + { + $this->_setConfig(oxRegistry::getConfig()); + } + + return $this->_oConfig; + } + + /** + * @param oxConfig $oConfig + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setConfig($oConfig) + { + $this->_oConfig = $oConfig; + } + + /** + * @return oxModule + * @author tronet GmbH + * @since 7.0.0 + */ + public function getModule() + { + if ($this->_oModule == null) + { + $this->_setModule(oxNew("oxModule")); + } + + return $this->_oModule; + } + + /** + * @param oxModule $oModule + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setModule($oModule) + { + $this->_oModule = $oModule; + } + + /** + * @param string $sPathToSOFORTModule + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setPathToSOFORTModule($sPathToSOFORTModule) + { + $this->_sPathToSOFORTModule = $sPathToSOFORTModule; + } + + /** + * @return string + * @author tronet GmbH + * @since 7.0.0 + */ + public function getPathToOXIDExportDirectory() + { + if ($this->_sPathToOXIDTmpDirectory == null) + { + $sShopHomeDirectory = $this->getConfig()->getConfigParam('sShopDir'); + $sOXIDTmpDirectory = $sShopHomeDirectory . 'export/'; + $this->_setPathToOXIDTmpDirectory($sOXIDTmpDirectory); + } + + return $this->_sPathToOXIDTmpDirectory; + } + + /** + * @param string $sPathToOXIDTmpDirectory + * + * @author tronet GmbH + * @since 7.0.0 + */ + protected function _setPathToOXIDTmpDirectory($sPathToOXIDTmpDirectory) + { + $this->_sPathToOXIDTmpDirectory = $sPathToOXIDTmpDirectory; + } + + /** + * Downloads a specific release from tronet-Server onto current server. + * + * @param trosofortueberweisungrelease $oSOFORTRelease + * + * @return string $sArchiveName + * @author tronet GmbH + * @since 7.0.0 + */ + public function downloadRelease($oSOFORTRelease) + { + $sCopyPath = $this->getPathToOXIDTmpDirectory(); + + $sTemporaryFile = $oSOFORTRelease->getArchiveName(); + $sFullPath = $sCopyPath . '/' . $sTemporaryFile; + + $blCopySuccessful = @copy($oSOFORTRelease->getDownload(), $sFullPath); + $sArchiveName = $sFullPath; + + if ($blCopySuccessful && file_exists($sArchiveName)) + { + $mReturn = $sArchiveName; + } + else + { + $mReturn = false; + } + + return $mReturn; + } + + /** + * @return string + * @author tronet GmbH + * @since 7.0.0 + */ + public function getPathToOXIDTmpDirectory() + { + if ($this->_sPathToOXIDTmpDirectory == null) + { + $sShopHomeDirectory = $this->getConfig()->getConfigParam('sShopDir'); + $sOXIDTmpDirectory = $sShopHomeDirectory . 'tmp/'; + $this->_setPathToOXIDTmpDirectory($sOXIDTmpDirectory); + } + + return $this->_sPathToOXIDTmpDirectory; + } + + /** + * Extracts a given archive into defined directory and optionally deletes the + * archive afterwards. + * + * @param string $sArchiveName Define a valid path to the archive. + * @param string $sExtractIntoDirectory In this directory data are extracted to. + * @param bool $blDeleteArchive Define whether the archive will be deleted after successful extraction. + * + * @return bool $blSuccess + * + * @author tronet GmbH + * @since 7.0.0 + */ + public function extractArchive($sArchiveName, $sExtractIntoDirectory, $blDeleteArchive) + { + $blSuccess = false; + $oZipArchive = new ZipArchive(); + $res = $oZipArchive->open($sArchiveName); + + if ($res === true) + { + $oZipArchive->extractTo($sExtractIntoDirectory); + $oZipArchive->close(); + $blSuccess = true; + } + + if ($blDeleteArchive) + { + unlink($sArchiveName); + } + + return $blSuccess; + } + + /** + * Copies data from source to target directory. + * + * @param string $sSourceDirectory Data to be copied. + * @param string $sTargetDirectory Directory in what data will be copied. + * + * @return mixed $mReturn + * @author tronet GmbH + * @since 7.0.0 + */ + public function copyDirectory($sSourceDirectory, $sTargetDirectory) + { + if (is_dir($sSourceDirectory) && is_dir($sTargetDirectory)) + { + $mReturn = true; + + $aSplFileInfo = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath($sSourceDirectory)), RecursiveIteratorIterator::LEAVES_ONLY); + + foreach ($aSplFileInfo as $sName => $sFile) + { + if (!$sFile->isdir()) + { + $sFilePath = $sFile->getRealPath(); + $sRelativePath = substr($sFilePath, strlen(realpath($sSourceDirectory)) + 1); + + $sTargetLocation = $sTargetDirectory . $sRelativePath; + $sSourceLocation = $sSourceDirectory . '/' . $sRelativePath; + copy($sSourceLocation, $sTargetLocation); + } + } + } + else + { + $mReturn = false; + } + + return $mReturn; + } + + /** + * Clears the OXID tmp/* directory. + * + * @author tronet GmbH + * @since 7.0.0 + */ + public function clearOxidTmpDirectory() + { + $sShopHomeDir = $this->getConfig()->getConfigParam('sShopDir'); + $sShopTmpDir = $sShopHomeDir . 'tmp'; + $this->clearTempDirectory($sShopTmpDir, true); + } + + /** + * @param string $sDirectory directory to clean + * @param bool $blRecursiveCleaning + * + * @author tronet GmbH + * @since 7.0.0 + */ + public function clearTempDirectory($sDirectory, $blRecursiveCleaning) + { + $dir = opendir($sDirectory); + while (false !== ($file = readdir($dir))) + { + if (($file != '.') && ($file != '..') && ($file[0] != '.')) + { + $full = $sDirectory . '/' . $file; + if (is_dir($full)) + { + $this->clearTempDirectory($full, $blRecursiveCleaning); + } + else + { + unlink($full); + } + } + } + closedir($dir); + + $sDirectoryFormat1 = str_replace(array( + '\\', + '/', + ), DIRECTORY_SEPARATOR, $sDirectory); + $sShopPathFormat1 = str_replace(array( + '\\', + '//', + ), DIRECTORY_SEPARATOR, getShopBasePath()) . 'tmp'; + + if ($sDirectoryFormat1 != $sShopPathFormat1) + { + rmdir($sDirectory); + } + } + } \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/library/about-library.txt b/src/copy_this/modules/tronet/trosofortueberweisung/library/about-library.txt new file mode 100644 index 0000000..6ad92f7 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/library/about-library.txt @@ -0,0 +1,10 @@ +# Description of the directory "library": + +## This directory contains following files and subdirectories: + +[FILE/DIRECTORY] [DESCRIPTION] +core Files provided by SOFORT +payment Files provided by SOFORT +sql Contains sql data required for this module. +translations Storage for translation files. In the original language files are includes, + pointing to this directory. \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/library/core/abstractDataHandler.php b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/abstractDataHandler.php new file mode 100644 index 0000000..2a367da --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/abstractDataHandler.php @@ -0,0 +1,248 @@ +setConfigKey($configKey); + } + + + /** + * Getter for the ApiKey + * + * @return string + */ + public function getApiKey() { + return $this->_apiKey; + } + + + /** + * Returns the connection, normally a http instance + * + * @return Connection Object + */ + public function getConnection() { + return $this->_Connection; + } + + + /** + * Getter for the ProjectId + * + * @return string + */ + public function getProjectId() { + return $this->_projectId; + } + + + /** + * Getter for the raw Request Data + * + * @return string + */ + public function getRawRequest() { + return $this->_rawRequest; + } + + + /** + * Getter for the raw Response Data + * + * @return string + */ + public function getRawResponse() { + return $this->_rawResponse; + } + + + /** + * Getter for the Request + * + * @return mixed + */ + public function getRequest() { + return $this->_request; + } + + + /** + * Getter for the Response + * + * @return mixed + */ + public function getResponse() { + return $this->_response; + } + + + /** + * Getter for the userId + * + * @return string + */ + public function getUserId() { + return $this->_userId; + } + + + abstract function handle($data); + + + abstract function sendMessage($data); + + + /** + * Setter for the ApiKey + * + * @param string $apiKey + * @return AbstractDataHandler $this + */ + public function setApiKey($apiKey) { + $this->_apiKey = $apiKey; + + return $this; + } + + + /** + * Setting the configKey and extracting userId, projectId and apiKey from configKey + * + * @param string $configKey + * @return AbstractDataHandler $this + */ + public function setConfigKey($configKey) { + $this->_configKey = $configKey; + list($this->_userId, $this->_projectId, $this->_apiKey) = explode(':', $configKey); + + return $this; + } + + + /** + * Setting the connection (standard: http instance) and the configkey + * + * @param string $Connection + * @return AbstractDataHandler $this + */ + public function setConnection($Connection) { + $this->_Connection = $Connection; + $this->_Connection->setConfigKey($this->_configKey); + + return $this; + } + + + /** + * Setter for the projectId + * + * @param string $projectId + * @return AbstractDataHandler $this + */ + public function setProjectId($projectId) { + $this->_projectId = $projectId; + + return $this; + } + + + /** + * Setter for the userId + * + * @param string $userId + * @return AbstractDataHandler $this + */ + public function setUserId($userId) { + $this->_userId = $userId; + + return $this; + } +} \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/library/core/abstractLoggerHandler.php b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/abstractLoggerHandler.php new file mode 100644 index 0000000..ba631ba --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/abstractLoggerHandler.php @@ -0,0 +1,16 @@ +_logfilePath = ($path != '') ? $path : dirname(__FILE__).'/logs/log.txt'; + $this->_errorLogfilePath = dirname(__FILE__).'/logs/error_log.txt'; + $this->_warningsLogfilePath = dirname(__FILE__).'/logs/warning_log.txt'; + } + + + /** + * Setting a log entry + * + * @param string $message + * @param string $log (default = 'log') + * @return bool + */ + public function log($message, $log = 'log') { + return $this->_log($message, $log); + } + + + /** + * Set the path of the logfile + * + * @param string $path + * @return void + */ + public function setLogfilePath($path) { + $this->_logfilePath = $path; + } + + + /** + * Logs $msg to a file which path is being set by it's unified resource locator + * + * @param string $message + * @param string $log (default = 'log') + * @return bool + */ + protected function _log($message, $log = 'log') { + switch ($log) { + case 'error': + $file = $this->_errorLogfilePath; + break; + case 'warning': + $file = $this->_warningsLogfilePath; + break; + default: + case 'log': + $file = $this->_logfilePath; + } + + if(!is_file($file)) { + $this->fp = fopen($file, 'w'); + fclose($this->fp); + } + + if (is_writable($file)) { + if ($log == 'log' && $this->_logRotate()) { + $this->fp = fopen($file, 'w'); + fclose($this->fp); + } + + $this->fp = fopen($file, 'a'); + fwrite($this->fp, '['.date('Y-m-d H:i:s').'] '.$message."\n"); + fclose($this->fp); + + return true; + } + + return false; + } + + + /** + * Copy the content of the logfile to a backup file if file size got too large + * Put the old log file into a tarball for later reference + * + * @return bool + */ + protected function _logRotate() { + if (!is_writable($this->_logfilePath)) { + return false; + } + + $date = date('Y-m-d_h-i-s', time()); + + if (file_exists($this->_logfilePath)) { + if ($this->fp != null + && filesize($this->_logfilePath) != false + && filesize($this->_logfilePath) >= $this->maxFilesize) { + $oldUri = $this->_logfilePath; + // file ending + $ending = $ext = pathinfo($oldUri, PATHINFO_EXTENSION); + $newUri = dirname($oldUri).'/log_'.$date.'.'.$ending; + rename($oldUri, $newUri); + + if (file_exists($oldUri)) { + unlink($oldUri); + } + + return true; + } + } + + return false; + } +} \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/arrayToXml.php b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/arrayToXml.php new file mode 100644 index 0000000..247e76f --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/arrayToXml.php @@ -0,0 +1,249 @@ + 50) { + throw new ArrayToXmlException('Max depth too high.'); + } + + $this->_maxDepth = $maxDepth; + + if (count($input) == 1) { + $tagName = key($input); + $SofortTag = new SofortTag( + $tagName, + $this->_extractAttributesSection($input[$tagName]), + $this->_extractDataSection($input[$tagName],$trim) + ); + $this->_render($input[$tagName], $SofortTag, 1, $trim); + $this->_parsedData = $SofortTag->render(); + } elseif(!$input) { + $this->_parsedData = ''; + } else { + throw new ArrayToXmlException('No valid input.'); + } + } + + + /** + * Static entry point. Options are: + * - version: (default 1.0) version string to put in xml prolog + * - encoding: (default UTF-8) use the specified encoding + * - trim: (default true) Trim values + * - depth: (default 10) Maximum depth to parse the given array, throws exception when exceeded + * + * @param array $input the input array + * @param array $options set additional options to pass to XmlToArray + * @throws ArrayToXmlException + * @return string + */ + public static function render(array $input, array $options = array()) { + $options = array_merge(array( + 'version' => '1.0', + 'encoding' => 'UTF-8', + 'trim' => true, + 'depth' => 10, + ), + $options + ); + $Instance = new ArrayToXml($input, $options['depth'], $options['trim']); + + return $Instance->toXml($options['version'], $options['encoding']); + } + + + /** + * Returns parsed array as XML structure + * Pass both params as null to exclude prologue + * + * @param string $version (default 1.0) + * @param string $encoding (default UTF-8) + * @return string + */ + public function toXml($version = '1.0', $encoding = 'UTF-8') { + return !$version && !$encoding + ? $this->_parsedData + : "\n{$this->_parsedData}"; + } + + + /** + * Checks if current depth is exceeded + * + * @param int $currentDepth + * @throws ArrayToXmlException if depth is exceeded + * @return void + */ + private function _checkDepth($currentDepth) { + if ($this->_maxDepth && $currentDepth > $this->_maxDepth) { + throw new ArrayToXmlException("Max depth ({$this->_maxDepth}) exceeded"); + } + } + + + /** + * Creates a new XML node + * + * @param string $name + * @param array $attributes + * @param array $children + * @return SofortTag + */ + private function _createNode($name, array $attributes, array $children) { + return new SofortTag($name, $attributes, $children); + } + + + /** + * Creates a new text node + * + * @param string $text + * @param bool $trim + * @return SofortText + */ + private function _createTextNode($text, $trim) { + return new SofortText($text, true, $trim); + } + + + /** + * Extracts the attributes section from a XmlToArray'd structure + * + * @param mixed $node (reference) + * @return array + */ + private function _extractAttributesSection(&$node) { + $attributes = array(); + + if (is_array($node) && isset($node['@attributes']) && $node['@attributes']) { + $attributes = is_array($node['@attributes']) ? $node['@attributes'] : array($node['@attributes']); + unset($node['@attributes']); + } elseif (is_array($node) && isset($node['@attributes'])) { + unset($node['@attributes']); + } + + return $attributes; + } + + + /** + * Extracts the data section from a XmlToArray'd structure + * + * @param mixed $node (reference) + * @param bool $trim + * @return array + */ + private function _extractDataSection(&$node, $trim) { + $children = array(); + + if (is_array($node) && isset($node['@data']) && $node['@data']) { + $children = array($this->_createTextNode($node['@data'], $trim)); + unset($node['@data']); + } elseif (is_array($node) && isset($node['@data'])) { + unset($node['@data']); + } + + return $children; + } + + + /** + * Recursively renders a XmlToArray'd structure into an object notation + * + * @param mixed $input + * @param SofortTag $ParentTag + * @param int $currentDepth + * @param bool $trim + * @return void + */ + private function _render($input, SofortTag $ParentTag, $currentDepth, $trim) { + $this->_checkDepth($currentDepth); + + if (is_array($input)) { + foreach ($input as $tagName => $data) { + $dataIsArray = is_array($data); + $dataIsArrayKeyDataIsInt = $dataIsArray && is_int(key($data)); + + if ($dataIsArrayKeyDataIsInt) { + $this->_checkDepth($currentDepth+1); + + foreach ($data as $line) { + $currentDepth = $this->_renderNode($tagName, $line, $ParentTag, $trim, $currentDepth); + } + } else { + $currentDepth = $this->_renderNode($tagName, $data, $ParentTag, $trim, $currentDepth); + } + } + + return; + } + + $ParentTag->children[] = $this->_createTextNode($input, $trim); + } + + + + /** + * Renders a single Node of the structure + * + * @param string $tagName + * @param string $data + * @param SofortTag $ParentTag + * @param int $trim + * @param int $currentDepth + * @return int + */ + private function _renderNode($tagName, $data, SofortTag $ParentTag, $trim, $currentDepth) { + $attributes = $this->_extractAttributesSection($data); + + if (is_array($data)) { + $Tag = $this->_createNode($tagName, $attributes, $this->_extractDataSection($data, $trim)); + $ParentTag->children[] = $Tag; + $this->_render($data, $Tag, $currentDepth+1, $trim); + } elseif (is_numeric($tagName)) { + $ParentTag->children[] = $this->_createTextNode($data, $trim); + } else { + $ParentTag->children[] = $this->_createNode($tagName, $attributes, array($this->_createTextNode($data, $trim))); + } + + return $currentDepth; + } +} \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/arrayToXmlException.php b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/arrayToXmlException.php new file mode 100644 index 0000000..eb6edac --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/arrayToXmlException.php @@ -0,0 +1,10 @@ +tagname = $tagname; + $this->attributes = $attributes; + $this->children = is_array($children) ? $children : array($children); + } + + + /** + * Renders the element (override) + * + * @see SofortElement::render() + * @return string + */ + public function render() { + $output = ''; + $attributes = ''; + + foreach ($this->children as $child) { + $output .= is_object($child) ? $child->render() : $child; + } + + foreach ($this->attributes as $key => $value) { + $attributes .= " $key=\"$value\""; + } + + return $this->_render($output, $attributes); + } + + + /** + * Render the output + * + * @param string $output + * @param string $attributes + * @return string + */ + protected function _render($output, $attributes) { + return $output !== '' + ? "<{$this->tagname}{$attributes}>{$output}tagname}>" + : "<{$this->tagname}{$attributes} />"; + } +} \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/elements/sofortText.php b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/elements/sofortText.php new file mode 100644 index 0000000..30e90cb --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/elements/sofortText.php @@ -0,0 +1,52 @@ +text = $trim ? trim($text) : $text; + $this->escape = $escape; + } + + + /** + * Renders the element (override) + * + * @see SofortElement::render() + * @return string + */ + public function render() { + return $this->escape ? htmlspecialchars($this->text) : $this->text; + } +} \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/xmlToArray.php b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/xmlToArray.php new file mode 100644 index 0000000..9254bb0 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/library/core/lib/xmlToArray.php @@ -0,0 +1,235 @@ + '€', + ); + + /** + * stop parsing when maxDepth is exceeded, defaults to no maximum (=0). + * + * @var int $_maxDepth + */ + private $_maxDepth = 0; + + /** + * Object reference for logging purposes + * + * @var Object $_Object + */ + private $_Object = null; + + /** + * Holds start tags in a row. + * Used for error reporting and counting the current depth + * + * @var array $_tagStack + */ + private $_tagStack = array(); + + + /** + * Loads XML into array representation. + * + * @param string $input + * @param int $maxDepth (default 20) + * @throws XmlToArrayException + * @return \XmlToArray + */ + public function __construct($input, $maxDepth = 20) { + if (!is_string($input)) throw new XmlToArrayException('No valid input.'); + $this->_maxDepth = $maxDepth; + + $XMLParser = xml_parser_create(); + xml_parser_set_option($XMLParser, XML_OPTION_SKIP_WHITE, false); + xml_parser_set_option($XMLParser, XML_OPTION_CASE_FOLDING, false); + xml_parser_set_option($XMLParser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); + xml_set_character_data_handler($XMLParser, array($this, '_contents')); + xml_set_default_handler($XMLParser, array($this, '_default')); + xml_set_element_handler($XMLParser, array($this, '_start'), array($this, '_end')); + + if (!xml_parse($XMLParser, $input, true)) { + $errorCode = xml_get_error_code($XMLParser); + $message = sprintf('%s. line: %d, char: %d'.($this->_tagStack ? ', tag: %s' : ''), + xml_error_string($errorCode), + xml_get_current_line_number($XMLParser), + xml_get_current_column_number($XMLParser)+1, + implode('->', $this->_tagStack)); + xml_parser_free($XMLParser); + throw new XmlToArrayException($message, $errorCode); + } + + xml_parser_free($XMLParser); + } + + + /** + * Log messages (debugging purpose) + * + * @param string $msg + * @param int $type (default 2) + * @return array|bool + */ + public function log($msg, $type = 2) { + if (class_exists('Object')) { + !($this->_Object instanceof Object) && $this->_Object = new Object(); + + return $this->_Object->log($msg, $type); + } + + return false; + } + + + /** + * Static entry point + * + * @param string $input + * @param bool $simpleStructure (default false) + * @param int $maxDepth only parse XML to the provided depth (default 20) + * @throws XmlToArrayException + * @return array + */ + public static function render($input, $simpleStructure = false, $maxDepth = 20) { + $Instance = new XmlToArray($input, $maxDepth); + + return $Instance->toArray($simpleStructure); + } + + + /** + * Returns parsed XML as array structure + * + * @param bool $simpleStructure (default false) + * @return array + */ + public function toArray($simpleStructure = false) { + return $this->_CurrentXmlToArrayNode->render($simpleStructure); + } + + + /** + * Handles cdata of the XML (user data between the tags) + * + * @param resource $parser a resource handle of the XML parser + * @param string $data + * @return void + */ + private function _contents($parser, $data) { + if (trim($data) !== '' && $this->_CurrentXmlToArrayNode instanceof XmlToArrayNode) { + $this->_CurrentXmlToArrayNode->setData($data); + } + } + + + /** + * Default handler for all other XML sections not implemented as callback + * + * @param resource $parser a resource handle of the XML parser + * @param mixed $data + * @throws XmlToArrayException + * @return void + */ + private function _default($parser, $data) { + $data = trim($data); + + if (in_array($data, get_html_translation_table(HTML_ENTITIES))) { + if ($this->_CurrentXmlToArrayNode instanceof XmlToArrayNode) { + $this->_CurrentXmlToArrayNode->setData(html_entity_decode($data)); + } + } elseif ($data && isset(self::$_htmlEntityExceptions[$data])) { + if ($this->_CurrentXmlToArrayNode instanceof XmlToArrayNode) { + $this->_CurrentXmlToArrayNode->setData(self::$_htmlEntityExceptions[$data]); + } + } elseif ($data && is_string($data) && strpos($data, ' +
+ + [{if $oViewConf->getActLanguageAbbr() == 'de'}] + [{oxmultilang ident= + [{else}] + [{oxmultilang ident= + [{/if}] + +
+ diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/out/blocks/trosofortueberweisung_paymentSelector.tpl b/src/copy_this/modules/tronet/trosofortueberweisung/out/blocks/trosofortueberweisung_paymentSelector.tpl new file mode 100644 index 0000000..deaa5ed --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/out/blocks/trosofortueberweisung_paymentSelector.tpl @@ -0,0 +1,36 @@ +[{*oxscript include="js/widgets/oxagbcheck.js" priority=10 *}] +[{if $sPaymentID == "trosofortgateway_su"}] +
+
+ getCheckedPaymentId() == $paymentmethod->oxpayments__oxid->value}]checked[{/if}]> + +
+
+
+ [{assign var="oTroConfig" value=$oView->getConfig()}] + [{assign var="blTroGateWayShowLogoInDeliverAndPayment" value=$oTroConfig->getConfigParam('blTroGateWayShowLogoInDeliverAndPayment')}] + + [{if $blTroGateWayShowLogoInDeliverAndPayment}] + [{if $oViewConf->getActLanguageAbbr() == 'de'}] + + [{oxmultilang ident= + + [{else}] + + + + + + + +
[{oxmultilang ident=
[{oxmultilang ident="TRO_SOFORT_BANNER_IMG_SUFFIX"}]
+ [{/if}] + [{/if}] + [{$paymentmethod->oxpayments__oxlongdesc->getRawValue()}] +
+
+
+[{else}] + [{$smarty.block.parent}] +[{/if}] \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/out/src/css/trosofortueberweisung.css b/src/copy_this/modules/tronet/trosofortueberweisung/out/src/css/trosofortueberweisung.css new file mode 100644 index 0000000..831e503 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/out/src/css/trosofortueberweisung.css @@ -0,0 +1,6 @@ +#payment_form_sofortueberweisung ul { + padding-left: 20px; +} +#payment_form_sofortueberweisung li { + list-style-type: disc; +} diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/translations/de/trosofortueberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/translations/de/trosofortueberweisung_lang.php new file mode 100644 index 0000000..38d14ab --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/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/translations/en/trosofortueberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/translations/en/trosofortueberweisung_lang.php new file mode 100644 index 0000000..ebcbff3 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/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/views/admin/de/trosofortuberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/views/admin/de/trosofortuberweisung_lang.php new file mode 100644 index 0000000..fd31463 --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/views/admin/de/trosofortuberweisung_lang.php @@ -0,0 +1,29 @@ +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); \ No newline at end of file diff --git a/src/copy_this/modules/tronet/trosofortueberweisung/views/admin/en/trosofortueberweisung_lang.php b/src/copy_this/modules/tronet/trosofortueberweisung/views/admin/en/trosofortueberweisung_lang.php new file mode 100644 index 0000000..40dd3be --- /dev/null +++ b/src/copy_this/modules/tronet/trosofortueberweisung/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); \ No newline at end of file diff --git a/src/copy_this/modules/tronet/vendormetadata.php b/src/copy_this/modules/tronet/vendormetadata.php new file mode 100644 index 0000000..bb6ceff --- /dev/null +++ b/src/copy_this/modules/tronet/vendormetadata.php @@ -0,0 +1,20 @@ +