static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); // TODO: Substitute the code below with a valid transaction code for your transaction //Transaction transaction = TransactionSearchService.SearchByCode(credentials, "59A13D84-52DA-4AB8-B365-1E7D893052B0", false); //Console.WriteLine(transaction); //Console.ReadKey(); Transaction preApprovalTransaction = TransactionSearchService.SearchByCode(credentials, "3DFAD3123412340334A96F9136C38804", true); Console.WriteLine(preApprovalTransaction); Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
// GET: PurchaseHistory/Details/1 public ActionResult Details(int id) { var cart = Carts.SingleOrDefault(c => c.Id == id); if (cart == null) { return(HttpNotFound()); } var credentials = PagSeguroConfiguration.Credentials(); if (cart.TransactionCode == null) { var transactionResult = TransactionSearchService.SearchByReference( credentials, cart.ReferenceCode ); foreach (var transactionSummary in transactionResult.Transactions) { if (transactionResult.Transactions.Count == 1) { cart.TransactionCode = transactionSummary.Code; } } _context.SaveChanges(); } var transaction = cart.TransactionCode != null?TransactionSearchService.SearchByCode(credentials, cart.TransactionCode) : null; return(View(new PurchaseHistoryViewModel(cart, transaction))); }
public ActionResult StatusCompra(string id_pagseguro) { id_pagseguro = "C58740AE-DF00-4732-AA48-DBDFB6A3122E"; // Inicializando credenciais AccountCredentials credentials = new AccountCredentials( "*****@*****.**", "86D588A7611E48FABA6125B049503F5F" ); // Código identificador da transação string transactionCode = id_pagseguro; // Realizando uma consulta de transação a partir do código identificador // para obter o objeto Transaction Transaction transaction = TransactionSearchService.SearchByCode( credentials, transactionCode ); int status = transaction.TransactionStatus; //1 Aguardando pagamento: o comprador iniciou a transação, mas até o momento o PagSeguro não recebeu nenhuma informação sobre o pagamento.WaitingPayment //2 Em análise: o comprador optou por pagar com um cartão de crédito e o PagSeguro está analisando o risco da transação.InAnalysis //3 Paga: a transação foi paga pelo comprador e o PagSeguro já recebeu uma confirmação da instituição financeira responsável pelo processamento.Paid //4 Disponível: a transação foi paga e chegou ao final de seu prazo de liberação sem ter sido retornada e sem que haja nenhuma disputa aberta. Available //5 Em disputa: o comprador, dentro do prazo de liberação da transação, abriu uma disputa. InDispute //6 Devolvida: o valor da transação foi devolvido para o comprador.Refunded //7 Cancelada: a transação foi cancelada sem ter sido finalizada. Cancelled return(View()); }
public static List <Transaction> BuscaPorCodigo(int pIdConta, string Codigo, out string error) { error = null; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(false); credentials.Email = pMeuEmail[pIdConta]; credentials.Token = pMeuToken[pIdConta]; var ret = new List <Transaction>(); Transaction result = TransactionSearchService.SearchByCode(credentials, Codigo); if (result != null) { ret.Add(result); } return(ret); } catch (Exception ex) { error = ex.ToString(); return(null); } }
// GET: ConfirmacaoPagamento public ActionResult Index(string transaction_id) { PagSeguroConfiguration.UrlXmlConfiguration = HttpRuntime.AppDomainAppPath + "/Configuration/PagSeguroConfig.xml"; bool isSandbox = false; string sdsSituacao = ""; Transaction transaction = null; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); transaction = TransactionSearchService.SearchByCode(credentials, transaction_id); if (transaction.TransactionStatus == Uol.PagSeguro.Enums.TransactionStatus.Paid) { var reference = long.Parse(transaction.Reference); FinanceiroController finC = new FinanceiroController(); finC.RealizarPagamentoPagSeguro(reference); } var nnrSituacao = (int)transaction.TransactionStatus; if (nnrSituacao == 1) { sdsSituacao = "Aguardando Pagamento"; } if (nnrSituacao == 2) { sdsSituacao = "Em Ánalise"; } if (nnrSituacao == 3) { sdsSituacao = "Paga"; } if (nnrSituacao == 4) { sdsSituacao = "Disponível"; } if (nnrSituacao == 5) { sdsSituacao = "Em disputa"; } if (nnrSituacao == 6) { sdsSituacao = "Devolvida"; } if (nnrSituacao == 7) { sdsSituacao = "Cancelada"; } ViewBag.transaction = transaction; ViewBag.sdsSituacao = sdsSituacao; return(View()); } catch { throw; } }
public static List <Transaction> BuscaPorData(int pIdConta, DateTime pDataDesde, out string error, DateTime?pDataAte = null, int?ItemsPerPage = null, string StatusCodes = "") { error = null; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(false); credentials.Email = pMeuEmail[pIdConta]; credentials.Token = pMeuToken[pIdConta]; var ret = new List <Transaction>(); bool hasResult = true; int page = 1; StatusCodes = (StatusCodes == null || StatusCodes == "" ? "" : "," + StatusCodes + ","); StatusCodes = StatusCodes.Replace(" ", ""); do { TransactionSearchResult result = TransactionSearchService.SearchByDate( credentials, pDataDesde, pDataAte == null ? DateTime.Now : pDataAte.Value, page, ItemsPerPage == null ? iDefaulMaxPerPage : ItemsPerPage.Value); if (result.Transactions.Count > 0) { foreach (TransactionSummary transactionsummary in result.Transactions) { if (StatusCodes == "" || StatusCodes.Contains("," + transactionsummary.TransactionStatus.ToString() + ",")) { Transaction transaction = TransactionSearchService.SearchByCode(credentials, transactionsummary.Code); ret.Add(transaction); } } } page++; hasResult = (page <= result.TotalPages); } while (hasResult); return(ret); } catch (Exception ex) { error = ex.ToString(); return(null); } }
static void SearchByCodeExample() { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); string transactionCode = "59A13D84-52DA-4AB8-B365-1E7D893052B0"; Transaction transaction = TransactionSearchService.SearchByCode(credentials, transactionCode); }
//static void RequestExample(HttpWebRequest Request) //{ // bool isSandbox = false; // EnvironmentConfiguration.ChangeEnvironment(isSandbox); // AccountCredentials credentials = new AccountCredentials("",""); // string notificationType = Request.Form["notificationType"]; // string notificationCode = Request.Form["notificationCode"]; // if (notificationType == "transaction") // { // // obtendo o objeto transaction a partir do código de notificação // Transaction transaction = // NotificationService.CheckTransaction(credentials, notificationCode); // var status = transaction.TransactionStatus; // } //} static void SearchByCodeExample() { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AccountCredentials credentials = new AccountCredentials("", ""); string transactionCode = "59A13D84-52DA-4AB8-B365-1E7D893052B0"; Transaction transaction = TransactionSearchService.SearchByCode(credentials, transactionCode); Console.WriteLine(transaction.TransactionStatus); Console.WriteLine(transaction.GrossAmount); }
static void SearchByCodeExample2() { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // Código identificador da transação string transactionCode = "59A13D84-52DA-4AB8-B365-1E7D893052B0"; // Realizando uma consulta de transação a partir do código identificador // para obter o objeto Transaction Transaction transaction = TransactionSearchService.SearchByCode( credentials, transactionCode); // Imprime o status da transação }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // TODO: Substitute the code below with a valid transaction code for your transaction Transaction transaction = TransactionSearchService.SearchByCode(credentials, "59A13D84-52DA-4AB8-B365-1E7D893052B0"); } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
public int ConsultaTransacaoStatus(string transacao) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); string transactionCode = transacao; try { Transaction transaction = TransactionSearchService.SearchByCode( credentials, transactionCode); return(transaction.TransactionStatus); } catch (PagSeguroServiceException exception) { return(0); } }
/// <summary> /// Retorno do PagSeguro. /// Método executado quando o usuário espera ou clica no botão /// para que seja redirecionado novamente ao site, recebe uma /// chave que contem o numero da transação no pagSeguro /// </summary> /// <author>Claudinei Nascimento</author> /// <business>Vip-Systems Tecnologia & Inovação LTDA></business> /// <param name="id_pagseguro">exemplo de id:766B9C-AD4B044B04DA-77742F5FA653-E1AB24</param> /// <returns></returns> public ActionResult Retorno(String id_pagseguro) { ViewBag.Tema = Settings.Default.Tema; AccountCredentials credentials = new AccountCredentials( Settings.Default.EmailCredential, Settings.Default.TokenCredential ); try { // obtendo o objeto transaction a partir do código de notificação Transaction transaction = TransactionSearchService.SearchByCode(credentials, id_pagseguro); ViewBag.Stattus = GetManutencaoPedido.statusRetornoPedido(transaction.TransactionStatus); ViewBag.Valor = "R$ " + transaction.GrossAmount; ViewBag.Codigo = id_pagseguro; ViewBag.Pagamento = GetManutencaoPedido.formaPagamentoPorNome(transaction.PaymentMethod.PaymentMethodType); } catch (PagSeguroServiceException ex) { StackTrace exe = new StackTrace(ex, true); CustomException ep = new CustomException(ex, exe, ""); ep.Save(AppDomain.CurrentDomain.BaseDirectory + "/Logs/Log.log"); if (ex.StatusCode == HttpStatusCode.Unauthorized) { GravarLog.gravarLogError("Unauthorized: lease verify if the credentials used in the web service call re correct./n", "Erro Transaction"); } foreach (PagSeguroServiceError error in ex.Errors) { GravarLog.gravarLogError(error.ToString(), "Erro PagSeguro"); } } return(View("Finalizar")); }
public IActionResult CheckTransaction([FromRoute] string code) { if (string.IsNullOrEmpty(code)) { return(BadRequest()); } try { const bool isSandbox = true; EnvironmentConfiguration.ChangeEnvironment(isSandbox); var credentials = PagSeguroConfiguration.Credentials(isSandbox); var transaction = TransactionSearchService.SearchByCode(credentials, code, false); return(Ok(transaction)); } catch (PagSeguroServiceException exception) { return(StatusCode(500, exception.Errors)); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
public Aluno_pgto ConsultarCode(string code) { EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); Transaction transaction = TransactionSearchService.SearchByCode(credentials, code); return(TratarRetorno(transaction)); } catch (PagSeguroServiceException exception) { string retorno = exception.Message + "\n"; foreach (ServiceError element in exception.Errors) { retorno += element + "\n"; } return(new Aluno_pgto()); } }