=== modified file 'payment/uc_google_checkout/uc_google_checkout.admin.inc'
--- a/payment/uc_google_checkout/uc_google_checkout.admin.inc	2011-02-15 18:30:30 +0000
+++ b/payment/uc_google_checkout/uc_google_checkout.admin.inc	2011-02-17 18:15:35 +0000
@@ -103,104 +103,24 @@
 }
 
 function uc_google_checkout_shipping_settings() {
-  $form = array(
-    '#tree' => TRUE
-  );
-
-  $services = uc_google_checkout_shipping_services();
-
-  foreach ($services as $key => $title) {
-    $shipping_settings = variable_get('uc_google_checkout_shipping_'. $key, array());
-    $form['services'][$key]['enable'] = array(
-      '#type' => 'checkbox',
-      '#default_value' => $shipping_settings['enable'],
-    );
-    $form['services'][$key]['title'] = array(
-      '#type' => 'markup',
-      '#value' => $title,
-    );
-    $form['services'][$key]['default'] = array(
-      '#type' => 'textfield',
-      '#default_value' => $shipping_settings['default'],
-      '#size' => 10,
-      '#field_prefix' => '$',
-    );
-    $form['services'][$key]['pickup'] = array(
-      '#type' => 'select',
-      '#default_value' => $shipping_settings['pickup'],
-      '#options' => array(
-        'REGULAR_PICKUP' => t('Regular pickup'),
-        'SPECIAL_PICKUP' => t('Special pickup'),
-        'DROP_OFF' => t('Drop off'),
-      ),
-    );
-    $form['services'][$key]['fixed_charge'] = array(
-      '#type' => 'textfield',
-      '#default_value' => $shipping_settings['fixed_charge'],
-      '#size' => 10,
-      '#field_prefix' => '$',
-    );
-    $form['services'][$key]['percent_adjustment'] = array(
-      '#type' => 'textfield',
-      '#default_value' => $shipping_settings['percent_adjustment'],
-      '#size' => 5,
-      '#field_suffix' => t('%'),
-    );
-  }
-
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Save configuration'),
-  );
-
-  return $form;
-}
-
-function theme_uc_google_checkout_shipping_settings($form) {
-  $header = array(t('Enable'), t('Service'), t('Default price'), t('Pickup type'), t('Handling charge'), t('Percentage markup/discount'));
-
-  $companies = uc_google_checkout_shipping_companies();
-  $company = '';
-  $rows = array();
-  foreach (element_children($form['services']) as $key) {
-    $row = array();
-    $temp = explode('_', $key, 2);
-    if ($company != $temp[0]) {
-      $company = $temp[0];
-      $rows[] = array(array('data' => '<strong>'. $companies[$company] .'</strong>', 'colspan' => 6));
-    }
-    foreach (array('enable', 'title', 'default', 'pickup', 'fixed_charge', 'percent_adjustment') as $field) {
-      $row[] = drupal_render($form['services'][$key][$field]);
-    }
-    $rows[] = $row;
-  }
-  $output = theme('table', $header, $rows) . drupal_render($form);
-
-  return $output;
-}
-
-function uc_google_checkout_shipping_settings_validate($form, &$form_state) {
-  foreach ($form_state['values']['services'] as $key => $service) {
-    if ($service['enable'] && empty($service['default'])) {
-      form_set_error('services]['. $key .'][default', t('A default shipping cost is required.'));
-    }
-    if (!empty($service['default']) && (!is_numeric($service['default']) || $service['default'] < 0)) {
-      form_set_error('services]['. $key .'][default', t('The default shipping cost should be a positive number.'));
-    }
-    if (!empty($service['fixed_charge']) && !is_numeric($service['fixed_charge'])) {
-      form_set_error('services]['. $key .'][fixed_charge', t('The fixed charge should be a number.'));
-    }
-    if (!empty($service['percent_adjustment']) && !is_numeric($service['percent_adjustment'])) {
-      form_set_error('services]['. $key .'][percent_adjustment', t('The percent adjustment should be a number.'));
-    }
-  }
-}
-
-function uc_google_checkout_shipping_settings_submit($form, &$form_state) {
-  foreach ($form_state['values']['services'] as $key => $service) {
-    variable_set('uc_google_checkout_shipping_'. $key, $service);
-  }
-  drupal_set_message(t('The configuration options have been saved.'));
+  $form = array();
+
+  $form['help'] = array(
+    '#value' => t("For merchant-calculated shipping, Google Checkout requires a fallback price in case it can't get a calculated shipping rate in time. When the cart request is sent to Google Checkout, Ubercart pre-calculates the shipping rates using this default address. Choose a location that will cause an average shipping cost to be returned."),
+  );
+
+  $form['uc_google_checkout_delivery_city'] = uc_textfield(uc_get_field_name('city'), variable_get('uc_google_checkout_delivery_city', ''), TRUE);
+  if (isset($_POST['country'])) {
+    $country = $_POST['country'];
+  }
+  else {
+    $country = variable_get('uc_google_checkout_delivery_country', 0);
+  }
+  $form['uc_google_checkout_delivery_country'] = uc_country_select(uc_get_field_name('country'), variable_get('uc_google_checkout_delivery_country', 0));
+  $form['uc_google_checkout_delivery_zone'] = uc_zone_select(uc_get_field_name('zone'), variable_get('uc_google_checkout_delivery_zone', 0), NULL, $country);
+  $form['uc_google_checkout_delivery_postal_code'] = uc_textfield(uc_get_field_name('postal_code'), variable_get('uc_google_checkout_delivery_postal_code', ''), TRUE, NULL, 10, 10);
+
+  return system_settings_form($form);
 }
 
 function uc_google_checkout_taxes_settings() {

=== modified file 'payment/uc_google_checkout/uc_google_checkout.install'
--- a/payment/uc_google_checkout/uc_google_checkout.install	2011-02-15 18:30:30 +0000
+++ b/payment/uc_google_checkout/uc_google_checkout.install	2011-02-17 18:15:35 +0000
@@ -227,3 +227,14 @@
 
   return $ret;
 }
