Solved

Paypal API not accepting Localhost

Posted on 2014-04-02
3
1,042 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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 …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now