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); }
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"); 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); // TODO: Substitute the code below with a valid transaction code for your transaction String transactionCode = "BCDD106976764746641F8FA665F51E88"; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(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(); } }
/// <summary> /// /// </summary> /// <param name="reader"></param> /// <returns></returns> internal static AccountCredentials GetAccountCredentials(XmlDocument xml, bool sandbox) { AccountCredentials credential = null; string email; string token; if (sandbox) { email = GetDataConfiguration(xml, PagSeguroConfigSerializer.SandboxEmail); token = GetDataConfiguration(xml, PagSeguroConfigSerializer.SandboxToken); } else { email = GetDataConfiguration(xml, PagSeguroConfigSerializer.Email); token = GetDataConfiguration(xml, PagSeguroConfigSerializer.Token); } try { credential = new AccountCredentials(email, token); } catch (System.Exception) { throw new ArgumentException("To use credentials from config.properties file you must " + "configure the properties credential email and credential token."); } return credential; }
static void Main(string[] args) { bool isSandbox = true; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = new AccountCredentials("", ""); 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 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); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(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(); } }
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()); }
private static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); string transactionCode = "3B1097583EC84C7E9EDC391949F9C4BC"; try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(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(); } }
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); } }
public Installments GetInstallmentsPagSeguro(Decimal amount, string creditCardBrand, int maxInstallmentNoInterest) { PagSeguroConfiguration.UrlXmlConfiguration = this.configuration; bool isSandbox = true; EnvironmentConfiguration.ChangeEnvironment(isSandbox); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); Installments result = InstallmentService.GetInstallments(credentials, amount, creditCardBrand, maxInstallmentNoInterest); return(result); } catch (PagSeguroServiceException exception) { return(new Installments()); //foreach (ServiceError element in exception.Errors) //{ //} } catch (Exception ex) { return(new Installments()); } }
private 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(); } }
/// <summary> /// /// </summary> /// <param name="reader"></param> /// <returns></returns> internal static AccountCredentials GetAccountCredentials(IPagSeguroConfiguration config, bool sandbox) { AccountCredentials credential = null; string email; string token; if (sandbox) { email = config.SandboxEmail; token = config.SandboxToken; } else { email = config.Email; token = config.Token; } try { credential = new AccountCredentials(email, token); } catch (System.Exception) { throw new ArgumentException("To use credentials from config.properties file you must " + "configure the properties credential email and credential token."); } return(credential); }
static void Main(string[] args) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); String transactionCode = "F3D9490291B54FA59F39B22AB9E76799"; Decimal refundValue = 150.00m; try { AccountCredentials credentials = new AccountCredentials("", ""); // TODO: Substitute the code below with a valid transaction code for your transaction RequestResponse result = RefundService.RequestRefund(credentials, transactionCode); //RequestResponse result = RefundService.RequestRefund(credentials, transactionCode, refundValue); 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(); } }
// 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 void AnEmailAddressShouldBeTheCorrectLength(string emailAddress, bool shouldBeValid) { var credentials = new AccountCredentials { EmailAddress = emailAddress, PlainTextPassword = VALID_PASSWORD }; Assert.Equal(TestTryValidate(credentials), shouldBeValid); }
public void APasswordShouldBeInTheCorrectFormat(string password, bool shouldBeValid) { var credentials = new AccountCredentials { EmailAddress = VALID_EMAILADDRESS, PlainTextPassword = password }; Assert.Equal(TestTryValidate(credentials), shouldBeValid); }
public void CredentialsAreValidIfNothingIsNullOrEmpty(string emailAddress, string plainTextPassword, bool shouldBeValid) { var credentials = new AccountCredentials { EmailAddress = emailAddress, PlainTextPassword = plainTextPassword }; Assert.Equal(shouldBeValid, TestTryValidate(credentials)); }
public string Boleto(string documento, string nome, string email, string telefone, string codigoHash, decimal valor) { bool isSandbox = false; EnvironmentConfiguration.ChangeEnvironment(isSandbox); BoletoCheckout checkout = new BoletoCheckout(); var endereco = GetEndereco(documento); checkout.PaymentMode = PaymentMode.DEFAULT; checkout.ReceiverEmail = "*****@*****.**"; checkout.Currency = Currency.Brl; checkout.Items.Add(new Item("0001", "Contabilidade Online", 1, valor)); checkout.Reference = documento; checkout.Shipping = new Shipping(); checkout.Shipping.ShippingType = ShippingType.Sedex; checkout.Shipping.Cost = 0.00m; checkout.Shipping.Address = new Address( "BRA", endereco.UF, endereco.Cidade, endereco.Bairro, endereco.CEP, endereco.TipoEnd + " " + endereco.Logradouro, endereco.Numrero, endereco.Complemento ); checkout.Sender = new Sender( nome, email, new Phone("11", telefone) ); checkout.Sender.Hash = codigoHash; SenderDocument senderCPF = new SenderDocument(Documents.GetDocumentByType("CNPJ"), documento); checkout.Sender.Documents.Add(senderCPF); try { AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox); Transaction result = TransactionService.CreateCheckout(credentials, checkout); GravaTransacao("2", codigoHash, Convert.ToDecimal(valor), result.PaymentLink, result.Code, result.LastEventDate.Day, result.LastEventDate.Month, documento); ///var corpo = " <html xmlns='http://www.w3.org/1999/xhtml'><head> <style type='text/css'> body, #bodyTable, #bodyCell, #bodyCell { height: 100% !important; margin: 0; padding: 0; width: 100% !important; font-family: Helvetica, Arial, 'Lucida Grande', sans-serif; } body, table, td, p, a, li, blockquote { -ms-text-size-adjust: 100%; -webkit-text-size-adjust: 100%; font-weight: normal !important; } body, #bodyTable { background-color: #E1E1E1; } </style> <script type='text/javascript' src='http://gc.kis.v2.scr.kaspersky-labs.com/D23BDC46-5991-6E46-B0E9-985879E9A50E/main.js' charset='UTF-8'></script></head><body bgcolor='#E1E1E1' leftmargin='0' marginwidth='0' topmargin='0' marginheight='0' offset='0'><center style='background-color:#E1E1E1;'><table border='0' cellpadding='0' cellspacing='0' height='100%' width='100%' id='bodyTable' style='table-layout: fixed;max-width:100% !important;width: 100% !important;min-width: 100% !important;'><tr><td align='center' valign='top' id='bodyCell'><table bgcolor='#FFFFFF' border='0' cellpadding='0' cellspacing='0' width='500' id='emailBody'><tr><td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%' style='color:#FFFFFF;' bgcolor='#F8F8F8'><tr><td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='500' class='flexibleContainer'><tr><td align='center' valign='top' width='500' class='flexibleContainerCell'><table border='0' cellpadding='30' cellspacing='0' width='100%'><tr><td align='left' valign='top' class='textContent' style='color: dodgerblue; '><h1>Contfy</h1> </td></tr></table></td></tr></table></td></tr></table></td></tr><tr><td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%' bgcolor='#FFFFFF'><tr> <td align='center' valign='top'> <table border='0' cellpadding='0' cellspacing='0' width='500' class='flexibleContainer'><tr><td align='center' valign='top' width='500' class='flexibleContainerCell'><table border='0' cellpadding='30' cellspacing='0' width='100%'><tr><td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%'><tr><td valign='top' class='textContent'><h3 style='color:#5F5F5F;line-height:125%;font-family:Helvetica,Arial,sans-serif;font-size:20px;font-weight:normal;margin-top:0;margin-bottom:3px;text-align:left;'>Segue o link de pagamento para uso da CONTFY:</h3><br /> </td></tr></table></td> </tr></table></td></tr></table></td></tr></table></td></tr><tr><td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%'> <tr style='padding-top:0;'> <td align='center' valign='top'> <table border='0' cellpadding='30' cellspacing='0' width='500' class='flexibleContainer'> <tr> <td style='padding-top:0;' align='center' valign='top' width='500' class='flexibleContainerCell'> <table border='0' cellpadding='0' cellspacing='0' width='50%' class='emailButton' style='background-color: #3498DB;'> <tr> <td align='center' valign='middle' class='buttonContent' style='padding-top:15px;padding-bottom:15px;padding-right:15px;padding-left:15px;'> <a style='color:#FFFFFF;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:20px;line-height:135%;' href='" + result.PaymentLink.ToString() + "' target='_blank'>Acesse aqui</a> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr><tr><td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='100%' bgcolor='#FFFFFF'><tr><td align='center' valign='top'><table border='0' cellpadding='0' cellspacing='0' width='500' class='flexibleContainer'><tr><td align='center' valign='top' width='500' class='flexibleContainerCell'> <table border='0' cellpadding='30' cellspacing='0' width='100%'> <tr> <td align='center' valign='top'> <table border='0' cellpadding='0' cellspacing='0' width='100%'> <tr> <td valign='top' class='textContent'> <div style='text-align:left;font-family:Helvetica,Arial,sans-serif;font-size:15px;margin-bottom:0;color:#5F5F5F;line-height:135%;'>CONTFY tem a oferecer aos nossos clientes a tecnologia às suas mãos para facilitar e agilizar todo esse processo burocrático na qual, estamos preparado, tanto na contabilidade tradicional quanto na online.</div> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <table bgcolor='#E1E1E1' border='0' cellpadding='0' cellspacing='0' width='500' id='emailFooter'> <tr> <td align='center' valign='top'> <table border='0' cellpadding='0' cellspacing='0' width='100%'> <tr> <td align='center' valign='top'> <!-- FLEXIBLE CONTAINER // --> <table border='0' cellpadding='0' cellspacing='0' width='500' class='flexibleContainer'> <tr> <td align='center' valign='top' width='500' class='flexibleContainerCell'> <table border='0' cellpadding='30' cellspacing='0' width='100%'> <tr> <td valign='top' bgcolor='#E1E1E1'> <div style='font-family:Helvetica,Arial,sans-serif;font-size:13px;color:#828282;text-align:center;line-height:120%;'> <div>Contfy © a sua contabilidade online.</div> </div> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> </center></body></html>"; return(result.PaymentLink); } catch (PagSeguroServiceException exception) { return(exception.Message); } }
public override Task OnDisconnected(bool stopCalled) { if (Context.User.IsInRole(RoleName.Student)) { int studentId = AccountCredentials.GetStudentId((ClaimsIdentity)Context.User.Identity); Connections.Remove(studentId, Context.ConnectionId); } return(base.OnDisconnected(stopCalled)); }
public async Task <JsonResult> CheckForActiveCumulativeQuiz() { var studentId = AccountCredentials.GetStudentId(); var cumulativeQuizId = await Context.CumulativeQuizPasseds .Where(iqp => iqp.StudentId == studentId && iqp.StartDate != null && iqp.EndDate == null) .OrderBy(o => o.StartDate).Select(s => s.Id).FirstOrDefaultAsync(); return(Json(cumulativeQuizId, JsonRequestBehavior.AllowGet)); }
public override Task OnConnected() { if (Context.User.IsInRole(RoleName.Student)) { int studentId = AccountCredentials.GetStudentId((ClaimsIdentity)Context.User.Identity); Connections.Add(studentId, Context.ConnectionId); } return(base.OnConnected()); }
private async void AutoSignIn(INavigation navigation, AccountCredentials credentials) { ServiceResult result = await this.authenticationManager.SignIn(credentials); if (result.ResultCode != ServiceResultCode.Success) { this.NavigateToIntroView(navigation); } }
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.Credentials(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(); } }
public ActionResult RedirectToHome() { var role = AccountCredentials.GetRole(); if (role == RoleName.Student) { return(RedirectToAction("Index", "Student")); } return(RedirectToAction("Index", "Admin")); }
public IActionResult Authenticate([FromBody] AccountCredentials credentials) { var user = _userService.Authenticate(credentials.Username, credentials.Password); if (user == null) { return(BadRequest(new { message = "Username or password is incorrect" })); } return(Ok(user)); }
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); } }
public ActionResult <AccountCredentials> GetUser() { var id = User.FindFirst("id").Value; var _user = _context.Users.SingleOrDefault(u => u.Id == id); AccountCredentials user = new AccountCredentials { UserName = _user.UserName }; return(user); }
public Guid GenerateNewAuthToken() { var newAuthToken = Guid.NewGuid(); Credentials = new AccountCredentials( passwordHash: Credentials.PasswordHash, authToken: newAuthToken.ToString(), passwordSalt: Credentials.PasswordSalt); return(newAuthToken); }
protected void Page_Load(object sender, EventArgs e) { // envia email para gestores avisando sobre nova entrega EnviarEmail(); //dados da solicitação string chkvalorstr = Request.QueryString["v1"]; decimal chkvalor = Convert.ToDecimal(chkvalorstr); Session["OSId"] = Request.QueryString["v2"]; bool isSandbox = true; 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", "Servico de Motoboy", 1, chkvalor)); // Sets a reference code for this payment request, it is useful to identify this payment in future notifications. payment.Reference = "Cli_" + Session["UserID"].ToString(); payment.AddParameter("shippingAddressRequired", "false"); // Sets the url used by PagSeguro for redirect user after ends checkout process payment.RedirectUri = new Uri("http://logvai01.azurewebsites.net/RedirectRetorno.aspx"); // Add and remove groups and payment methods List <string> accept = new List <string>(); accept.Add(ListPaymentMethodNames.DebitoItau); payment.AcceptPaymentMethodConfig(ListPaymentMethodGroups.CreditCard, accept); try { //faz requisição de check-out e aguarda retorno com link para pagamento AccountCredentials credentials = new AccountCredentials("*****@*****.**", "C1BF7C4BE89A481A8C215B3275F41973"); Uri paymentRedirectUri = payment.Register(credentials); string urlpagam = paymentRedirectUri.ToString(); //encaminha usuário para pagina de pagamento (ambiente pagseguro) Response.Write("<script>self.parent.location.href='" + urlpagam + "';</script>"); } catch (PagSeguroServiceException exception) { Response.Write("<script>alert('Tente Novamente! Motivo: " + exception.Message + "');</script>"); } }
public void SendAccountLoginEvent (AccountCredentials credentialsType) { string label; switch (credentialsType) { case AccountCredentials.Password: label = "Password"; break; case AccountCredentials.Google: label = "Google"; break; default: #if DEBUG throw new ArgumentException ("Invalid value", "credentialsType"); #else return; #endif } SendEvent ("Account", "Login", label); }
static void Main(string[] args) { //Use global configuration //PagSeguroConfiguration.UrlXmlConfiguration = "../../../../../Configuration/PagSeguroConfig.xml"; 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") ); SenderDocument document = new SenderDocument(Documents.GetDocumentByType("CPF"), "12345678909"); payment.Sender.Documents.Add(document); // 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); // Add discount per payment method payment.AddPaymentMethodConfig(PaymentMethodConfigKeys.DiscountPercent, 50.00, PaymentMethodGroup.CreditCard); // Add installment without addition per payment method payment.AddPaymentMethodConfig(PaymentMethodConfigKeys.MaxInstallmentsNoInterest, 6, PaymentMethodGroup.CreditCard); // Add installment limit per payment method payment.AddPaymentMethodConfig(PaymentMethodConfigKeys.MaxInstallmentsLimit, 8, PaymentMethodGroup.CreditCard); // Add and remove groups and payment methods List<string> accept = new List<string>(); accept.Add(ListPaymentMethodNames.DebitoItau); accept.Add(ListPaymentMethodNames.DebitoHSBC); payment.AcceptPaymentMethodConfig(ListPaymentMethodGroups.CreditCard, accept); List<string> exclude = new List<string>(); exclude.Add(ListPaymentMethodNames.Boleto); payment.ExcludePaymentMethodConfig(ListPaymentMethodGroups.Boleto, exclude); try { /// Create new account credentials /// This configuration let you set your credentials from your ".cs" file. AccountCredentials credentials = new AccountCredentials("*****@*****.**", "256422BF9E66458CA3FE41189AD1C94A"); /// @todo with you want to get credentials from xml config file uncommend the line below and comment the line above. //AccountCredentials credentials = PagSeguroConfiguration.Credentials(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(); } }