Index: uc_pma.install
===================================================================
RCS file: uc_pma.install
diff -N uc_pma.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ uc_pma.install	16 Sep 2010 19:15:12 -0000
@@ -0,0 +1,16 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_install().
+ */
+function uc_pma_install() {
+  // Ensure the module weight is lower than uc_taxes.
+  db_query("UPDATE {system} SET weight = -1 WHERE name = 'uc_pma'");
+}
+
+function uc_pma_update_1() {
+  $ret = array();
+  $ret[] = update_sql("UPDATE {system} SET weight = -1 WHERE name = 'uc_pma'");
+  return $ret;
+}
Index: uc_pma.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_pma/uc_pma.js,v
retrieving revision 1.2.2.1
diff -u -p -r1.2.2.1 uc_pma.js
--- uc_pma.js	6 Oct 2009 14:39:51 -0000	1.2.2.1
+++ uc_pma.js	16 Sep 2010 19:15:12 -0000
@@ -9,13 +9,18 @@ $(document).ready(
         update_method_line_item(this.value);
       }
     );
+
+    $("select[name*=delivery_country], select[name*=billing_country]").change(function() {
+      update_method_line_item('');
+    });
   }
 );
 
 /**
  * Update the payment method line item to reflect any payment specific subtotal adjustments
+ * or update the description for all payment methods, if no specific method is specified.
  */
-function update_method_line_item(path) {
+function update_method_line_item(method) {
   var order = serializeOrder();
 
   if (!!order) {
@@ -25,17 +30,28 @@ function update_method_line_item(path) {
     // Set the global timestamp for the update.
     method_update = this_update.getTime();
 
-    // Make the post to get the details for the chosen payment method.
-    $.post(Drupal.settings.basePath + 'cart/checkout/method_items/' + path, { order: order },
+    // Make the post to get the details for the chosen payment method (or all methods).
+    $.post(Drupal.settings.basePath + 'cart/checkout/method_items/' + method, { order: order },
       function(adjustment) {
         if (this_update.getTime() == method_update) {
-          var return_values = adjustment.split('|');
-          if(return_values[0] && (return_values[0] >= .01 || return_values[0] <= -.01)) {
-            set_line_item('payment_method', return_values[1], return_values[0], 1);
+          if (method) {
+            // Update line item for the specified payment method.
+            var return_values = adjustment.split('|');
+            if(return_values[0] && (return_values[0] >= .01 || return_values[0] <= -.01)) {
+              set_line_item('payment_method', return_values[1], return_values[0], 1);
+            }
+            else {
+              remove_line_item('payment_method');
+              render_line_items();
+            }
           }
           else {
-            remove_line_item('payment_method');
-            render_line_items();
+            // Update descriptions for all payment methods.
+            var adjustment = adjustment.split('^');
+            for (i in adjustment) {
+              var method_data = adjustment[i].split('|');
+              $('#payment-pane label.option:has(input:radio[value=' + method_data[0] + ']) + .description').html(method_data[1]);
+            }
           }
         }
       }
Index: uc_pma.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_pma/uc_pma.module,v
retrieving revision 1.2.2.1
diff -u -p -r1.2.2.1 uc_pma.module
--- uc_pma.module	6 Oct 2009 14:39:51 -0000	1.2.2.1
+++ uc_pma.module	16 Sep 2010 19:15:12 -0000
@@ -98,11 +98,24 @@ function uc_pma_line_item() {
 function uc_pma_order($op, &$arg1) {
   switch ($op) {
     case 'save':
+      foreach ($arg1->line_items as $i => $line) {
+        if ($line['type'] == 'payment_method') {
+          uc_order_delete_line_item($line['line_item_id']);
+          unset($arg1->line_items[$i]);
+        }
+      }
+
       $adjustment = _payment_method_adjustment($arg1);
-      db_query("DELETE FROM {uc_order_line_items} WHERE order_id = %d AND type = 'payment_method'", $arg1->order_id);
       $min_adjust = .01;
       if ($adjustment['value'] && ($adjustment['value'] >= $min_adjust || $adjustment['value'] <= -$min_adjust)) {
         uc_order_line_item_add($arg1->order_id, 'payment_method', $adjustment['description'], $adjustment['value'], 1);
+        $arg1->line_items[] = array(
+          'id' => 'payment_method',
+          'type' => 'payment_method',
+          'title' => $adjustment['description'],
+          'amount' => $adjustment['value'],
+          'weight' => 1,
+        );
       }
       break;
   }
@@ -131,18 +144,29 @@ function theme_uc_pma_payment_method_tab
   return theme('table', $header, $rows);
 }
 
-function uc_pma_method_items($payment_method) {
+function uc_pma_method_items($payment_method = NULL) {
   drupal_set_header("Content-Type: text/javascript; charset=utf-8");
   $order = $_POST['order'];
   if ($order = unserialize(rawurldecode($order))) {
-    $order->payment_method = $payment_method;
-    $adjustment = _payment_method_adjustment($order);
-    print $adjustment['value'] .'|'. $adjustment['description'];
+    if ($payment_method) {
+      $order->payment_method = $payment_method;
+      $adjustment = _payment_method_adjustment($order);
+      print $adjustment['value'] .'|'. $adjustment['description'];
+    }
+    else {
+      $adjustments = array();
+      foreach (_payment_method_list() as $method) {
+        if ($method['checkout'] && $description = payment_method_adjustment_description($method['id'], $order)) {
+          $adjustments[] = $method['id'] . '|' . $description;
+        }
+      }
+      print implode('^', $adjustments);
+    }
   }
   exit();
 }
 
-function payment_method_adjustment_description($method_id) {
+function payment_method_adjustment_description($method_id, $order = NULL) {
   $name = _payment_method_data($method_id, 'name');
   $adjustment = variable_get('uc_payment_method_'. $method_id .'_adjustment', '');
   if (empty($name) || empty($adjustment)) {
@@ -150,12 +174,27 @@ function payment_method_adjustment_descr
   }
 
   $adjustment = ereg_replace('[^-0-9'. variable_get('uc_currency_dec', '.') .'%]+', '', $adjustment);
+  $discount = strstr($adjustment, '-');
 
   if (!strstr($adjustment, '%')) {
-    $adjustment = uc_currency_format(str_replace(variable_get('uc_currency_dec', '.'), ".", $adjustment));
+    $adjustment = str_replace(variable_get('uc_currency_dec', '.'), ".", $adjustment);
+    $context = array(
+      'revision' => 'themed',
+      'type' => 'line_item',
+      'subject' => array(
+        'order' => $order,
+        'line_item' => array(
+          'id' => 'payment_method',
+          'type' => 'payment_method',
+          'amount' => $adjustment,
+          'weight' => 1,
+        ),
+      ),
+    );
+    $adjustment = uc_price($adjustment, $context);
   }
 
-  if (strstr($adjustment, '-')) {
+  if ($discount) {
     $description = t('Receive a !adjustment discount when paying by !method.', array('!adjustment' => str_replace('-', '', $adjustment), '!method' => $name));
   }
   else {
