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