+
+/**
+ * Delete old shipping settings.
+ */
+function uc_google_checkout_update_6004() {
+  $ret = array();
+
+  $ret[] = update_sql("DELETE FROM {variable} WHERE name LIKE 'uc_google_checkout_shipping_%%'");
+
+  return $ret;
+}

=== modified file 'payment/uc_google_checkout/uc_google_checkout.module'
--- a/payment/uc_google_checkout/uc_google_checkout.module	2011-02-15 18:30:30 +0000
+++ b/payment/uc_google_checkout/uc_google_checkout.module	2011-02-17 18:15:35 +0000
@@ -62,7 +62,13 @@
   );
   $items['google_checkout'] = array(
     'page callback' => 'uc_google_checkout_callback',
-    'access callback' => 'uc_google_checkout_callback_access',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+    'file' => 'uc_google_checkout.pages.inc',
+  );
+  $items['google_checkout/calculations'] = array(
+    'page callback' => 'uc_google_checkout_merchant_calculation',
+    'access callback' => TRUE,
     'type' => MENU_CALLBACK,
     'file' => 'uc_google_checkout.pages.inc',
   );
@@ -80,10 +86,6 @@
   return $items;
 }
 
-function uc_google_checkout_callback_access() {
-  return TRUE;
-}
-
 function uc_google_checkout_terminal_title($order) {
   return t('Google Checkout terminal: Order @order_id', array('@order_id' => $order->order_id));
 }
