OXID eShop CE  4.9.9
 All Classes Files Functions Variables Pages
oxonlinelicensecheckcaller.php
Go to the documentation of this file.
1 <?php
2 
12 {
13 
15  const WEB_SERVICE_URL = 'https://olc.oxid-esales.com/check.php';
16 
18  const XML_DOCUMENT_NAME = 'olcRequest';
19 
25  private $_sResponseElement = 'olc';
26 
35  public function doRequest(oxOnlineLicenseCheckRequest $oRequest)
36  {
37  $sResponse = $this->call($oRequest);
38 
39  return $this->_formResponse($sResponse);
40  }
41 
49  protected function _formEmail($oRequest)
50  {
51  $oRequest->keys = null;
52 
53  return parent::_formEmail($oRequest);
54  }
55 
65  protected function _formResponse($sRawResponse)
66  {
68  $oUtilsXml = oxRegistry::get("oxUtilsXml");
69  if (empty($sRawResponse) || !($oDomDoc = $oUtilsXml->loadXml($sRawResponse))) {
70  throw new oxException('OLC_ERROR_RESPONSE_NOT_VALID');
71  }
72 
73  if ($oDomDoc->documentElement->nodeName != $this->_sResponseElement) {
74  throw new oxException('OLC_ERROR_RESPONSE_UNEXPECTED');
75  }
76 
77  $oResponseNode = $oDomDoc->firstChild;
78 
79  if (!$oResponseNode->hasChildNodes()) {
80  throw new oxException('OLC_ERROR_RESPONSE_NOT_VALID');
81  }
82 
83  $oNodes = $oResponseNode->childNodes;
84 
86  $oResponse = oxNew('oxOnlineLicenseCheckResponse');
87 
88  // iterate through response node to get response parameters
89  for ($i = 0; $i < $oNodes->length; $i++) {
90  $sNodeName = $oNodes->item($i)->nodeName;
91  $sNodeValue = $oNodes->item($i)->nodeValue;
92  $oResponse->$sNodeName = $sNodeValue;
93  }
94 
95  return $oResponse;
96  }
97 
103  protected function _getXMLDocumentName()
104  {
106  }
107 
113  protected function _getServiceUrl()
114  {
115  return self::WEB_SERVICE_URL;
116  }
117 }