static void Main(string[] args) { bool isSandbox = true; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid code notification for your transaction String notificationCode = "29B0BEC9D653D653435EE42F3FAEF4461091"; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); PreApprovalTransaction result = PreApprovalSearchService.SearchByNofication(credentials, notificationCode); Console.WriteLine(result); Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid preApproval code for your transaction String preApprovalCode = "235FD1B69494E6ACC4C37F8A60C05E89"; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); PreApprovalTransaction result = PreApprovalSearchService.SearchByCode(credentials, preApprovalCode); Console.WriteLine(result); Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
public Aluno_pgto CancelarAssinaturaCode(string code) { EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); if (PreApprovalService.CancelPreApproval(credentials, code)) { var transaction = PreApprovalSearchService.SearchByCode(credentials, code); return(AssinaturaTratarRetorno(transaction)); } else { var transaction = PreApprovalSearchService.SearchByCode(credentials, code); return(AssinaturaTratarRetorno(transaction)); } } catch (PagSeguroServiceException exception) { string retorno = exception.Message + "\n"; foreach (ServiceError element in exception.Errors) { retorno += element + "\n"; } return(new Aluno_pgto()); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid preApproval days interval for your transaction int interval = 10; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); PreApprovalSearchResult result = PreApprovalSearchService.SearchByInterval(credentials, interval); if (result.PreApprovals.Count <= 0) { } foreach (PreApprovalSummary preApproval in result.PreApprovals) { } } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
public PessoaAssinatura ConsultaAssintura(string reference) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); var myTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); DateTime initialDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow.AddMonths(-12), myTimeZone); DateTime finalDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, myTimeZone); int maxPageResults = 10; int pageNumber = 1; AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); try { PreApprovalSearchResult result = PreApprovalSearchService.SearchByReference( credentials, reference, initialDate, finalDate, pageNumber, maxPageResults ); var pessoa = new PessoaAssinatura(); var resultAtive = result.PreApprovals.Where(m => m.Status == "ACTIVE").FirstOrDefault(); if (resultAtive != null) { pessoa.Codigo = 0; pessoa.CodigoPessoa = 0; pessoa.CodigoAssinatura = resultAtive.Code; pessoa.Status = resultAtive.Status; pessoa.DataAssinatura = resultAtive.Date; return(pessoa); } else { var resultNoAtive = result.PreApprovals.OrderByDescending(d => d.Date).FirstOrDefault(); pessoa.Codigo = 0; pessoa.CodigoPessoa = 0; pessoa.CodigoAssinatura = resultNoAtive.Code; pessoa.Status = resultNoAtive.Status; pessoa.DataAssinatura = resultNoAtive.Date; return(pessoa); } } catch (Exception) { return(null); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid preApproval reference for your transaction String reference = "REF1234"; DateTime initialDate = new DateTime(2015, 10, 01, 00, 00, 0); DateTime finalDate = DateTime.Now; //DateTime finalDate = new DateTime(2015, 10, 15, 11, 35, 15); int maxPageResults = 10; int pageNumber = 1; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); PreApprovalSearchResult result = PreApprovalSearchService.SearchByReference( credentials, reference, initialDate, finalDate, pageNumber, maxPageResults ); if (result.PreApprovals.Count <= 0) { Console.WriteLine("Nenhuma assinatura"); } foreach (PreApprovalSummary preApproval in result.PreApprovals) { Console.WriteLine("Começando listagem de assinaturas - \n"); Console.WriteLine(preApproval.ToString()); Console.WriteLine(" - Terminando listagem de assinaturas "); } Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }
public PreApprovalTransaction ConsultaRecorrenteNotificacao(string code) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); PreApprovalTransaction result = PreApprovalSearchService.SearchByNofication(credentials, code); return(result); } catch (PagSeguroServiceException exception) { return(null); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid preApproval reference for your transaction String reference = "REF1234"; DateTime initialDate = new DateTime(2015, 10, 01, 00, 00, 0); DateTime finalDate = DateTime.Now; //DateTime finalDate = new DateTime(2015, 10, 15, 11, 35, 15); int maxPageResults = 10; int pageNumber = 1; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); PreApprovalSearchResult result = PreApprovalSearchService.SearchByReference( credentials, reference, initialDate, finalDate, pageNumber, maxPageResults ); if (result.PreApprovals.Count <= 0) { } foreach (PreApprovalSummary preApproval in result.PreApprovals) { } } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
private bool IsAssinatura(string reference) { bool valida = false; bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); var myTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); DateTime initialDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow.AddMonths(-4), myTimeZone); DateTime finalDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, myTimeZone); int maxPageResults = 10; int pageNumber = 1; AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); try { PreApprovalSearchResult result = PreApprovalSearchService.SearchByReference( credentials, reference, initialDate, finalDate, pageNumber, maxPageResults ); if (result.PreApprovals.Count >= 1) { var dateMax = result.PreApprovals.Select(m => m.LastEventDate).Max(); var resultMax = result.PreApprovals.Where(m => m.LastEventDate == dateMax).FirstOrDefault(); if (resultMax.Status == "ACTIVE") { valida = true; } } return(valida); } catch (PagSeguroServiceException exception) { return(valida); } }
public void AssinaturaNotificacao(string notificationCode) { EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); PreApprovalTransaction transaction = PreApprovalSearchService.SearchByNofication(credentials, notificationCode); AssinaturaTratarRetorno(transaction); } catch (PagSeguroServiceException exception) { string retorno = exception.Message + "\n"; foreach (ServiceError element in exception.Errors) { retorno += element + "\n"; } } }
private static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid preApproval days interval for your transaction int interval = 10; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); PreApprovalSearchResult result = PreApprovalSearchService.SearchByInterval(credentials, interval); if (result.PreApprovals.Count <= 0) { Console.WriteLine("Nenhuma assinatura"); } foreach (PreApprovalSummary preApproval in result.PreApprovals) { Console.WriteLine("Começando listagem de assinaturas - \n"); Console.WriteLine(preApproval.ToString()); Console.WriteLine(" - Terminando listagem de assinaturas "); } Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }