Index: classes/class.ups.php =================================================================== --- classes/class.ups.php (revision 73) +++ classes/class.ups.php (working copy) @@ -8,6 +8,12 @@ var $debugMode; var $accessRequest; + // Begin BC Addition + var $req_num = 0; + var $transaction = ''; + var $debug_dir; + // End BC Addition + /********************************************** * $License = XML Access Code provided by UPS * $User = UPS.com Username @@ -25,6 +31,19 @@ $this->templatePath = 'xml/'; // No beginning slash if path is relative } + // Begin BC Addition + function setTransaction($id) + { + $this->transaction = $id; + } + + function setDebugDir($dir) + { + $this->debug_dir = $dir; + } + // End BC Addition + + function access(){ // This will create the AccessRequest XML that belongs at the beginning of EVERY request made to UPS $accessXML = $this->sandwich($this->templatePath.'AccessRequest.xml', array('{LICENSE}','{USER_ID}','{PASSWORD}'), array($this->License,$this->User,$this->Pass)); @@ -59,9 +78,22 @@ curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $output); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + // BC ADDITION + curl_setopt($ch, CURLINFO_HEADER_OUT, 1); + $curlReturned = curl_exec($ch); + + // BEGIN BC Addition - This will log the request and response for debugging (and certification) + if (!empty($this->debug_dir) && file_exists($this->debug_dir) && is_dir($this->debug_dir) && is_writeable($this->debug_dir)) { + file_put_contents("{$this->debug_dir}/{$this->transaction}-{$this->req_num}.request", print_r(curl_getinfo($ch),true)."OUTPUT:\n\n{$output}"); + file_put_contents("{$this->debug_dir}/{$this->transaction}-{$this->req_num}.response", $curlReturned); + } + $this->req_num++; + // END BC Addition + curl_close($ch); + // Find out if the UPS service is down preg_match_all('/HTTP\/1\.\d\s(\d+)/',$curlReturned,$matches); foreach($matches[1] as $key=>$value) {