public void finaliza()
        {
            Globales.cpIntegracion_sResult = string.Format("{0}<propina>{1}</propina>", Globales.cpIntegraEMV.getRspXML(), this.propina_total);
            string monto        = string.Format("<amount>{0}</amount>", this.importe);
            string tempBusqueda = string.Format("<amount>{0}</amount>", Globales.GetDataXml("amount", Globales.cpIntegracion_sResult));

            Globales.cpIntegracion_sResult = Globales.cpIntegracion_sResult.Replace(tempBusqueda, monto);

            if (Globales.FacturaE == "1")
            {
                if (Globales.MessageConfirm("¿Desea factura electronica?"))
                {
                    frmPreguntaFactura fFactura = new frmPreguntaFactura();
                    fFactura.abrirFrmAhora = abrir;
                    fFactura.cerraPage     = cierra;
                    abrir(fFactura);
                }
                else
                {
                    Globales.XMLFacturaE = string.Empty;
                }
            }
        }
Пример #2
0
        private void CmdEnviar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Globales.strNombreFP = NOMBRE_GENERAL + ".CmdEnviar_Click()";
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                string mensaje = string.Empty;


                dynamic Impte;
                dynamic IsAmex, strCadEncriptar, CadAmex;
                Impte = Globales.FormatMoneda(lblimportepreventa.Content.ToString());

                IsAmex = false;

                Globales.cpHTTP_Clear();
                Globales.cpHTTP_sURL_cpCUCT = TypeUsuario.Url;
                strCadEncriptar             = "&folio=" + lbloperacion.Content.ToString() +
                                              "&empresa=" + TypeUsuario.Id_Company +
                                              "&sucursal=" + TypeUsuario.Id_Branch +
                                              "&op=reimpvouchtermica" +
                                              "&co=true";
                strCadEncriptar         = strCadEncriptar.Replace("\r", "");
                strCadEncriptar         = strCadEncriptar.Replace("\t", "");
                Globales.cpHTTP_cadena1 = "enc=" + Globales.encryptString(strCadEncriptar, Globales.KEY_RC4, true);
                if (Globales.cpHTTP_SendcpCUCT())
                {
                    Mouse.OverrideCursor = null;
                    int InSrt = Globales.cpHTTP_sResult.IndexOf(System.Environment.NewLine);
                    if (InSrt == -1)
                    {
                        InSrt = 0;
                    }
                    InSrt++;

                    string cadena = Utils.Mid(Globales.cpHTTP_sResult, InSrt + 2);
                    cadena  = cadena.Replace(System.Environment.NewLine, "");
                    cadena  = cadena.Replace("\r", "");
                    cadena  = cadena.Replace("\t", "");
                    CadAmex = Globales.DecryptString(cadena, "KEY CREDIT CARD KEY", true);
                }

