--- original/6.x-2.x-dev/uc_ups.module	2010-01-21 21:22:00.000000000 -0800
+++ new/uc_ups.module	2010-01-26 20:50:08.000000000 -0800
@@ -568,7 +568,7 @@ function uc_ups_shipment_request($packag
         $package_schema .= "<PackageServiceOptions>";
           $package_schema .= "<InsuredValue>";
             $package_schema .= "<CurrencyCode>". variable_get('uc_currency_code', 'USD') ."</CurrencyCode>";
-            $package_schema .= "<MonetaryValue>". number_format($package->price, 2, '.', '') ."</MonetaryValue>";
+            $package_schema .= "<MonetaryValue>". number_format($package->value, 2, '.', '') ."</MonetaryValue>";
           $package_schema .= "</InsuredValue>";
         $package_schema .= "</PackageServiceOptions>";
       $package_schema .= "</Package>";
@@ -1058,6 +1058,51 @@ function uc_ups_fulfill_order_validate($
   $response_obj = drupal_http_request(variable_get('uc_ups_connection_address', 'https://wwwcie.ups.com/ups.app/xml/') .'ShipConfirm', array(), 'POST', $request);
   $response = new SimpleXMLElement($response_obj->data);
   //drupal_set_message('<pre>'. htmlentities($response->asXML()) .'</pre>');
+
+  //capture request and response for certification mode
+  if (variable_get('uc_ups_cert_mode', FALSE) && user_access('configure quotes')) {
+    $order_id = $form_state['values']['order_id'];
+    if (file_check_directory(file_create_path('ups_certification'), FILE_CREATE_DIRECTORY)) {
+      if (file_check_directory(file_create_path('ups_certification/oid-' . $order_id), FILE_CREATE_DIRECTORY)) {
+	$xml_request_path = file_create_path('ups_certification/oid-' . $order_id) .'/ShipmentConfirmRequest.xml';
+	$xml_response_path = file_create_path('ups_certification/oid-' . $order_id) .'/ShipmentConfirmResponse.xml';
+
+	//need to get rid of the UPS access request that has the user name and password
+	//this is the first xml document in $request, but I'm not sure why explode puts it 
+	//in the second array
+	$new_request_array = explode('<?xml version="1.0" encoding="UTF-8"?>', $request);
+	$new_request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . $new_request_array[2];
+	
+	if ($xml_request_file = fopen($xml_request_path, 'wb')) {
+	  fwrite($xml_request_file, $new_request);
+	  fclose($xml_request_file);
+	  $package->cert_shipment_accept_request_xml = 'ups_certification/oid-' . $order_id . basename($xml_request_path);
+	  drupal_set_message(t('ShipmentConfirmRequest.xml written to ups_certification/oid-' . $order_id . '/'));
+	}
+	else {
+	  drupal_set_message(t('Could not open a file to save the shipment confirm request XML document.'), 'error');
+	}
+
+	if ($xml_response_file = fopen($xml_response_path, 'wb')) {
+	  fwrite($xml_response_file, $response_obj->data);
+	  fclose($xml_response_file);
+	  $package->cert_shipment_accept_response_xml = 'ups_certification/oid-' . $order_id . basename($xml_response_path);
+	  drupal_set_message(t('ShipmentConfirmResponse.xml written to ups_certification/oid-' . $order_id . '/'));
+	}
+	else {
+	  drupal_set_message(t('Could not open a file to save the shipment confirm response XML document.'), 'error');
+	}
+      }
+      else {
+	drupal_set_message(t('Could not find or create the directory "ups_certification/oid-' . $order_id . '" in the file system path.'), 'error');
+      }
+    }
+    else {
+      drupal_set_message(t('Could not find or create the directory "ups_certification" in the file system path.'), 'error');
+    }
+  }
+  //end capture request and response for certification
+
   if (isset($response->Response->Error)) {
     $error = $response->Response->Error;
     $error_msg = (string)$error->ErrorSeverity .' Error '. (string)$error->ErrorCode .': '. (string)$error->ErrorDescription;
@@ -1149,7 +1194,7 @@ function uc_ups_request_pickup($digest, 
  */
 function uc_ups_void_shipment_request($shipment_number, $tracking_numbers = array()) {
   $schema = uc_ups_access_request();
-  $schema .= '<?xml version="1.0"?>';
+  $schema .= '<?xml version="1.0" encoding="UTF-8"?>';
   $schema .= '<VoidShipmentRequest>';
   $schema .= '<Request>';
     $schema .= '<RequestAction>Void</RequestAction>';
@@ -1202,6 +1247,51 @@ function uc_ups_void_shipment($shipment_
       $success = (string)$response->Status->StatusType->Code;
     }
   }
+
+  //capture request and response for certification mode		TODO fix void
+  if (variable_get('uc_ups_cert_mode', FALSE) && user_access('configure quotes')) {
+    if (file_check_directory(file_create_path('ups_certification'), FILE_CREATE_DIRECTORY)) {
+      if (file_check_directory(file_create_path('ups_certification/void-sid-' . $shipment_number), FILE_CREATE_DIRECTORY)) {
+	$xml_request_path = file_create_path('ups_certification/void-sid-' . $shipment_number) .'/VoidShipmentRequest.xml';
+	$xml_response_path = file_create_path('ups_certification/void-sid-' . $shipment_number) .'/VoidShipmentResponse.xml';
+
+	//need to get rid of the UPS access request that has the user name and password
+	//this is the first xml document in $request, but I'm not sure why explode puts it 
+	//in the second array
+	$new_request = $request;
+	$new_request_array = explode('<?xml version="1.0" encoding="UTF-8"?>', $request);
+	$new_request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . $new_request_array[2];
+	
+	if ($xml_request_file = fopen($xml_request_path, 'wb')) {
+	  fwrite($xml_request_file, $new_request);
+	  fclose($xml_request_file);
+	  $package->cert_shipment_confirm_request_xml = 'ups_certification/void-sid-' . $shipment_number . basename($xml_request_path);
+	  drupal_set_message(t('VoidShipmentRequest.xml written to ups_certification/void-sid-' . $shipment_number . '/'));
+	}
+	else {
+	  drupal_set_message(t('Could not open a file to save the void shipment request XML document.'), 'error');
+	}
+
+	if ($xml_response_file = fopen($xml_response_path, 'wb')) {
+	  fwrite($xml_response_file, $resp->data);
+	  fclose($xml_response_file);
+	  $package->cert_shipment_confirm_response_xml = 'ups_certification/void-sid-' . $shipment_number . basename($xml_response_path);
+	  drupal_set_message(t('VoidShipmentResponse.xml written to ups_certification/void-sid-' . $shipment_number . '/'));
+	}
+	else {
+	  drupal_set_message(t('Could not open a file to save the void shipment response XML document.'), 'error');
+	}
+      }
+      else {
+	drupal_set_message(t('Could not find or create the directory "ups_certification/oid-' . $shipment_number . '" in the file system path.'), 'error');
+      }
+    }
+    else {
+      drupal_set_message(t('Could not find or create the directory "ups_certification" in the file system path.'), 'error');
+    }
+  }
+  //end capture request and response for certification mode
+
   return (bool)$success;
 }
 
