コード例 #1
0
ファイル: Communication.php プロジェクト: samwaters/litlephp
 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;
     }
 }
コード例 #2
0
 public function __construct($overrides = array())
 {
     $config = Obj2xml::getConfig($overrides);
     $this->config = $config;
     $request_dir = $config['litle_requests_path'];
     if (substr($request_dir, -1, 1) != DIRECTORY_SEPARATOR) {
         $request_dir = $request_dir . DIRECTORY_SEPARATOR;
     }
     $ts = str_replace(" ", "", substr(microtime(), 2));
     $batches_filename = $request_dir . "request_" . $ts . "_batches";
     $request_filename = $request_dir . "request_" . $ts;
     $response_filename = $request_dir . "response_" . $ts;
     // if either file already exists, let's try again!
     if (file_exists($batches_filename) || file_exists($request_filename) || file_exists($response_filename)) {
         $this->__construct();
     }
     // if we were unable to write the file
     if (file_put_contents($batches_filename, "") === FALSE) {
         throw new \RuntimeException("A request file could not be written at {$batches_filename}. Please check your privilege.");
     }
     $this->batches_file = $batches_filename;
     // if we were unable to write the file
     if (file_put_contents($request_filename, "") === FALSE) {
         throw new \RuntimeException("A request file could not be written at {$request_filename}. Please check your privilege.");
     }
     $this->request_file = $request_filename;
     if (file_put_contents($response_filename, "") === FALSE) {
         throw new \RuntimeException("A response file could not be written at {$response_filename}. Please check your privilege.");
     }
     $this->response_file = $response_filename;
 }
コード例 #3
0
 public static function toXml($data, $hash_config, $type, $rootNodeName = 'litleOnlineRequest', $xml = null)
 {
     $config = Obj2xml::getConfig($hash_config);
     $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
     $xml->addAttribute('merchantId', $config["merchantId"]);
     $xml->addAttribute('version', $config["version"]);
     $xml->addAttribute('xmlns:xmlns', 'http://www.litle.com/schema');
     // does not show up on browser docs
     $authentication = $xml->addChild('authentication');
     $authentication->addChild('user', $config["user"]);
     $authentication->addChild('password', $config["password"]);
     $transacType = $xml->addChild($type);
     if (isset($data['partial'])) {
         $transacType->addAttribute('partial', $data["partial"]);
     }
     unset($data['partial']);
     #merchant SDK attribute $transacType-> addAttribute('partial',$data["partial"])
     if (isset($config['customerId'])) {
         $transacType->addAttribute('customerId', $config["customerId"]);
     }
     if (isset($config['reportGroup'])) {
         $transacType->addAttribute('reportGroup', $config["reportGroup"]);
     }
     if (isset($config['id'])) {
         $transacType->addAttribute('id', $config["id"]);
     }
     Obj2xml::iterateChildren($data, $transacType);
     return $xml->asXML();
 }
