I have a number of sites that are using this script for handling paypal purchases:

header("location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=".urlencode($strMail)."&item_name=".urlencode($strName)."&item_number=".urlencode($strCode)."&amount=".urlencode($strCost)."&no_shipping=0&return=".urlencode($strDomain.$strFolder."Thanks.php")."&cancel_return=".urlencode($strDomain.$strFolder."Cancel.php")."&notify_url=http%3a%2f%2fwww%2eincansoft%2ecom%2fipn%2ephp&no_note=1&currency_code=USD&lc=GR&bn=PP%2dBuyNowBF&charset=UTF%2d8");

The problem here is that when it redirects to the page "Thanks.php", I want it to update something in my database (change the availability of the item). I've read up on Payment Data Transfer and Auto Return, but turning on Auto Return requires me to have to input a constant return page and then edit ALL the sites I have to have individual Thank You pages.

My question is: Is there any other way to redirect and retrieve transaction data without setting 1 constant return page for ALL my products?

Edit: I guess it is possible, since, for example, Nanacast can do it. You just configure your email and the return URL, and then it returns even the transaction data. The question is: HOW?

有帮助吗?

解决方案

Have a look at PayPal Instant Payment Notification (IPN) - https://www.paypal.com/ipn/
This will force a POST of transactional data to be sent to you whenever a transaction has been initiated. The buyer doesn't even have to return to your 'Thanks' page in order for this to work; it's always sent as long as the buyer completes the payment on the PayPal website.

If you currently use Website Payments Standard (HTML based buttons), you can simply add

<input type="hidden" name="notify_url" value="http://full-URL-to-the-script-you-set-up-for-IPN">

Or in your case, append &notify_url=http://...... to your URL's.
Alternatively, you can also set up an IPN URL within your PayPal Profile which will apply to all incoming payments (unless overriden with the 'notify_url' HTML parameter).
You can set this up in Profile > My selling tools > Instant Payment Notification > Update.

You'll need to take all POST data you received from PayPal, append cmd=_notify-validate and send it back to https://www.paypal.com/cgi-bin/webscr (or https://www.sandbox.paypal.com/cgi-bin/webscr for Sandbox) in order to validate the IPN message.

Depending on this result, you'll get back an INVALID or VERIFIED responsein the body of the page.
INVALID may mean the IPN POST didn't originate from PayPal, whereas VERIFIED means the IPN POST was verified as indeed coming from PayPal.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top