*** uc_worldpay.module.orig	2012-03-07 12:39:44.000000000 +0000
--- uc_worldpay.module	2012-03-07 12:27:34.000000000 +0000
***************
*** 218,223 ****
--- 218,226 ----
    $uc_cart_id = $_POST['M_uc_cart_id'];
    global $base_url;
    drupal_set_html_head("<base href=\"$base_url/\" />\n");
+   // Google Analytics [http://drupal.org/node/371758]
+   // added one line to redirect after three seconds, so Ubercart can work without being proxied from the WorldPay domain.
+   drupal_set_html_head('<meta http-equiv="refresh" content="3;url='. url('/cart/checkout/complete', array('absolute' => TRUE)) .'" />');
  
    // Stop orders being processed for orders from different hosts.
    if ($_SERVER['HTTP_HOST'] != $_POST['M_http_host']) {
***************
*** 256,262 ****
    if (is_numeric($amount)) {
      switch ($trans_status) {
        case 'Y':
!         $output .= t('Your order is complete and payment has been confirmed.');
          $comment = t('Paid by !type, RBS Worldpay order #!order.', array('!type' => $card_type , '!order' => $cart_id));
          uc_payment_enter($order->order_id, 'RBS Worldpay', $amount, 0, NULL, $comment);
          break;
--- 259,268 ----
    if (is_numeric($amount)) {
      switch ($trans_status) {
        case 'Y':
!         // Google Analytics [http://drupal.org/node/371758]
!         // commented our one line, because we want people to wait three seconds and be redirected
!         // $output .= t('Your order is complete and payment has been confirmed.');
!         drupal_set_title(t('Payment Confirmed'));
          $comment = t('Paid by !type, RBS Worldpay order #!order.', array('!type' => $card_type , '!order' => $cart_id));
          uc_payment_enter($order->order_id, 'RBS Worldpay', $amount, 0, NULL, $comment);
          break;
***************
*** 281,291 ****
--- 287,313 ----
      }
    }
  
+   /* Google Analytics [http://drupal.org/node/371758]
+      three lines no longer needed if we redirect after three seconds:
+ 
    $output .= uc_cart_complete_sale($order);
    uc_cart_empty($uc_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');
+   */
+ 
+   // Google Analytics [http://drupal.org/node/371758]
+   // seven lines added for WorldPay redirect:
+   $_SESSION['do_complete'] = TRUE;
+   $_SESSION['cart_order'] = $order->id;
+ 
+   $output .= "<WPDISPLAY ITEM=banner>";
+   $output .= "<p>You will receive an email from WorldPay with full details of your payment.</p>";
+   $output .= '<p>'. t('<strong>Please wait</strong> while you are redirected back to the !site website.', array("!site" => variable_get('site_name', "the store"))) .'</p>';
+   $output .= '<p>'. t('If you are not automatically redirected, please <a href="'. url('cart/checkout/complete', array('absolute' => TRUE)) .'">click here</a>.') .'</p>';
+   // Google Analytics [http://drupal.org/node/371758]
+   // lines added to here.
  
    print theme('page', $output);
    return;
***************
*** 306,311 ****
--- 328,339 ----
   * Prepare and return the form to POST to RBS Worldpay.
   */
  function uc_worldpay_form($form_state, $order) {
+ 
+   // Google Analytics [http://drupal.org/node/371758]
+   // added two lines to work with WorldPay redirect after three seconds.
+   $_SESSION['do_complete'] = TRUE;
+   $_SESSION['do_review'] = TRUE;
+ 
    $form = array();
  
    $country_data = uc_get_country_data(array('country_id' => $order->billing_country));
***************
*** 399,405 ****
      'diners' => t('Diners'),
      'laser' => t('Laser'),
      'elv' => t('ELV'),
-     'paypal' => t('PayPal'),
    );
  }
  
--- 427,432 ----
