Ejemplo n.º 1
0
 public static function httpRequest($req, $hash_config = NULL)
 {
     $config = Obj2xml::getConfig($hash_config);
     if ((int) $config['print_xml']) {
         echo $req;
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_PROXY, $config['proxy']);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
     curl_setopt($ch, CURLOPT_URL, $config['url']);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
     curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, $config['timeout']);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     //curl_setopt($ch, CURLOPT_SSLVERSION, 3);
     $output = curl_exec($ch);
     //$responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if (!$output) {
         throw new \Exception(curl_error($ch));
     } else {
         curl_close($ch);
         if ((int) $config['print_xml']) {
             echo $output;
         }
         return $output;
     }
 }
 private function iterateChildren($data, $transacType)
 {
     foreach ($data as $key => $value) {
         if ($value == "REQUIRED") {
             throw new Exception("Missing Required Field: /{$key}/");
         } elseif (is_string($value) || is_numeric($value)) {
             $transacType->addChild($key, $value);
         } elseif (is_array($value)) {
             $node = $transacType->addChild($key);
             Obj2xml::iterateChildren($value, $node);
         }
     }
 }
Ejemplo n.º 3
0
 static function httpRequest($req, $hash_config = NULL)
 {
     $config = Obj2xml::getConfig($hash_config);
     if ((int) $config['print_xml']) {
         echo $req;
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_PROXY, $config['proxy']);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: text/xml'));
     curl_setopt($ch, CURLOPT_URL, $config['url']);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
     curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, true);
     curl_setopt($ch, CURLOPT_TIMEOUT, $config['timeout']);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_SSLVERSION, 6);
     Mage::log("vantiv tracking - ch: " . print_r($ch, true), null, "litle_transaction.log");
     if (Mage::getStoreConfig('payment/CreditCard/debug_enable')) {
         $xmlToPrint = Communication::cleanseAccountNumber($req);
         $xmlToPrint = Communication::cleanseCardValidationNum($xmlToPrint);
         $xmlToPrint = Communication::cleansePassword($xmlToPrint);
         Mage::log($xmlToPrint, null, "litle_transaction.log");
     }
     $output = curl_exec($ch);
     Mage::log("vantiv tracking - output: " . print_r($output, true), null, "litle_transaction.log");
     if (Mage::getStoreConfig('payment/CreditCard/debug_enable')) {
         $xmlToPrint = Communication::cleanseAccountNumber($output);
         Mage::log($xmlToPrint, null, "litle_transaction.log");
     }
     $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     if (!$output) {
         throw new Exception(curl_error($ch));
     } else {
         curl_close($ch);
         return $output;
     }
 }
Ejemplo n.º 4
0
 private function processRequest($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)
 {
     $hash_config = LitleOnlineRequest::overideconfig($hash_in);
     $hash = LitleOnlineRequest::getOptionalAttributes($hash_in, $hash_out);
     Checker::choice($choice1);
     Checker::choice($choice2);
     $request = Obj2xml::toXml($hash, $hash_config, $type);
     $litleOnlineResponse = $this->newXML->request($request, $hash_config, $this->useSimpleXml);
     return $litleOnlineResponse;
 }
Ejemplo n.º 5
0
 private static function iterateChildren($data, $transacType)
 {
     foreach ($data as $key => $value) {
         if ($value === "REQUIRED") {
             throw new InvalidArgumentException("Missing Required Field: /{$key}/");
         } elseif (substr($key, 0, 12) === 'lineItemData') {
             $temp_node = $transacType->addChild('lineItemData');
             Obj2xml::iterateChildren($value, $temp_node);
         } elseif (substr($key, 0, -1) == 'detailTax') {
             $temp_node = $transacType->addChild('detailTax');
             Obj2xml::iterateChildren($value, $temp_node);
         } elseif (is_string($value) || is_numeric($value)) {
             $transacType->addChild($key, str_replace('&', '&', $value));
         } elseif (is_array($value)) {
             $node = $transacType->addChild($key);
             Obj2xml::iterateChildren($value, $node);
         }
     }
 }
Ejemplo n.º 6
0
 public function closeRequest()
 {
     $handle = @fopen($this->transaction_file, "r");
     if ($handle) {
         file_put_contents($this->batch_file, Obj2xml::generateBatchHeader($this->counts_and_amounts), FILE_APPEND);
         while (($buffer = fgets($handle, 4096)) !== false) {
             file_put_contents($this->batch_file, $buffer, FILE_APPEND);
         }
         if (!feof($handle)) {
             throw new \RuntimeException("Error when reading transactions file at {$this->transaction_file}. Please check your privilege.");
         }
         fclose($handle);
         file_put_contents($this->batch_file, "</batchRequest>", FILE_APPEND);
         unlink($this->transaction_file);
         unset($this->transaction_file);
         $this->closed = true;
     } else {
         throw new \RuntimeException("Could not open transactions file at {$this->transaction_file}. Please check your privilege.");
     }
 }
Ejemplo n.º 7
0
 public function closeRequest()
 {
     $handle = @fopen($this->batches_file, "r");
     if ($handle) {
         file_put_contents($this->request_file, Obj2xml::generateRequestHeader($this->config, $this->num_batch_requests), FILE_APPEND);
         while (($buffer = fgets($handle, 4096)) !== false) {
             file_put_contents($this->request_file, $buffer, FILE_APPEND);
         }
         if (!feof($handle)) {
             throw new RuntimeException("Error when reading batches file at {$this->batches_file}. Please check your privilege.");
         }
         fclose($handle);
         file_put_contents($this->request_file, "</litleRequest>", FILE_APPEND);
         unlink($this->batches_file);
         unset($this->batches_file);
         $this->closed = true;
     } else {
         throw new RuntimeException("Could not open batches file at {$this->batches_file}. Please check your privilege.");
     }
 }