diff --git a/shipping/uc_ups/uc_ups.admin.inc b/shipping/uc_ups/uc_ups.admin.inc
index 8edcfa1..75bd1a1 100644
--- a/shipping/uc_ups/uc_ups.admin.inc
+++ b/shipping/uc_ups/uc_ups.admin.inc
@@ -221,6 +221,13 @@ function uc_ups_admin_settings() {
     '#description'   => t('Controls how long labels are stored on the server before being automatically deleted. Cron must be enabled for automatic deletion. Default is never delete the labels, keep them forever.'),
   );
 
+  $form['uc_ups_cert_mode'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Certification mode'),
+    '#default_value' => variable_get('uc_ups_cert_mode', FALSE),
+    '#description' => t('When enabled, the UPS module will produce the necessary files for certification by UPS. Not for production use!.'),
+  );
+
   $form['#validate'][] = 'uc_ups_admin_settings_validate';
 
   return system_settings_form($form);
diff --git a/shipping/uc_ups/uc_ups.module b/shipping/uc_ups/uc_ups.module
index 4018343..aec4500 100644
--- a/shipping/uc_ups/uc_ups.module
+++ b/shipping/uc_ups/uc_ups.module
@@ -432,7 +432,7 @@ function uc_ups_shipping_quote($packages, $origin, $destination, $ups_service) {
         $package_schema .= "<PackageServiceOptions>";
         $package_schema .=   "<InsuredValue>";
         $package_schema .=     "<CurrencyCode>" . variable_get('uc_currency_code', 'USD') . "</CurrencyCode>";
-        $package_schema .=     "<MonetaryValue>" . $package->price . "</MonetaryValue>";
+        $package_schema .= "<MonetaryValue>" . number_format($package->value, 2, '.', '') . "</MonetaryValue>";
         $package_schema .=   "</InsuredValue>";
         $package_schema .= "</PackageServiceOptions>";
       }
