diff --git includes/uc_payflowpro_recurring.inc includes/uc_payflowpro_recurring.inc
index bb8ceff..fdfd95a 100644
--- includes/uc_payflowpro_recurring.inc
+++ includes/uc_payflowpro_recurring.inc
@@ -1007,16 +1007,6 @@ function theme_payflow_address($title = 'Address', $address) {
 
   return drupal_render($render);
 }
-function _payment_payflowpro_auth_info() {
-  static $auth;
-  if(!isset($auth)) {
-    $auth['vendor'] = variable_get('ec_payflowpro_vendor', '');
-    $auth['partner'] = variable_get('ec_payflowpro_partner', '');
-    $auth['user'] = variable_get('ec_payflowpro_user', '');
-    $auth['password'] = variable_get('ec_payflowpro_password', '');
-  }
-  return $auth;
-}
 
 function uc_payflowpro_cancel_form($form_state, $profile_id, $cancel_path) {
   $form = array();
diff --git uc_payflowpro.install uc_payflowpro.install
index f1a2eb8..dabe028 100644
--- uc_payflowpro.install
+++ uc_payflowpro.install
@@ -174,22 +174,9 @@ function uc_payflowpro_update_1() {
  */
 function uc_payflowpro_uninstall() {
   drupal_uninstall_schema('uc_payflowpro');
-  
-  //This block is referenced but never set.
-  /*variable_del('ec_payflowpro_partner');
-  variable_del('ec_payflowpro_password');
-  variable_del('ec_payflowpro_sdk_cert_path');
-  variable_del('ec_payflowpro_tx_mode');
-  variable_del('ec_payflowpro_user');
-  variable_del('ec_payflowpro_vendor');*/
 
   //These variables are actually set by the settings form.
   variable_del('uc_payflowpro_cert_path');
-  variable_del('uc_payflowpro_ec_reqconfirmed_addr');
-  variable_del('uc_payflowpro_ec_review_comment');
-  variable_del('uc_payflowpro_ec_review_company');
-  variable_del('uc_payflowpro_ec_review_phone');
-  variable_del('uc_payflowpro_ec_review_shipping');
   variable_del('uc_payflowpro_enable_recurring');
   variable_del('uc_payflowpro_error_codes_accept');
   variable_del('uc_payflowpro_mode');
@@ -199,5 +186,4 @@ function uc_payflowpro_uninstall() {
   variable_del('uc_payflowpro_recurring_site_key');
   variable_del('uc_payflowpro_user');
   variable_del('uc_payflowpro_vendor');
-  variable_del('uc_payment_method_payflowpro_ec_checkout');
 }
diff --git uc_payflowpro.module uc_payflowpro.module
index a91386f..7e80a12 100644
--- uc_payflowpro.module
+++ uc_payflowpro.module
@@ -26,39 +26,6 @@ require_once('includes/uc_payflowpro_recurring.inc');
  * Implementation of hook_menu()
  */
 function uc_payflowpro_menu() {
-
-  // Callback functions for Express Checkout
-  $items['cart/echeckout/selected'] = array(
-    'title' => 'Review order',
-    'page callback' => 'uc_payflowpro_ec_review_redirect',
-    'access arguments' => array('access content'),
-    'type' => MENU_CALLBACK,
-  );
-  $items['cart/echeckout/review'] = array(
-    'title' => 'Review payment',
-    'page callback' => 'uc_payflowpro_ec_review',
-    'access arguments' => array('access content'),
-    'type' => MENU_CALLBACK,
-  );
-  $items['cart/echeckout/submit'] = array(
-    'title' => 'Submit order',
-    'page callback' => 'uc_payflowpro_ec_submit',
-    'access arguments' => array('access content'),
-    'type' => MENU_CALLBACK,
-  );
-  $items['cart/echeckout/complete'] = array(
-    'title' => 'Order complete',
-    'page callback' => 'uc_payflowpro_ec_complete',
-    'access arguments' => array('access content'),
-    'type' => MENU_CALLBACK,
-  );
-  $items['cart/echeckout/cancel'] = array(
-    'title' => 'PayPal payment cancelled',
-    'page callback' => 'uc_payflowpro_ec_cancel',
-    'access arguments' => array('access content'),
-    'type' => MENU_CALLBACK,
-  );
-
   // Recurring Billing administration
   $items['admin/store/settings/uc_recurring'] = array(
     'title' => 'Payflow Pro Recurring Settings',
@@ -127,64 +94,11 @@ function uc_payflowpro_theme($existing, $type, $theme, $path) {
   );
 }
 
-/**
- * Implementation of hook_form_alter()
- * To allow express checkout
- */
-function uc_payflowpro_form_alter(&$form, $form_state, $form_id) {
-  if ($form_id == 'uc_cart_checkout_form' && variable_get('uc_payment_method_payflowpro_ec_checkout', FALSE)) {
-    $form['#submit'] = (array)$form['#submit'] + array('uc_payflowpro_ec_checkout' => array());
-  }
-
-  if ($form_id == 'uc_cart_checkout_review_form' && !empty($_SESSION['TOKEN'])) {
-    $form['#submit'] = (array)$form['#submit'] + array('uc_payflowpro_ec_submit_form_submit' => array());
-  }
-
-}
-
 /*******************************************************************************
  * Hook Functions (Ubercart)
  ******************************************************************************/
 
 /**
- * Implementation of hook_cart_pane()
- */
-function uc_payflowpro_cart_pane() {
-
-  $panes[] = array(
-    'id' => 'uc_payflowpro_ec',
-    'title' => t('PayPal Express Checkout'),
-    'enabled' => FALSE,
-    'weight' => 1,
-    'body' => '<div align="right">'. drupal_get_form('uc_payflowpro_ec_form') .'</div>',
-  );
-
-  return $panes;
-}
-
-/**
-* Implementation of hook_payment_method().
- */
-function uc_payflowpro_payment_method() {
-  $title1 = '<img src="https://www.paypal.com/en_US/i/logo/PayPal_mark_37x23.gif" style="position: relative; top: 5px; margin-right: 4px;">'
-            . t('PayPal - pay without sharing your financial information.');
-
-  $methods[] = array(
-    'id' => 'payflowpro_ec',
-    'name' => t('PayPal Express Checkout'),
-    'title' => $title1,
-    'review' => t('PayPal'),
-    'desc' => t('Complete orders through PayPal Express Checkout.'),
-    'callback' => 'uc_payment_method_payflowpro_ec',
-    'weight' => 1,
-    'checkout' => FALSE,
-    'backend' => FALSE,
-  );
-
-  return $methods;
-}
-
-/**
  * Implementation of hook_payment_gateway()
  */
 function uc_payflowpro_payment_gateway() {
@@ -454,427 +368,6 @@ function uc_payflow_pro_pfp_gateway_validate($element, &$form_state) {
 }
 
 /*******************************************************************************
- * Express Checkout Functions
- ******************************************************************************/
-
-// Handles the Express Checkout payment method
-function uc_payment_method_payflowpro_ec($op, &$arg1) {
-  switch ($op) {
-    //case 'order-view':
-    case 'settings':
-      $form['redirect'] = array(
-        '#value' => '<div>'. t('For Express Checkout, you need to !cp_link and !wpp_link.', array('!cp_link' => l(t('enable the cart pane'), 'admin/store/settings/cart/edit/panes'), '!wpp_link' => l(t('configure the PayFlow Pro settings'), 'admin/store/settings/payment/edit/gateways'))) .'</div>',
-      );
-      return $form;
-  }
-}
-
-// Handles the review page for Express Checkout Mark Flow.
-function uc_payflowpro_ec_review_redirect() {
-  if (!isset($_SESSION['TOKEN']) || ($order = uc_order_load($_SESSION['cart_order'])) == FALSE) {
-    unset($_SESSION['cart_order']);
-    unset($_SESSION['have_details']);
-    unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
-    drupal_set_message(t('An error has occurred in your PayPal payment. Please review your cart and try again.'));
-    drupal_goto('cart');
-  }
-
-  $request = _uc_payflowpro_get_ec_xml($_SESSION['TOKEN']);
-  $response = _uc_payflowpro_submit_xml($request);
-
-  $_SESSION['PAYERID'] = $response->PayPalResult->PayerID;
-
-  drupal_goto('cart/checkout/review');
-}
-
-// Handles the review page for Express Checkout Shortcut Flow.
-function uc_payflowpro_ec_review() {
-  if (!isset($_SESSION['TOKEN']) || ($order = uc_order_load($_SESSION['cart_order'])) == FALSE) {
-    unset($_SESSION['cart_order']);
-    unset($_SESSION['have_details']);
-    unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
-    drupal_set_message(t('An error has occurred in your PayPal payment. Please review your cart and try again.'));
-    drupal_goto('cart');
-  }
-
-  if ($_SESSION['have_details'][$order->order_id] !== TRUE) {
-    $request = _uc_payflowpro_get_ec_xml($_SESSION['TOKEN']);
-    $response = _uc_payflowpro_submit_xml($request);
-
-    $_SESSION['PAYERID'] = $response->PayPalResult->PayerID;
-
-    // get variables to populate form
-    $billto_name = check_plain(trim($response->PayPalResult->Name));
-    $name_split = strrpos($billto_name, ' ');
-    if ($name_split > 0) {
-      $billto_firstname = substr($billto_name, 0, $name_split);
-      $billto_lastname = substr($billto_name, $name_split);
-    }
-    else {
-      $billto_firstname = $billto_name;
-      $billto_lastname = '';
-    }
-
-    if (empty($response->PayPalResult->ShipTo->Name)) {
-      $shipto_firstname = $billto_firstname;
-      $shipto_lastname = $billto_lastname;
-    }
-    else {
-      $shipto_name = check_plain(trim($response->PayPalResult->Name));
-      $name_split = strrpos($shipto_name, ' ');
-      if ($name_split > 0) {
-        $shipto_firstname = substr($shipto_name, 0, $name_split);
-        $shipto_lastname = substr($shipto_name, $name_split);
-      }
-      else {
-        $shipto_firstname = $shipto_name;
-        $shipto_lastname = '';
-      }
-    }
-
-    $zone_id = db_result(db_query("SELECT zone_id FROM {uc_zones} WHERE zone_code = '%s'", check_plain($response->PayPalResult->ShipTo->Address->State)));
-    $country_id = db_result(db_query("SELECT country_id FROM {uc_countries} WHERE country_iso_code_2 = '%s'", check_plain($response->PayPalResult->ShipTo->Address->Country)));
-
-    $order->delivery_first_name = $shipto_firstname;
-    $order->delivery_last_name = $shipto_lastname;
-    $order->delivery_street1 = check_plain($response->PayPalResult->ShipTo->Street);
-    $order->delivery_city = check_plain($response->PayPalResult->ShipTo->City);
-    $order->delivery_zone = !empty($zone_id) ? $zone_id : 0;
-    $order->delivery_postal_code = check_plain($response->PayPalResult->ShipTo->Zip);
-    $order->delivery_country = !empty($country_id) ? $country_id : 840;
-
-    $order->billing_first_name = $billto_firstname;
-    $order->billing_last_name = $billto_lastname;
-    $order->billing_street1 = $response->PayPalResult->EMail;
-
-    if (empty($order->primary_email)) {
-      $order->primary_email = $response->PayPalResult->EMail;
-    }
-    $order->payment_method = 'payflowpro_ec';
-
-    uc_order_save($order);
-
-    $_SESSION['have_details'][$order->order_id] = TRUE;
-  }
-
-  $output = t("Your order is almost complete!  Please fill in the following details and click 'Continue checkout' to finalize the purchase.");
-
-  $output .= drupal_get_form('uc_payflowpro_ec_review_form', $order);
-
-  return $output;
-}
-
-// Present the final total to the user for checkout!
-function uc_payflowpro_ec_submit() {
-  if (!isset($_SESSION['TOKEN']) || ($order = uc_order_load($_SESSION['cart_order'])) == FALSE) {
-    unset($_SESSION['cart_order'], $_SESSION['have_details']);
-    unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
-    drupal_set_message(t('An error has occurred in your PayPal payment. Please review your cart and try again.'));
-    drupal_goto('cart');
-  }
-
-  // [ML] FIXME: this doesn't seem normal to be here..
-  $output = '<div style="border: solid 1px #bbb;">'. _cart_review_table(FALSE) .'</div>';
-  $output .= uc_order_pane_line_items('customer', $order);
-  $output .= '<p>'. t("Your order is not complete until you click the 'Submit order' button below. Your PayPal account will be charged for the amount shown above once your order is placed. You will receive confirmation once your payment is complete.") .'</p>';
-  $output .= drupal_get_form('uc_payflowpro_ec_submit_form');
-
-  return $output;
-}
-
-// Redirects if a customer selects PayPal Express Checkout as a payment method.
-function uc_payflowpro_ec_checkout($form_id, $form_values) {
-  if ($form_values['panes']['payment']['pane']['payment_method'] != 'payflowpro_ec') {
-    return;
-  }
-
-  if (!_uc_payflowpro_check_requirements()) {
-    return array('success' => FALSE);
-  }
-
-  global $user;
-
-  $order_id = intval($_SESSION['cart_order']);
-
-  $order = uc_order_load($order_id);
-  if ($order === FALSE || $order->order_status != uc_get_order_status_id('in_checkout')) {
-    $_SESSION['cart_order'] = NULL;
-    unset($_SESSION['cart_order']);
-    drupal_goto('cart');
-  }
-
-  $request = _uc_payflowpro_set_ec_xml($order);
-  $response = _uc_payflowpro_submit_xml($request);
-
-  if (!$response) {
-    drupal_set_message(t('Received blank message from PayPal.  Please try again later'));
-    drupal_goto('cart/checkout');
-  }
-
-  $txn_result_code = $response->Result;
-  $txn_message = $response->Message;
-
-  if ((int)$txn_result_code != 0) {
-    drupal_set_message(t('Error message from PayPal:<br>!message', array('!message' => $txn_message)), 'error');
-    drupal_goto('cart/checkout');
-  }
-
-  $_SESSION['TOKEN'] = $response->PayPalResult->Token;
-
-  header('Location: '. _uc_payflowpro_ec_url());
-  exit();
-}
-
-function uc_payflowpro_ec_complete($order_id = 0) {
-  if (intval($order_id) < 1) {
-    drupal_goto('cart');
-  }
-
-  if (intval($_SESSION['cart_order']) != $order_id) {
-    $_SESSION['cart_order'] = $order_id;
-  }
-
-  $order = uc_order_load($order_id);
-
-  if ($order === FALSE || $oder->order_status != uc_get_order_status_id('in_checkout')) {
-    drupal_goto('cart');
-  }
-
-  // This lets us know it's a legitimate access of the complete page.
-  $_SESSION['do_complete'] = TRUE;
-
-  drupal_goto('cart/checkout/complete');
-}
-
-function uc_payflowpro_ec_cancel() {
-  unset($_SESSION['cart_order']);
-
-  drupal_set_message(t('Your PayPal.com payment was cancelled. Please feel free to continue shopping or contact us for assistance.'));
-
-  drupal_goto('cart');
-}
-
-function _uc_payflowpro_ec_url() {
-  if (variable_get('uc_payflowpro_mode', 'test') == 'test') {
-    $url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='. $_SESSION['TOKEN'];
-  }
-  else {
-    $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='. $_SESSION['TOKEN'];
-  }
-
-  return $url;
-  header('Location: '. $url);
-}
-
-/*******************************************************************************
- * Express Checkout Forms
- ******************************************************************************/
-
-// Returns the form for Express Checkout Shortcut Flow.
-function uc_payflowpro_ec_form() {
-  if (!_uc_payflowpro_check_requirements()) {
-    return array('success' => FALSE);
-  }
-
-  // Hack to allow the image button to submit.
-  if (isset($_POST['submit_x'])) {
-    $form['submit'] = array(
-      '#type' => 'submit',
-      '#value' => 'submit',
-    );
-  }
-
-  $form['submit_image'] = array(
-    '#value' => '<input name="submit" type="image" title="'. t('Checkout with PayPal.') .'" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckoutsm.gif" style="position: relative; top: -1.25em;">',
-  );
-
-  return $form;
-}
-
-// Returns the form for the custom Review Payment screen for Express Checkout.
-function uc_payflowpro_ec_review_form($order) {
-  if (module_exists('uc_quote') && variable_get('uc_payflowpro_ec_review_shipping', TRUE)) {
-    // Remove once line items are out of checkout. -RS
-    uc_add_base_path_js();
-    drupal_add_js(drupal_get_path('module', 'uc_payment') .'/uc_payment.js');
-
-    $result = uc_checkout_pane_quotes('view', $order, NULL);
-    $form['panes'] = array('#tree' => TRUE);
-    $form['panes']['quotes'] = $result->fields;
-    $form['panes']['quotes']['pane']['#collapsible'] = FALSE;
-    $form['panes']['quotes']['pane']['#title'] = t('Calculate shipping');
-
-    // Fake the checkout form delivery information.
-    $form['delivery_first_name'] = array('#type' => 'hidden', '#value' => $order->delivery_first_name);
-    $form['delivery_last_name'] = array('#type' => 'hidden', '#value' => $order->delivery_last_name);
-    $form['delivery_company'] = array('#type' => 'hidden', '#value' => $order->delivery_company);
-    $form['delivery_street1'] = array('#type' => 'hidden', '#value' => $order->delivery_street1);
-    $form['delivery_street2'] = array('#type' => 'hidden', '#value' => $order->delivery_street2);
-    $form['delivery_city'] = array('#type' => 'hidden', '#value' => $order->delivery_city);
-    $form['delivery_postal_code'] = array('#type' => 'hidden', '#value' => $order->delivery_postal_code);
-    $form['delivery_phone'] = array('#type' => 'hidden', '#value' => $order->delivery_phone);
-    $form['delivery_zone'] = array(
-      '#type' => 'select',
-      '#options' => drupal_map_assoc(array($order->delivery_zone)),
-      '#default_value' => $order->delivery_zone,
-      '#attributes' => array('style' => 'display: none;'),
-    );
-    $form['delivery_country'] = array(
-      '#type' => 'select',
-      '#options' => drupal_map_assoc(array($order->delivery_country)),
-      '#default_value' => $order->delivery_country,
-      '#attributes' => array('style' => 'display: none;'),
-    );
-  }
-
-  if (variable_get('uc_payflowpro_ec_review_company', TRUE)) {
-    $form['delivery_company'] = array(
-      '#type' => 'textfield',
-      '#title' => uc_get_field_name('company'),
-      '#description' => t('Leave blank if shipping to a residence.'),
-      '#default_value' => $order->delivery_company,
-    );
-  }
-
-  if (variable_get('uc_payflowpro_ec_review_phone', TRUE)) {
-    $form['delivery_phone'] = array(
-      '#type' => 'textfield',
-      '#title' => t('Contact phone number'),
-      '#default_value' => $order->delivery_phone,
-      '#size' => 24,
-    );
-  }
-
-  if (variable_get('uc_payflowpro_ec_review_comment', TRUE)) {
-    $form['order_comments'] = array(
-      '#type' => 'textarea',
-      '#title' => t('Order comments'),
-      '#description' => t('Special instructions or notes regarding your order.'),
-    );
-  }
-
-  if (empty($form)) {
-    drupal_goto('cart/echeckout/submit');
-  }
-
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Continue checkout'),
-  );
-
-  return $form;
-}
-
-// Submits an order, calling the NVP API to send the order total to PayPal.
-function uc_payflowpro_ec_submit_form() {
-  $form['submit'] = array(
-    '#type' => 'submit',
-    '#value' => t('Submit order'),
-  );
-
-  return $form;
-}
-
-/*******************************************************************************
- * Express Checkout Form Submissions
- ******************************************************************************/
-
-function uc_payflowpro_ec_form_submit($form, &$form_state) {
-  global $user;
-  $items = uc_cart_get_contents();
-
-  if (!is_array($items) || count($items) == 0) {
-    drupal_set_message(t('You do not have any items in your shopping cart.'));
-    return;
-  }
-
-  $order = uc_order_new($user->uid);
-  $order->products = $items;
-
-  $request = _uc_payflowpro_set_ec_xml($order);
-  $response = _uc_payflowpro_submit_xml($request);
-
-  if (!$response) {
-    drupal_set_message(t('Received blank message from PayPal.  Please try again later'));
-    drupal_goto('cart/checkout');
-  }
-
-  $txn_result_code = $response->Result;
-  $txn_message = $response->Message;
-
-  if ((int)$txn_result_code != 0) {
-    drupal_set_message(t('Error message from PayPal:<br>!message', array('!message' => $txn_message)), 'error');
-    drupal_goto('cart/checkout');
-  }
-
-  uc_order_save($order);
-
-  $_SESSION['cart_order'] = $order->order_id;
-  $_SESSION['token'] = $response->PayPalResult->Token;
-
-  $form_state['redirect'] = _uc_payflowpro_ec_url();
-}
-
-function uc_payflowpro_ec_review_form_validate($form, &$form_state) {
-  if (module_exists('uc_quote') && variable_get('uc_payflowpro_ec_review_shipping', TRUE)) {
-    if (empty($form_state['values']['panes']['quotes']['pane']['quote_method']) || !isset($_POST['quote-option'])) {
-      drupal_set_message(t('You must specify a shipping option.'), 'error');
-      return FALSE;
-    }
-  }
-}
-
-function uc_payflowpro_ec_review_form_submit($form, &$form_state) {
-  $order = uc_order_load($_SESSION['cart_order']);
-
-  if (module_exists('uc_quote') && variable_get('uc_payflowpro_ec_review_shipping', TRUE)) {
-    $order->quote['method'] = $form_state['values']['panes']['quotes']['pane']['quote_method'];
-    $order->quote['accessorials'] = isset($_POST['quote-option']) ? strval($_POST['quote-option']) : 0;
-    $order->quote['rate'] = $_POST['rate'][$order->quote['accessorials']];
-    $order->quote['quote_form'] = rawurldecode($_POST['quote-form']);
-    $methods = module_invoke_all('shipping_method');
-    $method = $methods[$order->quote['method']];
-    $label = is_null($_POST['quote-option']) ? t('Error calculating shipping') : $method['quote']['accessorials'][$order->quote['accessorials']];                   $result = db_query("SELECT line_item_id FROM {uc_order_line_items} WHERE order_id = %d AND type = 'shipping'", $order->order_id);                               if ($lid = db_result($result)) {
-      uc_order_update_line_item($lid, $label, $order->quote['rate']);
-    }
-    else {
-      uc_order_line_item_add($order->order_id, 'shipping', $label, $order->quote['rate']);
-    }
-  }
-
-  if (variable_get('uc_payflowpro_ec_review_company', TRUE)) {
-    $order->delivery_company = $form_state['values']['delivery_company'];
-  }
-
-  if (variable_get('uc_payflowpro_ec_review_phone', TRUE)) {
-    $order->delivery_phone = $form_state['values']['delivery_phone'];
-  }
-
-  if (variable_get('uc_payflowpro_ec_review_comment', TRUE)) {
-    db_query("DELETE FROM {uc_order_comments} WHERE order_id = %d", $order->order_id);
-    uc_order_comment_save($order->order_id, 0, $form_state['values']['order_comments'], 'order');
-  }
-
-  uc_order_save($order);
-
-  // drupal_goto('cart/echeckout/submit');
-  $form_state['redirect'] = 'cart/echeckout/submit';
-}
-
-function uc_payflowpro_ec_submit_form_submit($form, &$form_state) {
-  $order = uc_order_load($_SESSION['cart_order']);
-
-  $request = _uc_payflowpro_do_ec_xml($order);
-  $response = _uc_payflowpro_submit_xml($request);
-
-  unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
-  $_SESSION['do_complete'] = TRUE;
-
-  // drupal_goto('cart/checkout/complete');
-  $form_state['redirect'] = 'cart/checkout/complete';
-}
-
-/*******************************************************************************
  * XML Helper Functions
  ******************************************************************************/
 
@@ -1145,73 +638,6 @@ function _uc_payflowpro_cc_info_xml($order_id) {
   return $xml;
 }
 
-// Generate XML for SetExpressCheckout
-function _uc_payflowpro_set_ec_xml($order) {
-  // Get payment action (Sale or Authorization)
-  $payment_action = variable_get('uc_payflowpro_payment_action', '');
-
-  $xml = '         <SetExpressCheckout>
-          <' . $payment_action . '>
-            <PayData>
-' . _uc_payflowpro_invoice_xml($order) . '
-              <Tender>
-                <PayPal>
-                  <EMail>' . check_plain($order->primary_email) . '</EMail>
-                  <ReturnURL>' . url('cart/echeckout/selected', array('absolute' => TRUE)) . '</ReturnURL>
-                  <CancelURL>' . url('uc_payflowpro/ec/cancel', array('absolute' => TRUE)) . '</CancelURL>
-                  <ReqConfirmShipping>' . check_plain(variable_get('uc_payflowpro_ec_reqconfirmed_addr', '')) . '</ReqConfirmShipping>
-                </PayPal>
-              </Tender>
-            </PayData>
-          </' . $payment_action . '>
-        </SetExpressCheckout>';
-
-  return _uc_payflowpro_wrap_xml($xml);
-}
-
-// Generate XML for GetExpressCheckout
-function _uc_payflowpro_get_ec_xml($token) {
-  // Get payment action (Sale or Authorization)
-  $payment_action = variable_get('uc_payflowpro_payment_action', '');
-
-  $xml = '         <GetExpressCheckout>
-          <' . $payment_action . '>
-            <PayData>
-              <Tender>
-                <PayPal>
-                  <Token>' . check_plain($token) . '</Token>
-                </PayPal>
-              </Tender>
-            </PayData>
-          </' . $payment_action . '>
-        </GetExpressCheckout>';
-
-  return _uc_payflowpro_wrap_xml($xml);
-}
-
-// Generate XML for DoExpressCheckout
-function _uc_payflowpro_do_ec_xml($order) {
-  // Get payment action (Sale or Authorization)
-  $payment_action = variable_get('uc_payflowpro_payment_action', '');
-
-  $xml = '         <DoExpressCheckout>
-          <' . $payment_action . '>
-            <PayData>
-' . _uc_payflowpro_invoice_xml($order) . '
-              <Tender>
-                <PayPal>
-                  <Token>' . check_plain($_SESSION['TOKEN']) . ' </Token>
-                  <PayerID>' . check_plain($_SESSION['PAYERID']) . '</PayerID>
-                  <ButtonSource>Ubercart_ShoppingCart_EC_US</ButtonSource>
-                </PayPal>
-              </Tender>
-            </PayData>
-          </' . $payment_action . '>
-          </DoExpressCheckout>';
-
-  return _uc_payflowpro_wrap_xml($xml);
-}
-
 // Generate XML for Recurring profiles
 function _uc_payflowpro_recurring_profile($order, $opt = array()) {
   $billing_country = uc_get_country_data(array('country_id' => $order->billing_country));
diff --git uc_payflowpro_ec/uc_payflowpro_ec.info uc_payflowpro_ec/uc_payflowpro_ec.info
new file mode 100755
index 0000000..8ace3e2
--- /dev/null
+++ uc_payflowpro_ec/uc_payflowpro_ec.info
@@ -0,0 +1,7 @@
+; $Id$
+name = PayFlow Pro Express Checkout
+description = Allows use of Express Checkout with uc_payflowpro.
+dependencies[] = uc_payflowpro
+package = Ubercart - payment
+core = 6.x
+php = 5.0
diff --git uc_payflowpro_ec/uc_payflowpro_ec.install uc_payflowpro_ec/uc_payflowpro_ec.install
new file mode 100755
index 0000000..42d6354
--- /dev/null
+++ uc_payflowpro_ec/uc_payflowpro_ec.install
@@ -0,0 +1,14 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function uc_payflowpro_ec_uninstall() {
+  variable_del('uc_payflowpro_ec_reqconfirmed_addr');
+  variable_del('uc_payflowpro_ec_review_comment');
+  variable_del('uc_payflowpro_ec_review_company');
+  variable_del('uc_payflowpro_ec_review_phone');
+  variable_del('uc_payflowpro_ec_review_shipping');
+  variable_del('uc_payment_method_payflowpro_ec_checkout'); // TODO: used?
+}
diff --git uc_payflowpro_ec/uc_payflowpro_ec.module uc_payflowpro_ec/uc_payflowpro_ec.module
new file mode 100755
index 0000000..e9df79a
--- /dev/null
+++ uc_payflowpro_ec/uc_payflowpro_ec.module
@@ -0,0 +1,649 @@
+<?php
+// $Id$
+
+// TODO: make sure all functions are actually used, delete those that aren't.
+
+/**
+ * Implementation of hook_menu()
+ */
+function uc_payflowpro_ec_menu() {
+  // Callback functions for Express Checkout
+  //TODO: make sure that EC works.
+  $items['cart/echeckout/selected'] = array(
+    'title' => 'Review order',
+    'page callback' => 'uc_payflowpro_ec_review_redirect',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['cart/echeckout/review'] = array(
+    'title' => 'Review payment',
+    'page callback' => 'uc_payflowpro_ec_review',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['cart/echeckout/submit'] = array(
+    'title' => 'Submit order',
+    'page callback' => 'uc_payflowpro_ec_submit',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['cart/echeckout/complete'] = array(
+    'title' => 'Order complete',
+    'page callback' => 'uc_payflowpro_ec_complete',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+  $items['cart/echeckout/cancel'] = array(
+    'title' => 'PayPal payment cancelled',
+    'page callback' => 'uc_payflowpro_ec_cancel',
+    'access arguments' => array('access content'),
+    'type' => MENU_CALLBACK,
+  );
+
+  return $items;
+}
+
+/**
+ * Implementation of hook_form_alter()
+ * To allow express checkout
+ */
+function uc_payflowpro_ec_form_alter(&$form, $form_state, $form_id) {
+  if ($form_id == 'uc_cart_checkout_form' && variable_get('uc_payment_method_payflowpro_ec_checkout', FALSE)) {
+    $form['#submit'] = (array)$form['#submit'] + array('uc_payflowpro_ec_checkout' => array());
+  }
+
+  if ($form_id == 'uc_cart_checkout_review_form' && !empty($_SESSION['TOKEN'])) {
+    $form['#submit'] = (array)$form['#submit'] + array('uc_payflowpro_ec_submit_form_submit' => array());
+  }
+
+}
+
+/**
+ * Implementation of hook_cart_pane()
+ */
+function uc_payflowpro_ec_cart_pane() {
+
+  $panes[] = array(
+    'id' => 'uc_payflowpro_ec',
+    'title' => t('PayPal Express Checkout'),
+    'enabled' => FALSE,
+    'weight' => 1,
+    'body' => '<div align="right">'. drupal_get_form('uc_payflowpro_ec_form') .'</div>',
+  );
+
+  return $panes;
+}
+
+/**
+* Implementation of hook_payment_method().
+ */
+function uc_payflowpro_ec_payment_method() {
+  $title1 = '<img src="https://www.paypal.com/en_US/i/logo/PayPal_mark_37x23.gif" style="position: relative; top: 5px; margin-right: 4px;">'
+            . t('PayPal - pay without sharing your financial information.');
+
+  $methods[] = array(
+    'id' => 'payflowpro_ec',
+    'name' => t('PayPal Express Checkout'),
+    'title' => $title1,
+    'review' => t('PayPal'),
+    'desc' => t('Complete orders through PayPal Express Checkout.'),
+    'callback' => 'uc_payment_method_payflowpro_ec',
+    'weight' => 1,
+    'checkout' => FALSE,
+    'backend' => FALSE,
+  );
+
+  return $methods;
+}
+
+function uc_payflowpro_ec_form_uc_payment_gateways_form_alter(&$form, $form_state) {
+  // TODO: fix this.
+
+  /*$form['payflowpro_settings']['ec'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Express Checkout'),
+    '#description' => t('These settings are specifically for the alternate checkout system offered by Express Checkout.<br>To enable this on your site, you must enable the corresponding cart pane in the <em>Cart settings</em> menu.'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  $form['payflowpro_settings']['ec']['uc_payflowpro_ec_reqconfirmed_addr'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Require Express Checkout users to use a PayPal confirmed shipping address.'),
+    '#default_value' => variable_get('uc_payflowpro_ec_reqconfirmed_addr', FALSE),
+  );
+  $form['payflowpro_settings']['ec']['uc_payflowpro_ec_review_shipping'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable the shipping select form on the Review payment page.'),
+    '#default_value' => variable_get('uc_payflowpro_ec_review_shipping', TRUE),
+  );
+  $form['payflowpro_settings']['ec']['uc_paypflowpro_ec_review_company'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable the company name box on the Review payment page.'),
+    '#default_value' => variable_get('uc_payflowpro_ec_review_company', TRUE),
+  );
+  $form['payflowpro_settings']['ec']['uc_payflowpro_ec_review_phone'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable the contact phone number box on the Review payment page.'),
+    '#default_value' => variable_get('uc_payflowpro_ec_review_phone', TRUE),
+  );
+  $form['payflowpro_settings']['ec']['uc_payflowpro_ec_review_comment'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enable the comment text box on the Review payment page.'),
+    '#default_value' => variable_get('uc_payflowpro_ec_review_comment', TRUE),
+  );*/
+
+  /*$fields = array(
+    '#type' => 'fieldset',
+    '#title' => t('Recurring Settings'),
+    '#description' => t('Settings specific to recurring profiles.'),
+    '#collapsible' => TRUE,
+    '#collapsied' => TRUE,
+  );
+  // TODO: remove this option? also change in uninstall / update hooks
+  $fields['uc_payflowpro_recurring_create_order'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Successful recurring payments should create a duplicate order'),
+    '#default_value' => variable_get('uc_payflowpro_recurring_create_order', FALSE),
+    '#description' => t('If this box is unchecked, the original order will be updated instead.'),
+  );
+  $fields['uc_payflowpro_recurring_site_key'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Site key'),
+    '#description' => t('The site key is used to namespace your site from other
+                        sites. This should be short, all letters or numbers or both,
+                        e.g. mysite, or prodsite, etc.'),
+    '#default_value' => variable_get('uc_payflowpro_recurring_site_key', ''),
+  );
+
+  $form['gateways']['payflowpro']['payflowpro_settings']['recurring'] = $fields;*/
+}
+
+
+/*******************************************************************************
+ * Express Checkout Functions
+ ******************************************************************************/
+
+// Handles the Express Checkout payment method
+function uc_payment_method_payflowpro_ec($op, &$arg1) {
+  switch ($op) {
+    //case 'order-view':
+    case 'settings':
+      $form['redirect'] = array(
+        '#value' => '<div>'. t('For Express Checkout, you need to !cp_link and !wpp_link.', array('!cp_link' => l(t('enable the cart pane'), 'admin/store/settings/cart/edit/panes'), '!wpp_link' => l(t('configure the PayFlow Pro settings'), 'admin/store/settings/payment/edit/gateways'))) .'</div>',
+      );
+      return $form;
+  }
+}
+
+// Handles the review page for Express Checkout Mark Flow.
+function uc_payflowpro_ec_review_redirect() {
+  if (!isset($_SESSION['TOKEN']) || ($order = uc_order_load($_SESSION['cart_order'])) == FALSE) {
+    unset($_SESSION['cart_order']);
+    unset($_SESSION['have_details']);
+    unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
+    drupal_set_message(t('An error has occurred in your PayPal payment. Please review your cart and try again.'));
+    drupal_goto('cart');
+  }
+
+  $request = _uc_payflowpro_get_ec_xml($_SESSION['TOKEN']);
+  $response = _uc_payflowpro_submit_xml($request);
+
+  $_SESSION['PAYERID'] = $response->PayPalResult->PayerID;
+
+  drupal_goto('cart/checkout/review');
+}
+
+// Handles the review page for Express Checkout Shortcut Flow.
+function uc_payflowpro_ec_review() {
+  if (!isset($_SESSION['TOKEN']) || ($order = uc_order_load($_SESSION['cart_order'])) == FALSE) {
+    unset($_SESSION['cart_order']);
+    unset($_SESSION['have_details']);
+    unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
+    drupal_set_message(t('An error has occurred in your PayPal payment. Please review your cart and try again.'));
+    drupal_goto('cart');
+  }
+
+  if ($_SESSION['have_details'][$order->order_id] !== TRUE) {
+    $request = _uc_payflowpro_get_ec_xml($_SESSION['TOKEN']);
+    $response = _uc_payflowpro_submit_xml($request);
+
+    $_SESSION['PAYERID'] = $response->PayPalResult->PayerID;
+
+    // get variables to populate form
+    $billto_name = check_plain(trim($response->PayPalResult->Name));
+    $name_split = strrpos($billto_name, ' ');
+    if ($name_split > 0) {
+      $billto_firstname = substr($billto_name, 0, $name_split);
+      $billto_lastname = substr($billto_name, $name_split);
+    }
+    else {
+      $billto_firstname = $billto_name;
+      $billto_lastname = '';
+    }
+
+    if (empty($response->PayPalResult->ShipTo->Name)) {
+      $shipto_firstname = $billto_firstname;
+      $shipto_lastname = $billto_lastname;
+    }
+    else {
+      $shipto_name = check_plain(trim($response->PayPalResult->Name));
+      $name_split = strrpos($shipto_name, ' ');
+      if ($name_split > 0) {
+        $shipto_firstname = substr($shipto_name, 0, $name_split);
+        $shipto_lastname = substr($shipto_name, $name_split);
+      }
+      else {
+        $shipto_firstname = $shipto_name;
+        $shipto_lastname = '';
+      }
+    }
+
+    $zone_id = db_result(db_query("SELECT zone_id FROM {uc_zones} WHERE zone_code = '%s'", check_plain($response->PayPalResult->ShipTo->Address->State)));
+    $country_id = db_result(db_query("SELECT country_id FROM {uc_countries} WHERE country_iso_code_2 = '%s'", check_plain($response->PayPalResult->ShipTo->Address->Country)));
+
+    $order->delivery_first_name = $shipto_firstname;
+    $order->delivery_last_name = $shipto_lastname;
+    $order->delivery_street1 = check_plain($response->PayPalResult->ShipTo->Street);
+    $order->delivery_city = check_plain($response->PayPalResult->ShipTo->City);
+    $order->delivery_zone = !empty($zone_id) ? $zone_id : 0;
+    $order->delivery_postal_code = check_plain($response->PayPalResult->ShipTo->Zip);
+    $order->delivery_country = !empty($country_id) ? $country_id : 840;
+
+    $order->billing_first_name = $billto_firstname;
+    $order->billing_last_name = $billto_lastname;
+    $order->billing_street1 = $response->PayPalResult->EMail;
+
+    if (empty($order->primary_email)) {
+      $order->primary_email = $response->PayPalResult->EMail;
+    }
+    $order->payment_method = 'payflowpro_ec';
+
+    uc_order_save($order);
+
+    $_SESSION['have_details'][$order->order_id] = TRUE;
+  }
+
+  $output = t("Your order is almost complete!  Please fill in the following details and click 'Continue checkout' to finalize the purchase.");
+
+  $output .= drupal_get_form('uc_payflowpro_ec_review_form', $order);
+
+  return $output;
+}
+
+// Present the final total to the user for checkout!
+function uc_payflowpro_ec_submit() {
+  if (!isset($_SESSION['TOKEN']) || ($order = uc_order_load($_SESSION['cart_order'])) == FALSE) {
+    unset($_SESSION['cart_order'], $_SESSION['have_details']);
+    unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
+    drupal_set_message(t('An error has occurred in your PayPal payment. Please review your cart and try again.'));
+    drupal_goto('cart');
+  }
+
+  // [ML] FIXME: this doesn't seem normal to be here..
+  $output = '<div style="border: solid 1px #bbb;">'. _cart_review_table(FALSE) .'</div>';
+  $output .= uc_order_pane_line_items('customer', $order);
+  $output .= '<p>'. t("Your order is not complete until you click the 'Submit order' button below. Your PayPal account will be charged for the amount shown above once your order is placed. You will receive confirmation once your payment is complete.") .'</p>';
+  $output .= drupal_get_form('uc_payflowpro_ec_submit_form');
+
+  return $output;
+}
+
+// Redirects if a customer selects PayPal Express Checkout as a payment method.
+function uc_payflowpro_ec_checkout($form_id, $form_values) {
+  if ($form_values['panes']['payment']['pane']['payment_method'] != 'payflowpro_ec') {
+    return;
+  }
+
+  if (!_uc_payflowpro_check_requirements()) {
+    return array('success' => FALSE);
+  }
+
+  global $user;
+
+  $order_id = intval($_SESSION['cart_order']);
+
+  $order = uc_order_load($order_id);
+  if ($order === FALSE || $order->order_status != uc_get_order_status_id('in_checkout')) {
+    $_SESSION['cart_order'] = NULL;
+    unset($_SESSION['cart_order']);
+    drupal_goto('cart');
+  }
+
+  $request = _uc_payflowpro_set_ec_xml($order);
+  $response = _uc_payflowpro_submit_xml($request);
+
+  if (!$response) {
+    drupal_set_message(t('Received blank message from PayPal.  Please try again later'));
+    drupal_goto('cart/checkout');
+  }
+
+  $txn_result_code = $response->Result;
+  $txn_message = $response->Message;
+
+  if ((int)$txn_result_code != 0) {
+    drupal_set_message(t('Error message from PayPal:<br>!message', array('!message' => $txn_message)), 'error');
+    drupal_goto('cart/checkout');
+  }
+
+  $_SESSION['TOKEN'] = $response->PayPalResult->Token;
+
+  header('Location: '. _uc_payflowpro_ec_url());
+  exit();
+}
+
+function uc_payflowpro_ec_complete($order_id = 0) {
+  if (intval($order_id) < 1) {
+    drupal_goto('cart');
+  }
+
+  if (intval($_SESSION['cart_order']) != $order_id) {
+    $_SESSION['cart_order'] = $order_id;
+  }
+
+  $order = uc_order_load($order_id);
+
+  if ($order === FALSE || $oder->order_status != uc_get_order_status_id('in_checkout')) {
+    drupal_goto('cart');
+  }
+
+  // This lets us know it's a legitimate access of the complete page.
+  $_SESSION['do_complete'] = TRUE;
+
+  drupal_goto('cart/checkout/complete');
+}
+
+function uc_payflowpro_ec_cancel() {
+  unset($_SESSION['cart_order']);
+
+  drupal_set_message(t('Your PayPal.com payment was cancelled. Please feel free to continue shopping or contact us for assistance.'));
+
+  drupal_goto('cart');
+}
+
+function _uc_payflowpro_ec_url() {
+  if (variable_get('uc_payflowpro_mode', 'test') == 'test') {
+    $url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='. $_SESSION['TOKEN'];
+  }
+  else {
+    $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token='. $_SESSION['TOKEN'];
+  }
+
+  return $url;
+  header('Location: '. $url);
+}
+
+/*******************************************************************************
+ * Express Checkout Forms
+ ******************************************************************************/
+
+// Returns the form for Express Checkout Shortcut Flow.
+function uc_payflowpro_ec_form() {
+  if (!_uc_payflowpro_check_requirements()) {
+    return array('success' => FALSE);
+  }
+
+  // Hack to allow the image button to submit.
+  if (isset($_POST['submit_x'])) {
+    $form['submit'] = array(
+      '#type' => 'submit',
+      '#value' => 'submit',
+    );
+  }
+
+  $form['submit_image'] = array(
+    '#value' => '<input name="submit" type="image" title="'. t('Checkout with PayPal.') .'" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckoutsm.gif" style="position: relative; top: -1.25em;">',
+  );
+
+  return $form;
+}
+
+// Returns the form for the custom Review Payment screen for Express Checkout.
+function uc_payflowpro_ec_review_form($order) {
+  if (module_exists('uc_quote') && variable_get('uc_payflowpro_ec_review_shipping', TRUE)) {
+    // Remove once line items are out of checkout. -RS
+    uc_add_base_path_js();
+    drupal_add_js(drupal_get_path('module', 'uc_payment') .'/uc_payment.js');
+
+    $result = uc_checkout_pane_quotes('view', $order, NULL);
+    $form['panes'] = array('#tree' => TRUE);
+    $form['panes']['quotes'] = $result->fields;
+    $form['panes']['quotes']['pane']['#collapsible'] = FALSE;
+    $form['panes']['quotes']['pane']['#title'] = t('Calculate shipping');
+
+    // Fake the checkout form delivery information.
+    $form['delivery_first_name'] = array('#type' => 'hidden', '#value' => $order->delivery_first_name);
+    $form['delivery_last_name'] = array('#type' => 'hidden', '#value' => $order->delivery_last_name);
+    $form['delivery_company'] = array('#type' => 'hidden', '#value' => $order->delivery_company);
+    $form['delivery_street1'] = array('#type' => 'hidden', '#value' => $order->delivery_street1);
+    $form['delivery_street2'] = array('#type' => 'hidden', '#value' => $order->delivery_street2);
+    $form['delivery_city'] = array('#type' => 'hidden', '#value' => $order->delivery_city);
+    $form['delivery_postal_code'] = array('#type' => 'hidden', '#value' => $order->delivery_postal_code);
+    $form['delivery_phone'] = array('#type' => 'hidden', '#value' => $order->delivery_phone);
+    $form['delivery_zone'] = array(
+      '#type' => 'select',
+      '#options' => drupal_map_assoc(array($order->delivery_zone)),
+      '#default_value' => $order->delivery_zone,
+      '#attributes' => array('style' => 'display: none;'),
+    );
+    $form['delivery_country'] = array(
+      '#type' => 'select',
+      '#options' => drupal_map_assoc(array($order->delivery_country)),
+      '#default_value' => $order->delivery_country,
+      '#attributes' => array('style' => 'display: none;'),
+    );
+  }
+
+  if (variable_get('uc_payflowpro_ec_review_company', TRUE)) {
+    $form['delivery_company'] = array(
+      '#type' => 'textfield',
+      '#title' => uc_get_field_name('company'),
+      '#description' => t('Leave blank if shipping to a residence.'),
+      '#default_value' => $order->delivery_company,
+    );
+  }
+
+  if (variable_get('uc_payflowpro_ec_review_phone', TRUE)) {
+    $form['delivery_phone'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Contact phone number'),
+      '#default_value' => $order->delivery_phone,
+      '#size' => 24,
+    );
+  }
+
+  if (variable_get('uc_payflowpro_ec_review_comment', TRUE)) {
+    $form['order_comments'] = array(
+      '#type' => 'textarea',
+      '#title' => t('Order comments'),
+      '#description' => t('Special instructions or notes regarding your order.'),
+    );
+  }
+
+  if (empty($form)) {
+    drupal_goto('cart/echeckout/submit');
+  }
+
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Continue checkout'),
+  );
+
+  return $form;
+}
+
+// Submits an order, calling the NVP API to send the order total to PayPal.
+function uc_payflowpro_ec_submit_form() {
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Submit order'),
+  );
+
+  return $form;
+}
+
+/*******************************************************************************
+ * Express Checkout Form Submissions
+ ******************************************************************************/
+
+function uc_payflowpro_ec_form_submit($form, &$form_state) {
+  global $user;
+  $items = uc_cart_get_contents();
+
+  if (!is_array($items) || count($items) == 0) {
+    drupal_set_message(t('You do not have any items in your shopping cart.'));
+    return;
+  }
+
+  $order = uc_order_new($user->uid);
+  $order->products = $items;
+
+  $request = _uc_payflowpro_set_ec_xml($order);
+  $response = _uc_payflowpro_submit_xml($request);
+
+  if (!$response) {
+    drupal_set_message(t('Received blank message from PayPal.  Please try again later'));
+    drupal_goto('cart/checkout');
+  }
+
+  $txn_result_code = $response->Result;
+  $txn_message = $response->Message;
+
+  if ((int)$txn_result_code != 0) {
+    drupal_set_message(t('Error message from PayPal:<br>!message', array('!message' => $txn_message)), 'error');
+    drupal_goto('cart/checkout');
+  }
+
+  uc_order_save($order);
+
+  $_SESSION['cart_order'] = $order->order_id;
+  $_SESSION['token'] = $response->PayPalResult->Token;
+
+  $form_state['redirect'] = _uc_payflowpro_ec_url();
+}
+
+function uc_payflowpro_ec_review_form_validate($form, &$form_state) {
+  if (module_exists('uc_quote') && variable_get('uc_payflowpro_ec_review_shipping', TRUE)) {
+    if (empty($form_state['values']['panes']['quotes']['pane']['quote_method']) || !isset($_POST['quote-option'])) {
+      drupal_set_message(t('You must specify a shipping option.'), 'error');
+      return FALSE;
+    }
+  }
+}
+
+function uc_payflowpro_ec_review_form_submit($form, &$form_state) {
+  $order = uc_order_load($_SESSION['cart_order']);
+
+  if (module_exists('uc_quote') && variable_get('uc_payflowpro_ec_review_shipping', TRUE)) {
+    $order->quote['method'] = $form_state['values']['panes']['quotes']['pane']['quote_method'];
+    $order->quote['accessorials'] = isset($_POST['quote-option']) ? strval($_POST['quote-option']) : 0;
+    $order->quote['rate'] = $_POST['rate'][$order->quote['accessorials']];
+    $order->quote['quote_form'] = rawurldecode($_POST['quote-form']);
+    $methods = module_invoke_all('shipping_method');
+    $method = $methods[$order->quote['method']];
+    $label = is_null($_POST['quote-option']) ? t('Error calculating shipping') : $method['quote']['accessorials'][$order->quote['accessorials']];                   $result = db_query("SELECT line_item_id FROM {uc_order_line_items} WHERE order_id = %d AND type = 'shipping'", $order->order_id);                               if ($lid = db_result($result)) {
+      uc_order_update_line_item($lid, $label, $order->quote['rate']);
+    }
+    else {
+      uc_order_line_item_add($order->order_id, 'shipping', $label, $order->quote['rate']);
+    }
+  }
+
+  if (variable_get('uc_payflowpro_ec_review_company', TRUE)) {
+    $order->delivery_company = $form_state['values']['delivery_company'];
+  }
+
+  if (variable_get('uc_payflowpro_ec_review_phone', TRUE)) {
+    $order->delivery_phone = $form_state['values']['delivery_phone'];
+  }
+
+  if (variable_get('uc_payflowpro_ec_review_comment', TRUE)) {
+    db_query("DELETE FROM {uc_order_comments} WHERE order_id = %d", $order->order_id);
+    uc_order_comment_save($order->order_id, 0, $form_state['values']['order_comments'], 'order');
+  }
+
+  uc_order_save($order);
+
+  // drupal_goto('cart/echeckout/submit');
+  $form_state['redirect'] = 'cart/echeckout/submit';
+}
+
+function uc_payflowpro_ec_submit_form_submit($form, &$form_state) {
+  $order = uc_order_load($_SESSION['cart_order']);
+
+  $request = _uc_payflowpro_do_ec_xml($order);
+  $response = _uc_payflowpro_submit_xml($request);
+
+  unset($_SESSION['TOKEN'], $_SESSION['PAYERID']);
+  $_SESSION['do_complete'] = TRUE;
+
+  // drupal_goto('cart/checkout/complete');
+  $form_state['redirect'] = 'cart/checkout/complete';
+}
+
+
+// Generate XML for SetExpressCheckout
+function _uc_payflowpro_set_ec_xml($order) {
+  // Get payment action (Sale or Authorization)
+  $payment_action = variable_get('uc_payflowpro_payment_action', '');
+
+  $xml = '         <SetExpressCheckout>
+          <' . $payment_action . '>
+            <PayData>
+' . _uc_payflowpro_invoice_xml($order) . '
+              <Tender>
+                <PayPal>
+                  <EMail>' . check_plain($order->primary_email) . '</EMail>
+                  <ReturnURL>' . url('cart/echeckout/selected', array('absolute' => TRUE)) . '</ReturnURL>
+                  <CancelURL>' . url('uc_payflowpro/ec/cancel', array('absolute' => TRUE)) . '</CancelURL>
+                  <ReqConfirmShipping>' . check_plain(variable_get('uc_payflowpro_ec_reqconfirmed_addr', '')) . '</ReqConfirmShipping>
+                </PayPal>
+              </Tender>
+            </PayData>
+          </' . $payment_action . '>
+        </SetExpressCheckout>';
+
+  return _uc_payflowpro_wrap_xml($xml);
+}
+
+// Generate XML for GetExpressCheckout
+function _uc_payflowpro_get_ec_xml($token) {
+  // Get payment action (Sale or Authorization)
+  $payment_action = variable_get('uc_payflowpro_payment_action', '');
+
+  $xml = '         <GetExpressCheckout>
+          <' . $payment_action . '>
+            <PayData>
+              <Tender>
+                <PayPal>
+                  <Token>' . check_plain($token) . '</Token>
+                </PayPal>
+              </Tender>
+            </PayData>
+          </' . $payment_action . '>
+        </GetExpressCheckout>';
+
+  return _uc_payflowpro_wrap_xml($xml);
+}
+
+// Generate XML for DoExpressCheckout
+function _uc_payflowpro_do_ec_xml($order) {
+  // Get payment action (Sale or Authorization)
+  $payment_action = variable_get('uc_payflowpro_payment_action', '');
+
+  $xml = '         <DoExpressCheckout>
+          <' . $payment_action . '>
+            <PayData>
+' . _uc_payflowpro_invoice_xml($order) . '
+              <Tender>
+                <PayPal>
+                  <Token>' . check_plain($_SESSION['TOKEN']) . ' </Token>
+                  <PayerID>' . check_plain($_SESSION['PAYERID']) . '</PayerID>
+                  <ButtonSource>Ubercart_ShoppingCart_EC_US</ButtonSource>
+                </PayPal>
+              </Tender>
+            </PayData>
+          </' . $payment_action . '>
+          </DoExpressCheckout>';
+
+  return _uc_payflowpro_wrap_xml($xml);
+}
