public async Task <JsonResult> DeletePlanInProcess(HistorialPagosPersonasDTO paymentHistory) { Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>(); try { PagosServices payService = new PagosServices(); result.obj = await payService.EliminarPagoPendientePorPagar(new HistorialPagosPersonasDTO() { CodigoPersona = paymentHistory.CodigoPersona, Consecutivo = paymentHistory.Consecutivo }); if (result.obj != null) { return(Json(Helper.returnSuccessDeleteObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } else { return(Json(Helper.returnErrorDelete(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(Helper.returnErrorDelete(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } }
public async Task <JsonResult> GetMyPlanInProcess(HistorialPagosPersonasDTO myPlan) { Result <HistorialPagosPersonasDTO> result = new Result <HistorialPagosPersonasDTO>(); try { PagosServices planService = new PagosServices(); myPlan.CodigoPersona = UserLoggedIn().PersonaDelUsuario.Consecutivo; myPlan.CodigoIdiomaUsuarioBase = UserLoggedIn().PersonaDelUsuario.CodigoIdioma; result.obj = await planService.BuscarPagoEnTramiteDeUnaPersona(myPlan); if (result.obj != null) { return(Json(result, JsonRequestBehavior.AllowGet)); } else { return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } }
public async Task <JsonResult> ValidateIfIHaveAPlanInProcess() { Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>(); try { PagosServices planService = new PagosServices(); HistorialPagosPersonasDTO myPlan = new HistorialPagosPersonasDTO(); myPlan.CodigoPersona = UserLoggedIn().PersonaDelUsuario.Consecutivo; result.obj = await planService.VerificarQueNoExistaUnPagoEnTramite(myPlan); if (result.obj != null && result.obj.PagoEnTramite) { return(Json(result, JsonRequestBehavior.AllowGet)); } else { return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } }
public async Task <JsonResult> SavePaymentHistory(HistorialPagosPersonasDTO paymentHistory) { Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>(); try { PagosServices payService = new PagosServices(); paymentHistory.CodigoPersona = UserLoggedIn().PersonaDelUsuario.Consecutivo; paymentHistory.CodigoPais = UserLoggedIn().PersonaDelUsuario.CodigoPais; result.obj = await payService.CrearHistorialPagoPersona(paymentHistory); if (result.obj != null) { return(Json(result, JsonRequestBehavior.AllowGet)); } else { return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> Index(int id) { HistorialPagosPersonasDTO historial = new HistorialPagosPersonasDTO { Consecutivo = id }; PayUModel payModel = await _pagosService.ConfigurarPayU(historial); return(View(payModel)); }
public async Task <PayUModel> ConfigurarPayU(HistorialPagosPersonas pagoParaProcesar) { using (SportsGoEntities context = new SportsGoEntities(false)) { PagosRepository pagosRepo = new PagosRepository(context); HistorialPagosPersonasDTO pagoBuscado = await pagosRepo.BuscarHistorialPagoPersona(pagoParaProcesar); if (pagoBuscado.EstadoDelPago != EstadoDeLosPagos.EsperaPago && pagoBuscado.EstadoDelPago != EstadoDeLosPagos.Rechazado) { throw new InvalidOperationException("El pago no se puede procesar porque no esta en un estado valido"); } string descripcion = string.Empty; switch (pagoBuscado.Personas.IdiomaDeLaPersona) { case Idioma.Español: descripcion = "PayU Pago para el plan " + pagoBuscado.Planes.DescripcionIdiomaBuscado; break; case Idioma.Ingles: descripcion = "PayU Payment for plan " + pagoBuscado.Planes.DescripcionIdiomaBuscado; break; case Idioma.Portugues: descripcion = "PayU Plano de pagamento " + pagoBuscado.Planes.DescripcionIdiomaBuscado; break; } HasherCryptoService <MD5Cng> hashingService = new HasherCryptoService <MD5Cng>(); string signatureBuilder = AppConstants.PayUApiKey + "~" + AppConstants.PayUMerchantID + "~" + pagoBuscado.Consecutivo + "~" + Math.Round(pagoBuscado.Precio, 2, MidpointRounding.AwayFromZero).ToString().Replace(",", ".") + "~COP"; PayUModel payUModel = new PayUModel { merchantId = AppConstants.PayUMerchantID, accountId = AppConstants.PayUAccountID, tax = 0, taxReturnBase = 0, test = AppConstants.PayUTest, Url = AppConstants.PayUURL, currency = "COP", amount = pagoBuscado.Precio, referenceCode = pagoBuscado.Consecutivo.ToString(), buyerEmail = pagoBuscado.Personas.Usuarios.Email, description = descripcion, signature = hashingService.GetStringHash(signatureBuilder) }; return(payUModel); } }
public override async void Init(object initData) { base.Init(initData); Pago = initData as HistorialPagosModel; // Significa que es un nuevo pago if (Pago == null) { PlanesDTO planParaComprar = initData as PlanesDTO; try { FacturaFormatoDTO facturaFormatoParaBuscar = new FacturaFormatoDTO { IdiomaDeLaFacturaFormato = App.IdiomaPersona, CodigoPais = App.Persona.CodigoPais }; FacturaFormatoDTO facturaFormato = await _pagosService.BuscarFacturaFormato(facturaFormatoParaBuscar); if (facturaFormato != null) { HistorialPagosPersonasDTO historialPago = new HistorialPagosPersonasDTO(); historialPago.TextoFacturaFormato = facturaFormato.Texto; historialPago.CodigoPais = App.Persona.CodigoPais; historialPago.CodigoMoneda = App.Persona.Paises.CodigoMoneda; historialPago.Paises = App.Persona.Paises; historialPago.Monedas = App.Persona.Paises.Monedas; historialPago.CodigoPersona = App.Persona.Consecutivo; historialPago.Planes = planParaComprar; historialPago.CodigoPlan = planParaComprar.Consecutivo; historialPago.Precio = planParaComprar.Precio; Pago = new HistorialPagosModel(historialPago); RaisePropertyChanged(nameof(Pago)); } else { await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.ErrorAlConsultarInfoPagos, "OK"); } } catch (Exception) { await CoreMethods.DisplayAlert(SportsGoResources.Error, SportsGoResources.ErrorAlConsultarInfoPagos, "OK"); } } }
public async Task <HistorialPagosPersonasDTO> BuscarPagoEnTramiteDeUnaPersona(HistorialPagosPersonas historialPagoParaVerificar) { using (SportsGoEntities context = new SportsGoEntities(false)) { PagosRepository pagosRepo = new PagosRepository(context); HistorialPagosPersonasDTO pagoEnTramite = await pagosRepo.BuscarPagoEnTramiteDeUnaPersona(historialPagoParaVerificar); if (pagoEnTramite != null) { DateTimeHelperNoPortable helper = new DateTimeHelperNoPortable(); pagoEnTramite.FechaPago = helper.ConvertDateTimeFromAnotherTimeZone(historialPagoParaVerificar.ZonaHorariaGMTBase, helper.DifferenceBetweenGMTAndLocalTimeZone, pagoEnTramite.FechaPago); } return(pagoEnTramite); } }
public async Task <HistorialPagosPersonasDTO> BuscarPagoEnTramiteDeUnaPersona(HistorialPagosPersonasDTO historialPagoParaBuscar) { if (historialPagoParaBuscar == null) { throw new ArgumentNullException("No puedes buscar el pago en tramite si historialPagoParaBuscar es nula!."); } if (historialPagoParaBuscar.CodigoPersona <= 0 || historialPagoParaBuscar.IdiomaBase == Idioma.SinIdioma) { throw new ArgumentException("historialPagoParaBuscar vacio y/o invalido!."); } IHttpClient client = ConfigurarHttpClient(); HistorialPagosPersonasDTO pagoEnTramite = await client.PostAsync("Pagos/BuscarPagoEnTramiteDeUnaPersona", historialPagoParaBuscar); return(pagoEnTramite); }
public async Task <HistorialPagosPersonasDTO> BuscarHistorialPagoPersona(HistorialPagosPersonasDTO historialPagoParaBuscar) { if (historialPagoParaBuscar == null) { throw new ArgumentNullException("No puedes buscar un historico de un pago si historialPagoParaBuscar es nula!."); } if (historialPagoParaBuscar.Consecutivo <= 0) { throw new ArgumentException("historialPagoParaBuscar vacio y/o invalido!."); } IHttpClient client = ConfigurarHttpClient(); HistorialPagosPersonasDTO historialPagoBuscado = await client.PostAsync("Pagos/BuscarHistorialPagoPersona", historialPagoParaBuscar); return(historialPagoBuscado); }
/// <summary> /// Solo se puede borrar pagos que esten en estado "Espera pago" o "1", devolvera false si no es asi /// </summary> public async Task <WrapperSimpleTypesDTO> EliminarPagoPendientePorPagar(HistorialPagosPersonasDTO historialPagoParaEliminar) { if (historialPagoParaEliminar == null) { throw new ArgumentNullException("No puedes eliminar un pago si historialPagoParaEliminar es nulo!."); } if (historialPagoParaEliminar.CodigoPersona <= 0 || historialPagoParaEliminar.Consecutivo <= 0) { throw new ArgumentException("historialPagoParaEliminar vacio y/o invalido!."); } IHttpClient client = ConfigurarHttpClient(); WrapperSimpleTypesDTO wrapperEliminarPagoPendientePorPagar = await client.PostAsync <HistorialPagosPersonasDTO, WrapperSimpleTypesDTO>("Pagos/EliminarPagoPendientePorPagar", historialPagoParaEliminar); return(wrapperEliminarPagoPendientePorPagar); }
public async Task <PayUModel> ConfigurarPayU(HistorialPagosPersonasDTO pagoParaProcesar) { if (pagoParaProcesar == null) { throw new ArgumentNullException("No puedes procesar el pago en PayU si pagoParaProcesar es nulo!."); } if (pagoParaProcesar.Consecutivo <= 0) { throw new ArgumentException("pagoParaProcesar vacio y/o invalido!."); } IHttpClient client = ConfigurarHttpClient(); PayUModel payUModel = await client.PostAsync <HistorialPagosPersonasDTO, PayUModel> ("Pagos/ConfigurarPayU", pagoParaProcesar); return(payUModel); }
public async Task <IHttpActionResult> BuscarPagoEnTramiteDeUnaPersona(HistorialPagosPersonas historialPagoParaBuscar) { if (historialPagoParaBuscar == null || historialPagoParaBuscar.CodigoPersona <= 0 || historialPagoParaBuscar.IdiomaBase == Idioma.SinIdioma) { return(BadRequest("historialPagoParaBuscar vacio y/o invalido!.")); } try { HistorialPagosPersonasDTO pagoEnTramite = await _pagosBusiness.BuscarPagoEnTramiteDeUnaPersona(historialPagoParaBuscar); return(Ok(pagoEnTramite)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IHttpActionResult> BuscarHistorialPagoPersona(HistorialPagosPersonas historialPagoParaBuscar) { if (historialPagoParaBuscar == null || historialPagoParaBuscar.Consecutivo <= 0) { return(BadRequest("historialPagoParaBuscar vacio y/o invalido!.")); } try { HistorialPagosPersonasDTO historialPagoBuscado = await _pagosBusiness.BuscarHistorialPagoPersona(historialPagoParaBuscar); return(Ok(historialPagoBuscado)); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <WrapperSimpleTypesDTO> CrearHistorialPagoPersona(HistorialPagosPersonasDTO historialPagoParaCrear) { if (historialPagoParaCrear == null) { throw new ArgumentNullException("No puedes crear un historico de pago si historialPagoParaCrear es nula!."); } if (string.IsNullOrWhiteSpace(historialPagoParaCrear.TextoFacturaFormato) || historialPagoParaCrear.CodigoPersona <= 0 || historialPagoParaCrear.CodigoPais <= 0 || historialPagoParaCrear.CodigoPlan <= 0) { throw new ArgumentException("historialPagoParaCrear vacia y/o invalida!."); } IHttpClient client = ConfigurarHttpClient(); WrapperSimpleTypesDTO wrapperCrearHistorialPagoPersona = await client.PostAsync <HistorialPagosPersonasDTO, WrapperSimpleTypesDTO>("Pagos/CrearHistorialPagoPersona", historialPagoParaCrear); return(wrapperCrearHistorialPagoPersona); }
public async Task Confirmacion(PayUConfirmationModel paymentResponse) { if (paymentResponse != null && paymentResponse.TransaccionFueAprobada) { if (!string.IsNullOrWhiteSpace(paymentResponse.reference_sale)) { HistorialPagosPersonasDTO pagoParaBuscar = new HistorialPagosPersonasDTO { Consecutivo = Convert.ToInt32(paymentResponse.reference_sale) }; HistorialPagosPersonasDTO pagoParaAprobar = await _pagosService.BuscarHistorialPagoPersona(pagoParaBuscar); pagoParaAprobar.EstadoDelPago = EstadoDeLosPagos.Aprobado; pagoParaAprobar.ReferenciaPago = paymentResponse.reference_pol; pagoParaAprobar.ObservacionesCliente = paymentResponse.description; pagoParaAprobar.EsPagoPorPayU = true; WrapperSimpleTypesDTO wrapper = await _pagosService.ModificarEstadoPagoPersona(pagoParaAprobar); } } }
public async Task <WrapperSimpleTypesDTO> ModificarEstadoPagoPersona(HistorialPagosPersonasDTO historialPagoParaModificar) { if (historialPagoParaModificar == null) { throw new ArgumentNullException("No puedes modificar el estado de un pago si historialPagoParaModificar es nulo!."); } if (historialPagoParaModificar.Consecutivo <= 0 || historialPagoParaModificar.CodigoPersona <= 0 || historialPagoParaModificar.CodigoPlan <= 0 || historialPagoParaModificar.EstadoDelPago == EstadoDeLosPagos.SinEstadoDelPago) { throw new ArgumentException("historialPagoParaModificar vacio y/o invalido!."); } else if (historialPagoParaModificar.EstadoDelPago == EstadoDeLosPagos.PendientePorAprobar && historialPagoParaModificar.CodigoArchivo <= 0 && string.IsNullOrWhiteSpace(historialPagoParaModificar.ReferenciaPago)) { throw new ArgumentException("historialPagoParaModificar debe tener un archivo y codigo de referencia si se va a reportar!."); } IHttpClient client = ConfigurarHttpClient(); WrapperSimpleTypesDTO wrapperModificarEstadoPagoPersona = await client.PostAsync <HistorialPagosPersonasDTO, WrapperSimpleTypesDTO>("Pagos/ModificarEstadoPagoPersona", historialPagoParaModificar); return(wrapperModificarEstadoPagoPersona); }
public async Task <HistorialPagosPersonasDTO> BuscarPagoEnTramiteDeUnaPersona(HistorialPagosPersonas historialPagoParaVerificar) { int estadoPendiente = (int)EstadoDeLosPagos.EsperaPago; int estadoPorAprobar = (int)EstadoDeLosPagos.PendientePorAprobar; HistorialPagosPersonasDTO pagoEnTramite = await _context.HistorialPagosPersonas.Where(x => x.CodigoPersona == historialPagoParaVerificar.CodigoPersona && (x.CodigoEstado == estadoPendiente || x.CodigoEstado == estadoPorAprobar)) .Select(x => new HistorialPagosPersonasDTO { Consecutivo = x.Consecutivo, CodigoEstado = x.CodigoEstado, FechaPago = x.FechaPago, CodigoPais = x.CodigoPais, CodigoPersona = x.CodigoPersona, CodigoPlan = x.CodigoPlan, Precio = x.Precio, TextoFacturaFormato = x.TextoFacturaFormato, CodigoArchivo = x.CodigoArchivo, ReferenciaPago = x.ReferenciaPago, ObservacionesAdministrador = x.ObservacionesAdministrador, ObservacionesCliente = x.ObservacionesCliente, Planes = new PlanesDTO { Consecutivo = x.Planes.Consecutivo, CodigoArchivo = x.Planes.CodigoArchivo, DescripcionIdiomaBuscado = x.Planes.PlanesContenidos.Where(y => y.CodigoIdioma == historialPagoParaVerificar.CodigoIdiomaUsuarioBase).Select(y => y.Descripcion).FirstOrDefault(), }, Paises = new PaisesDTO { Consecutivo = x.Paises.Consecutivo, CodigoArchivo = x.Paises.CodigoArchivo, DescripcionIdiomaBuscado = x.Paises.PaisesContenidos.Where(z => z.CodigoIdioma == historialPagoParaVerificar.CodigoIdiomaUsuarioBase).Select(y => y.Descripcion).FirstOrDefault() } }) .AsNoTracking() .FirstOrDefaultAsync(); return(pagoEnTramite); }
public async Task <HistorialPagosPersonasDTO> BuscarHistorialPagoPersona(HistorialPagosPersonas historialPagoParaBuscar) { HistorialPagosPersonasDTO historialPagoBuscado = await _context.HistorialPagosPersonas.Where(x => x.Consecutivo == historialPagoParaBuscar.Consecutivo) .Select(x => new HistorialPagosPersonasDTO { Consecutivo = x.Consecutivo, CodigoArchivo = x.CodigoArchivo, CodigoEstado = x.CodigoEstado, CodigoMoneda = x.CodigoMoneda, CodigoPais = x.CodigoPais, CodigoPersona = x.CodigoPersona, CodigoPlan = x.CodigoPlan, FechaPago = x.FechaPago, ObservacionesAdministrador = x.ObservacionesAdministrador, ObservacionesCliente = x.ObservacionesCliente, Precio = x.Precio, ReferenciaPago = x.ReferenciaPago, TextoFacturaFormato = x.TextoFacturaFormato, Personas = new PersonasDTO { CodigoIdioma = x.Personas.CodigoIdioma, Usuarios = new UsuariosDTO { Email = x.Personas.Usuarios.Email } }, Planes = new PlanesDTO { DescripcionIdiomaBuscado = x.Planes.PlanesContenidos.Where(y => y.CodigoIdioma == x.Personas.CodigoIdioma).Select(y => y.Descripcion).FirstOrDefault() } }) .AsNoTracking() .FirstOrDefaultAsync(); return(historialPagoBuscado); }
public async Task <JsonResult> UpdatePaymentStatus(HistorialPagosPersonasDTO paymentHistory) { Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>(); try { PagosServices payService = new PagosServices(); paymentHistory.EstadoDelPago = EstadoDeLosPagos.PendientePorAprobar; result.obj = await payService.ModificarEstadoPagoPersona(paymentHistory); if (result.obj != null) { return(Json(Helper.returnSuccessfulPayment(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } else { return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } } catch (Exception) { return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } }
public HistorialPagosModel(HistorialPagosPersonasDTO historial) { HistorialPago = historial; }
public async Task <WrapperSimpleTypesDTO> VerificarQueNoExistaUnPagoEnTramite(HistorialPagosPersonasDTO historialPagoParaVerificar) { if (historialPagoParaVerificar == null) { throw new ArgumentNullException("No puedes verificar si hay un pago en tramite si historialPagoParaVerificar es nula!."); } if (historialPagoParaVerificar.CodigoPersona <= 0) { throw new ArgumentException("historialPagoParaVerificar vacio y/o invalido!."); } IHttpClient client = ConfigurarHttpClient(); WrapperSimpleTypesDTO wrapperVerificarQueNoExistaUnPagoEnTramite = await client.PostAsync <HistorialPagosPersonasDTO, WrapperSimpleTypesDTO>("Pagos/VerificarQueNoExistaUnPagoEnTramite", historialPagoParaVerificar); return(wrapperVerificarQueNoExistaUnPagoEnTramite); }
public async Task <TimeLineNotificaciones> VerificarSiPagoEstaAprobadoYTraerNotificacion(HistorialPagosPersonasDTO pagoParaVerificar) { if (pagoParaVerificar == null) { throw new ArgumentNullException("No puedes verificar un pago si pagoParaVerificar es nulo!."); } if (pagoParaVerificar.Consecutivo <= 0) { throw new ArgumentException("pagoParaVerificar vacio y/o invalido!."); } IHttpClient client = ConfigurarHttpClient(); TimeLineNotificaciones timeLineNotificacion = await client.PostAsync <HistorialPagosPersonasDTO, TimeLineNotificaciones>("Pagos/VerificarSiPagoEstaAprobadoYTraerNotificacion", pagoParaVerificar); return(timeLineNotificacion); }