Beispiel #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (CustomerId != null)
         {
             hashCode = hashCode * 59 + CustomerId.GetHashCode();
         }
         if (ExpiryMonth != null)
         {
             hashCode = hashCode * 59 + ExpiryMonth.GetHashCode();
         }
         if (ExpiryYear != null)
         {
             hashCode = hashCode * 59 + ExpiryYear.GetHashCode();
         }
         if (BillingDetails != null)
         {
             hashCode = hashCode * 59 + BillingDetails.GetHashCode();
         }
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Last4 != null)
         {
             hashCode = hashCode * 59 + Last4.GetHashCode();
         }
         if (PaymentMethod != null)
         {
             hashCode = hashCode * 59 + PaymentMethod.GetHashCode();
         }
         if (Fingerprint != null)
         {
             hashCode = hashCode * 59 + Fingerprint.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (CvvCheck != null)
         {
             hashCode = hashCode * 59 + CvvCheck.GetHashCode();
         }
         if (AvsCheck != null)
         {
             hashCode = hashCode * 59 + AvsCheck.GetHashCode();
         }
         return(hashCode);
     }
 }
Beispiel #2
0
 internal IDictionary <string, string> ToDictionary()
 {
     return(new Dictionary <string, string>
     {
         { nameof(MerchantTransactionId), MerchantTransactionId },
         { nameof(Amount), Amount.ToString("F", CultureInfo.InvariantCulture) },
         { nameof(CardNumber), CardNumber },
         { nameof(ExpiryMonth), ExpiryMonth.ToString() },
         { nameof(ExpiryYear), ExpiryYear.ToString() },
         { nameof(Cvv), Cvv },
         { nameof(Currency), Currency }
     });
 }
 public PaymentEntityMasked ToPaymentEntityMasked()
 {
     return(new PaymentEntityMasked()
     {
         Id = Id,
         PaymentStatus = PaymentStatus,
         CardNumber = CardNumber.Mask(0, 12),
         ExpiryYear = ExpiryYear.ToStringMask(0, 4),
         ExpiryMonth = ExpiryMonth.ToString("D2").Mask(0, 2),
         Amount = Amount,
         CurrencyCode = CurrencyCode,
         CVV = CVV.ToStringMask(0, 3)
     });
 }
Beispiel #4
0
        }                                          //сумма в копейках


        #region IPacketContent implementation

        public IEnumerable <KeyValuePair <string, string> > GetProperties()
        {
            yield return(new KeyValuePair <string, string>("order_id", OrderId));

            yield return(new KeyValuePair <string, string>("card_number", CardNumber));

            yield return(new KeyValuePair <string, string>("expiry_month", ExpiryMonth.ToString()));

            yield return(new KeyValuePair <string, string>("expiry_year", ExpiryYear.ToString()));

            yield return(new KeyValuePair <string, string>("cvv", CVV));

            yield return(new KeyValuePair <string, string>("cardholder_name", CardHolderName));

            yield return(new KeyValuePair <string, string>("amount_kop", AmountKop.ToString()));
        }
