dyn_trusted.php

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',
00011                                         'CREDIT_CARD',
00012                                         'INVOICE',
00013                                         'CASH_ON_DELIVERY',
00014                                         'PREPAYMENT',
00015                                         'CHEQUE',
00016                                         'PAYBOX',
00017                                         'PAYPAL',
00018                                         'AMAZON_PAYMENTS',
00019                                         'CASH_ON_PICKUP',
00020                                         'FINANCING',
00021                                         'LEASING',
00022                                         'T_PAY',
00023                                         'CLICKANDBUY',
00024                                         'GIROPAY',
00025                                         'GOOGLE_CHECKOUT',
00026                                         'SHOP_CARD',
00027                                         'DIRECT_E_BANKING',
00028                                         'MONEYBOOKERS',
00029                                         'DOTPAY',
00030                                         'PRZELEWY24',
00031                                         'OTHER'
00032                                     );
00033 
00040     public function render()
00041     {
00042         parent::render();
00043         $this->_aViewData['oxid'] = $this->getConfig()->getShopId();
00044         $aConfStr = array();
00045         $aConfBool = array();
00046         $aIds     = $this->_aViewData["confaarrs"]['iShopID_TrustedShops'];
00047         // compability to old data
00048         if ( $aConfStrs = $this->_aViewData["str"]['iShopID_TrustedShops'] ) {
00049             $aIds = array( 0 => $aConfStrs );
00050         }
00051 
00052         $this->_aViewData["aShopID_TrustedShops"] = $aIds;
00053         $this->_aViewData['aTsUser'] = $this->_aViewData["confaarrs"]['aTsUser'];
00054         $this->_aViewData['aTsPassword'] = $this->_aViewData["confaarrs"]['aTsPassword'];
00055         $this->_aViewData['tsTestMode'] = $this->_aViewData["confbools"]['tsTestMode'];
00056         $this->_aViewData['tsSealActive'] = $this->_aViewData["confbools"]['tsSealActive'];
00057         $this->_aViewData["alllang"] = oxRegistry::getLang()->getLanguageNames();
00058         $this->_aViewData["shoppaymenttypes"] = $this->getPaymentTypes();
00059         $this->_aViewData["tspaymenttypes"] = $this->_aTSPaymentIds;
00060 
00061         return "dyn_trusted.tpl";
00062     }
00063 
00069     public function save()
00070     {
00071         $this->_saveTsPaymentId();
00072 
00073         $aConfStr = oxConfig::getParameter( "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 if ( $oResults && $oResults->stateEnum == "INTEGRATION" ) {
00084                     $sErrorMessage = $oResults->stateEnum;
00085                     $sTsType[$sKey] = $oResults->typeEnum;
00086                 } else {
00087                     if ( $oResults ) {
00088                         $sErrorMessage = $oResults->stateEnum;
00089                     }
00090                     $blSave = false;
00091                 }
00092             }
00093         }
00094 
00095         $aTSIds = array_filter( $aConfStr );
00096         if ( $blNotEmpty && ( count( array_unique( $aTSIds ) ) < count( $aTSIds ) ) ) {
00097             $blSave = false;
00098         }
00099 
00100         if ( $blSave ) {
00101             $myConfig = $this->getConfig();
00102             $sShopId = $myConfig->getShopId();
00103             $myConfig->saveShopConfVar( "aarr", 'iShopID_TrustedShops', $aConfStr, $sShopId );
00104             $myConfig->saveShopConfVar( "aarr", 'aTsUser', oxConfig::getParameter( "aTsUser" ), $sShopId );
00105             $myConfig->saveShopConfVar( "aarr", 'aTsPassword', oxConfig::getParameter( "aTsPassword" ), $sShopId );
00106             $myConfig->saveShopConfVar( "bool", 'tsTestMode', oxConfig::getParameter( "tsTestMode" ), $sShopId );
00107             $myConfig->saveShopConfVar( "bool", 'tsSealActive', oxConfig::getParameter( "tsSealActive" ), $sShopId );
00108             $myConfig->saveShopConfVar( "aarr", 'tsSealType', $sTsType, $sShopId );
00109         } else {
00110             // displaying error..
00111             $this->_aViewData["errorsaving"] = 1;
00112             $this->_aViewData["errormessage"] = $sErrorMessage;
00113             $this->_aViewData["aShopID_TrustedShops"] = null;
00114         }
00115     }
00116 
00122     public function getViewId()
00123     {
00124         return 'dyn_interface';
00125     }
00126 
00132     public function getPaymentTypes()
00133     {
00134         if ( $this->_oPaymentTypes == null ) {
00135 
00136             // all paymenttypes
00137             $this->_oPaymentTypes = oxNew( "oxlist" );
00138             $this->_oPaymentTypes->init( "oxpayment");
00139             $oListObject = $this->_oPaymentTypes->getBaseObject();
00140             $oListObject->setLanguage( oxRegistry::getLang()->getObjectTplLanguage() );
00141             $this->_oPaymentTypes->getList();
00142         }
00143         return $this->_oPaymentTypes;
00144     }
00145 
00153     protected function _checkTsId( $sConfStrs )
00154     {
00155         if ( strlen( $sConfStrs ) != 33 || substr( $sConfStrs, 0, 1 ) != 'X' ) {
00156             $blSave = false;
00157         }
00158         $oTsProtection = oxNew("oxtsprotection");
00159         $oResults = $oTsProtection->checkCertificate( $sConfStrs, oxConfig::getParameter( "tsTestMode" ) );
00160         return $oResults;
00161     }
00162 
00168     protected function _saveTsPaymentId()
00169     {
00170         $aPaymentIds = oxConfig::getParameter( "paymentids" );
00171         
00172         if ( $aPaymentIds ) {
00173             foreach ( $aPaymentIds as $sShopPayId => $sTsPayId ) {
00174                 $aPayment = oxNew("oxpayment");
00175                 if ( $aPayment->load($sShopPayId) ) {
00176                     $aPayment->oxpayments__oxtspaymentid = new oxField($sTsPayId);
00177                     $aPayment->save();
00178                 }
00179             }
00180         }
00181     }
00182 
00183 }