Ejemplo n.º 1
0
        public void RegisterMembership(string nameImages)
        {
            BrPayments       brPayments = new BrPayments();
            BrUser           brUser     = new BrUser();
            BrTypeMembership brTypeMemb = new BrTypeMembership();

            string[] dataLogin = HttpContext.Current.User.Identity.Name.Split('¬');
            string   userName  = dataLogin[0];

            if (dataLogin.Length > 1)
            {
                userName = dataLogin[1];
            }
            string dataBdd = Session["datos"].ToString();

            string[] acarrito       = Session["carrito"].ToString().Split('|');
            string   TypeMembership = acarrito[6];

            string cronograma = Session["cronograma"].ToString();
            //string respData = brPayments.PersonGetData(userName);
            string respData = "";

            respData = respData + '^' + cronograma;

            double amountFinanciade = 0;

            string[] array1     = Session["cronogramaYa"].ToString().Split('^');
            string[] datosMem   = array1[0].Split('|');
            string[] array2     = array1[1].Split('~');
            string[] cuotas     = array2[0].Split('¬');
            string   cronoActiv = "";

            for (int i = 0; i < cuotas.Length - 1; i++)
            {
                var fila = cuotas[i].Split('|');
                if (fila[0].Substring(0, 7) != "Inicial")
                {
                    cronoActiv      += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd");
                    amountFinanciade = double.Parse(fila[2].Replace("S/.", ""));
                    break;
                }
                else
                {
                    cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd") + "¬";
                }
            }
            string codeCurrency = Session["TypeCurrency"].ToString();

            int ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + userName, amountFinanciade.ToString(), Int32.Parse(Session["membPred"].ToString()), codeCurrency);

            bool isRegister = false;

            if (Session["codeUpgrate"] != null)
            {
                //si es upgrate
                string exchange = Session["carrito"].ToString().Split('|')[4];
                //ultParametroSinCalculoDePuntaje
                isRegister = brPayments.GetCalculatePaymentScheduleUpgrate(respData, userName, ansNmembershi, exchange, 0);
                if (!isRegister)
                {
                    // Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                    return;
                }
                if (Session["dateup"] != null)
                {
                    string dateup = Session["dateup"].ToString();
                    bool   an     = brPayments.PutDateUpgrate(ansNmembershi, dateup);
                }
            }
            else
            {
                //si no es upgrate
                string exchange = Session["carrito"].ToString().Split('|')[4];
                isRegister = brPayments.GetCalculatePaymentSchedule(respData, userName, ansNmembershi, exchange, 0);
                if (!isRegister)
                {
                    //Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                    return;
                }
                BrActivation brActivation = new BrActivation();
                bool         registerActi = brActivation.PutCronograma(cronoActiv, userName, ansNmembershi);
            }

            if (Session["codeUpgrate"] != null)
            {
                int  codeUpgrate = int.Parse(Session["codeUpgrate"].ToString());
                bool upgrate     = brTypeMemb.CancelMembershipUpgrate(codeUpgrate, ansNmembershi);
                if (!upgrate)
                {
                    //  Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                    return;
                }
                BrActivation brActivation  = new BrActivation();
                string       fechaAnterior = Session["fechaanterior"].ToString();
                bool         registerActi  = brActivation.PutCronogramaUpgrade(fechaAnterior, userName, ansNmembershi, codeUpgrate);

                //cambia el estado de la cuota upgrate y si el segundo parametro es 1 paga la primera cuota
                BrMembershipPayDetail brMembershipPayDetail = new BrMembershipPayDetail();
                isRegister = brMembershipPayDetail.UpgrateStatusPaymentInitial(ansNmembershi, 0, "upgrade.png");
            }

            if (nameImages != null)
            {
                bool upload = brPayments.UploadReceiptUpgradeCerooInitial(ansNmembershi.ToString() + '|' + nameImages);
            }

            if (!isRegister)
            {
                //Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                return;
            }

            brPayments = null;
            brUser     = null;
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string token        = string.Empty;
                string currencyCode = string.Empty;
                int    numberQuotes = 0;

                token        = Request["tokenid"];
                numberQuotes = int.Parse(Request["ddlQuote"]);
                currencyCode = Request["ddlcurrencyCode"];

                if (currencyCode != "USD" && currencyCode != "PEN")
                {
                    Response.Write("false¬ocurrio un error.");
                    return;
                }

                string[] dataLogin   = HttpContext.Current.User.Identity.Name.Split('¬');
                string   userCurrent = dataLogin[0];

                if (dataLogin.Length > 1)
                {
                    userCurrent = dataLogin[1];
                }

                BrUser brUser = new BrUser();

                var arraycar   = Session["carrito"].ToString().Split('|');
                var tipocambio = double.Parse(arraycar[4]);

                string dataBdd        = Session["datos"].ToString();
                var    TypeMembership = (dataBdd.Split('$')[3]).Split('|')[7];
                // string data2 = (string)Session["civilStatus"];
                string   data2 = (string)Session["civilState"];
                string[] oIdMembreship_amount = brUser.RegisterUser(dataBdd, data2).Split('¬');

                if (oIdMembreship_amount.Length < 2)
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                    return;
                }

                string[] parameterPerson  = dataBdd.Split('$');
                string[] arraydata        = parameterPerson[0].Split('|');
                string[] arrayTypeaccount = parameterPerson[2].Split('|');
                string[] arrayaccount     = parameterPerson[3].Split('|');

                string parameterAccount = arraydata[5].Trim() + "|" + arrayTypeaccount[7].Trim() + '|' + userCurrent + '|' + oIdMembreship_amount[0];
                //'999999999999|1|sa|1'
                var newUserName = brUser.GenerateAccount(parameterAccount);

                if (string.IsNullOrEmpty(newUserName))
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                    return;
                }

                var dataKitMember = Session["cronograma"].ToString();

                string[] datos = Session["datos"].ToString().Split('$');

                if (Session["datos"] == null)
                {
                    Response.Write("false¬Ha Ocurrido Un Error, no hay datos.");
                    return;
                }
                string[] arraycontacto = datos[3].Split('|');
                string[] arrayperson   = datos[0].Split('|');

                var amountPay = double.Parse(Session["FirtsPay"].ToString());


                if (amountPay <= 0)
                {
                    Response.Write("false¬Ha Ocurrido Un Error id idMemberDetails vacio,amountPay vacio");
                    return;
                }

                //amount pay es un valor en soles
                if (currencyCode == "USD")
                {
                    amountPay = amountPay / tipocambio;
                }

                string dni = arrayperson[5];

                newUserName = arrayperson[0].Substring(0, 1).ToUpper() + arrayperson[1].Substring(0, 1).ToUpper() + dni;
                var emailNewUser = arraycontacto[0].Trim();


                PayCulqi   payCulqi   = new PayCulqi();
                MyMessages myMessages = new MyMessages();
                //string currencyCode = "PEN";
                string[] culqiAnwser = payCulqi.newPayment(newUserName, emailNewUser, amountPay, token, numberQuotes, currencyCode).Split('¬');
                if (culqiAnwser[0] == "false")
                {
                    Response.Write("false¬" + culqiAnwser[1]);
                    return;
                }

                /*=====================================================================================================================================================================*/

                //correo = arraycontacto[0];
                var namePeson = arrayperson[0] + " " + arrayperson[1];


                string date = dataKitMember.Split('$')[1];

                string[] array1          = Session["cronogramaYa"].ToString().Split('^');
                string[] datosMem        = array1[0].Split('|');
                string[] array2          = array1[1].Split('~');
                string[] cuotas          = array2[0].Split('¬');
                string   cronoActiv      = "";
                var      quotesPendiente = (cuotas.Length - 2).ToString();
                for (int i = 0; i < cuotas.Length - 1; i++)
                {
                    var fila = cuotas[i].Split('|');
                    if (fila[0].Substring(0, 7) != "Inicial")
                    {
                        cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd");
                        //amountFinanciade = double.Parse(fila[2].Replace("S/.", ""));
                        break;
                    }
                    else
                    {
                        cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd") + "¬";
                    }
                }

                BrPayments brPayments = new BrPayments();

                string respData = brPayments.PersonGetData(newUserName);
                respData = respData + '^' + dataKitMember;
                // isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName);
                string financedAmount = Session["financedAmount"].ToString();
                string codeCurrency   = Session["TypeCurrency"].ToString();

                Int32  ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, financedAmount, 1, codeCurrency);
                string exchange      = Session["carrito"].ToString().Split('|')[4];
                var    isRegister    = brPayments.GetCalculatePaymentSchedule(respData, newUserName, ansNmembershi, exchange, 1);

                //validamos si tiene consumo


                if (!isRegister)
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                    return;
                }

                BrActivation brActivation = new BrActivation();
                bool         registerActi = brActivation.PutCronograma(cronoActiv, newUserName, ansNmembershi);

                //obtengo el monto a pagar

                string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                if (username_idmen_amount_email.Length < 4)
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                    return;
                }
                var idMemberDetails = int.Parse(username_idmen_amount_email[1]);
                amountPay    = double.Parse(username_idmen_amount_email[2]);
                emailNewUser = username_idmen_amount_email[3];

                date = null;
                username_idmen_amount_email = null;
                dataKitMember = null;
                respData      = null;


                /*=============================================================================================================================*/

                var dateCurrent = DateTime.Now.ToString("yyyy-MM-dd").Split('-');;

                string tranferId    = culqiAnwser[2] == null ? "" : culqiAnwser[2];
                string numReceipt   = "0";
                string datecomplete = dateCurrent[2] + " de " + GetMonth(dateCurrent[1]) + " del " + dateCurrent[0];
                string nAffiliate   = "";

                string hour    = DateTime.Now.ToString("HH:mm:ss");
                string detalle = amountPay.ToString();


                //cvbc
                string nameTicket = GetRecibo(tranferId, newUserName, numReceipt, datecomplete, nAffiliate, TypeMembership, namePeson, hour, detalle, quotesPendiente, " Inicial 1");


                //marcar como pagado en la tabla membershipdetails
                bool habiliAccount = brUser.enableAcount(idMemberDetails, nameTicket);

                int nAfiliate = int.Parse(brUser.GetNafiliate(idMemberDetails));

                Cronograma2(nAfiliate, currencyCode);

                // enviar el email de confirmacion con la data y lo redirecciona al post register
                if (!habiliAccount)
                {
                    Response.Write("false¬Ha Ocurrido un Error al Intentar Habilitar Su Cuenta.Sin embargo su Pago fue Exitoso");
                    return;
                }


                string ruta = HttpContext.Current.Server.MapPath("~/Resources/PoliticsPdf/");
                //enviar email con los documentos
                //bool awnserEmailDoc = oEmail.SubmitEmailKit(emailNewUser, "[RIBERA DEL RIO - BIENVENIDO]", myMessages.DocumentosRegister(newUserName), true, ruta);

                Email oemail         = new Email();
                bool  awnserEmailDoc = oemail.SubmitEmail(emailNewUser, "[RIBERA DEL RIO - BIENVENIDO]", myMessages.DocumentosRegister(newUserName), true, ruta, newUserName);
                bool  awnserEmail    = oemail.SubmitEmail(emailNewUser, "[RIBERA DEL RIO - PAGO]", myMessages.EmailPago());

                //ejecutamos el core para los puntos de equipo
                // BrCore_Automation brCore_Automation = new BrCore_Automation();
                //bool isCoreRegister = brCore_Automation.ExecuteCore();

                Response.Write("true¬" + culqiAnwser[1]);
            }
            catch (Exception ex)
            {
                Response.Write("false¬ocurrio un error¬" + ex.Message);
            }
        }