Beispiel #5
0
        public NuevaTarjeta(TipoAnadidor tipo, TarjetasViewModel _t, RecargasViewModel _r)
        {
            try
            {
                InitializeComponent();
                Title = "Nueva tarjeta";
                ToolbarItems.Add(new ToolbarItem("Ayuda", "ayuda2.png", () =>
                {
                    var page = new InfoAyuda("nuevat.html");
                    Navigation.PushPopupAsync(page);
                }));
#if __IOS__
                grdScanner.IsVisible = false;
#endif

                tvm = _t;
                rvm = _r;
                this.BindingContext = tvm;
                Refresh();
                tvm.Idusuario = App.usr.idusuario;
                if (App.usr.idpais != 0)
                {
                    tvm.idpais = App.usr.idpais;
                }
                txtNum.Completed       += (s, e) => txtMes.Focus();
                txtMes.Completed       += (s, e) => txtAno.Focus();
                txtAno.Completed       += (s, e) => txtCvc.Focus();
                txtCvc.Completed       += (s, e) => txtTitularFN.Focus();
                txtTitularFN.Completed += (s, e) => txtTitularLN.Focus();
                txtTitularLN.Completed += (s, e) => txtCalleNum.Focus();
                txtCalleNum.Completed  += (s, e) => txtCP.Focus();

                tvm.TarjetaIncompleta += (s, e) =>
                {
                    if (e.estaincompleta)
                    {
                        if (tvm.idpais == 0 || tvm.IdEstado == 0 || tvm.IdCiudad == 0)
                        {
                            lblvalGeo.IsVisible = true;
                        }
                        else
                        {
                            lblvalGeo.IsVisible = false;
                        }
                        btnGuardar.IsEnabled = false;
                    }
                    else
                    {
                        lblvalGeo.IsVisible  = false;
                        btnGuardar.IsEnabled = true;
                    }
                };

                txtNum.TextChanged += (sender, e) =>
                {
                    if (!String.IsNullOrEmpty(txtNum.Text))
                    {
                        if (cardval.IsValid)
                        {
                            CreditCardDetector det = new CreditCardDetector(txtNum.Text);
                            tvm.idemisor         = SetEmisor(det.Brand);
                            tvm.NumeroTarjeta    = txtNum.Text;
                            lblvalCard.IsVisible = false;                             //.Text = "";
                        }
                        else
                        {
                            CreditCardDetector det = new CreditCardDetector(txtNum.Text);
                            tvm.idemisor         = SetEmisor(det.Brand);
                            tvm.NumeroTarjeta    = "";
                            lblvalCard.IsVisible = true;                             //.Text = "El numero de tarjeta es obligatorio, y tal cual aparece en la tarjeta";
                        }
                    }
                };
                txtMes.TextChanged       += Valfecha;
                txtAno.TextChanged       += Valfecha;
                txtCvc.TextChanged       += Valfecha;
                txtTitularFN.TextChanged += (s, e) =>
                {
                    if (valTitulFN.IsValid)
                    {
                        lblvalTitular.IsVisible = false;                         //.Text = "";
                        tvm.TitularFN           = CleanString.UseRegex(txtTitularFN.Text);
                    }
                    else
                    {
                        lblvalTitular.IsVisible = true;                         //.Text = "El nombre del titular es obligatorio y tal cual aparece en la tarjeta";
                        tvm.TitularFN           = "";
                    }
                };
                txtTitularLN.TextChanged += (s, e) =>
                {
                    if (valTitulLN.IsValid)
                    {
                        lblvalTitular.IsVisible = false;                         //.Text = "";
                        tvm.TitularLN           = CleanString.UseRegex(txtTitularLN.Text);
                    }
                    else
                    {
                        lblvalTitular.IsVisible = true;                         //.Text = "El nombre del titular es obligatorio y tal cual aparece en la tarjeta";
                        tvm.TitularLN           = "";
                    }
                };
                txtCalleNum.TextChanged += (s, e) =>
                {
                    if (valCalle.IsValid)
                    {
                        lblvalCalle.IsVisible = false;                         //.Text = "";
                        tvm.CalleyNum         = CleanString.UseRegex(txtCalleNum.Text);
                    }
                    else
                    {
                        lblvalCalle.IsVisible = true;                         //.Text = "El nombre del titular es obligatorio y tal cual aparece en la tarjeta";
                        tvm.CalleyNum         = "";
                    }
                };
                txtCP.TextChanged += (s, e) =>
                {
                    if (cpval.IsValid)
                    {
                        lblvalCP.IsVisible = false;                         //.Text = "";
                        tvm.CP             = check.SafeSqlLiteral(txtCP.Text);
                    }
                    else
                    {
                        lblvalCP.IsVisible = true;                         //.Text = "El nombre del titular es obligatorio y tal cual aparece en la tarjeta";
                        tvm.CP             = "";
                    }
                };

                string title = ""; ListaOpciones lo;
                //grdPais.Tapped += async (object sender, EventArgs e) =>
                TapGestureRecognizer tapgrdPais = new TapGestureRecognizer();
                tapgrdPais.Tapped += async(s, e) =>
                {
                    grdPais.BackgroundColor = Color.FromHex("#e5e5e5");                     //Color.FromHex((App.Current.Resources["ButtonRojo"] as Style).Setters.Where(x => x.Property == BackgroundColorProperty).FirstOrDefault().Value.ToString()); //.Opacity = .5;
                    await Task.Delay(100);

                    grdPais.BackgroundColor = Color.Transparent;                     //grdEstado.Opacity = 1;
                    ls.Clear();
                    title = "Seleccione un país";
                    ls    = tvm.lsPais().Select(x => new Opcion {
                        idopc = x.idpais, opc = x.pais, imgopc = x.img
                    }).ToObservableCollection();
                    lo       = new ListaOpciones(ls, title, 2);
                    lo.IdOpc = 1;
                    await App.Nav.PushAsync(lo, Constantes.animated);
                };
                grdPais.GestureRecognizers.Add(tapgrdPais);

                TapGestureRecognizer tapgrdTipo = new TapGestureRecognizer();
                tapgrdTipo.Tapped += async(s, e) =>
                                                                        //grdTipo.Tapped += async (object sender, EventArgs e) =>
                {
                    grdTipo.BackgroundColor = Color.FromHex("#e5e5e5"); //Color.FromHex((App.Current.Resources["ButtonRojo"] as Style).Setters.Where(x => x.Property == BackgroundColorProperty).FirstOrDefault().Value.ToString()); //.Opacity = .5;
                    await Task.Delay(100);

                    grdTipo.BackgroundColor = Color.Transparent;                     //grdEstado.Opacity = 1;
                    ls.Clear();
                    title = "Seleccione emisor";
                    ls    = tvm.LsEmisores().Select(x => new Opcion {
                        idopc = x.idemisor, opc = x.emisor, imgopc = x.img
                    }).ToObservableCollection();
                    lo       = new ListaOpciones(ls, title, 2);
                    lo.IdOpc = 2;
                    await App.Nav.PushAsync(lo, Constantes.animated);
                };
                grdTipo.GestureRecognizers.Add(tapgrdTipo);

                TapGestureRecognizer tapgrdScanner = new TapGestureRecognizer();
                tapgrdScanner.Tapped += async(s, e) =>
                                                                           //vclScanner.Tapped += (s, e) =>
                {
                    grdScanner.BackgroundColor = Color.FromHex("#e5e5e5"); //Color.FromHex((App.Current.Resources["ButtonRojo"] as Style).Setters.Where(x => x.Property == BackgroundColorProperty).FirstOrDefault().Value.ToString()); //.Opacity = .5;
                    await Task.Delay(100);

                    grdScanner.BackgroundColor = Color.Transparent;                     //grdEstado.Opacity = 1;
#if __ANDROID__
                    var plataforma = DependencyService.Get <ICardReader>();
                    if (plataforma != null)
                    {
                        plataforma.CardFound = delegate(string FormattedCardNumber, int ExpiryMonth, int ExpiryYear, string CardholderName, Card.IO.CardType CardType)
                        {
                            txtNum.Text = FormattedCardNumber;
                            //txtTitular.Text = CardholderName;
                            txtMes.Text = (ExpiryMonth > 0 ? ExpiryMonth.ToString() : "");
                            if (ExpiryYear > 0)
                            {
                                if (ExpiryYear.ToString().Length > 2)
                                {
                                    txtAno.Text = ExpiryYear.ToString().Substring(2, 2);
                                }
                                else
                                {
                                    txtAno.Text = ExpiryYear.ToString();
                                }
                            }
                            else
                            {
                                txtAno.Text = "";
                            }
                        };
                        plataforma.ReadCard();
                    }
#endif
#if __IOS__
                    //var plataforma = DependencyService.Get<ICardReader>();
                    //if (plataforma != null)
                    //{
                    //	plataforma.CardFound = delegate (string FormattedCardNumber, int ExpiryMonth, int ExpiryYear, string CardholderName, Card.IO.CreditCardType CardType)
                    //	{
                    //		txtNum.Text = FormattedCardNumber;
                    //		//txtTitular.Text = CardholderName;
                    //		txtMes.Text = (ExpiryMonth > 0 ? ExpiryMonth.ToString() : "");
                    //		if (ExpiryYear > 0)
                    //		{
                    //			if (ExpiryYear.ToString().Length > 2)
                    //				txtAno.Text = ExpiryYear.ToString().Substring(2, 2);
                    //			else
                    //				txtAno.Text = ExpiryYear.ToString();
                    //		}
                    //		else
                    //			txtAno.Text = "";
                    //	};
                    //	plataforma.ReadCard();
                    //}
#endif
                };
                grdScanner.GestureRecognizers.Add(tapgrdScanner);

                TapGestureRecognizer tapgrdEstado = new TapGestureRecognizer();
                tapgrdEstado.Tapped += async(s, e) =>
                                                                          //grdEstado.Tapped += async (object sender, EventArgs e) =>
                {
                    grdEstado.BackgroundColor = Color.FromHex("#e5e5e5"); //Color.FromHex((App.Current.Resources["ButtonRojo"] as Style).Setters.Where(x => x.Property == BackgroundColorProperty).FirstOrDefault().Value.ToString()); //.Opacity = .5;
                    await Task.Delay(100);

                    grdEstado.BackgroundColor = Color.Transparent;                     //grdEstado.Opacity = 1;
                    ls.Clear();
                    title = "Seleccione estado";
                    ls    = tvm.lsEstados(tvm.idpais).Select(x => new Opcion {
                        idopc = x.idestado, opc = x.estado,
                    }).ToObservableCollection();
                    lo       = new ListaOpciones(ls, title, 2);
                    lo.IdOpc = 3;
                    await App.Nav.PushAsync(lo, Constantes.animated);
                };
                grdEstado.GestureRecognizers.Add(tapgrdEstado);

                TapGestureRecognizer tapgrdCiudad = new TapGestureRecognizer();
                tapgrdCiudad.Tapped += async(s, e) =>
                                       //btnCiudad.Clicked += async (s,e) =>
                                       //vclCiudad.Tapped += async (s, e) =>
                {
                    grdCiudad.BackgroundColor = Color.FromHex("#e5e5e5");
                    await Task.Delay(100);

                    grdCiudad.BackgroundColor = Color.Transparent;                     //grdEstado.Opacity = 1;
                    ls.Clear();
                    title = "Seleccione ciudad";
                    ls    = tvm.lsMunicipios(tvm.IdEstado).OrderBy(x => x.municipio).Select(x => new Opcion {
                        idopc = x.idmunicipio, opc = x.municipio,
                    }).ToObservableCollection();
                    lo       = new ListaOpciones(ls, title, 2);
                    lo.IdOpc = 4;
                    await App.Nav.PushAsync(lo, Constantes.animated);
                };
                grdCiudad.GestureRecognizers.Add(tapgrdCiudad);

                btnGuardar.Clicked += async(sender, e) =>
                {
                    if (tvm.EsIncompleta())
                    {
                        await DisplayAlert("Error", "Faltan capturar o seleccionar algunos campos", "OK");
                    }
                    else
                    {
                        if (txtAno.Text.Trim().Length < 2 || txtMes.Text.Trim().Length < 2)
                        {
                            await DisplayAlert("Error", "Revise mes y año de expiración", "OK");
                        }
                        else
                        {
                            int mm = int.Parse(txtMes.Text.Trim());
                            int yy = int.Parse(txtAno.Text.Trim());
                            if (mm < 1 || mm > 12 || yy < DateTime.Now.Year - 2000)
                            {
                                await DisplayAlert("Error", "Revise mes y año de expiración", "OK");
                            }
                            else
                            {
                                if (App.usr == null || (App.usr != null && (App.usr.email == null || App.usr.idusuario == 0)))
                                {
                                    var login = new Login(App.Current);
                                    await App.Nav.PushAsync(login, Constantes.animated);
                                }
                                else
                                {
                                    btnGuardar.IsEnabled = false;
                                    //tvm.TarjetaAlta += async (s, ea) =>
                                    //{
                                    //	UserDialogs.Instance.HideLoading();
                                    //	if (ea.Error != null || ea.Cancelled)
                                    //		await DisplayAlert("Error", "Ocurrio un error, vuelva a intentar", "OK");
                                    //	else
                                    //		await App.Nav.PopAsync(Constantes.animated);
                                    //};
                                    //UserDialogs.Instance.ShowLoading("Guardando...");
                                    //tvm.Alta();
                                    rvm.idFormaPago = 2;                                     //tarjeta
                                    rvm.TipoTrans   = TipoTransaccion.PrimeraVez;
                                    rvm.IdTarjeta   = 0;
                                    Procesar pro = App.Nav.NavigationStack.OfType <Procesar>().FirstOrDefault();
                                    if (pro == null)
                                    {
                                        await App.Nav.PushAsync(new Procesar(rvm, tvm, TipoTransaccion.PrimeraVez), Constantes.animated);
                                    }
                                    else
                                    {
                                        pro.Refresh(rvm, tvm, TipoTransaccion.PrimeraVez);
                                        await App.Nav.PopAsync(Constantes.animated);                                         //boto nueva tarjeta (this)

                                        await App.Nav.PopAsync(Constantes.animated);                                         //boto medios pago
                                    }
                                }
                            }
                        }
                    }
                };
                tvm.ChecaIncompleta();
            }
            catch (Exception e)
            {
            }
        }
