dyn_trusted.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00009 class dyn_trusted extends Shop_Config
00010 {
00011 
00012     protected $_aTSPaymentIds = array('DIRECT_DEBIT',
00013                                       'CREDIT_CARD',
00014                                       'INVOICE',
00015                                       'CASH_ON_DELIVERY',
00016                                       'PREPAYMENT',
00017                                       'CHEQUE',
00018                                       'PAYBOX',
00019                                       'PAYPAL',
00020                                       'AMAZON_PAYMENTS',
00021                                       'CASH_ON_PICKUP',
00022                                       'FINANCING',
00023                                       'LEASING',
00024                                       'T_PAY',
00025                                       'CLICKANDBUY',
00026                                       'GIROPAY',
00027                                       'GOOGLE_CHECKOUT',
00028                                       'SHOP_CARD',
00029                                       'DIRECT_E_BANKING',
00030                                       'MONEYBOOKERS',
00031                                       'DOTPAY',
00032                                       'PRZELEWY24',
00033                                       'OTHER'
00034     );
00035 
00042     public function render()
00043     {
00044         parent::render();
00045         $this->_aViewData['oxid'] = $this->getConfig()->getShopId();
00046         $aConfStr = array();
00047         $aConfBool = array();
00048         $aIds = $this->_aViewData["confaarrs"]['iShopID_TrustedShops'];
00049         // compability to old data
00050         if ($aConfStrs = $this->_aViewData["str"]['iShopID_TrustedShops']) {
00051             $aIds = array(0 => $aConfStrs);
00052         }
00053 
00054         $this->_aViewData["aShopID_TrustedShops"] = $aIds;
00055         $this->_aViewData['aTsUser'] = $this->_aViewData["confaarrs"]['aTsUser'];
00056         $this->_aViewData['aTsPassword'] = $this->_aViewData["confaarrs"]['aTsPassword'];
00057         $this->_aViewData['tsTestMode'] = $this->_aViewData["confbools"]['tsTestMode'];
00058         $this->_aViewData['tsSealActive'] = $this->_aViewData["confbools"]['tsSealActive'];
00059         $this->_aViewData["alllang"] = oxRegistry::getLang()->getLanguageNames();
00060         $this->_aViewData["shoppaymenttypes"] = $this->getPaymentTypes();
00061         $this->_aViewData["tspaymenttypes"] = $this->_aTSPaymentIds;
00062 
00063         return "dyn_trusted.tpl";
00064     }
00065 
00069     public function save()
00070     {
00071         $this->_saveTsPaymentId();
00072 
00073         $aConfStr = oxRegistry::getConfig()->getRequestParameter("aShopID_TrustedShops");
00074         $blSave = true;
00075         $blNotEmpty = false;
00076         foreach ($aConfStr as $sKey => $sConfStrs) {
00077             if ($sConfStrs) {
00078                 $blNotEmpty = true;
00079                 $sConfStrs = trim($sConfStrs);
00080                 $oResults = $this->_checkTsId($sConfStrs);
00081                 if ($oResults && ($oResults->stateEnum == "PRODUCTION" || $oResults->stateEnum == "TEST")) {
00082                     $sTsType[$sKey] = $oResults->typeEnum;
00083                 } else {
00084                     if ($oResults && $oResults->stateEnum == "INTEGRATION") {
00085                         $sErrorMessage = $oResults->stateEnum;
00086                         $sTsType[$sKey] = $oResults->typeEnum;
00087                     } else {
00088                         if ($oResults) {
00089                             $sErrorMessage = $oResults->stateEnum;
00090                         }
00091                         $blSave = false;
00092                     }
00093                 }
00094             }
00095         }
00096 
00097         $aTSIds = array_filter($aConfStr);
00098         if ($blNotEmpty && (count(array_unique($aTSIds)) < count($aTSIds))) {
00099             $blSave = false;
00100         }
00101 
00102         if ($blSave) {
00103             $myConfig = $this->getConfig();
00104             $sShopId = $myConfig->getShopId();
00105             $myConfig->saveShopConfVar("aarr", 'iShopID_TrustedShops', $aConfStr, $sShopId);
00106             $myConfig->saveShopConfVar("aarr", 'aTsUser', oxRegistry::getConfig()->getRequestParameter("aTsUser"), $sShopId);
00107             $myConfig->saveShopConfVar("aarr", 'aTsPassword', oxRegistry::getConfig()->getRequestParameter("aTsPassword"), $sShopId);
00108             $myConfig->saveShopConfVar("bool", 'tsTestMode', oxRegistry::getConfig()->getRequestParameter("tsTestMode"), $sShopId);
00109             $myConfig->saveShopConfVar("bool", 'tsSealActive', oxRegistry::getConfig()->getRequestParameter("tsSealActive"), $sShopId);
00110             $myConfig->saveShopConfVar("aarr", 'tsSealType', $sTsType, $sShopId);
00111         } else {
00112             // displaying error..
00113             $this->_aViewData["errorsaving"] = 1;
00114             $this->_aViewData["errormessage"] = $sErrorMessage;
00115             $this->_aViewData["aShopID_TrustedShops"] = null;
00116         }
00117     }
00118 
00124     public function getViewId()
00125     {
00126         return 'dyn_interface';
00127     }
00128 
00134     public function getPaymentTypes()
00135     {
00136         if ($this->_oPaymentTypes == null) {
00137 
00138             // all paymenttypes
00139             $this->_oPaymentTypes = oxNew("oxlist");
00140             $this->_oPaymentTypes->init("oxpayment");
00141             $oListObject = $this->_oPaymentTypes->getBaseObject();
00142             $oListObject->setLanguage(oxRegistry::getLang()->getObjectTplLanguage());
00143             $this->_oPaymentTypes->getList();
00144         }
00145 
00146         return $this->_oPaymentTypes;
00147     }
00148 
00156     protected function _checkTsId($sConfStrs)
00157     {
00158         $oTsProtection = oxNew("oxtsprotection");
00159         $oResults = $oTsProtection->checkCertificate($sConfStrs, oxRegistry::getConfig()->getRequestParameter("tsTestMode"));
00160 
00161         return $oResults;
00162     }
00163 
00167     protected function _saveTsPaymentId()
00168     {
00169         $aPaymentIds = oxRegistry::getConfig()->getRequestParameter("paymentids");
00170 
00171         if ($aPaymentIds) {
00172             foreach ($aPaymentIds as $sShopPayId => $sTsPayId) {
00173                 $aPayment = oxNew("oxpayment");
00174                 if ($aPayment->load($sShopPayId)) {
00175                     $aPayment->oxpayments__oxtspaymentid = new oxField($sTsPayId);
00176                     $aPayment->save();
00177                 }
00178             }
00179         }
00180     }
00181 }