Пример #1
0
        public bool obtenerPedidoByPk()
        {
            PedidoDetalleModel aux;

            try
            {
                string sql = "SELECT * FROM VPEDIDOS WHERE PK=@PK AND BORRADO=0";
                db.PreparedSQL(sql);
                db.command.Parameters.AddWithValue("@PK", PK);
                ResultSet res = db.getTable();
                if (res.Next())
                {
                    PK                  = res.Get("PK");
                    PK_CLIENTE          = res.Get("PK_CLIENTE");
                    CLIENTE             = res.Get("CLIENTE");
                    TELEFONO_CLIENTE    = res.Get("TELEFONO");
                    PK_TIENDA           = res.Get("PK_TIENDA");
                    TIENDA              = res.Get("TIENDA");
                    DIRECCION_TIENDA    = res.Get("TIENDA_DIRECCION");
                    LATITUD_TIENDA      = res.Get("LATITUD_TIENDA");
                    LONGITUD_TIENDA     = res.Get("LONGITUD_TIENDA");
                    DIRECCION           = res.Get("DIRECCION");
                    LATITUD             = res.Get("LATITUD");
                    LONGITUD            = res.Get("LONGITUD");
                    PK_REPARTIDOR       = res.Get("PK_REPARTIDOR");
                    REPARTIDOR          = res.Get("REPARTIDOR");
                    PK_ESTATUS          = res.Get("PK_ESTATUS");
                    ESTATUS             = res.Get("ESTATUS");
                    SUBTOTAL            = res.GetDouble("SUBTOTAL");
                    ENVIO               = res.GetDouble("ENVIO");
                    COMISION_TARJETA    = res.GetDouble("COMISION_TARJETA");
                    TOTAL               = res.GetDouble("TOTAL");
                    METODO_PAGO         = res.Get("METODO_PAGO");
                    PAGO_EFECTIVO       = res.Get("PAGO_EFECTIVO");
                    FECHA_PAGO_EFECTIVO = res.Get("FECHA_PAGO_EFECTIVO");
                    IMAGEN_TIENDA       = res.Get("IMAGEN_TIENDA");
                    BORRADO             = res.Get("BORRADO");
                    FECHA_C             = res.Get("FECHA_C");
                    FECHA_M             = res.Get("FECHA_M");
                    FECHA_D             = res.Get("FECHA_D");
                    USUARIO_C           = res.Get("USUARIO_C");
                    USUARIO_M           = res.Get("USUARIO_M");
                    USUARIO_D           = res.Get("USUARIO_D");
                    aux                 = new PedidoDetalleModel();
                    aux.PK_PEDIDO       = PK;
                    LISTA               = aux.getByPkPedido();
                    if (METODO_PAGO.Equals("T"))
                    {
                        cargo           = new CargosModel();
                        cargo.PK_PEDIDO = PK;
                        cargo.obtenerCargoByPK();
                    }
                    return(true);
                }
            }
            catch { }

            return(false);
        }
Пример #2
0
        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);
        }