--- uc_worldpay.module	2008-12-05 18:28:29.000000000 +0000
+++ uc_worldpay_new.module	2009-07-01 16:31:01.000000000 +0100
@@ -259,11 +259,13 @@ function uc_worldpay_complete($cart_id =
   $trans_status = $_POST['transStatus'];
   $card_type = $_POST['cardType'];
   $uc_cart_id = $_POST['M_uc_cart_id'];
+  global $base_url;
+  drupal_set_html_head("<base href=\"$base_url/\" />\n");
 
   // Stop orders being processed for orders from different hosts.
   if ($_SERVER['HTTP_HOST'] != $_POST['M_http_host']) {
-    print t('There was an error with the transaction. The host did not match.');
-    exit();
+    print theme('page', t('There was an error with the transaction. The host did not match.'));
+    return;
   }
 
   // Log a new order notification to watchdog.
@@ -284,14 +286,14 @@ function uc_worldpay_complete($cart_id =
 
   // If the order could not be loaded print an error message and exit.
   if (!$order = uc_order_load($cart_id)) {
-    print t('The order could not be found and this transaction cannot continue.');
-    exit();
+    print theme('page', t('The order could not be found and this transaction cannot continue.'));
+    return;
   }
 
   // If the status of the order is not 'in_checkout' print an error and exit.
   if (uc_order_status_data($order->order_status, 'state') != 'in_checkout') {
-    print t('An error has occurred during payment.  Please contact us to ensure your order has submitted.');
-    exit();
+    print theme('page', t('An error has occurred during payment.  Please contact us to ensure your order has submitted.'));
+    return;
   }
 
   if (is_numeric($amount)) {
@@ -305,8 +307,8 @@ function uc_worldpay_complete($cart_id =
         $output .= t('Your order has been cancelled.');
         drupal_set_message(t('Your order has been cancelled.'));
         uc_order_comment_save($order->order_id, 0, t('Payment cancelled by user.'), 'admin');
-        print $output;
-        exit();
+        print theme('page', $output);
+        return;
         break;
       default:
         $output .= t('Your order is pending.');
@@ -322,8 +324,8 @@ function uc_worldpay_complete($cart_id =
   // Add a comment to let sales team know this came in through the site.
   uc_order_comment_save($order->order_id, 0, t('Order created through website.'), 'admin');
 
-  print $output;
-  exit();
+  print theme('page', $output);
+  return;
 }
 
 /**