コード例 #4
0
ファイル: Obj2xml.php プロジェクト: samwaters/litlephp
 public static function generateBatchHeader($counts_and_amounts)
 {
     $config = Obj2xml::getConfig(array());
     $xml = simplexml_load_string("<batchRequest />");
     $xml->addAttribute('merchantId', $config['merchantId']);
     $xml->addAttribute('merchantSdk', LitleConstants::$CURRENT_SDK_VERSION);
     $xml->addAttribute('authAmount', $counts_and_amounts['auth']['amount']);
     $xml->addAttribute('numAuths', $counts_and_amounts['auth']['count']);
     $xml->addAttribute('saleAmount', $counts_and_amounts['sale']['amount']);
     $xml->addAttribute('numSales', $counts_and_amounts['sale']['count']);
     $xml->addAttribute('creditAmount', $counts_and_amounts['credit']['amount']);
     $xml->addAttribute('numCredits', $counts_and_amounts['credit']['count']);
     $xml->addAttribute('numTokenRegistrations', $counts_and_amounts['tokenRegistration']['count']);
     $xml->addAttribute('captureGivenAuthAmount', $counts_and_amounts['captureGivenAuth']['amount']);
     $xml->addAttribute('numCaptureGivenAuths', $counts_and_amounts['captureGivenAuth']['count']);
     $xml->addAttribute('forceCaptureAmount', $counts_and_amounts['forceCapture']['amount']);
     $xml->addAttribute('numForceCaptures', $counts_and_amounts['forceCapture']['count']);
     $xml->addAttribute('authReversalAmount', $counts_and_amounts['authReversal']['amount']);
     $xml->addAttribute('numAuthReversals', $counts_and_amounts['authReversal']['count']);
     $xml->addAttribute('captureAmount', $counts_and_amounts['capture']['amount']);
     $xml->addAttribute('numCaptures', $counts_and_amounts['capture']['count']);
     $xml->addAttribute('echeckVerificationAmount', $counts_and_amounts['echeckVerification']['amount']);
     $xml->addAttribute('numEcheckVerification', $counts_and_amounts['echeckVerification']['count']);
     $xml->addAttribute('echeckCreditAmount', $counts_and_amounts['echeckCredit']['amount']);
     $xml->addAttribute('numEcheckCredit', $counts_and_amounts['echeckCredit']['count']);
     $xml->addAttribute('numEcheckRedeposit', $counts_and_amounts['echeckRedeposit']['count']);
     $xml->addAttribute('echeckSalesAmount', $counts_and_amounts['echeckSale']['amount']);
     $xml->addAttribute('numEcheckSales', $counts_and_amounts['echeckSale']['count']);
     $xml->addAttribute('numUpdateCardValidationNumOnTokens', $counts_and_amounts['updateCardValidationNumOnToken']['count']);
     $xml->addAttribute('numUpdateSubscriptions', $counts_and_amounts['updateSubscription']['count']);
     $xml->addAttribute('numCancelSubscriptions', $counts_and_amounts['cancelSubscription']['count']);
     $xml->addAttribute('numCreatePlans', $counts_and_amounts['createPlan']['count']);
     $xml->addAttribute('numUpdatePlans', $counts_and_amounts['updatePlan']['count']);
     $xml->addAttribute('numActivates', $counts_and_amounts['activate']['count']);
     $xml->addAttribute('activateAmount', $counts_and_amounts['activate']['amount']);
     $xml->addAttribute('numDeactivates', $counts_and_amounts['deactivate']['count']);
     $xml->addAttribute('numLoads', $counts_and_amounts['load']['count']);
     $xml->addAttribute('loadAmount', $counts_and_amounts['load']['amount']);
     $xml->addAttribute('numUnloads', $counts_and_amounts['unload']['count']);
     $xml->addAttribute('unloadAmount', $counts_and_amounts['unload']['amount']);
     $xml->addAttribute('numBalanceInquirys', $counts_and_amounts['balanceInquiry']['count']);
     $xml->addAttribute('numAccountUpdates', $counts_and_amounts['accountUpdate']['count']);
     return str_replace("/>", ">", str_replace("<?xml version=\"1.0\"?>\n", "", $xml->asXML()));
 }
コード例 #5
0
ファイル: Communication.php プロジェクト: Rodrifer/candyclub
 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;
     }
 }
コード例 #6
0
 private function addTransaction($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)
 {
     if ($this->closed) {
         throw new \RuntimeException("Could not add the transaction. This batchRequest is closed.");
     }
     if ($this->isFull()) {
         throw new \RuntimeException('The transaction could not be added to the batch. It is full.');
     }
     if ($type == 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] != $this->total_txns) {
         throw new \RuntimeException("The transaction could not be added to the batch. The transaction type {$type} cannot be mixed with non-Account Updates.");
     } elseif ($type != 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] == $this->total_txns && $this->total_txns > 0) {
         throw new \RuntimeException("The transaction could not be added to the batch. The transaction type {$type} cannot be mixed with AccountUpdates.");
     }
     if (isset($hash_in['reportGroup'])) {
         $report_group = $hash_in['reportGroup'];
     } else {
         $conf = Obj2xml::getConfig(array());
         $report_group = $conf['reportGroup'];
     }
     Checker::choice($choice1);
     Checker::choice($choice2);
     $request = Obj2xml::transactionToXml($hash_out, $type, $report_group);
     if (file_put_contents($this->transaction_file, $request, FILE_APPEND) === FALSE) {
         throw new \RuntimeException("A transaction could not be written to the batch file at {$this->transaction_file}. Please check your privilege.");
     }
     $this->total_txns += 1;
 }