PagSeguro Notification API receiving error 403

0
Hello, I'm integrating the PagSeguro API transparently and in the Sandbox environment, when I make a change in the Transaction Status in the PagSeguro panel, their system sends a request, but in the status http received, from 403 (prohibited).

My question is, when their system accesses the respective controller of the notification link from my system, is it to give some kind of feedback? Here's what I've been doing so far:

    [HttpPost]
    public ActionResult Notifications(string notificationCode, string notificationType)
    {
        HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "https://sandbox.pagseguro.uol.com.br");

        if (notificationCode.IsNullOrWhiteSpace())
            return Content("ERROR - Required code of transaction");

        try
        {
            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

            Transaction transaction = NotificationService.CheckTransaction(credentials, notificationCode);

            var dados = db.PsTransactions.FirstOrDefault(t => t.code.Equals(transaction.Code));
            if (dados != null)
            {
                if (dados.lasteventdate.Equals(transaction.LastEventDate))
                    return Content("Transaction already exists");
                dados.date = transaction.Date;
                dados.lasteventdate = transaction.LastEventDate;
                dados.status = PagSeguro.TransactionStatusToString(transaction.TransactionStatus);

                db.Entry(dados).State = EntityState.Modified;
                db.SaveChanges();
            }
            Infraestrutura.Notifications.Transactions(dados);
            TransactionsHub.NotifyCurrentTransactions();
        }
        catch (PagSeguroServiceException ex)
        {
            return Content("ERROR - " + ex.Message);
        }

        return Content("SUCCESS - Transaction update");    
    }

And follow the SandBox notification log:

    
asked by anonymous 24.03.2017 / 19:29

1 answer

0

I was able to identify the reason for this return. When I am in the development environment (localhost: 44333) the automatic sending of when changing the status in the sandbox somehow does not work.

To work, just click on the "Resend Local Notification" button and regardless of whether it appears to have failed, triggered the action on Controller .

    
27.03.2017 / 19:24