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