Index: uc_payflowpro.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_payflowpro/uc_payflowpro.module,v
retrieving revision 1.2.2.21
diff -u -r1.2.2.21 uc_payflowpro.module
--- uc_payflowpro.module	8 Feb 2010 15:03:17 -0000	1.2.2.21
+++ uc_payflowpro.module	8 Apr 2010 20:14:03 -0000
@@ -249,6 +249,11 @@
       'uid' => $user->uid,
       'data' => $data,
     );
+
+    if(variable_get('uc_payflowpro_enable_recurring', FALSE)) {
+      // The recurring fee needs to be created before ubercart truncates the CC info down to the last 4 digits.
+      uc_payflowpro_recurring_charge_process($order);
+    }
   }
   uc_order_comment_save($order_id, $user->uid, $message, 'admin');
 
Index: uc_payflowpro.ca.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_payflowpro/Attic/uc_payflowpro.ca.inc,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 uc_payflowpro.ca.inc
--- uc_payflowpro.ca.inc	15 Jul 2009 18:03:55 -0000	1.1.2.1
+++ uc_payflowpro.ca.inc	8 Apr 2010 20:14:02 -0000
@@ -25,14 +25,14 @@
   // Setup a default predicate for customer checkout notifications.
   $predicates['uc_checkout_complete_payflowpro'] = array(
     '#title' => t('Order Complete Recurring Profiles'),
-    '#description' => t('Create recurring profiles when the checkout is complete.'),
+    '#description' => t('Payflow Pro recurring order post-completion processing.'),
     '#class' => 'payment',
     '#status' => 1,
     '#trigger' => 'uc_checkout_complete',
     '#actions' => array(
       array(
         '#name' => 'uc_payflowpro_process_recurring',
-        '#title' => t('Create recurring profiles for the order.'),
+        '#title' => t('Assign automatically created users to the correct recurring profiles.'),
         '#argument_map' => array(
           'order' => 'order',
         ),
@@ -53,9 +53,9 @@
   );
 
   $actions['uc_payflowpro_process_recurring'] = array(
-    '#title' => t('Create recurring profiles for the order.'),
+    '#title' => t('Assign automatically created users to the correct recurring profiles.'),
     '#category' => t('Payment'),
-    '#callback' => 'uc_payflowpro_recurring_charge_process',
+    '#callback' => 'uc_payflowpro_checkout_complete_processing',
     '#arguments' => array(
       'order' => $order_arg,
     ),
Index: includes/uc_payflowpro_recurring.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_payflowpro/includes/uc_payflowpro_recurring.inc,v
retrieving revision 1.2.2.12
diff -u -r1.2.2.12 uc_payflowpro_recurring.inc
--- includes/uc_payflowpro_recurring.inc	3 Aug 2009 16:31:39 -0000	1.2.2.12
+++ includes/uc_payflowpro_recurring.inc	8 Apr 2010 20:14:03 -0000
@@ -8,11 +8,15 @@
  *
  */
 function uc_payflowpro_recurring_charge_process($order) {
-  // So, we're going to take the order in and process the recurring
-  // items by creating profiles for them, and linking the profile
-  // ID to a table in UC so we can look up their profile information.
+  // Take the order in and process the recurring items by creating profiles for
+  // them, and linking the profile ID to a table in UC so we can look up their
+  // profile information later.
 
   $cuser = user_load(array('uid' => $order->uid));
+  // User name is empty for anon checkout, so make one up the same way as uc_cart_complete_sale.
+  if ($cuser->uid < 1) {
+    $cuser->name = uc_store_email_to_username($order->primary_email);
+  }
   $payment = $order->payment_details;
   $site_key = variable_get('uc_payflowpro_recurring_site_key', 'drupal_uc');
   foreach($order->products as $k => $item) {
@@ -34,7 +38,7 @@
       $profile->setCompanyName( (($order->billing_company) ? $order->billing_company : $order->delivery_company));
       $profile->setBillTo(_uc_payflowpro_format_address($order, 'billto'));
       $profile->setShipTo(_uc_payflowpro_format_address($order, 'shipto'));
-      $profile->setEmail($cuser->mail);
+      $profile->setEmail($order->primary_email);
 
       // Tender
       $tender['Type'] = 'C';
@@ -86,6 +90,20 @@
 
 }
 
+function uc_payflowpro_checkout_complete_processing($order) {
+  // Anonymous users automatically have a user created for them on checkout
+  // complete. However, that happens after the CC info has already been
+  // truncated, so it's now too late to create the profile.  Since the only
+  // thing the uid is needed for is some user panel lookups, etc. we can make
+  // the profile earlier and then just fix the uid after the user has been created.
+  if ($order->uid > 0 && $order->order_id > 0) {
+    db_query(
+    	"UPDATE {uc_payflowpro_recurring_profiles} SET pfp_uid = %d WHERE order_id = %d",
+      $order->uid, $order->order_id
+   );
+  }
+}
+
 // Helpers to be moved
 // Returns the auth information for PFP
 function _uc_payflowpro_get_auth() {
