jeudi 3 septembre 2015

How to Get Callback message to my Backend side of my site

I'm developing a asp.net mvc site, and I'm using a third party payment service that send me a callback to my site after the payment approved. according to them they send it server to server.

They send a Json to a specific url to my site- http://ift.tt/1hC7g1R.

I Tried using a HttpListenrer but i receive nothing.

  public class PostListener
{
    Task task;
    public PostListener()
    {
        task = new Task(RunServer);
        task.Start();
    }

    private static async void RunServer()
    {
        var listener = new HttpListener();
        listener.Prefixes.Add("http://ift.tt/1hC7g1R");
        listener.Start();

        new Thread(
            () =>
            {
                while (listener.IsListening)
                {
                    var ctx = listener.GetContext();
                    ThreadPool.QueueUserWorkItem((_) => ProcessRequest(ctx));
                }
            }
            ).Start();
    }

    private static void ProcessRequest(HttpListenerContext ctx)
    {

    }
}

But the listener.GetContext() doesn't return nothing after the payment approved, Am I doing it all wrong and need to put the code inside the controller of the page or what? Do I need to use a different method?

Please Help!

Thanks.




Aucun commentaire:

Enregistrer un commentaire