OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
dyn_trusted.php
Go to the documentation of this file.
1 <?php
2 
3 
8 class dyn_trusted extends Shop_Config
9 {
10  protected $_aTSPaymentIds = array( 'DIRECT_DEBIT',
11  'CREDIT_CARD',
12  'INVOICE',
13  'CASH_ON_DELIVERY',
14  'PREPAYMENT',
15  'CHEQUE',
16  'PAYBOX',
17  'PAYPAL',
18  'AMAZON_PAYMENTS',
19  'CASH_ON_PICKUP',
20  'FINANCING',
21  'LEASING',
22  'T_PAY',
23  'CLICKANDBUY',
24  'GIROPAY',
25  'GOOGLE_CHECKOUT',
26  'SHOP_CARD',
27  'DIRECT_E_BANKING',
28  'MONEYBOOKERS',
29  'DOTPAY',
30  'PRZELEWY24',
31  'OTHER'
32  );
33 
40  public function render()
41  {
43  $this->_aViewData['oxid'] = $this->getConfig()->getShopId();
44  $aConfStr = array();
45  $aConfBool = array();
46  $aIds = $this->_aViewData["confaarrs"]['iShopID_TrustedShops'];
47  // compability to old data
48  if ( $aConfStrs = $this->_aViewData["str"]['iShopID_TrustedShops'] ) {
49  $aIds = array( 0 => $aConfStrs );
50  }
51 
52  $this->_aViewData["aShopID_TrustedShops"] = $aIds;
53  $this->_aViewData['aTsUser'] = $this->_aViewData["confaarrs"]['aTsUser'];
54  $this->_aViewData['aTsPassword'] = $this->_aViewData["confaarrs"]['aTsPassword'];
55  $this->_aViewData['tsTestMode'] = $this->_aViewData["confbools"]['tsTestMode'];
56  $this->_aViewData['tsSealActive'] = $this->_aViewData["confbools"]['tsSealActive'];
57  $this->_aViewData["alllang"] = oxRegistry::getLang()->getLanguageNames();
58  $this->_aViewData["shoppaymenttypes"] = $this->getPaymentTypes();
59  $this->_aViewData["tspaymenttypes"] = $this->_aTSPaymentIds;
60 
61  return "dyn_trusted.tpl";
62  }
63 
69  public function save()
70  {
71  $this->_saveTsPaymentId();
72 
73  $aConfStr = oxConfig::getParameter( "aShopID_TrustedShops" );
74  $blSave = true;
75  $blNotEmpty = false;
76  foreach ( $aConfStr as $sKey => $sConfStrs ) {
77  if ( $sConfStrs ) {
78  $blNotEmpty = true;
79  $sConfStrs = trim($sConfStrs);
80  $oResults = $this->_checkTsId( $sConfStrs );
81  if ( $oResults && ($oResults->stateEnum == "PRODUCTION" || $oResults->stateEnum == "TEST")) {
82  $sTsType[$sKey] = $oResults->typeEnum;
83  } else if ( $oResults && $oResults->stateEnum == "INTEGRATION" ) {
84  $sErrorMessage = $oResults->stateEnum;
85  $sTsType[$sKey] = $oResults->typeEnum;
86  } else {
87  if ( $oResults ) {
88  $sErrorMessage = $oResults->stateEnum;
89  }
90  $blSave = false;
91  }
92  }
93  }
94 
95  $aTSIds = array_filter( $aConfStr );
96  if ( $blNotEmpty && ( count( array_unique( $aTSIds ) ) < count( $aTSIds ) ) ) {
97  $blSave = false;
98  }
99 
100  if ( $blSave ) {
101  $myConfig = $this->getConfig();
102  $sShopId = $myConfig->getShopId();
103  $myConfig->saveShopConfVar( "aarr", 'iShopID_TrustedShops', $aConfStr, $sShopId );
104  $myConfig->saveShopConfVar( "aarr", 'aTsUser', oxConfig::getParameter( "aTsUser" ), $sShopId );
105  $myConfig->saveShopConfVar( "aarr", 'aTsPassword', oxConfig::getParameter( "aTsPassword" ), $sShopId );
106  $myConfig->saveShopConfVar( "bool", 'tsTestMode', oxConfig::getParameter( "tsTestMode" ), $sShopId );
107  $myConfig->saveShopConfVar( "bool", 'tsSealActive', oxConfig::getParameter( "tsSealActive" ), $sShopId );
108  $myConfig->saveShopConfVar( "aarr", 'tsSealType', $sTsType, $sShopId );
109  } else {
110  // displaying error..
111  $this->_aViewData["errorsaving"] = 1;
112  $this->_aViewData["errormessage"] = $sErrorMessage;
113  $this->_aViewData["aShopID_TrustedShops"] = null;
114  }
115  }
116 
122  public function getViewId()
123  {
124  return 'dyn_interface';
125  }
126 
132  public function getPaymentTypes()
133  {
134  if ( $this->_oPaymentTypes == null ) {
135 
136  // all paymenttypes
137  $this->_oPaymentTypes = oxNew( "oxlist" );
138  $this->_oPaymentTypes->init( "oxpayment");
139  $oListObject = $this->_oPaymentTypes->getBaseObject();
140  $oListObject->setLanguage( oxRegistry::getLang()->getObjectTplLanguage() );
141  $this->_oPaymentTypes->getList();
142  }
143  return $this->_oPaymentTypes;
144  }
145 
153  protected function _checkTsId( $sConfStrs )
154  {
155  if ( strlen( $sConfStrs ) != 33 || substr( $sConfStrs, 0, 1 ) != 'X' ) {
156  $blSave = false;
157  }
158  $oTsProtection = oxNew("oxtsprotection");
159  $oResults = $oTsProtection->checkCertificate( $sConfStrs, oxConfig::getParameter( "tsTestMode" ) );
160  return $oResults;
161  }
162 
168  protected function _saveTsPaymentId()
169  {
170  $aPaymentIds = oxConfig::getParameter( "paymentids" );
171 
172  if ( $aPaymentIds ) {
173  foreach ( $aPaymentIds as $sShopPayId => $sTsPayId ) {
174  $aPayment = oxNew("oxpayment");
175  if ( $aPayment->load($sShopPayId) ) {
176  $aPayment->oxpayments__oxtspaymentid = new oxField($sTsPayId);
177  $aPayment->save();
178  }
179  }
180  }
181  }
182 
183 }