SagePay development with localhost

ASP.NET MVC,SagePay 24 January 2012 | 1 Comment

I thought it would be a good idea to share how I have managed to get SagePay’s simulator working and accepting my localhost development server as valid. This is kind of a big deal for me as I can now develop and test in an easier environment, previously had to upload to a VPS which was very messy and time consuming.

Firstly, SagePay expects the following of the server it tries to call:

  • Have a fully qualified domain name (doesn’t seem to like an IP address for the NotificationURL)
  • Be accessible to it (via the internet, most localhost development servers aren’t due to firewalls etc)
  • The server’s IP address must be registered with them.

To solve all these problems I did the following:

  1. Moved my localhost server onto port 80, SagePay does not like ports in addresses.
  2. Opened port 80 in my firewall.
  3. Accessed my router and setup port forwarding of port 80 to my machine.
  4. Found my home internet connections IP address (Google “What is my IP”)
  5. Registered an account with no-ip.com
  6. Setup a hostname using my above ip and their free extension, e.g. “my-test-server.no-ip.org”
  7. Signed into the SagePay simulator and registed my above IP address (I entered subnet as 255.255.255.000)

In my project, (I’m using Jeremy Skinner’s SagePayMvc library with my ASP.NET MVC project) I setup the NotificationUrl as “my-test-server.no-ip.org”.

Voila! I can now handle notifications sent from SagePay’s servers on my localhost server, makes development and testing much easier.

If you get stuck when using this approach, feel free to comment as they are emailed to me and I might be able to help debug the problem. Only if your using Jeremy Skinner’s library, sorry PHP guys.

One Response on “SagePay development with localhost”

  1. Lukas says:

    Thank you so much for this! Saved my life! Have this setup as well now.

Leave a Reply