What if more than one user is logged in at the time? It seems your code would have no way of knowing which session to access.
Could you possibly get the info you need from the PayPal API?
If only one user could be logged in, you could put a snippet on one of the pages that writes the username to a file, then your external PHP script could just read that file.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODx info for everyone:
http://bobsguides.com/MODx.html