public List <Card> obneterTargetasPorPkCliente1() { List <Card> cards = new List <Card>(); TarjetasModel aux; try { ClientesModel cliente = new ClientesModel(); cliente.PK = PK_CLIENTE; cliente.getClienteByPk(); if (Resources.DEVELOP.ToUpper().Equals("TRUE")) { api = new OpenpayAPI(Resources.SK_OPEN_PAY_DEV, Resources.ID_OPEN_PAY_DEV, false); } else { api = new OpenpayAPI(Resources.SK_OPEN_PAY, Resources.ID_OPEN_PAY, true); } SearchParams request = new SearchParams(); //request.CreationGte = new DateTime(2100, 5, 1); //request.CreationLte = new DateTime(2014, 5, 15); //request.Offset = 0; request.Limit = 100; cards = api.CardService.List(cliente.OPENID, request); } catch (Exception e) { LogModel.registra("Error al obtener tarjetas", e.ToString()); } return(cards); }
public bool agregarTarjeta() { try { ClientesModel cliente = new ClientesModel(); cliente.PK = PK_CLIENTE; cliente.getClienteByPk(); if (!String.IsNullOrEmpty(cliente.OPENID)) { if (Resources.DEVELOP.ToUpper().Equals("TRUE")) { api = new OpenpayAPI(Resources.SK_OPEN_PAY_DEV, Resources.ID_OPEN_PAY_DEV, false); } else { api = new OpenpayAPI(Resources.SK_OPEN_PAY, Resources.ID_OPEN_PAY, true); } Card request = new Card(); request.TokenId = ID_TARJETA; request.DeviceSessionId = DEVICE_SESSION_ID; request = api.CardService.Create(cliente.OPENID, request); MARCA = request.Brand; MARCA = request.CardNumber; card = request; return(!String.IsNullOrEmpty(request.Brand)); } /* * string sql = "INSERT INTO TARJETAS_CLIENTES(PK_CLIENTE,ID_TARJETA,DIGITOS,MARCA)" + * "VALUES (@PK_CLIENTE,@ID_TARJETA,@DIGITOS,@MARCA)"; * db.PreparedSQL(sql); * db.command.Parameters.AddWithValue("@PK_CLIENTE", PK_CLIENTE); * db.command.Parameters.AddWithValue("@ID_TARJETA", ID_TARJETA); * db.command.Parameters.AddWithValue("@DIGITOS", request.CardNumber); * db.command.Parameters.AddWithValue("@MARCA", request.Brand); * PK = db.executeId(); * if (!string.IsNullOrEmpty(PK)) { * return true; * } */ } catch (OpenpayException e1) { string error1 = e1.ToString(); LogModel.registra("error al agregar tajera Openpay ", error1); ERROR = ErroresOpenPayModel.error(e1.ErrorCode); } catch (Exception e) { string error = e.ToString(); LogModel.registra("error al agregar tajera", error); } return(false); }
public async Task <ActionResult> Post([FromBody] PedidosModel pedidom) { int result = 0; string msj = "¡Error al actualizar estatus intente más tarde!"; try { if (pedidom.setEstatus()) { try { if (pedidom.obtenerPedidoByPk()) { ClientesModel cliente = new ClientesModel(); cliente.PK = pedidom.PK_CLIENTE; if (cliente.getClienteByPk()) { if (!string.IsNullOrEmpty(cliente.TOKEN)) { NotificacionesModel notificacion = new NotificacionesModel(); notificacion.TITLE = "¡Se está preparando el pedido!"; notificacion.MESSAGE = "¡La tienda '" + pedidom.TIENDA + "' está preparando tu pedido!"; notificacion.TOKENS.Add(cliente.TOKEN); await notificacion.sendNotificationAsync(); } } } } catch (Exception e) { LogModel.registra("Error al enviar notificación set estatus Pedido Tienda", e.ToString()); } result = 1; msj = "¡Estatus actualizado!"; } } catch { result = 0; msj = "¡Error al actualizar estatus intente más tarde!"; } return(Ok(new { resultado = result, mensaje = msj, pedido = pedidom })); }
public async Task <ActionResult> Post([FromBody] PedidosModel pedidom) { int result = 0; string msj = "¡Error al actualizar estatus intente más tarde!"; try { if (pedidom.setEstatus()) { try { if (pedidom.obtenerPedidoByPk()) { ClientesModel cliente = new ClientesModel(); cliente.PK = pedidom.PK_CLIENTE; RepartidoresModel repartidor = new RepartidoresModel(); repartidor.PK = pedidom.PK_REPARTIDOR; if (cliente.getClienteByPk() && repartidor.obtenerUsuarioByPK()) { if (!string.IsNullOrEmpty(cliente.TOKEN)) { NotificacionesModel notificacion = new NotificacionesModel(); switch (int.Parse(pedidom.PK_ESTATUS)) { case 3: notificacion.TITLE = "¡Tu repartidor esta en negocio!"; notificacion.MESSAGE = "¡" + repartidor.NOMBRE + "' está esperando la entrega de tu pedido!"; break; case 4: notificacion.TITLE = "¡Tu pedido está en camino!"; notificacion.MESSAGE = "¡" + repartidor.NOMBRE + "' está en camino con tu pedido!"; break; case 5: notificacion.TITLE = "¡Tu pedido se entrego!"; notificacion.MESSAGE = "¡Gracias por utilizar acmarket!"; break; } notificacion.TOKENS.Add(cliente.TOKEN); await notificacion.sendNotificationAsync(); } } } } catch (Exception e) { LogModel.registra("Error al enviar notificación set estatus Pedido Tienda", e.ToString()); } result = 1; msj = "¡Estatus actualizado!"; } } catch { result = 0; msj = "¡Error al actualizar estatus intente más tarde!"; } return(Ok(new { resultado = result, mensaje = msj, pedido = pedidom })); }
public bool pagar() { try { ClientesModel cliente = new ClientesModel(); cliente.PK = PK_CLIENTE; cliente.getClienteByPk(); if (!String.IsNullOrEmpty(cliente.OPENID)) { if (Resources.DEVELOP.ToUpper().Equals("TRUE")) { api = new OpenpayAPI(Resources.SK_OPEN_PAY_DEV, Resources.ID_OPEN_PAY_DEV, false); } else { api = new OpenpayAPI(Resources.SK_OPEN_PAY, Resources.ID_OPEN_PAY, true); } ChargeRequest request = new ChargeRequest(); Customer customer = new Customer(); customer.Name = cliente.NOMBRE; customer.LastName = cliente.APELLIDOS; customer.PhoneNumber = cliente.TELEFONO; customer.Email = cliente.CORREO; request.Method = "card"; request.SourceId = SOURCE_ID; request.Amount = new Decimal(TOTAL); request.Currency = "MXN"; request.Description = "Pedido polar " + PK; request.OrderId = PK; request.DeviceSessionId = DEVICE_SESSION_ID; //request.Customer = customer;>>>>>>>>>>>> request.Cvv2 = CVV2; try { Charge charge = api.ChargeService.Create(cliente.OPENID, request); cargo = new CargosModel(); cargo.ID = charge.Id; cargo.AUTHORIZATION = charge.Authorization; cargo.AMOUNT = (double)charge.Amount; cargo.METHOD = charge.Method; cargo.ESTATUS = charge.Status; cargo.PK_PEDIDO = PK; cargo.ERROR_MESSAGE = charge.ErrorMessage; cargo.agregarCargo(); if (cargo.ESTATUS.Equals("completed")) { return(true); } else { ERROR = charge.ErrorMessage; delete(); } } catch (OpenpayException e) { LogModel.registra("Error al pagar", e.ToString()); CargosErroresModel aux1 = new CargosErroresModel(); aux1.category = e.Category; aux1.description = e.Description; aux1.http_code = e.HResult; aux1.request_id = e.RequestId; aux1.PK_PEDIDO = PK; aux1.agregarCargoError(); ERROR = ErroresOpenPayModel.error(e.ErrorCode); delete(); } catch (Exception ex) { LogModel.registra("Error al pagar", ex.ToString()); ERROR = ex.Message; delete(); } } } catch (Exception e) { LogModel.registra("Error al pagar", e.ToString()); ERROR = e.Message; } return(false); }