Update @ 2016-01-25: The following sample code may be outdated. please try the new sample code from paypal as stated in this comment.
PayPal Payment Data Transfer (PDT) provides a simple way for gathering the PayPal transaction details after the payment. You can even make use of it to trigger any post-transaction action. This article guide you how to test your PDT flow in PayPal Sandbox
Continue reading PayPal – Payment Data Transfer Sample Code