Ejemplo n.º 3
0
        public void registerTodo(int metodo)
        {
            brUser = new BrUser();
            int typeRegister = 0;

            typeRegister = int.Parse(Session["typeRegister"].ToString());
            //REGISTER
            string[] dataLogin   = HttpContext.Current.User.Identity.Name.Split('¬');
            string   userCurrent = dataLogin[0];

            if (dataLogin.Length > 1)
            {
                userCurrent = dataLogin[1];
            }
            string dataBdd        = Session["datos"].ToString();
            string TypeMembership = (dataBdd.Split('$')[3]).Split('|')[7];
            string data2          = (string)Session["civilState"];

            string[] oIdMembreship_amount = brUser.RegisterUser(dataBdd, data2).Split('¬');

            if (oIdMembreship_amount.Length < 2)
            {
                //  Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                Response.Redirect("Pagos.aspx");
                return;
            }

            string[] parameterPerson  = dataBdd.Split('$');
            string[] arraydata        = parameterPerson[0].Split('|');
            string[] arrayTypeaccount = parameterPerson[2].Split('|');
            string[] arrayaccount     = parameterPerson[3].Split('|');

            string parameterAccount = arraydata[5].Trim() + "|" + arrayTypeaccount[7].Trim() + '|' + userCurrent + '|' + oIdMembreship_amount[0];

            //'999999999999|1|sa|1'
            newUserName = brUser.GenerateAccount(parameterAccount);
            bool ans = brUser.ActivateAccount(newUserName);

            // bool notAvilable = brUser.NotAvailableUser(newUserName);
            if (string.IsNullOrEmpty(newUserName))
            {
                //Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                Response.Redirect("Pagos.aspx");
                return;
            }

            //END REGISTER
            if (typeRegister == 1)
            {
                string arrayKit = Session["arrayKit"].ToString() + "¬" + newUserName;
                //'2018-10-19¬31¬31¬31¬userName'
                string data3        = Session["financedAmount"].ToString();
                string codeCurrency = Session["TypeCurrency"].ToString();

                Int32 ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, data3, 1, codeCurrency);
                bool  isRegister    = brUser.PutRegisterkIT(arrayKit, ansNmembershi);
                if (lblSubTotal.Text == "S/0")
                {
                    bool payInitial = brUser.PayInitial(newUserName);
                }
                //monto a pagar
                string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                if (username_idmen_amount_email.Length < 4)
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                    return;
                }
                /*subidaDeRecibo con newUserName*/
                BrPayments brPayments = new BrPayments();
                // bool upload = brPayments.UploadReceipt(newUserName + '|' + nombreArchivo);

                int    idMemberDetails = int.Parse(username_idmen_amount_email[1]);
                double amountPay       = double.Parse(username_idmen_amount_email[2]);
                string emailNewUser    = username_idmen_amount_email[3];
                username_idmen_amount_email = null;
            }

            if (typeRegister == 2)
            {
                string dataKitMember = Session["cronograma"].ToString();

                string     date       = dataKitMember.Split('$')[1];
                BrPayments brPayments = new BrPayments();
                string     respData   = brPayments.PersonGetData(newUserName);
                respData = respData + '^' + dataKitMember;
                brUser   = new BrUser()
                ; //  bool ansNmembershi = brUser.RegisterNmembership(respData+'|'+ newUserName);
                string data3        = Session["financedAmount"].ToString();
                string codeCurrency = Session["TypeCurrency"].ToString();

                Int32  ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, data3, 1, codeCurrency);
                string exchange      = Session["carrito"].ToString().Split('|')[4];
                bool   isRegister    = brPayments.GetCalculatePaymentSchedule(respData, newUserName, ansNmembershi, exchange, 0);
                if (lblSubTotal.Text == "S/0")
                {
                    bool payInitial = brUser.PayInitial(newUserName);
                }
                /*subidaDeRecibo con newUserName*/
                //  bool upload = brPayments.UploadReceipt(newUserName + '|' + nombreArchivo);

                //validamos si tiene consumo


                if (!isRegister)
                {
                    // Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                    Response.Redirect("Pagos.aspx");
                    return;
                }
                //obtengo el monto a pagar
                string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                if (username_idmen_amount_email.Length < 4)
                {
                    //  Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                    Response.Redirect("Pagos.aspx");
                    return;
                }
                //idMemberDetails = int.Parse(username_idmen_amount_email[1]);
                //amountPay = double.Parse(username_idmen_amount_email[2]);
                //emailNewUser = username_idmen_amount_email[3];
                date = null;
                username_idmen_amount_email = null;
                dataKitMember = null;
                respData      = null;
            }
            //si se efectuo el envio
            //Response.Redirect("EndPayments3.aspx",true);
            return;
            /*TRY MERGE*/
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MyConstants mc = new MyConstants();

            try
            {
                string token        = "";
                int    numberQuotes = 0;

                token        = Request["token"].ToString();
                numberQuotes = int.Parse(Request["numcuotes"].ToString());

                //pagar con wallet
                BrWallet brWallet      = new BrWallet();
                var      amountWalletc = decimal.Parse(brWallet.GetAmount(User.Identity.Name.Split('¬')[1]));

                var amountTotal = 0m;

                if (Session["MontoWallet"] != null)
                {
                    amountTotal = decimal.Parse(Session["MontoWallet"].ToString());
                }


                var amountRestan = amountTotal - amountWalletc;

                //if (amountWalletc < quota)
                //{
                //    MessageError.Text = "No tiene el monto suficiente para realizar Pago.";
                //    return;
                //}

                var methods2 = "CULQI";

                var recibe = string.Empty;



                BrPayments brPayments    = new BrPayments();
                BrUser     brUser        = new BrUser();
                string     dataKitMember = Session["cronograma"].ToString();


                string date = dataKitMember.Split('$')[1];

                var cart = Session["carrito"].ToString();

                var arrayCart = cart.Split('|');
                var codeMemb  = arrayCart[6];

                string[] datos   = Session["datos"].ToString().Split('$');
                var      dataBdd = Session["datos"].ToString();



                if (Session["datos"] == null)
                {
                    Response.Write("false¬Ha Ocurrido Un Error, no hay datos.");
                    return;
                }
                string[] arraycontacto = datos[3].Split('|');
                string[] arrayperson   = datos[0].Split('|');


                string dni = arrayperson[5];

                var newUserName     = User.Identity.Name.Split('¬')[1];
                var emailNewUser    = arraycontacto[0].Trim();
                var codeCurrencyPay = Session["TypeCurrency"].ToString();



                string[] array1          = Session["cronogramaYa"].ToString().Split('^');
                string[] datosMem        = array1[0].Split('|');
                string[] array2          = array1[1].Split('~');
                string[] cuotas          = array2[0].Split('¬');
                string   cronoActiv      = "";
                var      quotesPendiente = (cuotas.Length - 2).ToString();
                for (int i = 0; i < cuotas.Length - 1; i++)
                {
                    var fila = cuotas[i].Split('|');
                    if (fila[0].Substring(0, 7) != "Inicial")
                    {
                        cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd");
                        //amountFinanciade = double.Parse(fila[2].Replace("S/.", ""));
                        break;
                    }
                    else
                    {
                        cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd") + "¬";
                    }
                }

                var respDataper = brPayments.PersonGetData(newUserName);

                string respData = string.Empty;
                respData = respData + '^' + dataKitMember;

                // isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName);
                //string data2 = Session["financedAmount"].ToString();

                string data2 = "0";
                //string codeCurrency = Session["TypeCurrency"].ToString();



                var currencyCode = Session[""].ToString();

                PayCulqi payCulqi = new PayCulqi();

                string[] culqiAnwser = payCulqi.newPayment(newUserName, emailNewUser, double.Parse(amountRestan.ToString()), token, numberQuotes, codeCurrencyPay).Split('¬');
                if (culqiAnwser[0] == "false")
                {
                    Response.Write("false¬" + culqiAnwser[1]);
                    return;
                }


                Int32 ansNmembershi = brUser.RegisterNmembership(codeMemb + '|' + newUserName, data2, 1, codeCurrencyPay);

                BrTypeMembership brTypeMemb = new BrTypeMembership();
                string           typeChange = arrayCart[4];

                //var isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName, ansNmembershi, typeChange, 1);
                bool isRegister = false;
                if (Session["codeUpgrate"] != null)
                {
                    //si es upgrate

                    isRegister = brPayments.GetCalculatePaymentScheduleUpgrate(respData, newUserName, ansNmembershi, typeChange, 1);
                    if (!isRegister)
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                        return;
                    }

                    if (Session["dateup"] != null)
                    {
                        string dateup = Session["dateup"].ToString();
                        bool   an     = brPayments.PutDateUpgrate(ansNmembershi, dateup);
                    }

                    //registramos si upgrate para
                }
                else
                {
                    //si no es upgrate

                    isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName, ansNmembershi, typeChange, 1);
                    if (!isRegister)
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                        return;
                    }
                    //cronograma de activacion
                    BrActivation brActivation = new BrActivation();
                    bool         registerActi = brActivation.PutCronograma(cronoActiv, newUserName, ansNmembershi);
                }

                if (Session["codeUpgrate"] != null)
                {
                    //el id de account n membership del upgrate ¬ y el nuevo
                    int  codeUpgrate = int.Parse(Session["codeUpgrate"].ToString());
                    bool upgrate     = brTypeMemb.CancelMembershipUpgrate(codeUpgrate, ansNmembershi);
                    if (!upgrate)
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                        return;
                    }
                    BrActivation brActivation  = new BrActivation();
                    string       fechaAnterior = Session["fechaanterior"].ToString();
                    bool         registerActi  = brActivation.PutCronogramaUpgrade(fechaAnterior, newUserName, ansNmembershi, codeUpgrate);
                }
                //validamos si tiene consumo


                if (!isRegister)
                {
                    // "Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario";
                    return;
                }

                //BrActivation brActivation = new BrActivation();
                //bool registerActi = brActivation.PutCronograma(cronoActiv, newUserName, ansNmembershi);

                //obtengo el monto a pagar

                string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                if (username_idmen_amount_email.Length < 4)
                {
                    // "false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar";
                    return;
                }
                var idMemberDetails = int.Parse(username_idmen_amount_email[1]);
                var amountPay       = double.Parse(username_idmen_amount_email[2]);
                emailNewUser                = username_idmen_amount_email[3];
                codeCurrencyPay             = username_idmen_amount_email[4];
                date                        = null;
                username_idmen_amount_email = null;
                dataKitMember               = null;
                respData                    = null;


                var namePeson = arrayperson[0].Trim() + " " + arrayperson[1].Trim();

                var dateCurrent = DateTime.Now.ToString("yyyy-MM-dd").Split('-');;

                string tranferId    = "";
                string numReceipt   = "0";
                string datecomplete = dateCurrent[2] + " de " + GetMonth(dateCurrent[1]) + " del " + dateCurrent[0];
                string nAffiliate   = "";

                string     hour       = DateTime.Now.ToString("HH:mm:ss");
                string     detalle    = amountRestan.ToString();
                MyMessages myMessages = new MyMessages();
                namePeson = myMessages.ToCapitalize(namePeson);
                //cvbc
                var imgTicket = GetRecibo(tranferId, newUserName, numReceipt, datecomplete, nAffiliate, codeMemb, namePeson, hour, detalle, quotesPendiente, " Inicial 1");


                /*=============================================================================================================================*/

                //var currencyCode = Session["CurrencyCode"].ToString();
                BrMembershipPayDetail brMembership = new BrMembershipPayDetail();
                var response = brMembership.GetQuote(idMemberDetails, User.Identity.Name.Split('¬')[1]).Split('|');

                if (decimal.Parse(response[0]) == 0)
                {
                    // "Ocurrio un error.";
                    return;
                }
                var amount = decimal.Parse(response[0]).ToString();


                if (codeCurrencyPay == "USD")
                {
                    amount = (decimal.Parse(amount) * decimal.Parse(typeChange)).ToString();
                }


                var idInfo = idMemberDetails.ToString();
                //dos es que wallet es una parte del pago de una cuota
                var typeInfo         = "2";
                var walleOperationId = "2";


                bool IsPay = brMembership.IsPayQuote(idMemberDetails.ToString());

                if (!IsPay)
                {
                    // "Tu Cuota ya esta Pagada.Verifica tu cronograma de pagos.";
                    return;
                }


                var amountWallet = decimal.Parse(brWallet.GetAmount(User.Identity.Name.Split('¬')[1]));

                //if (amountWallet < decimal.Parse(amount))
                //{
                //    MessageError.Text = "No tiene el monto suficiente para realizar Pago.";
                //    return;
                //}

                imgTicket += recibe;

                var moneyStatus = 0;

                if (amountWallet > 0)
                {
                    var imgTicketWalle = GetRecibo(idMemberDetails.ToString(), newUserName, numReceipt, datecomplete, nAffiliate, codeMemb, namePeson, hour, amountWalletc.ToString(), quotesPendiente, " Inicial 1");
                    imgTicket += $"~{imgTicketWalle}";
                    //amount | @idInfo | @typeInfo | @walletOperationId | @currencyCode | @typeChange | idmembershipDetail | imgTicket
                    string data   = $"{amountWalletc}|{idInfo}|{typeInfo}|{walleOperationId}|PEN|{typeChange}|{idMemberDetails.ToString()}|{imgTicket}";
                    bool   answer = brWallet.Put(data, User.Identity.Name.Split('¬')[1], moneyStatus);

                    //Extorno

                    if (!answer)
                    {
                        // = "Ocurrio un error.";
                        return;
                    }
                }
                //MessageSucces.Text = "Su Pago de Realizo Con Exito.";

                /*=============================================================================================================================*/

                var amountOthers = amount;
                //esta en estado pendienete
                var statusPay = 1;

                //marcar como pagado en la tabla membershipdetails

                //TODO: Agregar los detalles del pago


                bool habiliAccount = brUser.BiPayQuote(idMemberDetails, imgTicket, amountWalletc, amountRestan, "WALLET", methods2, statusPay, decimal.Parse(typeChange));

                int nAfiliate = int.Parse(brUser.GetNafiliate(idMemberDetails));

                BrTypeMembership brTypeMembership = new BrTypeMembership();
                var correlativo = int.Parse(brTypeMembership.GetTotalMemberships(User.Identity.Name.Split('¬')[1]));

                correlativo--;

                if (correlativo < 0)
                {
                    correlativo = 0;
                }

                Cronograma2(nAfiliate, codeCurrencyPay, correlativo.ToString());

                // enviar el email de confirmacion con la data y lo redirecciona al post register
                if (!habiliAccount)
                {
                    Response.Write("false¬Ha Ocurrido un Error al Intentar Habilitar Su Cuenta.Sin embargo su Pago fue Exitoso");
                    return;
                }


                var urlRedirect = "EndPaymendMbs";

                if (codeMemb == "EXP" || codeMemb == "LHT" || codeMemb == "STD" ||
                    codeMemb == "PLUS" || codeMemb == "TOP" || codeMemb == "VIT")
                {
                    urlRedirect = "EndPaymendMbs";
                }
                if (codeMemb == "EVOL" || codeMemb == "MVC")
                {
                    urlRedirect = "EndPaymendMbs";
                }
                if (codeMemb == "SBY")
                {
                    urlRedirect = "EndPaymentSby";
                }


                Response.Write($"true¬{urlRedirect}.aspx");
            }
            catch (Exception ex)
            {
                Email email = new Email();
                email.SendEmail(mc.ErrorEmail, "error-inresorts", ex.StackTrace + '¬' + DateTime.Now.ToLongDateString(), false);
                Response.Write("false¬ocurrio un error");
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string[]         dataLogin = null;
            int              typeRegister = 0, numberQuotes = 0, formPay = 0, idMemberDetails = 0;
            string           dataKit = null, dataKitMember = null, dataMemberSinKit;
            string           token = null, userCurrent = null, newUserName = null, emailNewUser = null;
            double           amountPay        = 0;
            bool             isRegister       = false;
            BrUser           brUser           = null;
            BrTypeMembership brTypeMembership = null;
            Email            oEmail           = null;
            BrPayments       brPayments       = null;
            BrConsuption     brConsuption;

            if (Session["typeRegister"] == null)
            {
                Session["typeRegister"] = 0;
            }

            typeRegister = int.Parse(Session["typeRegister"].ToString());
            //formPay = int.Parse(Session["formPay"].ToString());
            formPay = int.Parse("1");
            // token = Request["token"].ToString();
            numberQuotes     = 1;
            brUser           = new BrUser();
            brTypeMembership = new BrTypeMembership();
            dataLogin        = HttpContext.Current.User.Identity.Name.Split('¬');
            oEmail           = new Email();
            brPayments       = new BrPayments();
            brConsuption     = new BrConsuption();
            string TypeMembership = "";



            userCurrent = dataLogin[0];
            if (dataLogin.Length > 1)
            {
                userCurrent = dataLogin[1];
            }



            if (formPay == 1)
            {
                string dataBdd = Session["datos"].ToString();
                TypeMembership = (dataBdd.Split('$')[3]).Split('|')[7];
                string   data2 = (string)Session["civilState"];
                string[] oIdMembreship_amount = brUser.RegisterUser(dataBdd, data2).Split('¬');

                if (oIdMembreship_amount.Length < 2)
                {
                    //Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario1");
                    Response.Redirect("Pagos.aspx");
                    return;
                }

                string[] parameterPerson  = dataBdd.Split('$');
                string[] arraydata        = parameterPerson[0].Split('|');
                string[] arrayTypeaccount = parameterPerson[2].Split('|');
                string[] arrayaccount     = parameterPerson[3].Split('|');

                string parameterAccount = arraydata[5].Trim() + "|" + arrayTypeaccount[7].Trim() + '|' + userCurrent + '|' + oIdMembreship_amount[0];
                //'999999999999|1|sa|1'
                newUserName = brUser.GenerateAccount(parameterAccount);

                if (string.IsNullOrEmpty(newUserName))
                {
                    //Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario2");
                    //Response.Redirect("Pagos.aspx");
                    return;
                }
            }


            if (typeRegister == 1)
            {
                // string arrayKit = Session["arrayKit"].ToString() + "¬" + newUserName;
                //'2018-10-19¬31¬31¬31¬userName'
                //isRegister = brUser.PutRegisterkIT(arrayKit);
                string arrayKit = Session["arrayKit"].ToString() + "¬" + newUserName;
                //'2018-10-19¬31¬31¬31¬userName'
                string data2        = Session["financedAmount"].ToString();
                string codeCurrency = Session["TypeCurrency"].ToString();

                Int32 ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, data2, 1, codeCurrency);
                isRegister = brUser.PutRegisterkIT(arrayKit, ansNmembershi);
                //monto a pagar
                string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                /*UPDATE*/
                bool resp = brPayments.InitialExoneration(newUserName);
                // bool notAvilable = brUser.NotAvailableUser(newUserName);
                Response.Redirect("EndPayments.aspx");
            }

            if (typeRegister == 2)
            {
                dataKitMember = Session["cronograma"].ToString();

                string date = dataKitMember.Split('$')[1];

                string respData = brPayments.PersonGetData(newUserName);


                respData = respData + '^' + dataKitMember;
                // isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName);
                string data2        = Session["financedAmount"].ToString();
                string codeCurrency = Session["TypeCurrency"].ToString();

                Int32 ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, data2, 1, codeCurrency);
                var   exchange      = Session["exchange"];
                if (string.IsNullOrEmpty(exchange.ToString()))
                {
                    exchange = "0.00";
                }
                isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName, ansNmembershi, exchange.ToString(), 1);

                //validamos si tiene consumo
                if (!isRegister)
                {
                    // Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                    //Response.Redirect("Pagos.aspx");
                    return;
                }
                //obtengo el monto a pagar
                string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                if (username_idmen_amount_email.Length < 4)
                {
                    //Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                    //Response.Redirect("Pagos.aspx");
                    return;
                }
                idMemberDetails             = int.Parse(username_idmen_amount_email[1]);
                amountPay                   = double.Parse(username_idmen_amount_email[2]);
                emailNewUser                = username_idmen_amount_email[3];
                date                        = null;
                username_idmen_amount_email = null;
                dataKitMember               = null;
                respData                    = null;
                /*UPDATE*/
                bool resp = brPayments.InitialExoneration(newUserName);
                //  bool notAvilable = brUser.NotAvailableUser(newUserName);
                Response.Redirect("EndPayments.aspx");
            }
        }
