You have to enable auto return in your PayPal account, otherwise it will ignore the return
field.
From the documentation (updated to reflect new layout Jan 2019):
Auto Return is turned off by default.
To turn on Auto Return:
- Log in to your PayPal account at https://www.paypal.com or https://www.sandbox.paypal.com
The My Account Overview page appears.- Click the gear icon top right.
The Profile Summary page appears.- Click the My Selling Preferences link in the left column.
- Under the Selling Online section, click the Update link in the row for Website Preferences.
The Website Payment Preferences page appears- Under Auto Return for Website Payments, click the On radio button to enable Auto
Return.- In the Return URL field, enter the URL to which you want your payers redirected after
they complete their payments.
NOTE: PayPal checks the Return URL that you enter. If the URL is not properly formatted
or cannot be validated, PayPal will not activate Auto Return.- Scroll to the bottom of the page, and click the Save button.
IPN is for instant payment notification. It will give you more reliable/useful information than what you’ll get from auto-return.
Documentation for IPN is here: https://www.x.com/sites/default/files/ipnguide.pdf
Online Documentation for IPN: https://developer.paypal.com/docs/classic/ipn/gs_IPN/
The general procedure is that you pass a notify_url
parameter with the request, and set up a page which handles and validates IPN notifications, and PayPal will send requests to that page to notify you when payments/refunds/etc. go through. That IPN handler page would then be the correct place to update the database to mark orders as having been paid.