?
Solved

Paypal API not accepting Localhost

Posted on 2014-04-02
3
Medium Priority
?
1,205 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 2000 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

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

741 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