Ejemplo n.º 6
0
        public void registerTodo(int metodo)
        {
            brPayment = new BrPayments();
            brUser    = new BrUser();
            int typeRegister = 0;

            if (Session["typeRegister"] == null)
            {
                Session["typeRegister"] = 0;
            }

            typeRegister = int.Parse(Session["typeRegister"].ToString());
            //REGISTER
            string[] dataLogin   = HttpContext.Current.User.Identity.Name.Split('¬');
            string   userCurrent = dataLogin[0];

            if (dataLogin.Length > 1)
            {
                userCurrent = dataLogin[1];
            }
            string dataBdd        = Session["datos"].ToString();
            string TypeMembership = (dataBdd.Split('$')[3]).Split('|')[7];

            if (!string.IsNullOrEmpty((string)Session["tienda"]))
            {
                if (Session["tienda"].ToString() != "1")
                {
                    string   data2 = (string)Session["civilState"];
                    string[] oIdMembreship_amount = brUser.RegisterUser(dataBdd, data2).Split('¬');

                    if (oIdMembreship_amount.Length < 2)
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                        return;
                    }
                    string[] array1     = Session["cronogramaYa"].ToString().Split('^');
                    string[] datosMem   = array1[0].Split('|');
                    string[] array2     = array1[1].Split('~');
                    string[] cuotas     = array2[0].Split('¬');
                    string   cronoActiv = "";
                    for (int i = 0; i < cuotas.Length - 1; i++)
                    {
                        var fila = cuotas[i].Split('|');
                        if (fila[0].Substring(0, 7) != "Inicial")
                        {
                            cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd");
                            //amountFinanciade = double.Parse(fila[2].Replace("S/.", ""));
                            break;
                        }
                        else
                        {
                            cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd") + "¬";
                        }
                    }

                    string[] parameterPerson  = dataBdd.Split('$');
                    string[] arraydata        = parameterPerson[0].Split('|');
                    string[] arrayTypeaccount = parameterPerson[2].Split('|');
                    string[] arrayaccount     = parameterPerson[3].Split('|');

                    string parameterAccount = arraydata[5].Trim() + "|" + arrayTypeaccount[7].Trim() + '|' + userCurrent + '|' + oIdMembreship_amount[0];

                    newUserName = brUser.GenerateAccount(parameterAccount);
                    bool notAvilable = brUser.NotAvailableUser(newUserName);
                    if (string.IsNullOrEmpty(newUserName))
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                        return;
                    }


                    //END REGISTER
                    if (typeRegister == 1)
                    {
                        string arrayKit = Session["arrayKit"].ToString() + "¬" + newUserName;
                        //'2018-10-19¬31¬31¬31¬userName'
                        string data3        = Session["financedAmount"].ToString();
                        string codeCurrency = Session["TypeCurrency"].ToString();

                        Int32 ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, data3, 1, codeCurrency);

                        if (ansNmembershi > 0)
                        {
                            //GeneracionDePuntos
                            bool isRegister = brUser.PutRegisterkIT(arrayKit, ansNmembershi);
                        }

                        //monto a pagar

                        /*subidaDeRecibo con newUserName*/
                        brUser = new BrUser();
                        BrPayments brPayments = new BrPayments();
                        bool       upload     = brPayments.UploadReceipt(ansNmembershi.ToString() + '|' + nombreArchivo);
                        if (!string.IsNullOrEmpty(newUserName))
                        {
                            bool UpdateD = brUser.UpdateInitialQuoteDescription(newUserName);
                        }
                        else
                        {
                            bool UpdateD = brUser.UpdateInitialQuoteDescription(userCurrent);
                        }

                        BrActivation brActivation = new BrActivation();
                        bool         registerActi = brActivation.PutCronograma(cronoActiv, newUserName, ansNmembershi);

                        string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                        if (username_idmen_amount_email.Length < 4)
                        {
                            Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                            return;
                        }
                        idMemberDetails = int.Parse(username_idmen_amount_email[1]);

                        double amountPay    = double.Parse(username_idmen_amount_email[2]);
                        string emailNewUser = username_idmen_amount_email[3];
                        username_idmen_amount_email = null;
                    }

                    if (typeRegister == 2)
                    {
                        string     dataKitMember = Session["cronograma"].ToString();
                        string     date          = dataKitMember.Split('$')[1];
                        BrPayments brPayments    = new BrPayments();
                        string     respData      = brPayments.PersonGetData(newUserName);
                        respData = respData + '^' + dataKitMember;
                        brUser   = new BrUser();
                        string data3        = Session["financedAmount"].ToString();
                        string codeCurrency = Session["TypeCurrency"].ToString();

                        Int32 ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, data3, 1, codeCurrency);
                        //GeneracionDePuntosConLaInicialDeLaMembresia
                        //string exchange2 = "";
                        var exchange = Session["exchange"];

                        bool isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName, ansNmembershi, exchange.ToString(), 0);
                        brUser = new BrUser();
                        //TODO: la fecha de pago debe ser el dia de subida del voucher
                        bool upload = brPayments.UploadReceipt(ansNmembershi.ToString() + '|' + nombreArchivo);


                        BrActivation brActivation = new BrActivation();
                        bool         registerActi = brActivation.PutCronograma(cronoActiv, newUserName, ansNmembershi);



                        if (!isRegister)
                        {
                            Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                            return;
                        }
                        //obtengo el monto a pagar

                        string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
                        if (username_idmen_amount_email.Length < 4)
                        {
                            Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                            return;
                        }
                        idMemberDetails = int.Parse(username_idmen_amount_email[1]);


                        date = null;
                        username_idmen_amount_email = null;
                        dataKitMember = null;
                        respData      = null;
                    }
                }
            }
            else
            {
                //entra aqui pagar despues
                string   data2 = (string)Session["civilState"];
                string[] oIdMembreship_amount = brUser.RegisterUser(dataBdd, data2).Split('¬');

                if (oIdMembreship_amount.Length < 2)
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                    return;
                }

                string[] parameterPerson  = dataBdd.Split('$');
                string[] arraydata        = parameterPerson[0].Split('|');
                string[] arrayTypeaccount = parameterPerson[2].Split('|');
                string[] arrayaccount     = parameterPerson[3].Split('|');

                string parameterAccount = arraydata[5].Trim() + "|" + arrayTypeaccount[7].Trim() + '|' + userCurrent + '|' + oIdMembreship_amount[0];

                newUserName = brUser.GenerateAccount(parameterAccount);


                string dataKitMember = "";
                string date          = "";
                if (!string.IsNullOrEmpty((string)Session["cronograma"]))
                {
                    dataKitMember = Session["cronograma"].ToString();
                    date          = dataKitMember.Split('$')[1];
                }

                string[] array1     = Session["cronogramaYa"].ToString().Split('^');
                string[] datosMem   = array1[0].Split('|');
                string[] array2     = array1[1].Split('~');
                string[] cuotas     = array2[0].Split('¬');
                string   cronoActiv = "";
                for (int i = 0; i < cuotas.Length - 1; i++)
                {
                    var fila = cuotas[i].Split('|');
                    if (fila[0].Substring(0, 7) != "Inicial")
                    {
                        cronoActiv += fila[1];
                        break;
                    }
                    else
                    {
                        cronoActiv += fila[1] + "¬";
                    }
                }

                BrPayments brPayments = new BrPayments();
                string     respData   = brPayments.PersonGetData(dataLogin[0]);
                respData = respData + '^' + dataKitMember;
                brUser   = new BrUser();
                string financedAmountsa = Session["financedAmount"].ToString();
                string codeCurrency     = Session["TypeCurrency"].ToString();

                Int32 ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, financedAmountsa, 1, codeCurrency);
                //GeneracionDePuntosConLaInicialDeLaMembresia
                string        exchange      = "";
                BrInformacion brInformacion = new BrInformacion();
                string[]      info          = brInformacion.GetInformation().Split('¬');



                if (!string.IsNullOrEmpty(info[1]))
                {
                    exchange = info[1];
                }
                else
                {
                    exchange = "0.00";
                }
                string   currentUser = "";
                string[] arrayLink   = Session["link"].ToString().Split('|');
                if (arrayLink.Length > 1)
                {
                    currentUser = arrayLink[0];
                }
                else
                {
                    currentUser = dataLogin[0];
                }

                bool isRegister = brPayments.GetCalculatePaymentSchedule(respData, currentUser, ansNmembershi, exchange, 0);

                BrActivation brActivation = new BrActivation();
                bool         registerActi = brActivation.PutCronograma(cronoActiv, newUserName, ansNmembershi);

                /*subidaDeRecibo con newUserName*/
                if (!string.IsNullOrEmpty(nombreArchivo))
                {
                    brUser = new BrUser();
                    bool upload = brPayments.UploadReceipt(currentUser + '|' + nombreArchivo);
                    if (!string.IsNullOrEmpty(newUserName))
                    {
                        bool UpdateD = brUser.UpdateInitialQuoteDescription(newUserName);
                        //bool ans = brPayment.UploadReceiptCalendar(newUserName + '|' + nombreArchivo);
                    }
                    else
                    {
                        bool UpdateD = brUser.UpdateInitialQuoteDescription(userCurrent);
                        //bool ans = brPayment.UploadReceiptCalendar(newUserName + '|' + nombreArchivo);
                    }
                }

                if (!isRegister)
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                    return;
                }
                return;
            }
            return;
            /*TRY MERGE*/
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    string quotesPendiente = "";
                    string namePeson = "";
                    string token = "", emailNewUser = "", userName = "", codeMembers = "";
                    int    numberQuotes = 0, idMemberDetails = 0;
                    double amountPay    = 0;
                    string currencyCode = string.Empty;

                    BrUser           brUser     = new BrUser();
                    BrPayments       brPayments = new BrPayments();
                    BrTypeMembership brTypeMemb = new BrTypeMembership();

                    string[] dataLogin = HttpContext.Current.User.Identity.Name.Split('¬');
                    userName = dataLogin[1];

                    token        = Request["tokenid"].ToString();
                    numberQuotes = int.Parse(Request["ddlQuote"].ToString());
                    currencyCode = Request["ddlcurrencyCode"].ToString();



                    if (numberQuotes < 0 || numberQuotes > 32)
                    {
                        Response.Write("false¬" + "Numero de Cuotas No Valido");
                        return;
                    }

                    codeMembers = Session["carrito"].ToString().Split('|')[6];

                    string   dataBdd       = Session["datos"].ToString();
                    string[] arraycontacto = dataBdd.Split('$')[3].Split('|');
                    string[] arrayperson   = dataBdd.Split('$')[0].Split('|');

                    //correo = arraycontacto[0];
                    namePeson = arrayperson[0] + " " + arrayperson[1];

                    string[] acarrito       = Session["carrito"].ToString().Split('|');
                    string   TypeMembership = acarrito[6];

                    string cronograma = Session["cronograma"].ToString();
                    //string respData = brPayments.PersonGetData(userName);
                    string respData = "";
                    respData = respData + '^' + cronograma;

                    double amountFinanciade = 0;
                    string cronogramaYa     = Session["cronogramaYa"].ToString();



                    string[] array1     = Session["cronogramaYa"].ToString().Split('^');
                    string[] datosMem   = array1[0].Split('|');
                    string[] array2     = array1[1].Split('~');
                    string[] cuotas     = array2[0].Split('¬');
                    string   cronoActiv = "";
                    for (int i = 0; i < cuotas.Length - 1; i++)
                    {
                        var fila = cuotas[i].Split('|');
                        if (fila[0].Substring(0, 7) != "Inicial")
                        {
                            cronoActiv      += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd");
                            amountFinanciade = double.Parse(fila[2].Replace("S/.", ""));
                            break;
                        }
                        else
                        {
                            cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd") + "¬";
                        }
                    }
                    string codeCurrency = Session["TypeCurrency"].ToString();

                    int    ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + userName, amountFinanciade.ToString(), Int32.Parse(Session["membPred"].ToString()), codeCurrency);
                    bool   isRegister    = false;
                    string exchange      = Session["carrito"].ToString().Split('|')[4];

                    var typeChange = double.Parse(exchange);

                    if (Session["codeUpgrate"] != null)
                    {
                        //si es upgrate

                        isRegister = brPayments.GetCalculatePaymentScheduleUpgrate(respData, userName, ansNmembershi, exchange, 1);
                        if (!isRegister)
                        {
                            Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                            return;
                        }

                        if (Session["dateup"] != null)
                        {
                            string dateup = Session["dateup"].ToString();
                            bool   an     = brPayments.PutDateUpgrate(ansNmembershi, dateup);
                        }

                        //registramos si upgrate para
                    }
                    else
                    {
                        //si no es upgrate

                        isRegister = brPayments.GetCalculatePaymentSchedule(respData, userName, ansNmembershi, exchange, 1);
                        if (!isRegister)
                        {
                            Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                            return;
                        }
                        //cronograma de activacion
                        BrActivation brActivation = new BrActivation();
                        bool         registerActi = brActivation.PutCronograma(cronoActiv, userName, ansNmembershi);
                    }

                    if (Session["codeUpgrate"] != null)
                    {
                        //el id de account n membership del upgrate ¬ y el nuevo
                        int  codeUpgrate = int.Parse(Session["codeUpgrate"].ToString());
                        bool upgrate     = brTypeMemb.CancelMembershipUpgrate(codeUpgrate, ansNmembershi);
                        if (!upgrate)
                        {
                            Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                            return;
                        }
                        BrActivation brActivation  = new BrActivation();
                        string       fechaAnterior = Session["fechaanterior"].ToString();
                        bool         registerActi  = brActivation.PutCronogramaUpgrade(fechaAnterior, userName, ansNmembershi, codeUpgrate);
                    }

                    //validamos si tiene consumo
                    if (!isRegister)
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Cronograma de Pagos del Usuario");
                        return;
                    }

                    string[] username_idmen_amount_email = brUser.GetAmountPay(ansNmembershi).Split('|');

                    if (username_idmen_amount_email.Length < 4)
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                        return;
                    }
                    idMemberDetails = int.Parse(username_idmen_amount_email[1]);
                    amountPay       = double.Parse(username_idmen_amount_email[2]);
                    emailNewUser    = username_idmen_amount_email[3];

                    username_idmen_amount_email = null;
                    brPayments = null;
                    brUser     = null;

                    if (idMemberDetails <= 0 || amountPay <= 0)
                    {
                        Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar al Usuario");
                        return;
                    }

                    if (currencyCode == "USD")
                    {
                        amountPay = amountPay / typeChange;
                    }

                    PayCulqi payCulqi    = new PayCulqi();
                    string[] culqiAnwser = payCulqi.newPayment(userName, emailNewUser, amountPay, token, numberQuotes, currencyCode).Split('¬');
                    if (culqiAnwser[0] == "false")
                    {
                        Response.Write("false¬" + culqiAnwser[1]);
                        return;
                    }
                    //marcar como pagado en la tabla membershipdetails
                    BrMembershipPayDetail brMembershipPayDetail = new BrMembershipPayDetail();

                    if (Session["codeUpgrate"] != null)
                    {
                        bool habiliAccount = brMembershipPayDetail.UpgrateStatusPaymentInitial(ansNmembershi, 1, "");

                        //enviar el email de confirmacion con la data y lo redirecciona al post register
                        if (!habiliAccount)
                        {
                            Response.Write("false¬Ha Ocurrido un Error al Intentar Habilitar Su Cuenta.");
                            return;
                        }
                    }
                    else
                    {
                        var dateCurrent = DateTime.Now.ToString("yyyy-MM-dd").Split('-');;

                        string tranferId  = culqiAnwser[2] == null ? "" : culqiAnwser[2];
                        string numReceipt = "0";
                        string date       = dateCurrent[2] + " de " + GetMonth(dateCurrent[1]) + " del " + dateCurrent[0];
                        string nAffiliate = "";

                        string hour    = DateTime.Now.ToString("HH:mm:ss");
                        string detalle = amountPay.ToString();


                        //cvbc
                        string nameTicket = GetRecibo(tranferId, userName, numReceipt, date, nAffiliate, TypeMembership, namePeson, hour, detalle, quotesPendiente);


                        bool habiliAccount = brMembershipPayDetail.UpgrateStatusPaymentInitial(ansNmembershi, 0, nameTicket);

                        //enviar el email de confirmacion con la data y lo redirecciona al post register
                        if (!habiliAccount)
                        {
                            Response.Write("false¬Ha Ocurrido un Error al Intentar Habilitar Su Cuenta.");
                            return;
                        }
                    }

                    Email oEmail      = new Email();
                    bool  awnserEmail = oEmail.SubmitEmail(emailNewUser, "[RIBERA DEL RIO - PAGO]", "Ud. Ha efectuado su pago en Ribera del Rio con Exito.");
                    if (!awnserEmail)
                    {
                        Response.Write("false¬" + culqiAnwser[1] + "\n" + "Ocurrio un Error al intentar enviar un Email de conformidad con su compra");
                        return;
                    }
                    //ejecutamos el core para los puntos de equipo
                    //BrCore_Automation brCore_Automation = new BrCore_Automation();
                    // bool isCoreRegister = brCore_Automation.ExecuteCore();
                    var urlRedire = string.Empty;

                    var codeMemb = TypeMembership.Trim();

                    if (codeMemb == "EXP" || codeMemb == "LHT" || codeMemb == "STD" ||
                        codeMemb == "PLUS" || codeMemb == "TOP" || codeMemb == "VIT")
                    {
                        urlRedire = "EndPayments";
                    }
                    if (codeMemb == "EVOL" || codeMemb == "MVC")
                    {
                        urlRedire = "EndPaymentQuote";
                    }
                    if (codeMemb == "SBY")
                    {
                        urlRedire = "EndPaymentSby";
                    }

                    Response.Write($"true¬{urlRedire}.aspx");
                    return;
                }
            }
            catch (Exception ex)
            {
                Response.Redirect("error.aspx?error=" + ex.Message, true);
            }
        }
