Solved

Paypal API not accepting Localhost

Posted on 2014-04-02
3
1,166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

707 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