//public PagoTarjeta(string formadepago,string FolioCliente, string FolioPagoTarjeta) public PagoTarjeta(string formadepago, string FolioCliente) { InitializeComponent(); TipoDeFormaDePago = formadepago; for (int i = 0; i < App.MVProducto.ListaDelCarrito.Count; i++) { cantidad += App.MVProducto.ListaDelCarrito[i].Cantidad; decimal a = decimal.Parse(App.MVProducto.ListaDelCarrito[i].StrCosto); } for (int i = 0; i < App.MVProducto.ListaDelInformacionSucursales.Count; i++) { TotalEnvio += App.MVProducto.ListaDelInformacionSucursales[i].CostoEnvio; TotalPagar += App.MVProducto.ListaDelInformacionSucursales[i].Total.ToString("N2"); subtotal += App.MVProducto.ListaDelInformacionSucursales[i].Subtotal; TotalPropina += App.MVProducto.ListaDelInformacionSucursales[i].DPropina; } TotalPagar = (decimal.Parse(TotalPagar) + TotalPropina).ToString("N2"); UidOrden = Guid.NewGuid(); UidOrdenPago = Guid.NewGuid(); App.MVCorreoElectronico.BuscarCorreos(UidPropietario: new Guid(App.Global1), strParametroDebusqueda: "Usuario"); string ArchivoXml = "" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + "<P>\r\n <business>\r\n" + " <id_company>Z937</id_company>\r\n" + " <id_branch>1050</id_branch>\r\n" + " <user>Z937SDUS1</user>\r\n" + " <pwd>09K1HT91B3</pwd>\r\n" + " </business>\r\n" + " <url>\r\n" + " <reference>" + UidOrdenPago.ToString() + "</reference>\r\n" + " <amount>" + TotalPagar + "</amount>\r\n" + " <moneda>MXN</moneda>\r\n" + " <canal>W</canal>\r\n" + " <omitir_notif_default>1</omitir_notif_default>\r\n" + " <st_correo>1</st_correo>\r\n" + " <mail_cliente>" + App.MVCorreoElectronico.CORREO + "</mail_cliente>\r\n" + " <datos_adicionales>\r\n" + " <data id=\"1\" display=\"false\">\r\n" + " <label>PRINCIPAL</label>\r\n" + " <value>" + FolioCliente + "</value>\r\n" + " </data>\r\n" + " <data id=\"2\" display=\"true\">\r\n" + " <label>Concepto:</label>\r\n" + " <value>Orden en GoDeliverix.</value>\r\n" + " </data>\r\n" + " <data id=\"3\" display=\"false\">\r\n" + " <label>Color</label>\r\n" + " <value>Azul</value>\r\n" + " </data>\r\n" + " </datos_adicionales>\r\n" + " </url>\r\n" + "</P>\r\n"; string originalString = ArchivoXml; string key = "7AACFE849FABD796F6DCB947FD4D5268"; AESCrypto o = new AESCrypto(); string encryptedString = o.encrypt(originalString, key); string finalString = encryptedString.Replace("%", "%25").Replace(" ", "%20").Replace("+", "%2B").Replace("=", "%3D").Replace("/", "%2F"); string encodedString = HttpUtility.UrlEncode("<pgs><data0>9265655113</data0><data>" + encryptedString + "</data></pgs>"); string postParam = "xml=" + encodedString; var client = new RestClient("https://bc.mitec.com.mx/p/gen"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/x-www-form-urlencoded"); request.AddParameter("application/x-www-form-urlencoded", postParam, ParameterType.RequestBody); IRestResponse response = client.Execute(request); var content = response.Content; //lblRespuesta.Text = o.decrypt(key, content); string decryptedString = o.decrypt(key, content); string str1 = decryptedString.Replace("<P_RESPONSE><cd_response>success</cd_response><nb_response></nb_response><nb_url>", ""); string url = str1.Replace("</nb_url></P_RESPONSE>", ""); WVWebPay.Source = new UrlWebViewSource { Url = url }; tiempo.Interval = 2000; tiempo.Elapsed += new ElapsedEventHandler(VerificaPago); tiempo.Start(); }
private string GenLigaPara(string id_company, string id_branch, string user, string pwd, string Referencia, decimal Importe, string moneda, string canal, string promocion, int intCorreo, string Vencimiento, string Correo, string Concepto, string semillaAES, string data0, string urlGen) { string url = string.Empty; string ArchivoXml = "" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + "<P>\r\n " + " <business>\r\n" + " <id_company>" + id_company + "</id_company>\r\n" + " <id_branch>" + id_branch + "</id_branch>\r\n" + " <user>" + user + "</user>\r\n" + " <pwd>" + pwd + "</pwd>\r\n" + " </business>\r\n" + " <url>\r\n" + " <reference>" + Referencia + "</reference>\r\n" + " <amount>" + Importe + "</amount>\r\n" + " <moneda>" + moneda + "</moneda>\r\n" + " <canal>" + canal + "</canal>\r\n" + " <omitir_notif_default>1</omitir_notif_default>\r\n" + " <promociones>" + promocion + "</promociones>\r\n" + " <st_correo>" + intCorreo + "</st_correo>\r\n" + " <fh_vigencia>" + Vencimiento + "</fh_vigencia>\r\n" + " <mail_cliente>" + Correo + "</mail_cliente>\r\n" + " <datos_adicionales>\r\n" + " <data id=\"1\" display=\"true\">\r\n" + " <label>Concepto:</label>\r\n" + " <value>" + Concepto + "</value>\r\n" + " </data>\r\n" + " <data id=\"2\" display=\"false\">\r\n" + " <label>Color</label>\r\n" + " <value>Azul</value>\r\n" + " </data>\r\n" + " </datos_adicionales>\r\n" + " </url>\r\n" + "</P>\r\n"; string originalString = ArchivoXml; string key = semillaAES; AESCrypto aesCrypto = new AESCrypto(); string encryptedString = aesCrypto.encrypt(originalString, key); string finalString = encryptedString.Replace("%", "%25").Replace(" ", "%20").Replace("+", "%2B").Replace("=", "%3D").Replace("/", "%2F"); string encodedString = HttpUtility.UrlEncode("<pgs><data0>" + data0 + "</data0><data>" + encryptedString + "</data></pgs>"); string postParam = "xml=" + encodedString; var client = new RestClient(urlGen); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/x-www-form-urlencoded"); request.AddParameter("application/x-www-form-urlencoded", postParam, ParameterType.RequestBody); IRestResponse response = client.Execute(request); var content = response.Content; string decryptedString = aesCrypto.decrypt(key, content); string str1 = decryptedString.Replace("<P_RESPONSE><cd_response>success</cd_response><nb_response></nb_response><nb_url>", ""); url = str1.Replace("</nb_url></P_RESPONSE>", ""); return(url); }
public void GenerarLiga() { int idUsuario = int.Parse(ViewState["IdUsuario"].ToString()); DateTime thisDay = DateTime.Now; string j = thisDay.ToString("dd/MM/yyyy HH:mm:ss.fff"); string o = j.Replace("/", ""); string s = o.Replace(":", ""); string u = s.Replace(".", ""); string e = u.Replace(".", ""); string Referencia = e.Replace(" ", ""); Guid UidOrden = Guid.NewGuid(); Guid UidOrdenPago = Guid.NewGuid(); string ArchivoXml = "" + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + "<P>\r\n " + " <business>\r\n" + " <id_company>Z937</id_company>\r\n" + " <id_branch>851</id_branch>\r\n" + " <user>Z937SIUS21</user>\r\n" + " <pwd>7TYGNDWO48</pwd>\r\n" + " </business>\r\n" + " <url>\r\n" + " <reference>" + idUsuario + Referencia + "</reference>\r\n" + " <amount>" + txtNombre.Text + "</amount>\r\n" + " <moneda>MXN</moneda>\r\n" + " <canal>W</canal>\r\n" + " <omitir_notif_default>1</omitir_notif_default>\r\n" + " <st_correo>1</st_correo>\r\n" + " <fh_vigencia>" + txtFecha.Text + "</fh_vigencia>\r\n" + " <mail_cliente>" + txtCorreo.Text + "</mail_cliente>\r\n" + " <datos_adicionales>\r\n" + " <data id=\"1\" display=\"false\">\r\n" + " <label>PRINCIPAL</label>\r\n" + " <value>" + idUsuario + "</value>\r\n" + " </data>\r\n" + " <data id=\"2\" display=\"true\">\r\n" + " <label>Concepto:</label>\r\n" + " <value>" + txtConcepto.Text + "</value>\r\n" + " </data>\r\n" + " <data id=\"3\" display=\"false\">\r\n" + " <label>Color</label>\r\n" + " <value>Azul</value>\r\n" + " </data>\r\n" + " </datos_adicionales>\r\n" + " </url>\r\n" + "</P>\r\n"; string originalString = ArchivoXml; //string key = "5DCC67393750523CD165F17E1EFADD21"; string key = "7AACFE849FABD796F6DCB947FD4D5268"; AESCrypto aesCrypto = new AESCrypto(); string encryptedString = aesCrypto.encrypt(originalString, key); string finalString = encryptedString.Replace("%", "%25").Replace(" ", "%20").Replace("+", "%2B").Replace("=", "%3D").Replace("/", "%2F"); string encodedString = HttpUtility.UrlEncode("<pgs><data0>9265655113</data0><data>" + encryptedString + "</data></pgs>"); string postParam = "xml=" + encodedString; var client = new RestClient("(https://bc.mitec.com.mx/p/gen"); var request = new RestRequest(Method.POST); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/x-www-form-urlencoded"); request.AddParameter("application/x-www-form-urlencoded", postParam, ParameterType.RequestBody); IRestResponse response = client.Execute(request); var content = response.Content; //lblRespuesta.Text = o.decrypt(key, content); string decryptedString = aesCrypto.decrypt(key, content); string str1 = decryptedString.Replace("<P_RESPONSE><cd_response>success</cd_response><nb_response></nb_response><nb_url>", ""); string url = str1.Replace("</nb_url></P_RESPONSE>", ""); txtUrlGene.Text = url; }
public ResponseHelpers PostPagosTarjeta([FromBody] RespuestaPago strResponse) { CorreosServices correosServices = new CorreosServices(); CorreosEscuelaServices correosEscuelaServices = new CorreosEscuelaServices(); ValidacionesServices validacionesServices = new ValidacionesServices(); ClienteCuentaServices clienteCuentaServices = new ClienteCuentaServices(); LigasUrlsServices ligasUrlsServices = new LigasUrlsServices(); WhatsAppPendientesServices whatsAppPendientesServices = new WhatsAppPendientesServices(); TicketsServices ticketsServices = new TicketsServices(); TarifasServices tarifasServices = new TarifasServices(); ParametrosTwiServices parametrosTwiServices = new ParametrosTwiServices(); ColegiaturasServices colegiaturasServices = new ColegiaturasServices(); PagosColegiaturasServices pagosColegiaturasServices = new PagosColegiaturasServices(); strResponse.StrResponse = HttpUtility.HtmlEncode(strResponse.StrResponse); var respuesta = new ResponseHelpers(); string finalString = strResponse.StrResponse.Replace("%25", "%").Replace("%20", " ").Replace("%2B", "+").Replace("%3D", "=").Replace("%2F", "/").Replace("%0D%0A", "\r\n"); // key con produccion string cadena = finalString; DateTime HoraDelServidor = DateTime.Now; DateTime thisDay = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(HoraDelServidor, TimeZoneInfo.Local.Id, "Eastern Standard Time (Mexico)"); try { correosServices.CorreoCadena(thisDay + " finalString " + cadena, "*****@*****.**"); } catch (Exception ex) { string mnsj = ex.Message; } //string key = "5DCC67393750523CD165F17E1EFADD21"; //Credenciales sanbox string key = "7AACFE849FABD796F6DCB947FD4D5268"; AESCrypto o = new AESCrypto(); string decryptedString = o.decrypt(key, cadena); if (!string.IsNullOrEmpty(decryptedString)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(decryptedString); XmlNodeList RespuestaWebPayPlus = doc.DocumentElement.SelectNodes("//CENTEROFPAYMENTS"); string reference = string.Empty; string response = string.Empty; string foliocpagos = string.Empty; string auth = string.Empty; string cc_type = string.Empty; string tp_operation = string.Empty; string cc_number = string.Empty; string amount = string.Empty; string fecha = string.Empty; string Hora = string.Empty; string nb_company = string.Empty; string bn_merchant = string.Empty; string id_url = string.Empty; string cd_error = string.Empty; string nb_error = string.Empty; string cc_mask = string.Empty; DateTime DtFechaOperacion = thisDay; for (int i = 0; i < RespuestaWebPayPlus[0].ChildNodes.Count; i++) { switch (RespuestaWebPayPlus[0].ChildNodes[i].Name) { case "nb_company": nb_company = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "bn_merchant": bn_merchant = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "id_url": id_url = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "nb_error": nb_error = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cd_error": cd_error = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "reference": reference = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "response": response = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "foliocpagos": foliocpagos = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "auth": auth = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "date": fecha = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "time": Hora = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cc_type": cc_type = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "tp_operation": tp_operation = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cc_number": cc_number = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cc_mask": cc_mask = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "amount": amount = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; default: break; } } PagosServices pagosServices = new PagosServices(); DateTime fechaRegistro = DateTime.MinValue; switch (response) { case "denied": fechaRegistro = thisDay; DtFechaOperacion = thisDay; cc_type = "denied"; auth = "denied"; tp_operation = "denied"; amount = "0"; break; case "approved": fechaRegistro = thisDay; string fecha1 = DateTime.Parse(fecha + " " + Hora).ToString("dd/MM/yyyy HH:mm:ss"); DtFechaOperacion = DateTime.Parse(fecha1); break; case "error": fechaRegistro = thisDay; DtFechaOperacion = thisDay; cc_type = "error"; auth = "error"; tp_operation = "error"; amount = "0"; break; } if (pagosServices.AgregarInformacionTarjeta(auth, reference, fechaRegistro, response, cc_type, tp_operation, nb_company, bn_merchant, id_url, cd_error, nb_error, cc_number, cc_mask, foliocpagos, decimal.Parse(amount), DtFechaOperacion)) { respuesta.Data = true; if (response == "approved") { //pagosServices.ConsultarPagoEventoLiga(reference); //if (pagosServices.lsLigasEventoPayCardModel.Count >= 1) //{ // pagosServices.ObtenerCorreoAuxiliar(reference); //} // ==> ENVIO DE CORREO DE PAGO COLEGIATURA var para = pagosServices.ConsultarPagoColegiatura(reference); if (!string.IsNullOrEmpty(para.Item1)) { var list = pagosServices.ObtenerPagoColegiatura(Guid.Parse(para.Item1)); pagosServices.ActualizarPagoColegiatura(Guid.Parse(para.Item1)); correosEscuelaServices.CorreoEnvioPagoColegiatura(list.Item1, list.Item2, "Comprobante de pago de colegiatura", reference, fechaRegistro, "************" + cc_number, foliocpagos, para.Item2, "APROBADO", Guid.Parse(para.Item3)); var data = pagosServices.ConsultarDatosValidarPago(Guid.Parse(para.Item1)); Guid UidClienteLocal = Guid.Parse(data.Item1); Guid UidUsuario = Guid.Parse(data.Item2); Guid UidFechaColegiatura = Guid.Parse(data.Item3); Guid UidAlumno = Guid.Parse(data.Item4); //Necesito saber el importe de la colegiatura decimal ImporteCole = colegiaturasServices.ObtenerDatosFechaColegiatura(UidClienteLocal, UidUsuario, UidFechaColegiatura, UidAlumno); //Necesito saber el importe de todos los pagos decimal ImportePagado = pagosColegiaturasServices.ObtenerPagosPadresRLE(UidFechaColegiatura, UidAlumno); decimal ImportePendiente = pagosColegiaturasServices.ObtenerPendientesPadresRLE(UidFechaColegiatura, UidAlumno); // ==>Validar con importe<== if (ImporteCole == ImportePagado) //el importeColegiatura es igual al importe de todos los pagos con estatus aprobado { //Se cambia el estatus de la colegiatura a pagado. colegiaturasServices.ActualizarEstatusFeColegiaturaAlumno(UidFechaColegiatura, UidAlumno, Guid.Parse("605A7881-54E0-47DF-8398-EDE080F4E0AA"), true); } else if (ImporteCole == (ImportePagado + ImportePendiente)) //el importe de los pagos aprobado y pendiente es igual al importe la colegiatura { // La colegiatura mantiene el estatus en proceso colegiaturasServices.ActualizarEstatusFeColegiaturaAlumno(UidFechaColegiatura, UidAlumno, Guid.Parse("5554CE57-1288-46D5-B36A-8AC69CB94B9A"), true); } else { // La colegiatura regresa al ultimo estatus DateTime HoraServidor = DateTime.Now; DateTime hoy = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(HoraServidor, TimeZoneInfo.Local.Id, "Eastern Standard Time (Mexico)"); string UidEstatus = colegiaturasServices.ObtenerEstatusColegiaturasRLE(hoy, UidFechaColegiatura, UidAlumno); colegiaturasServices.ActualizarEstatusFeColegiaturaAlumno(UidFechaColegiatura, UidAlumno, Guid.Parse(UidEstatus.ToString()), false); } } pagosServices.ConsultarPromocionLiga(reference); if (pagosServices.lsLigasUrlsPayCardModel.Count >= 1) { foreach (var item in pagosServices.lsLigasUrlsPayCardModel) { pagosServices.AgregarInformacionTarjeta("canceled", item.IdReferencia, fechaRegistro.AddMinutes(-30), "canceled", "canceled", "canceled", "", "", "", "", "", "", "", "", decimal.Parse("0"), DtFechaOperacion.AddMinutes(-20)); } } else { if (validacionesServices.ValidarPagoClientePayCard(reference)) { ligasUrlsServices.ObtenerDatosUrl(reference); if (validacionesServices.ExisteCuentaDineroCliente(ligasUrlsServices.ligasUrlsRepository.ligasUrlsGridViewModel.UidPropietario)) { clienteCuentaServices.ObtenerDineroCuentaCliente(ligasUrlsServices.ligasUrlsRepository.ligasUrlsGridViewModel.UidPropietario); decimal NuevoSaldo = clienteCuentaServices.clienteCuentaRepository.clienteCuenta.DcmDineroCuenta + ligasUrlsServices.ligasUrlsRepository.ligasUrlsGridViewModel.DcmImporte; clienteCuentaServices.ActualizarDineroCuentaCliente(NuevoSaldo, ligasUrlsServices.ligasUrlsRepository.ligasUrlsGridViewModel.UidPropietario, reference); } else { clienteCuentaServices.RegistrarDineroCuentaCliente(ligasUrlsServices.ligasUrlsRepository.ligasUrlsGridViewModel.DcmImporte, ligasUrlsServices.ligasUrlsRepository.ligasUrlsGridViewModel.UidPropietario, reference); } whatsAppPendientesServices.ObtenerWhatsPntHistPago(ligasUrlsServices.ligasUrlsRepository.ligasUrlsGridViewModel.UidPropietario); DateTime HoraDelServidor2 = DateTime.Now; DateTime hoy = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(HoraDelServidor2, TimeZoneInfo.Local.Id, "Eastern Standard Time (Mexico)"); DateTime horParse = DateTime.Parse(hoy.ToString("dd/MM/yyyy")); if (whatsAppPendientesServices.lsWhatsAppPendientes.Count >= 1) { ////******Configuracion de Twilio****** parametrosTwiServices.ObtenerParametrosTwi(); string accountSid = parametrosTwiServices.parametrosTwiRepository.parametrosTwi.AccountSid; string authToken = parametrosTwiServices.parametrosTwiRepository.parametrosTwi.AuthToken; string NumberFrom = parametrosTwiServices.parametrosTwiRepository.parametrosTwi.NumberFrom; //string accountSid = "ACc7561cb09df3180ee1368e40055eedf5"; ////string authToken = "0f47ce2d28c9211ac6a9ae42f630d1d6"; //string authToken = "3f914e588826df9a93ed849cee73eae2"; ////string NumberFrom = "+14158739087"; //string NumberFrom = "+14155238886"; foreach (var item in whatsAppPendientesServices.lsWhatsAppPendientes) { DateTime DtVencimiento = DateTime.Parse(item.DtVencimiento.ToString("dd/MM/yyyy")); if (DtVencimiento >= horParse) { string prefijo = item.VchTelefono.Split('(', ')')[1]; string NumberTo = item.VchTelefono.Split('(', ')')[2]; if (prefijo == "+52") { prefijo = prefijo + "1"; } try { tarifasServices.CargarTarifas(); clienteCuentaServices.ObtenerDineroCuentaCliente(item.UidPropietario); decimal DcmCuenta = clienteCuentaServices.clienteCuentaRepository.clienteCuenta.DcmDineroCuenta; decimal DcmWhatsapp = 0; foreach (var tariWhats in tarifasServices.lsTarifasGridViewModel) { DcmWhatsapp = tariWhats.DcmWhatsapp; } if (DcmCuenta >= DcmWhatsapp) { TwilioClient.Init(accountSid, authToken); var message = MessageResource.Create( body: item.VchUrl.Replace("[n]", "\n"), from: new Twilio.Types.PhoneNumber("whatsapp:" + NumberFrom), to: new Twilio.Types.PhoneNumber("whatsapp:" + prefijo + NumberTo)); decimal NuevoSaldo = DcmCuenta - DcmWhatsapp; string[] DatosUsuario = Regex.Split(validacionesServices.ObtenerDatosUsuario(item.UidUsuario, item.UidPropietario), ","); string IdCliente = string.Empty; string IdUsuario = string.Empty; if (DatosUsuario.Length >= 2) { IdCliente = DatosUsuario[0]; IdUsuario = DatosUsuario[1]; } string Folio = IdCliente + IdUsuario + thisDay.ToString("ddMMyyyyHHmmssfff"); if (ticketsServices.RegistrarTicketPago(Folio, DcmWhatsapp, 0, DcmWhatsapp, item.VchDescripcion, item.UidPropietario, hoy, 1, 0, 0, DcmCuenta, DcmWhatsapp, NuevoSaldo)) { clienteCuentaServices.ActualizarDineroCuentaCliente(NuevoSaldo, item.UidPropietario, ""); whatsAppPendientesServices.ActualizarWhatsPendiente(item.UidWhatsAppPendiente, Guid.Parse("FB046B99-A9DF-4826-9EDB-E47BCE0251EA")); } } } catch (Exception ex) { } } } } } } } } } else { respuesta.Data = "Lo sentimos, no hemos podido desifrar la cadena. " + cadena; } return(respuesta); }
public ResponseHelper PostPagosTarjeta([FromBody] RespuestaPago strResponse) { strResponse.StrResponse = HttpUtility.HtmlEncode(strResponse.StrResponse); respuesta = new ResponseHelper(); string finalString = strResponse.StrResponse.Replace("%25", "%").Replace("%20", " ").Replace("%2B", "+").Replace("%3D", "=").Replace("%2F", "/").Replace("%0D%0A", "\r\n"); // key con produccion string cadena = finalString; // Credenciales sanbox string key = "5DCC67393750523CD165F17E1EFADD21"; string key = "7AACFE849FABD796F6DCB947FD4D5268"; AESCrypto o = new AESCrypto(); string decryptedString = o.decrypt(key, cadena); if (!string.IsNullOrEmpty(decryptedString)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(decryptedString); XmlNodeList RespuestaWebPayPlus = doc.DocumentElement.SelectNodes("//CENTEROFPAYMENTS"); string reference = string.Empty; string response = string.Empty; string foliocpagos = string.Empty; string auth = string.Empty; string cc_type = string.Empty; string tp_operation = string.Empty; string cc_number = string.Empty; string amount = string.Empty; string fecha = string.Empty; string Hora = string.Empty; string nb_company = string.Empty; string bn_merchant = string.Empty; string id_url = string.Empty; string cd_error = string.Empty; string nb_error = string.Empty; string cc_mask = string.Empty; for (int i = 0; i < RespuestaWebPayPlus[0].ChildNodes.Count; i++) { switch (RespuestaWebPayPlus[0].ChildNodes[i].Name) { case "nb_company": nb_company = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "bn_merchant": bn_merchant = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "id_url": id_url = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "nb_error": nb_error = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cd_error": cd_error = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "reference": reference = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "response": response = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "foliocpagos": foliocpagos = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "auth": auth = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "date": fecha = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "time": Hora = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cc_type": cc_type = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "tp_operation": tp_operation = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cc_number": cc_number = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "cc_mask": cc_mask = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; case "amount": amount = RespuestaWebPayPlus[0].ChildNodes[i].InnerText; break; default: break; } } VMPagos MVPagos = new VMPagos(); string fecha1 = fecha + " " + Hora; DateTime fechaRegistro = DateTime.MinValue; switch (response) { case "denied": fechaRegistro = DateTime.Now; cc_type = "denied"; auth = "denied"; tp_operation = "denied"; amount = "0.0"; break; case "approved": fechaRegistro = DateTime.Parse(fecha1); break; case "error": fechaRegistro = DateTime.Now; cc_type = "error"; auth = "error"; tp_operation = "error"; amount = "0.0"; break; } respuesta.Data = MVPagos.AgregarInformacionTarjeta(auth, reference, fechaRegistro, response, cc_type, tp_operation, nb_company, bn_merchant, id_url, cd_error, nb_error, cc_number, cc_mask, foliocpagos, monto: amount); } else { respuesta.Data = "la cadena no se puede desifrar " + cadena; } return(respuesta); }