static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); String referenceCode = "REF123"; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // Realizando a consulta TransactionSearchResult result = TransactionSearchService.SearchByReference(credentials, referenceCode); if (result.Transactions.Count <= 0) { } foreach (TransactionSummary transaction in result.Transactions) { } } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
// 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 bool ConsultaBoletoRef(String reference) { bool valida = false; bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); var myTimeZone = TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time"); var dataAtual = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, myTimeZone); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); // Realizando a consulta TransactionSearchResult result = TransactionSearchService.SearchByReference(credentials, reference); foreach (var item in result.Transactions.Where(m => m.LastEventDate.Month == dataAtual.Month && m.LastEventDate.Year == dataAtual.Year)) { if (item.TransactionStatus != 3) { valida = false; } else { valida = true; } } } catch (PagSeguroServiceException exception) { } return(valida); }
private static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); string referenceCode = "REF123"; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); // Realizando a consulta TransactionSearchResult result = TransactionSearchService.SearchByReference(credentials, referenceCode); if (result.Transactions.Count <= 0) { Console.WriteLine("Nenhuma transação encontrada com a referência " + referenceCode); } foreach (TransactionSummary transaction in result.Transactions) { Console.WriteLine("Começando listagem de transações - \n"); Console.WriteLine(transaction.ToString()); Console.WriteLine(" - Terminando listagem de transações "); } Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
private TransactionSummary GetTransaction(AccountCredentials credentials, string referenceCode) => TransactionSearchService.SearchByReference(credentials, referenceCode)?.Items?.FirstOrDefault();