Ejemplo n.º 8
0
        public bool RegistarSinPagarInicial()
        {
            string newUserName = "", TypeMembership = "", userCurrent = "";

            string[]    dataLogin;
            BrUser      brUser      = new BrUser();
            MyConstants myConstants = new MyConstants();

            dataLogin   = HttpContext.Current.User.Identity.Name.Split('¬');
            userCurrent = dataLogin[0];
            if (dataLogin.Length > 1)
            {
                userCurrent = dataLogin[1];
            }

            string dataKitMember = "";

            dataKitMember = Session["cronograma"].ToString();
            //1050 | 3.31 | empty | empty | 12 | 2019 - 03 - 15 | 311.14 | 10 | 1 | empty ^ 2019 - 03 - 15 | 278.04~jorge samir | pazo torres | 165894515 | 65894515$2019 - 04 - 15
            string datecrono   = dataKitMember.Split('^')[1];
            string dateinitial = datecrono.Split('|')[0];
            string currentDate = DateTime.Now.ToString(myConstants.DateFormatBd);

            if (dateinitial == currentDate)
            {
                return(false);
            }


            string dataBdd = Session["datos"].ToString();

            TypeMembership = (dataBdd.Split('$')[3]).Split('|')[7];
            // string data2 = (string)Session["civilStatus"];
            string civilState = (string)Session["civilState"];

            string[] oIdMembreship_amount = brUser.RegisterUser(dataBdd, civilState).Split('¬');

            if (oIdMembreship_amount.Length < 2)
            {
                return(false);
            }

            string[] array1     = Session["cronogramaYa"].ToString().Split('^');
            string[] datosMem   = array1[0].Split('|');
            string[] array2     = array1[1].Split('~');
            string[] cuotas     = array2[0].Split('¬');
            string   cronoActiv = "";

            for (int i = 0; i < cuotas.Length - 1; i++)
            {
                var fila = cuotas[i].Split('|');
                if (fila[0].Substring(0, 7) != "Inicial")
                {
                    cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd");
                    break;
                }
                else
                {
                    cronoActiv += DateTime.Parse(fila[1]).ToString("yyyy-MM-dd") + "¬";
                }
            }

            string[] parameterPerson  = dataBdd.Split('$');
            string[] arraydata        = parameterPerson[0].Split('|');
            string[] arrayTypeaccount = parameterPerson[2].Split('|');
            string[] arrayaccount     = parameterPerson[3].Split('|');

            string parameterAccount = arraydata[5].Trim() + "|" + arrayTypeaccount[7].Trim() + '|' + userCurrent + '|' + oIdMembreship_amount[0];

            //'999999999999|1|sa|1'
            newUserName = brUser.GenerateAccount(parameterAccount);

            BrPayments brPayments = new BrPayments();


            string respData = brPayments.PersonGetData(newUserName);

            respData = respData + '^' + dataKitMember;
            // isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName);
            string financedAmount = Session["financedAmount"].ToString();
            string codeCurrency   = Session["TypeCurrency"].ToString();

            Int32  ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + newUserName, financedAmount, 1, codeCurrency);
            string exchange      = Session["carrito"].ToString().Split('|')[4];
            //5 cualqier numero
            bool isRegister = brPayments.GetCalculatePaymentSchedule(respData, newUserName, ansNmembershi, exchange, 5);

            //validamos si tiene consumo


            if (!isRegister)
            {
                return(false);
            }
            //obtengo el monto a pagar
            string[] username_idmen_amount_email = brUser.getAmountPay(newUserName).Split('¬');
            if (username_idmen_amount_email.Length < 4)
            {
                Response.Write("false¬Ha Ocurrido Un Error al Intentar Obtener el monto a Pagar");
                return(false);
            }
            int    idMemberDetails = int.Parse(username_idmen_amount_email[1]);
            double amountPay       = double.Parse(username_idmen_amount_email[2]);
            string emailNewUser    = username_idmen_amount_email[3];

            username_idmen_amount_email = null;
            dataKitMember = null;
            respData      = null;
            Email      oEmail     = new Email();
            MyMessages myMessages = new MyMessages();
            //habilitar hasta la fecha de pago de su inicial
            bool isActive = brUser.GetNotPayInitial(dateinitial, newUserName, ansNmembershi);

            BrActivation brActivation = new BrActivation();
            bool         registerActi = brActivation.PutCronograma(cronoActiv, newUserName, ansNmembershi);

            string ruta = HttpContext.Current.Server.MapPath("~/Resources/PoliticsPdf/");

            //bool awnserEmailDoc = oEmail.submitEmail(emailNewUser, "[RIBERA DEL RIO - BIENVENIDO]", myMessages.DocumentosRegister(newUserName), true, ruta, newUserName);

            var email          = SendEmailPay();
            var awnserEmailDoc = SendEmailFounder(arraydata[0], arraydata[3], newUserName + "0", ruta, emailNewUser);



            if (awnserEmailDoc)
            {
                return(false);
            }
            return(true);
        }