Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting PayPal return URL to localhost

I'm trying to integrate Paypal and I'm using sandbox in the process. I follow the step of the accepted answer in the below question. Setting PayPal return URL and making it auto return?

But when I try to enter the URL, Paypal return the below error.

We were unable to validate the URL you have entered. Please check your entry and try again.

URL I'm trying to set is http://localhost:8888/paypal/success.php.

Also I tried sending the return url with the form as below.

<input type="hidden" name="return" value="http://localhost:8888/paypal/success.php">

Both methods does not work for me.

Full Form

<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" value="[email protected]" name="business">
<!-- Specify a Buy Now button. -->
<input type="hidden" value="_xclick" name="cmd">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" value="AM Test Item" name="item_name">
<input type="hidden" value="22.16" name="amount">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" value="item_number" name="item_number">
<input type="hidden" name="return" value="http://localhost:8888/paypal/success.php">
<!-- Display the payment button. -->
<input type="image" name="submit" border="0" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynow_LG.gif" alt="PayPal - The safer, easier way to pay online">
<img alt="" border="0" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >
</form> 

How can I test this on my development pc ?

like image 297
Techie Avatar asked Jan 21 '13 10:01

Techie


People also ask

How do I change my PayPal return URL?

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.

Does PayPal work on localhost?

It should work without a problem, however it might get picky if you send in "invalid URLs" for return urls and IPN message urls. Meaning, sending in http://localhost/cancelpaypal.php as cancelURL might tell you that it is an invalid url.


2 Answers

What if you try to specify your IP address instead of localhost?

Local host cannot be resolved on distant machines. It's only your local DNS which knows localhost statement and is 127.0.0.1.

http://your-IP-address:8888/paypal/success.php
like image 179
Andrew Adamich Avatar answered Oct 10 '22 01:10

Andrew Adamich


You can create some URL alias for your website and add it to your hosts file (http://en.wikipedia.org/wiki/Hosts_(file)). Then pass that URL as your return URL to paypal. They just trigger a re-direct within the browser to that location at which point your host file will resolve it to your local development server.

For Example: Add a line to your hosts file like 127.0.0.1 local.mywebdomain.com

Then in your PayPal button, pass that same URL for the return parameter (e.g. <input type="hidden" name="return" value="http://local.mywebdomain.com/success.php">)

like image 24
munsellj Avatar answered Oct 09 '22 23:10

munsellj