Bohdi Bohdi - 2 months ago 27
PHP Question

Paypal notify_url and return_url. Recieving variables without IPN using PHP

I am trying to set up a simple payment option to paypal, but am having some trouble/confussion with the return and notify URLS. I am fairly new to php and have accomplished this previously in asp, but I have now become lost.

SO my basic paypal form:

<form action="" method="post" id="PayPalForm" name="PayPalForm" target="_top">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="">
<input type="hidden" name="amount" value="0.01">
<input type="hidden" name="item_name" value="Composite Door">
<input type="hidden" name="item_number" value="<?php echo $orderID ?>">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="cancel_return" value="">
<input type="hidden" name="return" value="">
<input type="hidden" name="notify_url" value="">


As you can see the form posts to paypal, and then returns depending on the outcome, if failed/cancelled it goes to paypal-notcompleted.php.

If its successful it goes to paypal-completed.php. And this is where I am unable to understand, I haven't set up an IPN, all I want to do is grab some of the variables paypal posts back to me, to run a simple insert query and display some details in a confirmation message to the customer.

Am I allowed to have the notify_url and return_url as the same page?

Why does paypal not post the full expected (as seen here: Notify url of Paypal ) back to the page?

I understand there is osmething to do with XML and such, but I just figured that I would be able to $_GET the variables that paypal sent back. Has anyone done it this way, can they tell me where I am going wrong?


To return details back to the your return URL you'll need to use PDT. It's very similar to IPN except it's intended for use with your return URL, while IPN is intended for use with a 3rd party IPN listener script on your server.

PDT is fine for simply displaying transaction to the user on the return URL page, but it's not recommended to do any any post-payment processing with PDT (ie. database updates, sending out email receipts, etc.) because there is no guarantee the user will make it back to this page, even with Auto-Return enabled in your PayPal account.

IPN will be triggered every time a transaction occurs regardless of whether or not the user makes it back to your site after completing payment.

The notify URL is used for IPN only, and it would override any setting you have in your PayPal profile for IPN. PDT needs to be configured in your PayPal account profile in order to get data returned to your return URL.

You're going to want to use different URL's for return and notify, otherwise that same code would run twice: once when the user returns to your site, and again from the PayPal IPN POST.