Exemplo n.º 1
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");
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                PayCulqi culqi = new PayCulqi();
                BrMembershipPayDetail payDetail = new BrMembershipPayDetail();
                BrDaysFree            daysFree = new BrDaysFree();
                string userName = "", email = "", token = "", typeMembresia = "", namePerson = "";
                int    numberQuotes = 0, numberDays = 0;;

                token        = Request["token"] == null ? "" : Request["token"];
                numberQuotes = Request["numcuotes"] == null ? 0 : int.Parse(Request["numcuotes"]);

                if (string.IsNullOrEmpty(token) || numberQuotes <= 0 || numberQuotes >= 20)
                {
                    Response.Write("[{data:{'success':false,'message':'Ocurrio un error'}}]");
                    return;
                }

                if (Session["changingschedule"] == null)
                {
                    Response.Write("[{data:{'success':false,'message':'Ocurrio un error'}}]");
                    return;
                }

                var data         = (Dictionary <string, object>)Session["changingschedule"];

                var action       = data["Action"];
                var valueQuote   = Convert.ToDouble(data["ValueQuote"]);
                var numQuote     = Convert.ToDouble(data["NumQuote"]);
                var idMembership = Convert.ToInt32(data["IdMembership"]);
                var payDate      = Convert.ToDateTime(data["PayDate"]);


                TimeSpan ts      = DateTime.Now - payDate;

                // Difference in days.
                numberDays = ts.Days;

                var valueTotal   = valueQuote * numQuote;

                userName = User.Identity.Name.Split('¬')[1].Trim();
                email    = User.Identity.Name.Split('¬')[8].Trim();
                string currencyCode = "PEN";
                if (Session["CurrencyCode"] != null)
                {
                    currencyCode = Session["CurrencyCode"].ToString();
                }
                var response = culqi.newPayment(userName, email, valueTotal, token, numberQuotes, currencyCode).Split('¬');

                if (!bool.Parse(response[0]))
                {
                    Response.Write("[{data:{'success':false,'message':'Ocurrio un error'}}]");
                    return;
                }
                Session.RemoveAll();
                int    numQuotes = int.Parse(numQuote.ToString());
                string nameImage = "", concepto = "";

                var info = payDetail.GetInfoQuoteForRecibo(idMembership).Split('|');

                if (info.Length > 1)
                {
                    typeMembresia = info[0].ToUpper();
                    namePerson    = info[1].ToUpper();
                    concepto      = info[2].ToUpper();
                }
                else
                {
                    typeMembresia = userName;
                    namePerson    = userName;
                    concepto      = userName;
                }

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

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

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

                nameImage = GetRecibo(tranferId, userName, date, typeMembresia, namePerson, hour, detalle, concepto);

                bool responseb = payDetail.PutQuotesChangingSchedule(idMembership, numQuotes, nameImage, 1);

                if (numberDays > 0)
                {
                    responseb = daysFree.Put(userName, numberDays, idMembership);
                }

                Response.Write("[{data:{'success':true,'message':'" + response[1] + "'}}]");
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //declaracion de variables
            int        opcionRegister = 0;
            BrUser     brUser;
            BrPayments brPayments;

            string parameterToken = null;
            string oNumberQuotes  = null;

            this.NumberQuotes = int.Parse(Request["numcuotes"]);

            parameterToken    = Request["token"];
            oNumberQuotes     = Request["numcuotes"];
            this.NumberQuotes = int.Parse(Request["numcuotes"]);
            this.CodeIgnore   = 0;

            //string parameterToken = "";
            if (string.IsNullOrEmpty(parameterToken))
            {
                Response.Write("false¬Ha Ocurrido un Error Al Intentar Token");
                return;
            }
            if (string.IsNullOrEmpty(oNumberQuotes))
            {
                Response.Write("false¬Ha Ocurrido un Error,el numero de Cuotas es Invalido");
                return;
            }


            if (this.NumberQuotes < 1)
            {
                Response.Write("false¬Ha Ocurrido un Error,el numero de Cuotas es Invalido");
                return;
            }
            if (this.NumberQuotes > 32)
            {
                Response.Write("false¬Ha Ocurrido un Error,el numero de Cuotas es Invalido");
                return;
            }

            //Session["datos"] = "samir|torres|cuarto|15-04-2018|M|[email protected]|111112122212|ubigeo|1|20202020845454|EXP|knava|1|50|24";
            /*registes user and general account*/
            if (Session["datos"] != null)
            {
                //cuando va a registrar
                string dataBdd              = Session["datos"].ToString();
                string TypeMembership       = (dataBdd.Split('$')[3]).Split('|')[7];
                BrUser obrUser              = new BrUser();
                string data2                = (string)Session["civilState"];
                string idMembreship_amount  = obrUser.RegisterUser(dataBdd, data2);
                var    oIdMembreship_amount = idMembreship_amount.Split('¬');

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

                var parameterPerson = dataBdd.Split('$');

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

                var arrayInfo = HttpContext.Current.User.Identity.Name.Split('¬');

                string padre = arrayInfo[0];
                if (arrayInfo.Length > 1)
                {
                    padre = arrayInfo[1];
                }/*merge*/

                string parameterAccount = arraydata[5].Trim() + "|" + arrayTypeaccount[7].Trim() + '|' + padre + '|' + oIdMembreship_amount[0];
                //'999999999999|1|sa|1'
                this.NewUserName = obrUser.GenerateAccount(parameterAccount);

                if (string.IsNullOrEmpty(this.NewUserName))
                {
                    Response.Write("false¬Ha Ocurrido Un Error al Intentar Generar la Cuenta de Usuario");
                    return;
                }

                brPayments = new BrPayments();

                //IdPerson | empty ^ amountDollars | changeTo | empty | empty | nQuote | InititalDate | InitalAmount | PercentInterest | default:1 | Empty ^ QuoteDate | InitalAmountQuote ~vvhvbnvbnvb|nvbnvbnvbnvb|1|6756575|67567567$2018-09-19
                var listParameters = HttpContext.Current.User.Identity.Name.Split('¬'); //fullName,userName

                var userName = listParameters[0];

                if (listParameters.Length > 1)
                {
                    userName = listParameters[1];
                }
                //sacar monto

                if (!string.IsNullOrEmpty((string)Session["SwitchAmort"]))
                {
                    var values      = (string)Session["dataAmort"];
                    var arrayValues = values.Split('|');
                    if (!string.IsNullOrEmpty(values))
                    {
                        brPayments = new BrPayments();
                        // (int TypePay, string IdMembershipDetail, int nQuotes, decimal NewAmort, int Rate)
                        bool ans = brPayments.Amortization(2, arrayValues[0], Int32.Parse(arrayValues[1]), decimal.Parse(arrayValues[2]), Int32.Parse(arrayValues[3]), "culqi");

                        Response.Redirect("Payments.aspx");
                        return;
                    }
                }
                else if (Session["cronograma"] != null)
                {
                    var  ej = Session["cronograma"].ToString();
                    bool registerCronograma = false;
                    //si es kit  inserte unico '2018-10-19¬31¬31¬31¬HOLA'

                    string fecha = ej.Split('$')[1];

                    //double amountKit = double.Parse("10");
                    //double tpKit = double.Parse(ej.Split('|')[1]);

                    //double totalKit = (amountKit * tpKit);
                    //string arrayKit = fecha + "¬" + totalKit.ToString() + "¬" + totalKit.ToString() + "¬" + totalKit.ToString() + "¬" + this.UserName;

                    //registerCronograma = brPayments.PutRegisterkIT(arrayKit);

                    //if (!registerCronograma)
                    //{
                    //    Response.Write("false¬Ha Ocurrido Un Error al Intentar Registrar el Kit de Inicio");
                    //    return;
                    //}
                    //var ej = "2500|3.25|VE034|VE035|23|2018-09-19|1944|10|1|obs^2018-09-19|1944~nombre|apellido|1|45345345|45345345$2018-10-19";
                    //1|EXP  ^6300.00|3.25|empty|empty|60|2018-10-17|2047.5|10|1|empty^2018-10-17|2047.5~Jose|dcvsdf|1966660000|966660000$2018-11-01
                    string respData = brPayments.PersonGetData(userName);  //1|EXP|knava vs|CLB^3000|3.2|VE034|VE035|24|2018-10-10|soles1000|10|1|obs^2018-10-11|1000~nombres|apellidos|1|73680066|963258741$2018-10-12
                    respData = respData + '^' + ej;
                    brUser   = new BrUser();
                    string data3 = Session["financedAmount"].ToString();
                    //  Int32 ansNmembershi = brUser.RegisterNmembership(TypeMembership + '|' + userName, data3);
                    // registerCronograma = brPayments.GetCalculatePaymentSchedule(respData, this.NewUserName, ansNmembershi);


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

                    this.IsCronograma = 1;
                    // en el caso que tenga cronograma de pagos
                    BrUser brUser2 = new BrUser();
                    //this.UserName = "******";
                    //monto a pagar en el registro
                    this.username_idmen_amount_email = brUser2.getAmountPay(this.NewUserName).Split('¬');
                    //username¬amount¬email
                    brUser2 = null;

                    if (this.username_idmen_amount_email.Length < 4)
                    {
                        Response.Write("false¬Ha Ocurrido un Error al Intentar Verificar el Monto a Pagar");
                        return;
                    }

                    if (Session["exonerar"] != null)
                    {
                        if (Session["exonerar"].ToString() == "true")
                        {
                            this.Exonerar = 1;
                        }
                    }


                    var change = HttpContext.Current.User.Identity.Name.Split('¬')[5];
                    //le agrego el monto del kit
                    //username_idmen_amount_email[2] = (double.Parse(username_idmen_amount_email[2]) + (double.Parse("10") * double.Parse(change))).ToString();
                }
                else
                {
                    this.CodeIgnore = 1;
                }
                Email email2 = new Email();
                if (!email2.SubmitEmail(arrayaccount[0].Trim(), "[USUARIO_REGISTRADO]", "Tu usuario Es :" + this.NewUserName.ToUpper() + "\n" + "Tu contraseña es:" + this.NewUserName.ToUpper()))
                {
                    Response.Write("false¬Ha Ocurrido un Error al Intentar Enviarle un Email Con Sus Datos de su Cuenta");
                    return;
                }
                email2 = null;
            }
            else
            {
                if (Session["kit"] != null)
                {
                    this.CodeIgnore = 1;
                }
                else
                {
                    var login = HttpContext.Current.User.Identity.Name.Split('¬');
                    if (login.Length > 1)
                    {
                        this.IdMembreship = int.Parse(Session["numMembershipDet"].ToString());
                        BrUser brUser1 = new BrUser();
                        this.NewUserName = login[1];
                        this.username_idmen_amount_email = brUser1.getAmountPay(this.IdMembreship, this.NewUserName).Split('¬');
                        brUser1 = null;
                        if (this.username_idmen_amount_email.Length < 4)
                        {
                            Response.Write("false¬Ha Ocurrido un Error al Intentar Verificar el Monto a Pagar");
                            return;
                        }
                    }
                    else
                    {
                        Response.Write("false¬Intentelo mas Tarde");
                        return;
                    }
                }
            }
            /*end register user and general account*/


            /*page on line*/

            if (this.CodeIgnore == 0)
            {
                if (username_idmen_amount_email.Length < 4)
                {
                    Response.Write("false¬Ha Ocurrido un Error al Intentar Verificar el Monto a Pagar");
                    return;
                }
            }


            double monto = 0;

            //solo el kit
            if (this.CodeIgnore == 1)
            {
                monto = double.Parse("10") * double.Parse(Session["tipocambio"].ToString());
            }

            if (this.CodeIgnore == 0)
            {
                if (this.Exonerar != 1)
                {
                    monto = double.Parse(username_idmen_amount_email[2]) + (double.Parse("10") * double.Parse(Session["tipocambio"].ToString()));
                }

                else
                {
                    monto = double.Parse(username_idmen_amount_email[2]);
                }
            }


            PayCulqi payCulqi     = new PayCulqi();
            string   currencyCode = "PEN";

            string[] culqiAnwser = payCulqi.newPayment(this.NewUserName, "*****@*****.**", monto, parameterToken, this.NumberQuotes, currencyCode).Split('¬');


            string miemail = "";

            if (this.CodeIgnore == 1)
            {
                miemail = Session["email"].ToString();
            }
            else
            {
                miemail = username_idmen_amount_email[3];
                brUser  = new BrUser();
                bool habiliAccount = brUser.enableAcount(int.Parse(username_idmen_amount_email[1]), "");
                brUser = null;
                //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 email = new Email();

            if (email.SubmitEmail(miemail, "[RIBERA DEL RIO - PAGO]", "Ud. Ha efectuado su pago en Ribera del Rio con Exito."))
            {
                email = null;
                Response.Clear();
                Response.Write("true¬" + culqiAnwser[1]);
                Session["datos"] = null;
                return;
            }
            Response.Write("false");
            return;
        }