@@ -490,66 +492,30 @@
     $output .= '<merchant-checkout-flow-support>';
 
     if (uc_order_is_shippable($order)) {
-      $companies = uc_google_checkout_shipping_companies();
-      $services = uc_google_checkout_shipping_services();
-      $shipping_options = '';
-      foreach ($services as $key => $title) {
-        $settings = variable_get('uc_google_checkout_shipping_'. $key, array());
-        if ($settings['enable']) {
-          $shipping_options .= '<carrier-calculated-shipping-option>';
-          $shipping_options .= '<price currency="'. variable_get('uc_currency_code', 'USD') .'">'. $settings['default'] .'</price>';
-          $temp = explode('_', $key, 2);
-          $shipping_options .= '<shipping-company>'. $companies[$temp[0]] .'</shipping-company>';
-          $shipping_options .= '<carrier-pickup>'. $settings['pickup'] .'</carrier-pickup>';
-          $shipping_options .= '<shipping-type>'. $services[$key] .'</shipping-type>';
-          if ($settings['fixed_charge']) {
-            $context = array(
-              'revision' => 'formatted-original',
-              'type' => 'amount',
-            );
-            $options = array(
-              'sign' => FALSE,
-              'thou' => FALSE,
-              'dec' => '.',
-            );
-            $shipping_options .= '<additional-fixed-charge currency="'. variable_get('uc_currency_code', 'USD') .'">'. uc_price($settings['fixed_charge'], $context, $options) .'</additional-fixed-charge>';
-          }
-          if ($settings['percent_adjustment']) {
-            $shipping_options .= '<additional-variable-charge-percent>'. (float)$settings['percent_adjustment'] .'</additional-variable-charge-percent>';
-          }
-          $shipping_options .= '</carrier-calculated-shipping-option>';
-        }
-      }
-      if ($shipping_options) {
-        $output .= '<shipping-methods>';
-        $output .= '<carrier-calculated-shipping>';
-        $output .= '<carrier-calculated-shipping-options>';
-        $output .= $shipping_options;
-        $output .= '</carrier-calculated-shipping-options>';
-
-        $address = variable_get('uc_quote_store_default_address', new stdClass());
-        if (empty($address)) {
-          $address->city = variable_get('uc_store_city', NULL);
-          $address->zone = uc_get_zone_code(variable_get('uc_store_zone', NULL));
-          $address->postal_code = variable_get('uc_store_postal_code', NULL);
-          $address->country = uc_store_default_country();
-        }
-        $country = uc_get_country_data(array('country_id' => $address->country));
-        $address->country_code = $country[0]['country_iso_code_2'];
-        $output .= '<shipping-packages>';
-        $output .= '<shipping-package>';
-        $output .= '<ship-from id="here">';
-        $output .= '<city>'. $address->city .'</city>';
-        $output .= '<region>'. $address->zone .'</region>';
-        $output .= '<country-code>'. $address->country_code .'</country-code>';
-        $output .= '<postal-code>'. $address->postal_code .'</postal-code>';
-        $output .= '</ship-from>';
-        $output .= '</shipping-package>';
-        $output .= '</shipping-packages>';
-
-        $output .= '</carrier-calculated-shipping>';
-        $output .= '</shipping-methods>';
-      }
+      $output .= '<shipping-methods>';
+
+      $order->delivery_city = variable_get('uc_google_checkout_delivery_city', '');
+      $order->delivery_zone = variable_get('uc_google_checkout_delivery_zone', 0);
+      $order->delivery_country = variable_get('uc_google_checkout_delivery_country', 0);
+      $order->delivery_postal_code = variable_get('uc_google_checkout_delivery_postal_code', '');
+
+      $methods = module_invoke_all('shipping_method');
+      module_load_include('inc', 'uc_quote', 'uc_quote.pages');
+      $quote_data = _uc_quote_assemble_quotes($order);
+      foreach ($quote_data as $method_id => $options) {
+        foreach ($options as $accsrl => $data) {
+          if (isset($data['rate'])) {
+            $output .= '<merchant-calculated-shipping name="'. check_plain($methods[$method_id]['quote']['accessorials'][$accsrl]) .'">';
+            $output .= '<price currency="'. variable_get('uc_currency_code', 'USD') .'">'. $data['rate'] .'</price>';
+            $output .= '</merchant-calculated-shipping>';
+          }
+        }
+      }
+
+      $output .= '</shipping-methods>';
+      $output .= '<merchant-calculations>';
+      $output .= '<merchant-calculations-url>'. url('google_checkout/calculations', array('absolute' => TRUE)) .'</merchant-calculations-url>';
+      $output .= '</merchant-calculations>';
     }
 
     $tax_table = '';