Continuar:
                if (string.IsNullOrWhiteSpace(Propina.Text))
                {
                    Globales.MessageBoxMit("Introduzca la propina.");
                    Propina.Focus();
                }
                else
                {
                    CmdEnviar.IsEnabled = false;

                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                    string strTypeC = string.Empty;
                    Globales.cpIntegracion_Clear();
                    Globales.cpIntegracion_sURL_cpINTEGRA = Globales.URL_DLL_CIERREPREVENTA;


                    Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                    Globales.cpIntegraEMV.sndCierrePreventaMOTO(TypeUsuario.usu,
                                                                TypeUsuario.Pass,
                                                                "",
                                                                TypeUsuario.Id_Company,
                                                                TypeUsuario.Id_Branch,
                                                                TypeUsuario.country,
                                                                Impte,
                                                                Propina.Text,
                                                                lbloperacion.Content.ToString());

                    Globales.cpIntegracion_sResult = Globales.cpIntegraEMV.getRspXML() + "<propina>" + Propina.Text + "</propina>";
                    Globales.cpIntegracion_sResult = Globales.cpIntegracion_sResult.Replace("<amount/>", "<amount>" + Impte + "</amount>");

                    Mouse.OverrideCursor = null;


                    string caso = Globales.GetDataXml("response", Globales.cpIntegracion_sResult).ToLower();
                    switch (caso)
                    {
                    case "approved":
                        Propina.IsEnabled = false;

                        mensaje = string.Format("Aut. {0}", Globales.GetDataXml("auth", Globales.cpIntegracion_sResult));
                        Globales.MessageBoxMitApproved(mensaje, "Cierre Preventa Aprobado");

                        TypeUsuario.strVoucherCoP = Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult).Trim();
                        TypeUsuario.strVoucherCoP = Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult).Trim();

                        //                 //'************************************************************************************************
                        //                 //   ''********************************** FIRMA EN PANEL *********************************************
                        //                 //   'VALIDACIONES PARA LA FIRMA EN PANEL
                        string textoAgua = string.Empty;
                        textoAgua  = "Folio: " + Globales.cpIntegraEMV.getRspOperationNumber() + System.Environment.NewLine;
                        textoAgua += "Auth: " + Globales.cpIntegraEMV.getRspAuth() + System.Environment.NewLine;
                        textoAgua += "Importe: " + Globales.cpIntegraEMV.getTx_Amount() + System.Environment.NewLine;
                        textoAgua += "Fecha: " + Globales.cpIntegraEMV.getRspDate() + System.Environment.NewLine;
                        textoAgua += "Merchant: " + Globales.cpIntegraEMV.getRspDsMerchant() + System.Environment.NewLine;
                        textoAgua += " " + System.Environment.NewLine;
                        textoAgua += ";___________________" + System.Environment.NewLine;
                        textoAgua += "FIRMA DIGITALIZADA:" + System.Environment.NewLine;


                        //                    '************************************************************************************************
                        //                    'valida si la tarjeta es Chip and Pin
                        bool   IsChipAndPin = false; bool esQPS = false;
                        string cadenaHexFirma = string.Empty;
                        int    tipoVta        = 1;
                        var    aux            = Globales.cpIntegraEMV.chkCc_IsPin();
                        if (Globales.cpIntegraEMV.chkCc_IsPin() == "01")
                        {
                            IsChipAndPin = true;
                        }
                        if (Globales.cpIntegraEMV.getRspVoucher().Contains("@cnn Autorizado sin Firma ") && tipoVta == 1 && !IsChipAndPin)
                        {
                            esQPS = true;
                        }

                        //                    '************************************************************************************************
                        //                    'Si la PinPad no soporta Firma en Panel y no es touch, sigue el flujo normal de PcPay
                        if (!Globales.cpIntegraEMV.EsTouch() && !Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                        {    // Then
                            goto GoImpresion;
                        }

                        //                    '************************************************************************************************
                        //                    'Si la PinPad Soporta Firma en Panel y no es touch,
                        if (!Globales.cpIntegraEMV.EsTouch() && Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                        {
                            // 'Llama a la función de obtener la firma en Panel
                            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                            cadenaHexFirma       = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua, Globales.cpIntegraEMV.getRspVoucher(),
                                                                                              IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                            Mouse.OverrideCursor = null;
                            if (!cadenaHexFirma.Contains("Error"))
                            {
                                //  'Llama a la funcion de Guardar la firma
                                if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Globales.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                {
                                    imgEmailFirmaPanel.Visibility = Visibility.Visible;
                                }
                            }
                            else
                            {
                                Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad");
                            }

                            goto GoImpresion;
                        }

                        if (Globales.cpIntegraEMV.EsTouch())
                        {
                            if (TypeUsuario.UtilizarCapacidadTouch && TypeUsuario.EnviarVoucherMail)
                            {
                                if (!Globales.ObtieneFirmaPanel(Globales.ipFirmaPanel, textoAgua, (short)tipoVta, IsChipAndPin, esQPS))
                                {
                                    goto GoImpresion;
                                }
                                else
                                {
                                    goto finaliza;
                                }
                            }


                            if (TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                            {
                                //Llama a la función de obtener la firma en Panel
                                cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(true, textoAgua,
                                                                                            Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                                if (!cadenaHexFirma.Contains("Error"))
                                {
                                    //  'Llama a la funcion de Guardar la firma
                                    if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Globales.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                    {
                                        imgEmailFirmaPanel.Visibility = Visibility.Visible;
                                    }
                                }
                                else
                                {
                                    Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad");
                                }

                                goto GoImpresion;
                            }


                            if (!TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                            {
                                if (Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                                {
                                    // 'Llama a la función de obtener la firma en Panel
                                    cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua,
                                                                                                Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                                    if (!cadenaHexFirma.Contains("Error"))
                                    {
                                        //   'Llama a la funcion de Guardar la firma
                                        if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Globales.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                        {
                                            imgEmailFirmaPanel.Visibility = Visibility.Visible;
                                        }
                                    }
                                    else
                                    {
                                        Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                                    }
                                }

                                goto GoImpresion;
                            }
                        }


                        //                '************************************************************************************************************
GoImpresion:
                        escogerImpresora();
finaliza:
                        //'fin del case

                        if (TypeUsuario.IsAQ)
                        {
                            Globales.VerificaVoucher();
                        }
                        cmdVoucher.Visibility = Visibility.Visible;
                        CmdEnviar.Visibility  = Visibility.Hidden;

                        if (Globales.FacturaE == "1")
                        {
                            if (Globales.MessageConfirm("¿Desea factura electrónica?"))
                            {
                                frmPreguntaFactura frmPregunta = new frmPreguntaFactura();
                                frmPregunta.abrirFrmAhora = abrirFrmNuevo;
                                frmPregunta.cerraPage     = cierra;
                                abrirFrmNuevo(frmPregunta, "Factura Electronica");
                                Mouse.OverrideCursor = null;
                                return;
                            }
                            else
                            {
                                Globales.XMLFacturaE = "";
                            }
                        }


                        break;

                    case "denied":
                        Propina.IsEnabled = false;
                        mensaje           = Globales.msjRech + ": " + Globales.GetDataXml("cd_response", Globales.cpIntegracion_sResult) + " " + Globales.GetDataXml("friendly_response", Globales.cpIntegracion_sResult);
                        Globales.MessageBoxMitDenied(mensaje);
                        CmdEnviar.Visibility = Visibility.Hidden;
                        break;

                    case "error":
                        mensaje = Globales.GetDataXml("nb_error", Globales.cpIntegracion_sResult);
                        Globales.MessageBoxMitError(mensaje);
                        CmdEnviar.Visibility = Visibility.Visible;
                        break;

                    default:
                        mensaje = "Verifique su conexión de Internet.";
                        Globales.MessageBoxMitError(mensaje);
                        CmdEnviar.Visibility = Visibility.Visible;
                        break;
                    }
                    Mouse.OverrideCursor = null;
                    CmdEnviar.IsEnabled  = true;
                }
            }
            catch
            {
            }
        }
Пример #3
0
        private void cmdEnviarClick(object sender, RoutedEventArgs e)
        {
            bool   bolOperacion = false;
            string isCheckin    = "";

            if (string.IsNullOrWhiteSpace(txtCalle.Text))
            {
                Globales.MessageBoxMit("Introduzca la calle del domicilio");
                //txtCalle.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(txtExt.Text))
            {
                Globales.MessageBoxMit("Introduzca el número exterior del domicilio.");
                //txtExt.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(txtCP.Text))
            {
                Globales.MessageBoxMit("Introduzca el código postal del domicilio");
                //txtCP.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(cboColonia.Text))
            {
                Globales.MessageBoxMit("Introduzca la colonia del domicilio.");
                //cboColonia.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(txtDelMun.Text))
            {
                Globales.MessageBoxMit("Introduzca la delegación o municipio del domicilio.");
                //txtDelMun.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(txtCiudad.Text))
            {
                Globales.MessageBoxMit("Introduzca la ciudad del domicilio.");
                // txtCiudad.Focus();
                return;
            }
            else if (string.IsNullOrWhiteSpace(txtEstado.Text))
            {
                Globales.MessageBoxMit("Introduzca el estado del domicilio.");
                //  txtEstado.Focus();
                return;
            }
            else
            {
                if (Globales.isAerolinea)
                {
                    if (string.IsNullOrWhiteSpace(Fecha.Text))
                    {
                        Globales.MessageBoxMit("Favor de seleccionar la fecha de salida");
                        cmdEnviar.IsEnabled = true;
                        return;
                    }
                    if (numOrden.Text.Length != 6)
                    {
                        Globales.MessageBoxMit("El PNR debe de ser de 6 dígitos.");
                        cmdEnviar.IsEnabled = true;
                        return;
                    }
                }

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                boletos = string.Empty;
                foreach (var item in lista_boletos)
                {
                    boletos += item + ",";
                }
                if (!string.IsNullOrEmpty(boletos))
                {
                    boletos = boletos.Substring(0, boletos.Length - 1);
                }


                if (Globales.isAerolinea)
                {
                    if (!string.IsNullOrEmpty(boletos))
                    {
                        if (!Globales.insertaBoletoAgencia(TypeUsuario.Id_Company, "", boletos, Fecha.Text, FechaR.Text))
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(boletos))
                    {
                        if (Globales.insertaBoletoAgencia(TypeUsuario.Id_Company, "", boletos, Fecha.Text, ""))
                        {
                            return;
                        }
                    }
                }



                cmdEnviar.IsEnabled = false;
                //  MousePointer = vbHourglass
                string strTypeC = string.Empty;
                Globales.cpIntegracion_Clear();
                if (Globales.isAmex)
                {
                    strTypeC = "AMEX";
                }
                else
                {
                    strTypeC = "V/MC";
                }


                Globales.cpIntegracion_sURL_cpINTEGRA = Globales.URL_DLL;
                string strTpOperacion = string.Empty;
                strTpOperacion = "17";



                string FRetorno     = string.Empty;
                string FechaRetorno = string.Empty;

                if (Globales.isAerolinea)
                {
                    if (string.IsNullOrWhiteSpace(FechaR.Text))
                    {
                        // FechaRetorno.Text = FechaSalida.Text;
                    }
                    else
                    {
                        FechaRetorno = FechaR.Text;
                    }
                }
                else
                {
                    FechaRetorno = "";
                }

                if ((Globales.isAgencias || Globales.isAerolinea) && string.IsNullOrWhiteSpace(numCvv.Password) && !TypeUsuario.CadenaXML.Contains("<PCPAYRP3>"))
                {
                    if (strTypeC == "V/MC")
                    {
                        numCvv.Password = "******";
                    }
                    else
                    {
                        numCvv.Password = "******";
                    }
                }

                bolOperacion = Globales.cpIntegracion_cpAVSs2(TypeUsuario.Id_Company, TypeUsuario.Id_Branch, TypeUsuario.country,
                                                              TypeUsuario.usu,
                                                              TypeUsuario.Pass,
                                                              Globales.merchantMoto,
                                                              numOrden.Text,
                                                              strTpOperacion,
                                                              strTypeC,
                                                              nomTdc.Text,
                                                              numeroTarjeta,
                                                              Mes.Text,
                                                              Anio.Text.Substring(2, 2),
                                                              numCvv.Password,
                                                              importe.Text,
                                                              lblMoneda.Content.ToString(),
                                                              txtCalle.Text,
                                                              txtInt.Text,
                                                              txtExt.Text,
                                                              txtDelMun.Text,
                                                              txtCiudad.Text,
                                                              txtEstado.Text,
                                                              txtCP.Text,
                                                              cboColonia.Text,
                                                              txtNombre.Text + " " + txtPaterno.Text + " " + txtMaterno.Text,
                                                              txtPais.Text,
                                                              txtLadaPersonal.Text + txtTelefonoPersonal.Text, txtEmail.Text, "", boletos, Fecha.Text, FechaR.Text);


                Mouse.OverrideCursor = null;
                string strCadEncriptar = string.Empty;

                cmdRev.IsEnabled = false;
                string eva = Globales.GetDataXml("response", Globales.cpIntegracion_sResult).ToLower();

                switch (eva)
                {
                case "approved":
                    numTdc.IsEnabled = false;
                    Mes.IsEnabled    = false;
                    Anio.IsEnabled   = false;
                    nomTdc.IsEnabled = false;
                    numCvv.IsEnabled = false;
                    // cboBanco.IsEnabled = false;
                    //FormaPago.IsEnabled = false;
                    numOrden.IsEnabled    = false;
                    importe.IsEnabled     = false;
                    txtCalle.IsEnabled    = false;
                    txtExt.IsEnabled      = false;
                    txtInt.IsEnabled      = false;
                    txtCP.IsEnabled       = false;
                    cboColonia.IsEnabled  = false;
                    BADDBOLETOS.IsEnabled = false;

                    txtDelMun.IsEnabled = false;
                    txtCiudad.IsEnabled = false;
                    txtEstado.IsEnabled = false;
                    txtPais.IsEnabled   = false;

                    string mensaje = Globales.GetDataXml("auth", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitApproved(mensaje);
                    Fecha.IsEnabled           = false;
                    FechaR.IsEnabled          = false;
                    TypeUsuario.strVoucherCoP = Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult).Trim();
                    Mouse.OverrideCursor      = System.Windows.Input.Cursors.Wait;
                    switch (TypeUsuario.TipoImpresora)
                    {
                    case "6":

                        Globales.PrintOptions(TypeUsuario.strVoucherCoP);
                        cmdVoucher.IsEnabled = true;
                        cmdNuevo.IsEnabled   = true;
                        break;

                    case "1":
                        if (Globales.VoucherHtml(Globales.GetDataXml("foliocpagos", Globales.cpIntegracion_sResult), TypeUsuario.Id_Company, TypeUsuario.Id_Branch, "impvouch", "false"))
                        {
                            TypeUsuario.strVoucher = Globales.cpHTTP_sResult;
                            Globales.Imprimir_HTML(TypeUsuario.strVoucher);
                        }


                        break;

                    case "4":
                        if (Globales.VoucherHtml(Globales.GetDataXml("foliocpagos", Globales.cpIntegracion_sResult), TypeUsuario.Id_Company, TypeUsuario.Id_Branch, "impvouch", "false"))
                        {
                            TypeUsuario.strVoucher = Globales.VoucherHtml1(Globales.cpHTTP_sResult);
                            Globales.Imprimir_HTML(TypeUsuario.strVoucher);
                        }
                        break;

                    case "3":
                        Globales.imprimirEpson();
                        break;

                    default:
                        Globales.MessageBoxMit("No existe impresora, favor de escoger una en administración->Escoger_impresora");
                        break;
                    }

                    Mouse.OverrideCursor = null;
                    if (TypeUsuario.IsAQ)
                    {
                        Globales.VerificaVoucher();
                    }

                    cmdVoucher.IsEnabled = true;
                    cmdNuevo.Visibility  = Visibility.Visible;
                    cmdNuevo.IsEnabled   = true;
                    cmdEnviar.Visibility = Visibility.Hidden;

                    this.BENVIAMAIL.Visibility = TypeUsuario.enviaCorreo ? Visibility.Visible : Visibility.Hidden;
                    this.BENVIAMAIL.Tag        = this.nomTdc.Text;

                    if (Globales.FacturaE == "1")
                    {
                        if (Globales.MessageConfirm("¿Desea factura electrónica?"))
                        {
                            frmPreguntaFactura pregunta = new frmPreguntaFactura();
                            pregunta.abrirFrmAhora = abrir;
                            pregunta.cerraPage     = cerrar;
                            abrir(pregunta);
                            return;
                        }
                        else
                        {
                            Globales.XMLFacturaE = "";
                        }
                    }
                    break;

                case "denied":
                    numTdc.IsEnabled = false;
                    Mes.IsEnabled    = false;
                    Anio.IsEnabled   = false;
                    nomTdc.IsEnabled = false;
                    numCvv.IsEnabled = false;
                    //  cboBanco.IsEnabled = false;
                    // FormaPago.IsEnabled = false;
                    numOrden.IsEnabled   = false;
                    importe.IsEnabled    = false;
                    txtCalle.IsEnabled   = false;
                    txtExt.IsEnabled     = false;
                    txtInt.IsEnabled     = false;
                    txtCP.IsEnabled      = false;
                    cboColonia.IsEnabled = false;

                    txtDelMun.IsEnabled = false;
                    txtCiudad.IsEnabled = false;
                    txtEstado.IsEnabled = false;
                    txtPais.IsEnabled   = false;
                    Globales.MessageBoxMitDenied("Cobro rechazado" + Globales.msjRech + "\n" + Globales.GetDataXml("cd_response", Globales.cpIntegracion_sResult) + " " + Globales.GetDataXml("friendly_response", Globales.cpIntegracion_sResult));
                    cmdNuevo.Visibility   = Visibility.Visible;
                    cmdEnviar.Visibility  = Visibility.Hidden;
                    cmdNuevo.IsEnabled    = true;
                    BADDBOLETOS.IsEnabled = false;

                    this.BENVIAMAIL.Visibility = Visibility.Hidden;
                    this.BENVIAMAIL.Tag        = string.Empty;


                    // FechaSalida.IsEnabled = false;
                    Fecha.IsEnabled = false;
                    //FechaRetorno.IsEnabled = false;
                    FechaR.IsEnabled = false;
                    break;

                case "error":
                    Globales.MessageBoxMitError(Globales.GetDataXml("nb_error", Globales.cpIntegracion_sResult));
                    cmdNuevo.Visibility        = Visibility.Hidden;
                    cmdEnviar.Visibility       = Visibility.Visible;
                    cmdRev.IsEnabled           = true;
                    this.BENVIAMAIL.Visibility = Visibility.Hidden;
                    this.BENVIAMAIL.Tag        = string.Empty;
                    break;

                default:
                    Globales.MessageBoxMitError("Verifique su conexión de Internet.");
                    cmdNuevo.Visibility        = Visibility.Hidden;
                    cmdEnviar.Visibility       = Visibility.Visible;
                    cmdRev.IsEnabled           = true;
                    this.BENVIAMAIL.Visibility = Visibility.Hidden;
                    this.BENVIAMAIL.Tag        = string.Empty;
                    break;
                }
            }
            Mouse.OverrideCursor = null;
            cmdEnviar.IsEnabled  = true;
        }
        private void CmdEnviar_Click(object sender, RoutedEventArgs e)
        {
            Globales.strNombreFP = NOMBRE_GENERAL + ".CmdEnviar_Click()";

            string mensaje = string.Empty;

            if (string.IsNullOrWhiteSpace(Importe.Text))
            {
                Globales.MessageBoxMit("Introduzca el importe.");
                Importe.Focus();
            }
            else
            {
                lblimportecheckin.Content = lblimportecheckin.Content.ToString().Replace(",", "");
                string importe = lblimportecheckin.Content.ToString();
                importe = importe.Replace("$", "");
                importe = importe.Trim();

                if (Convert.ToDouble(Importe.Text) > Convert.ToDouble(importe))
                {
                    double ImporteRA;
                    ImporteRA = Convert.ToDouble(Importe.Text) - Convert.ToDouble(lblimportecheckin.Content.ToString().Replace("$", "").Trim());

                    Globales.cpIntegracion_Clear();
                    Globales.cpIntegracion_sURL_cpINTEGRA = Globales.URL_DLL_RA;
                    CmdEnviar.IsEnabled = false;

                    Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                    Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
                    Globales.cpIntegraEMV.sndReautorizacionMOTO(TypeUsuario.usu,
                                                                TypeUsuario.Pass,
                                                                "",
                                                                TypeUsuario.Id_Company,
                                                                TypeUsuario.Id_Branch,
                                                                TypeUsuario.country,
                                                                ImporteRA.ToString(),
                                                                lblOperacion);
                    Globales.cpIntegracion_sResult = Globales.cpIntegraEMV.getRspXML();
                    Mouse.OverrideCursor           = null;
                    string caso = Globales.GetDataXml("response", Globales.cpIntegracion_sResult).ToLower();
                    switch (caso)
                    {
                    case "approved":
                        goto DoCheckout;
                        break;

                    default:

                        Globales.MessageBoxMit("No es posible realizar el checkout");
                        CmdEnviar.IsEnabled  = true;
                        CmdEnviar.Visibility = Visibility.Visible;
                        return;

                        break;
                    }
                }
                else
                {
                    goto DoCheckout;
                }

DoCheckout:
                CmdEnviar.IsEnabled = false;

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                string strTypeC = string.Empty;
                Globales.cpIntegracion_Clear();

                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                Globales.cpIntegraEMV.dbgSetUrl(Globales.URL_3GATE);
                Globales.cpIntegraEMV.sndCheckOutMOTO(TypeUsuario.usu,
                                                      TypeUsuario.Pass,
                                                      "",
                                                      TypeUsuario.Id_Company,
                                                      TypeUsuario.Id_Branch,
                                                      TypeUsuario.country,
                                                      Importe.Text,
                                                      this.lblOperacion);
                Globales.cpIntegracion_sResult = Globales.cpIntegraEMV.getRspXML();

                Mouse.OverrideCursor = null;
                string strCadEncriptar = string.Empty;

                string case2 = Globales.GetDataXml("response", Globales.cpIntegracion_sResult).ToLower();

                switch (case2)
                {
                case "approved":
                    Importe.IsEnabled = false;
                    mensaje           = Globales.GetDataXml("auth", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitApproved(mensaje);
                    TypeUsuario.strVoucherCoP = (Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult)).Trim();
                    TypeUsuario.strVoucherCoP = (Globales.GetDataXml("voucher", Globales.cpIntegracion_sResult)).Trim();


                    //'************************************************************************************************
                    //''********************************** FIRMA EN PANEL *********************************************
                    //'VALIDACIONES PARA LA FIRMA EN PANEL

                    //'Texto de marca de agua ceriroji
                    string textoAgua = string.Empty;
                    textoAgua  = "Folio: " + Globales.cpIntegraEMV.getRspOperationNumber() + "\n";
                    textoAgua += "Auth: " + Globales.cpIntegraEMV.getRspAuth() + "\n";
                    textoAgua += "Importe: " + Globales.cpIntegraEMV.getTx_Amount() + "\n";
                    textoAgua += "Fecha: " + Globales.cpIntegraEMV.getRspDate() + "\n";
                    textoAgua += "Merchant: " + Globales.cpIntegraEMV.getRspDsMerchant() + "\n";
                    textoAgua += " " + "\n";
                    textoAgua += "___________________" + "\n";
                    textoAgua += "FIRMA DIGITALIZADA:" + "\n";


                    //'************************************************************************************************
                    //'valida si la tarjeta es Chip and Pin
                    bool   IsChipAndPin, esQPS;
                    string cadenaHexFirma = string.Empty;
                    int    tipoVta;
                    IsChipAndPin = false;
                    esQPS        = false;
                    tipoVta      = 1;

                    //'valida si es chip and pin
                    if (Globales.cpIntegraEMV.chkCc_IsPin() == "01")
                    {
                        IsChipAndPin = true;
                    }

                    //'************************************************************************************************
                    //'valida si la venta es QPS
                    if (Globales.cpIntegraEMV.getRspVoucher().Contains("@cnn Autorizado sin Firma ") && tipoVta == 1 && !IsChipAndPin)
                    {
                        esQPS = true;
                    }

                    //'************************************************************************************************
                    //'Si la PinPad no soporta Firma en Panel y no es touch, sigue el flujo normal de PcPay
                    if (!Globales.cpIntegraEMV.EsTouch() && !Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                    {
                        goto GoImpresion;
                    }

                    //'************************************************************************************************
                    //'Si la PinPad Soporta Firma en Panel y no es touch,
                    if (!Globales.cpIntegraEMV.EsTouch() && Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                    {
                        // 'Llama a la función de obtener la firma en Panel
                        cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua, Globales.cpIntegraEMV.getRspVoucher(),
                                                                                    IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                        if (!cadenaHexFirma.Contains("Error"))
                        {
                            //'Llama a la funcion de Guardar la firma
                            if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                            {
                                imgEmailFirmaPanel.Visibility = Visibility.Visible;
                            }
                        }
                        else
                        {
                            Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad");
                        }
                        goto GoImpresion;
                    }

                    //'************************************************************************************************
                    //'SI EL DISPOSITIVO TIENE CAPACIDAD TOUCH
                    if (Globales.cpIntegraEMV.EsTouch())
                    {
                        if (TypeUsuario.UtilizarCapacidadTouch && TypeUsuario.EnviarVoucherMail)
                        {
                            if (!Globales.ObtieneFirmaPanel(Program.ipFirmaPanel, textoAgua, (short)tipoVta, IsChipAndPin, esQPS))
                            {
                                goto GoImpresion;
                            }
                            else
                            {
                                cmdVoucher.Visibility = Visibility.Visible;
                                cmdVoucher.IsEnabled  = false;
                                CmdEnviar.Visibility  = Visibility.Hidden;

                                goto finaliza;
                            }
                        }
                    }


                    if (TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                    {
                        //   'Llama a la función de obtener la firma en Panel
                        cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(true, textoAgua,
                                                                                    Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);

                        if (!cadenaHexFirma.Contains("Error"))
                        {
                            // 'Llama a la funcion de Guardar la firma
                            if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                            {
                                imgEmailFirmaPanel.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                            }

                            goto GoImpresion;
                        }
                    }
                    if (!TypeUsuario.UtilizarCapacidadTouch && !TypeUsuario.EnviarVoucherMail)
                    {
                        if (Globales.cpIntegraEMV.getRspSoportaFirmaPanel())
                        {
                            //  'Llama a la función de obtener la firma en Panel
                            cadenaHexFirma = Globales.cpIntegraEMV.sndObtieneFirmaPanel(false, textoAgua,
                                                                                        Globales.cpIntegraEMV.getRspVoucher(), IsChipAndPin, Globales.cpIntegraEMV.chkPp_Trademark(), (short)tipoVta, esQPS);
                            if (!cadenaHexFirma.Contains("Error"))
                            {
                                // 'Llama a la funcion de Guardar la firma
                                if (Globales.cpIntegraEMV.sndGuardaFirmaPanel(cadenaHexFirma, Program.ipFirmaPanel, Globales.cpIntegraEMV.getRspOperationNumber(), Globales.cpIntegraEMV.chkPp_Serial()))
                                {
                                    imgEmailFirmaPanel.Visibility = Visibility.Visible;
                                }
                                else
                                {
                                    Globales.MessageBoxMit("No se pudo obtener la imagen del PinPad" + "\n" + cadenaHexFirma);
                                }
                            }
                            goto GoImpresion;
                        }
                    }

                    //    '************************************************************************************************************
GoImpresion:

                    //  Select Case Mid(TypeUsuario.TipoImpresora, 1, 1)
                    cmdVoucher.IsEnabled = true;
                    CmdEnviar.Visibility = Visibility.Hidden;
                    escogerImpresora();

                    if (TypeUsuario.IsAQ)
                    {
                        //VerificaVoucher
                    }

                    CmdEnviar.Visibility  = Visibility.Hidden;
                    cmdVoucher.Visibility = Visibility.Visible;

finaliza:
                    //    'fin del case

                    //   '''*******************************FACTURA ELECTRONICA*********************************
                    Globales.cpIntegracion_sResult = Globales.cpIntegracion_sResult.Replace("<amount/>", "<amount>" + Importe.Text + "</amount>");
                    if (Globales.FacturaE == "1")
                    {
                        if (Globales.MessageConfirm("¿Desea factura electrónica?"))
                        {
                            frmPreguntaFactura fpf = new frmPreguntaFactura();
                            fpf.abrirFrmAhora = abrir;
                            fpf.cerraPage     = cierra;
                            abrir(fpf);
                        }
                        else
                        {
                            Globales.XMLFacturaE = "";
                        }
                    }
                    break;
                //    ''''***********************************************************************************



                case "denied":
                    Importe.IsEnabled = false;
                    mensaje           = " msjRech" + "\n" + Globales.GetDataXml("cd_response", Globales.cpIntegracion_sResult) + " " + Globales.GetDataXml("friendly_response", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitDenied(mensaje);
                    CmdEnviar.Visibility = Visibility.Hidden;
                    break;

                case "error":
                    mensaje = Globales.GetDataXml("nb_error", Globales.cpIntegracion_sResult);
                    Globales.MessageBoxMitError(mensaje);
                    CmdEnviar.Visibility = Visibility.Visible;
                    break;

                default:
                    mensaje = "Verifique su conexión de Internet.";
                    Globales.MessageBoxMitError(mensaje);
                    CmdEnviar.Visibility = Visibility.Visible;
                    Mouse.OverrideCursor = null;
                    CmdEnviar.IsEnabled  = true;
                    break;
                }
            }
        }