Index: lm_paypal.module
===================================================================
--- lm_paypal.module	(revision 778)
+++ lm_paypal.module	(working copy)
@@ -134,6 +134,20 @@
       }
     }
   }
+
+  // Recover any messages intended for this user.  This will be executed when
+  // returning from PayPal, and will recover messages that were saved after
+  // processing the ipn.
+  if ($txn_id = $_POST['txn_id']) {
+    if ($cache = cache_get('lm_paypal_messages_'.$txn_id)) {
+      $data = unserialize($cache->data);
+      foreach($data as $type => $messages) {
+        foreach ($messages as $message) {
+          drupal_set_message($message, $type);
+        }
+      }
+    }
+  }
 }
 
 /**
@@ -660,6 +674,14 @@
     }
   }
 
+  // save any messages that have been written by process functions
+  if ($txn_id = $_POST['txn_id']) {
+    $messages = drupal_get_messages();
+    cache_set('lm_paypal_messages_'.$txn_id, serialize($messages),
+              (60 * 60 * 1) // how many seconds to cache
+    );
+  }
+
   return 'IPN: Only PayPal will ever see this page - humans go away!';
 }
 
