Saturday, March 28, 2015

.Net MVC Paypal IPN Configuration

The Problem

I've been fighting with PayPal's IPN(Instant Payment Notification) for a little while, now, and I finally had a breakthrough. I'd gone through all of the steps to configure my IPN target, and still no joy. The basic steps:
  • Log in to your sandbox account, and create a subscription button. In the advanced settings enter a URL for the target of your IPN.
  • In your MVC controller create a listener to listen for the notifications, a little something like this:
    •  public ActionResult Ipn()  
       {  
       var param = Request.BinaryRead(Request.ContentLength);
       var request = Encoding.ASCII.GetString(param);   
       }  
  • Log in to your developer account, go over to the IPN Simulator, enter the url to your listener, adjust the call settings, and send your request. 
After going through all these steps all I got was a "We're sorry, we could not send an IPN." Nothing else. No errors, no breakpoints getting hit, nothing. 

The Solution

After searching for way longer than I should have, I finally stumbled across the solution. The issue was that when I set up port forwarding to my development environment I decided to use a non-standard port for HTTP traffic. IPN notifications do not work over non-standard ports.
I went in and adjusted my port forwarding configuration to listen on standard HTTP ports, and bam. I'm suddenly hitting breakpoints and receiving calls from the IPN simulator.