Go to the documentation of this file.00001 <?php
00002
00003
00008 class dyn_trusted extends Shop_Config
00009 {
00010 protected $_aTSPaymentIds = array('DIRECT_DEBIT','CREDIT_CARD','INVOICE','CASH_ON_DELIVERY','PREPAYMENT','CHEQUE','PAYBOX','PAYPAL','CASH_ON_PICKUP','FINANCING','LEASING','T_PAY','CLICKANDBUY','GIROPAY','GOOGLE_CHECKOUT','SHOP_CARD','DIRECT_E_BANKING','OTHER');
00011
00018 public function render()
00019 {
00020 parent::render();
00021 $this->_aViewData['oxid'] = $this->getConfig()->getShopId();
00022 $aConfStr = array();
00023 $aConfBool = array();
00024 $aIds = $this->_aViewData["confaarrs"]['iShopID_TrustedShops'];
00025
00026 if ( $aConfStrs = $this->_aViewData["str"]['iShopID_TrustedShops'] ) {
00027 $aIds = array( 0 => $aConfStrs );
00028 }
00029
00030 $this->_aViewData["aShopID_TrustedShops"] = $aIds;
00031 $this->_aViewData['aTsUser'] = $this->_aViewData["confaarrs"]['aTsUser'];
00032 $this->_aViewData['aTsPassword'] = $this->_aViewData["confaarrs"]['aTsPassword'];
00033 $this->_aViewData['tsTestMode'] = $this->_aViewData["confbools"]['tsTestMode'];
00034 $this->_aViewData['tsSealActive'] = $this->_aViewData["confbools"]['tsSealActive'];
00035 $this->_aViewData["alllang"] = oxRegistry::getLang()->getLanguageNames();
00036 $this->_aViewData["shoppaymenttypes"] = $this->getPaymentTypes();
00037 $this->_aViewData["tspaymenttypes"] = $this->_aTSPaymentIds;
00038
00039 return "dyn_trusted.tpl";
00040 }
00041
00047 public function save()
00048 {
00049 $this->_saveTsPaymentId();
00050
00051 $aConfStr = oxConfig::getParameter( "aShopID_TrustedShops" );
00052 $blSave = true;
00053 $blNotEmpty = false;
00054 foreach ( $aConfStr as $sKey => $sConfStrs ) {
00055 if ( $sConfStrs ) {
00056 $blNotEmpty = true;
00057 $sConfStrs = trim($sConfStrs);
00058 $oResults = $this->_checkTsId( $sConfStrs );
00059 if ( $oResults && ($oResults->stateEnum == "PRODUCTION" || $oResults->stateEnum == "TEST")) {
00060 $sTsType[$sKey] = $oResults->typeEnum;
00061 } else if ( $oResults && $oResults->stateEnum == "INTEGRATION" ) {
00062 $sErrorMessage = $oResults->stateEnum;
00063 $sTsType[$sKey] = $oResults->typeEnum;
00064 } else {
00065 if ( $oResults ) {
00066 $sErrorMessage = $oResults->stateEnum;
00067 }
00068 $blSave = false;
00069 }
00070 }
00071 }
00072
00073 $aTSIds = array_filter( $aConfStr );
00074 if ( $blNotEmpty && ( count( array_unique( $aTSIds ) ) < count( $aTSIds ) ) ) {
00075 $blSave = false;
00076 }
00077
00078 if ( $blSave ) {
00079 $myConfig = $this->getConfig();
00080 $sShopId = $myConfig->getShopId();
00081 $myConfig->saveShopConfVar( "aarr", 'iShopID_TrustedShops', $aConfStr, $sShopId );
00082 $myConfig->saveShopConfVar( "aarr", 'aTsUser', oxConfig::getParameter( "aTsUser" ), $sShopId );
00083 $myConfig->saveShopConfVar( "aarr", 'aTsPassword', oxConfig::getParameter( "aTsPassword" ), $sShopId );
00084 $myConfig->saveShopConfVar( "bool", 'tsTestMode', oxConfig::getParameter( "tsTestMode" ), $sShopId );
00085 $myConfig->saveShopConfVar( "bool", 'tsSealActive', oxConfig::getParameter( "tsSealActive" ), $sShopId );
00086 $myConfig->saveShopConfVar( "aarr", 'tsSealType', $sTsType, $sShopId );
00087 } else {
00088
00089 $this->_aViewData["errorsaving"] = 1;
00090 $this->_aViewData["errormessage"] = $sErrorMessage;
00091 $this->_aViewData["aShopID_TrustedShops"] = null;
00092 }
00093 }
00094
00100 public function getViewId()
00101 {
00102 return 'dyn_interface';
00103 }
00104
00110 public function getPaymentTypes()
00111 {
00112 if ( $this->_oPaymentTypes == null ) {
00113
00114
00115 $this->_oPaymentTypes = oxNew( "oxlist" );
00116 $this->_oPaymentTypes->init( "oxpayment");
00117 $oListObject = $this->_oPaymentTypes->getBaseObject();
00118 $oListObject->setLanguage( oxRegistry::getLang()->getObjectTplLanguage() );
00119 $this->_oPaymentTypes->getList();
00120 }
00121 return $this->_oPaymentTypes;
00122 }
00123
00131 protected function _checkTsId( $sConfStrs )
00132 {
00133 if ( strlen( $sConfStrs ) != 33 || substr( $sConfStrs, 0, 1 ) != 'X' ) {
00134 $blSave = false;
00135 }
00136 $oTsProtection = oxNew("oxtsprotection");
00137 $oResults = $oTsProtection->checkCertificate( $sConfStrs, oxConfig::getParameter( "tsTestMode" ) );
00138 return $oResults;
00139 }
00140
00146 protected function _saveTsPaymentId()
00147 {
00148 $aPaymentIds = oxConfig::getParameter( "paymentids" );
00149
00150 if ( $aPaymentIds ) {
00151 foreach ( $aPaymentIds as $sShopPayId => $sTsPayId ) {
00152 $aPayment = oxNew("oxpayment");
00153 if ( $aPayment->load($sShopPayId) ) {
00154 $aPayment->oxpayments__oxtspaymentid = new oxField($sTsPayId);
00155 $aPayment->save();
00156 }
00157 }
00158 }
00159 }
00160
00161 }