Notifications API PagSeguro

3

Sirs, good night!

I'm doing an integration with the pagseguro for my site.

I've set the page to receive the notification whenever its status changes as per the code below.

 protected void Page_Load(object sender, EventArgs e)
        {
            var notificationCode = Request.QueryString["notificationCode"];
            var token = "***";
            var email = "********@live.com";

            if (notificationCode != null)
            {
            HttpWebRequest request = (HttpWebRequest)
            WebRequest.Create("https://ws.pagseguro.uol.com.br/v3/transactions/notifications/" + notificationCode + "?email=" + email + "&token=" + token);
            request.Method = "GET";
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            }
        }

I check if there is a notification code, if it exists, it does a redirect on the pagseguro page requesting the XML of this notification. But I think this is not correct.

I would like a help to make a GET request in the pagseguro, with the link, and receive this XML, besides, save the payment status and reference in any variable ... (var status and var reference for example)

The status stays inside the node transaction

<transaction>      
        <status>3</status>    
</transaction>  

Someone please help me?

    
asked by anonymous 22.09.2015 / 04:57

1 answer

1

This is the hard way to do it. In this answer, I teach several use cases involving the API . Just install the NuGet package and change the examples.

If you need more help, you can answer me by commenting to improve the answer.

    
23.09.2015 / 07:18