0
Hello, I am doing the integration of the Pagseguro API in a transparent way and in the test environment (Sandbox), when I make a change in the status of the transaction there in the Pagseguro panel, their system send a request, but in the status http received, 403 (prohibited).
My question is, when their system accesses the respective controller of my system notification link, is it to give some kind of feedback? Follow down what I’ve done 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:
You what (semantically) means the 403 code?
– Jéf Bueno
is an HTTP response, just like 404 (not found), 403 is access denied @jbueno
– Matheus Silva