php - PayPal auto return does not send back any POST data
I have a similar problem to this post
Setting PayPal return URL and making it auto return?
However, the solution there is not working. We have IPN set up and POST variables get passed back (the visitor clicks back and is able to download purchased PDF files) but then I tried to get rid of Paypal order confirmation page that says
you just completed your payment. Your transaction ID for this payment is: XXXXXXXXXXXXX.
and enabled "Auto Return" in Website Payment Preferences, specifying the URL http://www.educted.ca/payment_complete.php, the POST variables now do not get passed back to payment_complete.php - it shows blank. As soon as I disable "Auto Return", POST variables display properly and products purchased can be downloaded. I am using Paypal Sandbox account, of course.
<input type="hidden" name="return" value="<?php echo LIVE_SITE;>payment_complete.php"> <input type="hidden" name="cancel_return" value="<?php echo LIVE_SITE; ?>catalog.php"> <input type="hidden" name="notify_url" value="<?php echo LIVE_SITE; ?>ipn.php"> <input type="hidden" name="rm" value="2">
If you enable Auto Return, the values are always going to get returned via GET irrespective of what
rmis set to.
If you want to do immediate file delivery after the buyer has completed the transaction, have a look at PayPal Payment Data Transfer. Once enabled, PDT adds a
txGET var to your return URL; by calling PayPal at https://www.paypal.com/cgi-bin/webscr?cmd=_notify-synch&tx=value-for-tx-here&at=value-for-your-paypal-account-authentication-token you'll be able to pull in extra data about the transaction, and immediately check whether it's valid.
See also https://www.paypal.com/pdt/
IPN should be reserved for backend processing as it can come with a significant delay.
PDT, on the other hand, has you pulling the info from PayPal, and is as such immediate.
You can still keep Auto Return set to On, but make sure you DISABLE PDT, and you will get all the transaction variables sent to your return URL via POST (if you have the rm parameter set to 2 in your request of course, as you said you have).
For some reason, enabling PDT will ignore the rm parameter and force the GET method to be used.
This is the correct answer! You must not enable sending payment data with auto response, if you want get POST-Data.
BUT, in this case you have to use a https-site, otherwise the customer get a warning before redirecting!
In your particular case, it was showing blank because of an error in your code:
That doesn't parse as valid PHP - it'd cause a fatal error. If no information has been output yet and error reporting is off, it'll be a blank page.