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.GetAccountCredentials(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(); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); String transactionCode = "3B1097583EC84C7E9EDC391949F9C4BC"; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // TODO: Substitute the code below with a valid transaction code for your transaction RequestResponse result = CancelService.RequestCancel(credentials, transactionCode); Console.WriteLine(result.ToString()); 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); 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) { } } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); Session result = SessionService.CreateSession(credentials); Console.WriteLine(result.ToString()); 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 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) { } } }
static void SearchByDateExample() { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // Definindo a data de ínicio da consulta DateTime initialDate = new DateTime(2011, 06, 1, 08, 50, 0); // Definindo a data de término da consulta DateTime finalDate = new DateTime(2011, 06, 29, 10, 30, 0); // Definindo o número máximo de resultados por página int maxPageResults = 20; // Definindo o número da página int pageNumber = 1; // Realizando a consulta TransactionSearchResult result = TransactionSearchService.SearchByDate( credentials, initialDate, finalDate, pageNumber, maxPageResults); }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid transaction code for your transaction String transactionCode = "BCDD106976764746641F8FA665F51E88"; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); bool cancelResult = PreApprovalService.CancelPreApproval(credentials, transactionCode); Console.WriteLine(cancelResult); 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); // Instantiate a new payment request PaymentRequest payment = new PaymentRequest(); // Sets the currency payment.Currency = Currency.Brl; // Add an item for this preApproval payment request payment.Items.Add(new Item("0001", "Seguro contra roubo do Notebook", 1, 10.00m)); // Sets a reference code for this payment request, it is useful to identify this payment in future notifications. payment.Reference = "REF1234"; // Sets the previous preApproval code payment.PreApprovalCode = "235FD1B69494E6ACC4C37F8A60C05E89"; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); String result = PreApprovalService.ChargePreApproval(credentials, payment); } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // TODO: Substitute the code below with a notification code for your transaction. // You receive this notification code through a post on the URL that you specify in // this page: https://pagseguro.uol.com.br/integracao/notificacao-de-transacoes.jhtml // Use notificationType to check if is PreApproval (preApproval or transaction) Transaction transaction = NotificationService.CheckTransaction(credentials, "766B9C-AD4B044B04DA-77742F5FA653-E1AB24"); Console.WriteLine(transaction); 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 = true; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // TODO: Substitute the code below with a valid code notification for your transaction String notificationCode = "29B0BEC9D653D653435EE42F3FAEF4461091"; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); PreApprovalTransaction result = PreApprovalSearchService.SearchByNofication(credentials, notificationCode); } catch (PagSeguroServiceException exception) {} foreach (ServiceError element in exception.Errors) { } }
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"); Console.WriteLine(transaction); 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); Decimal amount = 1000.00m; String creditCardBrand = "visa"; Int32 maxInstallmentNoInterest = 5; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); Installments result = InstallmentService.GetInstallments(credentials, amount, creditCardBrand, maxInstallmentNoInterest); foreach (Installment installment in result.Get()) { } } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // Definindo a data de ínicio da consulta DateTime initialDate = new DateTime(2015, 10, 14, 08, 50, 0); // Definindo a data de término da consulta DateTime finalDate = DateTime.Now.AddMinutes(-15); // Definindo o número máximo de resultados por página int maxPageResults = 10; // Definindo o número da página int pageNumber = 1; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // Realizando a consulta TransactionSearchResult result = TransactionSearchService.SearchAbandoned( credentials, initialDate, finalDate, pageNumber, maxPageResults); if (result.Transactions.Count <= 0) { Console.WriteLine("Nenhuma transação abandonada"); } foreach (TransactionSummary transaction in result.Transactions) { Console.WriteLine("Começando listagem de transações abandonadas - \n"); Console.WriteLine(transaction.ToString()); Console.WriteLine(" - Terminando listagem de transações abandonadas"); } 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 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(); } }
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 Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // Definindo a data de ínicio da consulta DateTime initialDate = new DateTime(2015, 10, 05, 00, 00, 0); // Definindo a data de término da consulta DateTime finalDate = DateTime.Now; // Definindo o número máximo de resultados por página int maxPageResults = 100; // Definindo o número da página int pageNumber = 1; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // Realizando a consulta TransactionSearchResult result = TransactionSearchService.SearchByDate( credentials, initialDate, finalDate, pageNumber, maxPageResults); if (result.Transactions.Count <= 0) { } foreach (TransactionSummary transaction in result.Transactions) { } } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
static void RegisterExample() { PaymentRequest paymentRequest = new PaymentRequest(); // Preencher propriedades da requisição do pagamento aqui bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); // Criando o código de requisição de pagamento // e obtendo a URL da página de pagamento // do PagSeguro Uri paymentRedirectUri = paymentRequest.Register(credentials); //Response.Redirect(paymentRedirectUri.ToString()); }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); Session result = SessionService.CreateSession(credentials); } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
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 RequestExample(HttpRequest Request) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); 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); int status = transaction.TransactionStatus; } }
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) { 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(); } }
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) { 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(); } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); Decimal amount = 1000.00m; String creditCardBrand = "visa"; Int32 maxInstallmentNoInterest = 5; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); Installments result = InstallmentService.GetInstallments(credentials, amount, creditCardBrand, maxInstallmentNoInterest); Console.WriteLine("Começando listagem de parcelas - \n"); foreach (Installment installment in result.Get()) { Console.WriteLine(installment.ToString()); } Console.WriteLine(" - Terminando listagem de parcelas "); 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 = true; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // Instantiate a new preApproval request PreApprovalRequest preApproval = new PreApprovalRequest(); // Sets the currency preApproval.Currency = Currency.Brl; // Sets a reference code for this preApproval request, it is useful to identify this payment in future notifications. preApproval.Reference = "REF1234"; // Sets your customer information. preApproval.Sender = new Sender( "Joao Comprador", "*****@*****.**", new Phone("11", "56273440") ); // Sets the preApproval informations var now = DateTime.Now; preApproval.PreApproval = new PreApproval(); preApproval.PreApproval.Charge = Charge.Manual; preApproval.PreApproval.Name = "Seguro contra roubo do Notebook"; preApproval.PreApproval.AmountPerPayment = 100.00m; preApproval.PreApproval.MaxAmountPerPeriod = 100.00m; preApproval.PreApproval.MaxPaymentsPerPeriod = 5; preApproval.PreApproval.Details = string.Format("Todo dia {0} será cobrado o valor de {1} referente ao seguro contra roubo do Notebook.", now.Day, preApproval.PreApproval.AmountPerPayment.ToString("C2")); preApproval.PreApproval.Period = Period.Monthly; preApproval.PreApproval.DayOfMonth = now.Day <= 28 ? now.Day : 28; preApproval.PreApproval.InitialDate = now; preApproval.PreApproval.FinalDate = now.AddMonths(6); preApproval.PreApproval.MaxTotalAmount = 600.00m; // Sets the url used by PagSeguro for redirect user after ends checkout process preApproval.RedirectUri = new Uri("http://www.lojamodelo.com.br/retorno"); // Sets the url used for user review the signature or read the rules preApproval.ReviewUri = new Uri("http://www.lojamodelo.com.br/revisao"); // Sets sender CPF SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909"); preApproval.Sender.Documents.Add(senderCPF); // Sets sender Address Address senderAddress = new Address("BR", "RJ", "Rio de Janeiro", "Copacabana", "03351-800", "Avenida Copacabana", "1000", "2o Andar"); preApproval.Sender.Address = senderAddress; try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); Uri preApprovalRedirectUri = preApproval.Register(credentials); } catch (PagSeguroServiceException exception) { foreach (ServiceError element in exception.Errors) { } } }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); // Instantiate a new payment request PaymentRequest payment = new PaymentRequest(); // Sets the currency payment.Currency = Currency.Brl; // Add an item for this payment request payment.Items.Add(new Item("0001", "Notebook Prata", 1, 2430.00m)); // Add another item for this payment request payment.Items.Add(new Item("0002", "Notebook Rosa", 2, 150.99m)); // Sets a reference code for this payment request, it is useful to identify this payment in future notifications. payment.Reference = "REF1234"; // Sets shipping information for this payment request payment.Shipping = new Shipping(); payment.Shipping.ShippingType = ShippingType.Sedex; //Passando valor para ShippingCost payment.Shipping.Cost = 10.00m; payment.Shipping.Address = new Address( "BRA", "SP", "Sao Paulo", "Jardim Paulistano", "01452002", "Av. Brig. Faria Lima", "1384", "5o andar" ); // Sets your customer information. payment.Sender = new Sender( "Joao Comprador", "*****@*****.**", new Phone("11", "56273440") ); // Sets the url used by PagSeguro for redirect user after ends checkout process payment.RedirectUri = new Uri("http://www.lojamodelo.com.br"); // Add checkout metadata information payment.AddMetaData(MetaDataItemKeys.GetItemKeyByDescription("CPF do passageiro"), "123.456.789-09", 1); payment.AddMetaData("PASSENGER_PASSPORT", "23456", 1); // Another way to set checkout parameters payment.AddParameter("senderBirthday", "07/05/1980"); payment.AddIndexedParameter("itemColor", "verde", 1); payment.AddIndexedParameter("itemId", "0003", 3); payment.AddIndexedParameter("itemDescription", "Mouse", 3); payment.AddIndexedParameter("itemQuantity", "1", 3); payment.AddIndexedParameter("itemAmount", "200.00", 3); SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909"); payment.Sender.Documents.Add(senderCPF); // Sets the preApproval informations payment.PreApproval = new PreApproval(); var now = DateTime.Now; // Only works with Manual payment.PreApproval.Charge = Charge.Manual; payment.PreApproval.Name = "Seguro contra roubo do Notebook"; payment.PreApproval.AmountPerPayment = 100.00m; payment.PreApproval.MaxAmountPerPeriod = 100.00m; payment.PreApproval.Details = string.Format("Todo dia {0} será cobrado o valor de {1} referente ao seguro contra roubo do Notebook.", now.Day, payment.PreApproval.AmountPerPayment.ToString("C2")); payment.PreApproval.Period = Period.Monthly; payment.PreApproval.DayOfMonth = now.Day; payment.PreApproval.InitialDate = now; payment.PreApproval.FinalDate = now.AddMonths(6); payment.PreApproval.MaxTotalAmount = 600.00m; payment.PreApproval.MaxPaymentsPerPeriod = 1; payment.ReviewUri = new Uri("http://www.lojamodelo.com.br/revisao"); try { AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox); Uri paymentRedirectUri = payment.Register(credentials); Console.WriteLine("URL do pagamento : " + paymentRedirectUri); Console.ReadKey(); } catch (PagSeguroServiceException exception) { Console.WriteLine(exception.Message + "\n"); foreach (ServiceError element in exception.Errors) { Console.WriteLine(element + "\n"); } Console.ReadKey(); } }