@@ -764,7 +764,7 @@ function theme_uc_ups_option_label($service, $packages) {
  */
 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>';
@@ -818,6 +818,51 @@ function uc_ups_void_shipment($shipment_number, $tracking_numbers = array()) {
       $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;
 }
 
diff --git a/shipping/uc_ups/uc_ups.ship.inc b/shipping/uc_ups/uc_ups.ship.inc
index f666043..c29c09e 100644
--- a/shipping/uc_ups/uc_ups.ship.inc
+++ b/shipping/uc_ups/uc_ups.ship.inc
@@ -279,6 +279,51 @@ function uc_ups_fulfill_order_validate($form, &$form_state) {
   $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;
@@ -437,8 +482,17 @@ function uc_ups_shipment_request($packages, $origin, $destination, $ups_service)
     <RequestOption>validate</RequestOption>
   </Request>
   <Shipment>";
+  // If destination is Canada or Puerto Rico
+  if ($destination->country == 124 || $destination->country == 630) {
+    $schema .= "<InvoiceLineTotal>";
+    $schema .=   "<CurrencyCode>". variable_get('uc_currency_code', 'USD') ."</CurrencyCode>";
+    $schema .=   "<MonetaryValue>". number_format($package->value, 0, '.', '') ."</MonetaryValue>";
+    $schema .= "</InvoiceLineTotal>";
+  }
+  $schema .=   "<Description>". $store['name'] ." Online Order</Description>";
   $schema .=   "<Shipper>";
   $schema .=     "<Name>". $store['name'] ."</Name>";
+  $schema .=     "<AttentionName>". $origin->first_name .' '. $origin->last_name ."</AttentionName>";
   $schema .=     "<ShipperNumber>". variable_get('uc_ups_shipper_number', '') ."</ShipperNumber>";
   if ($store['phone']) {
     $schema .=   "<PhoneNumber>". $store['phone'] ."</PhoneNumber>";
@@ -605,6 +659,49 @@ function uc_ups_confirm_shipment_submit($form, &$form_state) {
   $packages = array_keys($_SESSION['ups']['packages']);
   $request = uc_ups_request_pickup($form_state['values']['digest'], $order_id, $packages);
   $result = drupal_http_request(variable_get('uc_ups_connection_address', 'https://wwwcie.ups.com/ups.app/xml/') .'ShipAccept', array(), 'POST', $request);
+
+  // capture request and response for certification mode
+  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/oid-' . $order_id), FILE_CREATE_DIRECTORY)) {
+  $xml_request_path = file_create_path('ups_certification/oid-' . $order_id) .'/ShipmentAcceptRequest.xml';
+  $xml_response_path = file_create_path('ups_certification/oid-' . $order_id) .'/ShipmentAcceptResponse.xml';
+
+  // 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_confirm_request_xml = 'ups_certification/oid-' . $order_id . basename($xml_request_path);
+    drupal_set_message(t('ShipmentAcceptRequest.xml written to ups_certification/oid-' . $order_id . '/'));
+  }
+  else {
+    drupal_set_message(t('Could not open a file to save the shipment accept request XML document.'), 'error');
+  }
+
+  if ($xml_response_file = fopen($xml_response_path, 'wb')) {
+    fwrite($xml_response_file, $result->data);
+    fclose($xml_response_file);
+    $package->cert_shipment_confirm_response_xml = 'ups_certification/oid-' . $order_id . basename($xml_response_path);
+    drupal_set_message(t('ShipmentAcceptResponse.xml written to ups_certification/oid-' . $order_id . '/'));
+  }
+  else {
+    drupal_set_message(t('Could not open a file to save the shipment accept 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
+
   $response = new SimpleXMLElement($result->data);
   $code = (string)$response->Response->ResponseStatusCode;
   if ($code == 0) { // failed request
@@ -646,6 +743,12 @@ function uc_ups_confirm_shipment_submit($form, &$form_state) {
     $package =& current($shipment->packages);
     $package->tracking_number = (string)$package_results->TrackingNumber;
     $label_image = (string)$package_results->LabelImage->GraphicImage;
+
+    // for certification, grab the html page used to display the label
+    if (variable_get('uc_ups_cert_mode', FALSE) && user_access('configure quotes')) {
+      $html_page = (string)$package_results->LabelImage->HTMLImage;
+    }
+
     if (file_check_directory(file_create_path('ups_labels'), FILE_CREATE_DIRECTORY)) {
       $label_path = file_create_path('ups_labels') .'/label'. $package->tracking_number .'.gif';
       if ($label_file = fopen($label_path, 'wb')) {
@@ -660,10 +763,65 @@ function uc_ups_confirm_shipment_submit($form, &$form_state) {
     else {
       drupal_set_message(t('Could not find or create the directory "ups_labels" in the file system path.'), 'error');
     }
+
+    // capture label and html page for certification mode
+    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/oid-' . $order_id), FILE_CREATE_DIRECTORY)) {
+    $label_path = file_create_path('ups_certification/oid-' . $order_id) .'/label' . $package->tracking_number . '.gif';
+    $html_path = file_create_path('ups_certification/oid-' . $order_id) .'/' . $package->tracking_number . '.html';
+
+    if ($label_file = fopen($label_path, 'wb')) {
+      fwrite($label_file, base64_decode($label_image));
+      fclose($label_file);
+      $package->cert_label = 'ups_certification/oid-' . $order_id . basename($label_path);
+      drupal_set_message(t(basename($label_path) . ' written to ups_certification/oid-' . $order_id . '/'));
+    }
+    else {
+      drupal_set_message(t('Could not open a file to save ' . basename($label_path) . '.'), 'error');
+    }
+
+    if ($html_file = fopen($html_path, 'wb')) {
+      fwrite($html_file, base64_decode($html_page));
+      fclose($html_file);
+      $package->cert_label_html = 'ups_certification/oid-' . $order_id . basename($html_path);
+      drupal_set_message(t(basename($html_path) . ' written to ups_certification/oid-' . $order_id . '/'));
+    }
+    else {
+      drupal_set_message(t('Could not open a file to save ' . basename($html_path) . '.'), '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 mode
+
     unset($package);
     next($shipment->packages);
   }
 
+  // capture high value report for certification
+  if (variable_get('uc_ups_cert_mode', FALSE) && user_access('configure quotes')) {
+    if (isset($response->ShipmentResults->ControlLogReceipt)) {
+      if (file_check_directory(file_create_path('ups_certification/oid-' . $order_id), FILE_CREATE_DIRECTORY)) {
+  $html_path = file_create_path('ups_certification/oid-' . $order_id) . '/high-value-report.html';
+  $html_image = $response->ShipmentResults->ControlLogReceipt->GraphicImage;
+  if ($html_file = fopen($html_path, 'wb')) {
+    fwrite($html_file, base64_decode($html_image));
+    fclose($html_file);
+    $shipment->high_value_image = $html_path;
+    drupal_set_message(t('High value report written to ups_certification/oid-' . $order_id . '/'));
+  }
+      }
+    }
+  }
+  // end capture high value report for certification
+
   uc_shipping_shipment_save($shipment);
 
   unset($_SESSION['ups']);
