Hi,
I am sorry but I am bit confused now - are you using our built-in
E-commerce module or are you using fully custom code?
In the second case, you can inspire by the default IPN page and code from the
CMS web project files, but it is fully up to you how you will implement this function according to PayPal's directions. I am sorry but I am not able to give you better answer because I do not know how exactly you have achieved your need and where and how are you storing the order data.
Best regards,
Juraj Ondrus