Example #1
0
 /**
  * Confirmation of the request
  */
 public function execute($config)
 {
     // Post strings
     $xml_post_string_one = '<request><EventType>ConfirmMeter</EventType><event><DeviceId>' . $config['DeviceId'] . '</DeviceId><DeviceSer>' . $config['DeviceSer'] . '</DeviceSer><UserPin>' . $config['UserPin'] . '</UserPin><MeterNum>' . $this->meterNumber . '</MeterNum><Amount>0</Amount><Reference></Reference></event></request>' . PHP_EOL;
     $xml_post_string_two = '<request><SessionId></SessionId><EventType>Reprint</EventType><event><TransRef>' . $this->transref . '</TransRef><MeterNum>' . $this->meterNumber . '</MeterNum><OrigReference>' . $this->reference . '</OrigReference></event></request>' . PHP_EOL;
     // Create a TCP/IP socket
     $socket = new \CodeChap\Aeon\Socket($config);
     // STEP 1. Authenticate //
     // Send confirmation request
     $socket->write($xml_post_string_one);
     // Get result of send
     $result_one = $socket->get();
     // STEP 2. Reprint //
     // Find session id field
     preg_match('/<SessionId>(.*)<\\/SessionId>/', $result_one, $SessionId);
     // Swop in Session ID
     $xml_post_string_two = preg_replace('/<SessionId><\\/SessionId>/', $SessionId[0], $xml_post_string_two);
     // Send confirmation request
     $socket->write($xml_post_string_two);
     // Get result of send
     $result = $socket->get();
     // Done
     $finalResult = \LSS\XML2Array::createArray($result);
     // Return usefull data
     return $finalResult['response'];
 }
Example #2
0
 /**
  * Confirmation of the request
  */
 public function execute($config)
 {
     // Post strings
     $xml_post_string_one = '<request><EventType>Authentication</EventType><event><DeviceId>' . $config['DeviceId'] . '</DeviceId><DeviceSer>' . $config['DeviceSer'] . '</DeviceSer><UserPin>' . $config['UserPin'] . '</UserPin><TransType>AccountInfo</TransType><Reference>' . $this->reference . '</Reference></event></request>' . PHP_EOL;
     // Create a TCP/IP socket
     $socket = new \CodeChap\Aeon\Socket($config);
     // Send confirmation request
     $socket->write($xml_post_string_one);
     // Get result of send
     $result = $socket->get();
     // Done
     $finalResult = \LSS\XML2Array::createArray($result);
     // Return usefull data
     return $finalResult['response'];
 }
Example #3
0
 /**
  * Confirmation of the request
  */
 public function execute($config)
 {
     // Set path to temp file
     $filePath = $this->getTemp() . md5($this->meternumber) . ".xml";
     // Open it
     if ($xml = file_get_contents($filePath)) {
         // Create a TCP/IP socket
         $socket = new \CodeChap\Aeon\Socket($config);
         // Send confirmation request
         $socket->write($xml);
         // Get result of send
         $result = $socket->get();
         // Done
         $finalResult = \LSS\XML2Array::createArray($result);
         // Return usefull data
         return $finalResult['response'];
     }
 }
Example #4
0
 /**
  * Execute the call
  */
 public function execute($config)
 {
     // Post strings
     $xml_post_string_one = '<request><EventType>ConfirmMeter</EventType><event><DeviceId>' . $config['DeviceId'] . '</DeviceId><DeviceSer>' . $config['DeviceSer'] . '</DeviceSer><UserPin>' . $config['UserPin'] . '</UserPin><MeterNum>' . $this->meterNumber . '</MeterNum><Amount>' . $this->credit . '</Amount><Reference>' . $this->reference . '</Reference></event></request>' . PHP_EOL;
     $xml_post_string_two = '<request><SessionId></SessionId><EventType>GetVoucher</EventType><event><Type></Type><TransRef></TransRef><Reference>' . $this->reference . '</Reference></event></request>' . PHP_EOL;
     // Create step three's confirmation settings
     $xml_post_string_thr = '<request><EventType>SoldVoucher</EventType><event><DeviceId>' . $config['DeviceId'] . '</DeviceId><DeviceSer>' . $config['DeviceSer'] . '</DeviceSer><UserPin>' . $config['UserPin'] . '</UserPin><TransRef></TransRef><Reference>' . $this->reference . '</Reference></event></request>' . PHP_EOL;
     // Create a TCP/IP socket
     $socket = new \CodeChap\Aeon\Socket($config);
     // STEP 1. AUTHENTICATE //
     // Send confirmation request
     $socket->write($xml_post_string_one);
     // Get result of send
     $result_one = $socket->get();
     // STEP 2. BUY //
     // Find session id field
     preg_match('/<SessionId>(.*)<\\/SessionId>/', $result_one, $SessionId);
     // Find transfer reference field
     preg_match('/<TransRef>(.*)<\\/TransRef>/', $result_one, $TransRef);
     // Swop in Session ID and transfer ref with first result
     $xml_post_string_two = preg_replace('/<SessionId><\\/SessionId>/', $SessionId[0], $xml_post_string_two);
     $xml_post_string_two = preg_replace('/<TransRef><\\/TransRef>/', $TransRef[0], $xml_post_string_two);
     // Send voucher request
     $socket->write($xml_post_string_two);
     // Get result of send
     $result_two = $socket->get();
     // Shutdown and close the socket
     $socket->close();
     // Done
     $finalResult = \LSS\XML2Array::createArray($result_two);
     // STEP 3. Confirmation (To be performed by user later so we store it in a temp file) //
     // Find transfer reference field
     preg_match('/<TransRef>(.*)<\\/TransRef>/', $result_two, $TransRef);
     // Swop in transfer reference
     $xml_post_string_thr = preg_replace('/<TransRef><\\/TransRef>/', $TransRef[0], $xml_post_string_thr);
     // Store this xml string in the php temp folder
     if ($file = fopen($this->getTemp() . md5($this->meterNumber) . ".xml", "w")) {
         fwrite($file, $xml_post_string_thr);
         fclose($file);
     }
     // Return usefull data
     return $finalResult['response'];
 }