Solved

Paypal API not accepting Localhost

Posted on 2014-04-02
3
1,086 Views
Last Modified: 2016-03-24
Hi all,

I'm having issues testing the Paypal API as I am getting an error from Paypal saying my returnURL is invalid.

If I alter this to be the finalised url i.e. www.mysite.com/returnURL this fires correctly.

Obviously for debug purposes I want to return to http://localhost:1939/returnURL

I think it is the : in thestring its rejecting.

Are there any ways around this?
0
Comment
Question by:flynny
  • 2
3 Comments
 
LVL 11

Expert Comment

by:Andrew Angell
ID: 39971552
The value you pass to PayPal for Return and Cancel URL's is the value their servers will use when the time comes to redirect.  If that value is http://localhost they would just be redirecting to themselves.  This isn't going to work, of course, and that's why they reject it.

In order to test on your local server you'll need to use your full IP address instead of localhost or setup some DNS of some sort.  You could use a dynamic DNS service, or just manually create A records to point to your IP address there.  

For example, if I'm setting up a new website for a client I'll login to their hosting account, go into the DNS settings, and create a new A record that points sandbox.domain.com to my IP address here.  

Then, I setup a vhost in my Apache config for sandbox.domain.com.  This way the site can be accessed publicly via http://sandbox.domain.com and I can use that with my PayPal tests or anything else I need.  

Another trick you can do when you setup your test server like this is you can have your config settings work dynamically based off the subdomain of the site.  When it's running sandbox.domain.com you can have all your config settings use PayPal sandbox credentials and database test credentials, etc.  When it's not running on sandbox, use all live credentials.  This way  you don't have to keep switching everything back and forth.
0
 

Author Comment

by:flynny
ID: 39971611
Thanks for that Andrew, that helpful.

referring to your last comment do you mean I can filter in the web.config? would you be able to provide a little test code for this? as this could be really helpful.
0
 
LVL 11

Accepted Solution

by:
Andrew Angell earned 500 total points
ID: 39971618
No, I just mean in a basic config file.  For example, I use this a lot...

$host_split = explode('.',$_SERVER['HTTP_HOST']);
$sandbox = $host_split[0] == 'sandbox' && $host_split[1] == 'domain' ? TRUE : FALSE;
$domain = $sandbox ? 'http://sandbox.domain.com/' : 'http://www.domain.com/';

Open in new window


That would check the current subdomain and domain (whatever.domain) and it would set $sandbox to true if it was sandbox.domain.com.  In any other case $sandbox would be false.  

Then I do everything else in my config files based on $sandbox, so it automatically handles different credentials for test vs. live databases, API's, etc.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question