Beispiel #6
0
        /// <summary>
        /// Returns true if Card instances are equal
        /// </summary>
        /// <param name="other">Instance of Card to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(CardSource other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     CustomerId == other.CustomerId ||
                     CustomerId != null &&
                     CustomerId.Equals(other.CustomerId)
                     ) &&
                 (
                     ExpiryMonth == other.ExpiryMonth ||
                     ExpiryMonth != null &&
                     ExpiryMonth.Equals(other.ExpiryMonth)
                 ) &&
                 (
                     ExpiryYear == other.ExpiryYear ||
                     ExpiryYear != null &&
                     ExpiryYear.Equals(other.ExpiryYear)
                 ) &&
                 (
                     BillingDetails == other.BillingDetails ||
                     BillingDetails != null &&
                     BillingDetails.Equals(other.BillingDetails)
                 ) &&
                 (
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                 ) &&
                 (
                     Last4 == other.Last4 ||
                     Last4 != null &&
                     Last4.Equals(other.Last4)
                 ) &&
                 (
                     PaymentMethod == other.PaymentMethod ||
                     PaymentMethod != null &&
                     PaymentMethod.Equals(other.PaymentMethod)
                 ) &&
                 (
                     Fingerprint == other.Fingerprint ||
                     Fingerprint != null &&
                     Fingerprint.Equals(other.Fingerprint)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     CvvCheck == other.CvvCheck ||
                     CvvCheck != null &&
                     CvvCheck.Equals(other.CvvCheck)
                 ) &&
                 (
                     AvsCheck == other.AvsCheck ||
                     AvsCheck != null &&
                     AvsCheck.Equals(other.AvsCheck)
                 ));
        }