Search code examples
meteorpaypalpaypal-ipn

Testing Paypal IPN locally


based on Paypal tutorial, this is the form they provide for testing the IPN:

<form target="_new" method="post" action="https://www.YourDomain.com/Path/YourIPNHandler.php">
  <input type="hidden" name="SomePayPalVar" value="SomeValue1"/>
  <input type="hidden" name="SomeOtherPPVar" value="SomeValue2"/>

  <!-- code for other variables to be tested ... -->

  <input type="submit"/>
</form>

I got my IPN listener code in server/routing.js and used iron router and specified the path to /ipn. here is the code for it

Router.map(function () {
    this.route('ipn', {
        path: '/ipn',
        where: 'server',

so my question now, what URL should i put in the form instead of "https://www.YourDomain.com/Path/YourIPNHandler.php" URL? Because am testing it in my local machine "localhost:3000"


Solution

  • I had the same problem friend. The solution was very simple. Paypal does not allow test in your local machine: Paypal says: We're sorry, URL with port number is not allowed for IPN. You must have a server with your "www.YourDomain.com". In my case for development tests I downloaded a "tunnel" application called NGROK which gives to you a testing domain. You can get it from here. Then will be enought just open the ngrok console and write the command:

    > ngrok http -host-header=localhost 3000
    

    After that execute your web application. After you've started ngrok, just open http://localhost:4040 in a web browser to review your domain provided by ngrok. When you go to localhost:4040 in your browser ngrok show to you a http and http domains like they show in the examples.

    http://92832de0.ngrok.io 
    https://92832de0.ngrok.io
    

    Now just replace "www.YourDomain.com" with this ngrok URL.

    Hope this helps to you. Regards!