Exemplo n.º 1
0
        public ActionResult Buy()
        {
            try
            {
                string Biller = "6";
                TempData["message"]    = LoadImage(Biller);
                TempData["BillerName"] = getDiscoName(Biller);

                Internetserviceprovider.InternetServiceObj cusdataobj =
                    new Internetserviceprovider.InternetServiceObj();
                cusdataobj = (Internetserviceprovider.InternetServiceObj)TempData["cusdataobj"];
                MethodName = "planchangelist";
                var CustomerID = cusdataobj.CustomerID;

                HttpWebRequest request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName);
                request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName);
                //var val = ChekMyIP();
                using (WebResponse response = request.GetResponse())
                {
                    using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                    {
                        soapResult = rd.ReadToEnd();
                        soapResult = soapResult.Replace(@"\", "");
                        var    soapResults = soapResult.Substring(1);
                        string sp          = soapResults.Substring(0, soapResults.Length - 1);
                        JArray jObj        = JArray.Parse(sp);
                        ViewBag.Data = jObj.ToList();

                        // var value = jObj[0];
                    }
                }

                //SoapResult = SoapResult.Replace(@"\", "");
                //JArray jObj = JArray.Parse(SoapResult);
                //ViewBag.Data = jObj;
                return(View(cusdataobj));
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Exemplo n.º 2
0
 public ActionResult Checkout()
 {
     try
     {
         string Biller = "6";
         TempData["message"]    = LoadImage(Biller);
         TempData["BillerName"] = getDiscoName(Biller);
         Internetserviceprovider.InternetServiceObj cusdataobj =
             new Internetserviceprovider.InternetServiceObj();
         cusdataobj = (Internetserviceprovider.InternetServiceObj)TempData["cusdataobj"];
         double TotalAmt = Convert.ToDouble(cusdataobj.Amount) + Convert.ToDouble(cusdataobj.ConvFee);
         TempData["TotalAmt"]      = TotalAmt;
         cusdataobj.transactionlNo = isp.SerialNum();
         InsertTransactionLog(cusdataobj);
         return(View(cusdataobj));
     }
     catch (Exception ex)
     {
         WebLog.Log(ex.Message.ToString());
         return(null);
     }
 }
Exemplo n.º 3
0
        public string ValidatePayRequest(string CustomerID)
        {
            try
            {
                dynamic AgentObj = new JObject();
                AgentObj.CustomerID = CustomerID;

                Internetserviceprovider.InternetServiceObj cusdataobj =
                    new Internetserviceprovider.InternetServiceObj();
                string soapResult = "";
                var    Resp       = "";
                string MethodName = "";
                MethodName = ConfigurationManager.AppSettings["Fetchuser"];
                // var CustomerID = AgentObj.CustomerID;

                Internetserviceprovider.CustomerObj ispObject = new Internetserviceprovider.CustomerObj();
                //Customer Validation
                if (string.IsNullOrEmpty(CustomerID))
                {
                    soapResult =
                        new JObject(
                            new JProperty("status", "error"),
                            new JProperty("message", "Empty CustomerID"),
                            new JProperty("data", new JObject(soapResult))).ToString();
                    //return Json(soapResult);
                    return(soapResult.ToString());
                }

                var    req       = Request;
                var    headers   = req.Headers;
                string myAgentID = "";
                try
                {
                    myAgentID = headers.GetValues("agentID").First() ?? "";
                }
                catch
                {
                    WebLog.Log("Cannot Read AgentID as header");
                }

                var agentID   = headers.GetValues("agentID").First() ?? "";
                var agentKey  = headers.GetValues("agentKey").First() ?? "";
                var signature = headers.GetValues("signature").First() ?? "";

                AgentObj.AgentID   = agentID;
                AgentObj.AgentKey  = agentKey;
                AgentObj.Signature = signature;
                var Authenticated = IsTransactionAutheticated(AgentObj);

                if (Authenticated == false)
                {
                    soapResult =
                        new JObject(
                            new JProperty("status", "Error"),
                            new JProperty("message", "Authentication Failed"),
                            new JProperty("data", new JObject())).ToString();
                    // return Json(soapResult);
                    return(soapResult.ToString());
                }
                //var CustomerID = ispObject.CustomerID;
                Internetserviceprovider intnets = new Internetserviceprovider();
                HttpWebRequest          request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName);
                request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName);
                //var val = ChekMyIP();
                using (WebResponse response = request.GetResponse())
                {
                    using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                    {
                        soapResult = rd.ReadToEnd();
                        soapResult = soapResult.Replace(@"\", "");
                        var soapResults = soapResult.Substring(1);
                    }
                }
                if (soapResult == null)
                {
                    //return Json(soapResult);
                    return(soapResult.ToString());
                }
                if (soapResult != null)
                {
                    // return Json(soapResult);
                    return(soapResult.ToString());
                }
                // return Json(soapResult);
                return(soapResult.ToString());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex);
                var obj =
                    new JObject(
                        new JProperty("status", "error"),
                        new JProperty("message", $"{ex.Message}"),
                        new JProperty("data", new JObject()));
                //return Json(obj);
                return(obj.ToString());
            }
        }
Exemplo n.º 4
0
        public ActionResult BuyAirtime(FormCollection form, Internetserviceprovider.InternetServiceObj AirtimeObj)
        {
            try
            {
                dynamic        Jobj        = new JObject();
                string         Paymenttype = "";
                Paytv.PaytvObj PaytvObj    = new Paytv.PaytvObj();
                // i added this line today for Validation
                Classes.Internetserviceprovider.InternetServiceObj _ptv    = new Classes.Internetserviceprovider.InternetServiceObj();
                Classes.Internetserviceprovider.InternetServiceObj Airtime = new Classes.Internetserviceprovider.InternetServiceObj();
                string user = LoggedInuser.LoggedInUser();
                if (user != null)
                {
                    // dynamic Airtime = new JObject();

                    Airtime.Amount     = AirtimeObj.Amount;
                    Airtime.Phone      = AirtimeObj.CustomerID;
                    Airtime.CustomerID = AirtimeObj.CustomerID;

                    Paymenttype         = Convert.ToString(form["paymenttype"]);
                    Airtime.paymentType = Convert.ToInt16(Paymenttype);
                    var service = Convert.ToString(form["Recuring"]);
                    if (service.StartsWith("Select"))
                    {
                        TempData["PaytvObj"] = Airtime;
                        //TempData["message"] = PaytvObj.BillerName;
                        //TempData["BillerName"] = PaytvObj.BillerImg;
                        TempData["Msg"] = "Please Select Airtime !";
                        return(Redirect("/Airtime/BuyAirtime/"));
                    }
                    service            = service.After("Airtime/").Trim();
                    service            = service.Before(".").Trim();
                    Airtime.Service    = service;
                    AirtimeObj.Service = Airtime.Service;
                    string services = AirtimeObj.Service;


                    string amount = Airtime.Amount;
                    string phone  = Airtime.Phone;

                    if (amount == "" || phone == "")
                    {
                        return(View());
                    }
                    bool Result = newutil.ValidateNum(amount, phone);
                    if (Result == false)
                    {
                        return(View());
                    }
                    string Phones      = "";
                    bool   ValidAmount = newutil.ValidateAmount(amount);
                    if (ValidAmount == false)
                    {
                        TempData["PaytvObj"] = Airtime;
                        // TempData["message"] = PaytvObj.BillerName;
                        //TempData["BillerName"] = PaytvObj.BillerImg;
                        TempData["Msg"] = "Amount Must Be Than N50!";
                        return(Redirect("/Airtime/BuyAirtime/"));
                    }
                    var isValid = Utility.ValidatePhoneNumber(phone, out Phones);
                    if (isValid == false)
                    {
                        TempData["PaytvObj"] = Airtime;
                        // TempData["message"] = PaytvObj.BillerName;
                        //TempData["BillerName"] = PaytvObj.BillerImg;
                        TempData["Msg"] = "Invalid Phone Number!";
                        return(Redirect("/Airtime/BuyAirtime/"));
                    }

                    PaytvObj.Amount         = AirtimeObj.Amount;
                    PaytvObj.CustomerID     = AirtimeObj.CustomerID;
                    PaytvObj.Service        = AirtimeObj.Service;
                    PaytvObj.transactionlNo = Utility.GenerateAlphanumericUniqueId(30);
                    PaytvObj.transactionlNo = "VTU" + PaytvObj.transactionlNo;
                    PaytvObj.Phone          = AirtimeObj.Phone;
                    PaytvObj.ConvFee        = ConfigurationManager.AppSettings["payviceConvFee"];
                    PaytvObj.paymentType    = Convert.ToInt16(Paymenttype);
                    PaytvObj.MerchantId     = getmerchantID(services);
                    // PaytvObj.MerchantId = 300;
                    // var RefNum = PaytvObj.transactionlNo;

                    string RefNum = paytvcontroller.InsertTransactionLog(PaytvObj);
                    return(RedirectToAction("Checkout", new { @RefNum = RefNum }));
                    //return View(PaytvObj);
                    //   }


                    // }
                    // return View();
                }
                return(View());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Exemplo n.º 5
0
        public ActionResult Buy(Internetserviceprovider.InternetServiceObj cusdata, FormCollection form)
        {
            try
            {
                Internetserviceprovider.InternetServiceObj cusdataobj =
                    new Internetserviceprovider.InternetServiceObj();
                string service = "";
                cusdataobj.Amount     = cusdata.Amount;
                cusdataobj.ConvFee    = ConfigurationManager.AppSettings["SpectranetConvFee"];
                cusdataobj.CustomerID = cusdata.CustomerID;
                cusdataobj.Phone      = cusdata.Phone;
                service = Convert.ToString(form["Services"]);
                var Bouquet = service.Before("+").Trim();
                service = service.After("+").Trim();

                cusdataobj.Service = service;

                cusdataobj.customerName  = cusdata.customerName;
                cusdataobj.Bouquet       = Bouquet;
                cusdataobj.Email         = cusdata.Email;
                cusdataobj.paymentPlanId = cusdata.paymentPlanId;
                cusdataobj.paymentType   = Convert.ToInt32(form["Recuring"]);
                string Phone  = cusdataobj.Phone;
                string Phones = "";
                service = cusdataobj.Service;
                string PaymentType = Convert.ToString(cusdataobj.paymentType);

                // For Top-Up
                if (cusdataobj.Service == "Top-up")
                {
                    cusdataobj.Pin     = cusdata.Pin;
                    cusdataobj.Voucher = cusdata.Voucher;
                    if (cusdataobj.Pin == null)
                    {
                        TempData["Msg"] = "Input Pin";
                        RedirectToAction("Buy");
                    }
                    if (cusdataobj.Voucher == null)
                    {
                        TempData["Msg"] = "Input Voucher";
                        RedirectToAction("Buy");
                    }
                }
                //For Phone Numbers
                var isValid = Utility.ValidatePhoneNumber(Phone, out Phones);
                if (isValid == false)
                {
                    TempData["cusdataobj"] = cusdataobj;
                    TempData["Msg"]        = "Invalid Phone Number!";
                    return(Redirect("/Isp/Buy/"));
                }

                //Service Type
                if (service == "Select Service type")
                {
                    TempData["cusdataobj"] = cusdataobj;
                    TempData["Msg"]        = "Please Select Service Type!";
                    return(Redirect("/Isp/Buy/"));
                }
                // Payment Type
                if (PaymentType == "Select Payment type")
                {
                    TempData["cusdataobj"] = cusdataobj;
                    TempData["Msg"]        = "Please Select Payment Type!";
                    return(Redirect("/Isp/Buy/"));
                }
                TempData["cusdataobj"] = cusdataobj;
                return(RedirectToAction("Checkout"));
                //return View(cusdataobj);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Exemplo n.º 6
0
        public string InsertTransactionLog(Internetserviceprovider.InternetServiceObj IspObj)
        {
            try
            {
                string RefNum = "";
                //string user = LoggedInuser.LoggedInUser();
                //if (user != null)
                //{
                IspObj.transactionlNo = IspObj.transactionlNo;
                DateTime Dates = DateTime.Now;
                // int userid = _dr.GetUserIdByEmail(user);
                int userid = 001;
                _ct.ReferenceNumber = Convert.ToString(IspObj.transactionlNo);
                var valid = _dr.ValidateCusTranc(_ct.ReferenceNumber);
                _tL.ReferenceNumber = Convert.ToString(IspObj.transactionlNo);
                var valids = _dr.ValidateCusTrancLog(_tL.ReferenceNumber);
                if (valid == false)
                {
                    _tL.Amount          = Convert.ToDouble(IspObj.Amount);
                    _tL.CustomerID      = IspObj.CustomerID;
                    _tL.CustomerName    = IspObj.customerName;
                    _tL.Customer_FK     = userid;
                    _tL.Merchant_FK     = 1;
                    _tL.ServiceCharge   = Convert.ToDouble(ConfigurationManager.AppSettings["SpectranetConvFee"]);
                    _tL.TrnDate         = Dates;
                    _tL.ValueDate       = DateTime.Now.ToString("yyyy:mm:ss");
                    _tL.ValueTime       = DateTime.Now.ToString("yyyy:mm:ss");
                    _tL.ServiceDetails  = IspObj.Service;
                    _tL.TransactionType = 1;
                    _tL.PaymentType     = IspObj.paymentType;
                    _tL.Pin             = IspObj.Pin;
                    _tL.Voucher         = IspObj.Voucher;
                    _tL.ServiceCode     = IspObj.Bouquet;
                }
                _dc.InitiateTransacLog(_tL);

                _pL.ReferenceNumber = Convert.ToString(IspObj.transactionlNo);
                var validpl = _dr.ValidatePayTrancLog(_tL.ReferenceNumber);
                if (valid == false)
                {
                    _pL.CustomerPhoneNumber = IspObj.Phone;
                    _pL.Amount       = Convert.ToDouble(IspObj.Amount);
                    _pL.CustomerID   = IspObj.CustomerID;
                    _pL.CustomerName = IspObj.customerName;

                    _pL.ServiceCharge       = Convert.ToDouble(ConfigurationManager.AppSettings["SpectranetConvFee"]);
                    _pL.ValueDate           = DateTime.Now.ToString("yyyy:mm:ss");
                    _pL.ValueTime           = DateTime.Now.ToString("yyyy:mm:ss");
                    _pL.ReferenceNumber     = IspObj.transactionlNo;
                    _pL.TrnDate             = Dates;
                    _pL.CustomerEmail       = IspObj.Email;
                    _pL.ResponseDescription = "initiated";
                    // }
                    RefNum = _pL.ReferenceNumber;
                    _dc.InitiatePaymentLog(_pL);
                }
                return(RefNum);
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return("");
            }
        }
Exemplo n.º 7
0
        public ActionResult Checkout(FormCollection form, Internetserviceprovider.InternetServiceObj cusdata)
        {
            try
            {
                Classes.Paytv.PaytvObj paytv  = new Paytv.PaytvObj();
                Classes.Paytv.PaytvObj paytvs = new Paytv.PaytvObj();
                paytv  = (Classes.Paytv.PaytvObj)ViewBag.PaytvObj;
                paytvs = (Classes.Paytv.PaytvObj)TempData["PaytvObj"];

                string Firstname   = cusdata.customerName;
                string Email       = cusdata.customerName;
                string PhoneNumber = cusdata.Phone;
                string Amount      = cusdata.Amount;
                string ConvFee     = cusdata.ConvFee;
                string RefNum      = cusdata.transactionlNo;
                cusdata.transactionlNo = RefNum;
                //string ConvFee = ConfigurationManager.AppSettings["ConvFee"];
                var    TotalAmt  = Convert.ToDecimal(Amount) + Convert.ToDecimal(ConvFee);
                string TotalAmts = TotalAmt.ToString();
                var    TranNum   = cusdata.transactionlNo;
                // int paymenttype = _dr.GetCustomerpaytype(TranNum);
                int paymenttype = 1;
                // int paymentplanId = _dr.GetPaymentPlanID(_pv.Bouquet);
                int  paymentplanId = 2;
                bool isNum         = Decimal.TryParse(TotalAmts, out TotalAmt);

                if (isNum)
                {
                    PaymentManager.Payment PayObj = new PaymentManager.Payment();
                    PayObj.PaymentType  = paymenttype;
                    PayObj.RefNumber    = TranNum; //System.DateTime.Now.ToString("yyyyMMddHmmss");
                    PayObj.amount       = TotalAmt.ToString();
                    PayObj.customerid   = "2";
                    PayObj.customerName = Firstname;
                    PayObj.emailaddress = Email;
                    PayObj.narration    = $"{Firstname.Trim()} Payment of NGN {decimal.Parse(PayObj.amount)}";
                    PayObj.phoneNo      = PhoneNumber;

                    PayObj.returnUrl     = ConfigurationManager.AppSettings["SpecPaymentReturnUrls"];
                    PayObj.PaymentPlanID = paymentplanId;
                    //PayObj.returnUrl = GetReturnUrl(PayObj.returnUrl);
                    string formObject = PaymentManager.GetPaymentPageDatails(PayObj);
                    if (formObject != "")
                    {
                        /*string RefNum = "420020181227072633oNl8R";
                         *   // I Added This today .
                         * Requery(RefNum);*/
                        // Today I Added This For Requery*/
                        Response.Clear();
                        Response.ContentEncoding = Encoding.GetEncoding("ISO-8859-1"); Response.HeaderEncoding = Encoding.GetEncoding("ISO-8859-1");
                        Response.Charset         = "ISO-8859-1";
                        Response.Write(formObject);
                        Response.End();
                    }
                    else
                    {
                        TempData["Message"] = "Error Calling Payment Page - Code P002";
                    }
                }
                else
                {
                    TempData["Message"] = "Error Calling Payment Page - Code P002";
                }



                return(View());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }
Exemplo n.º 8
0
        public ActionResult Check(FormCollection form)
        {
            try
            {
                Internetserviceprovider.InternetServiceObj cusdataobj =
                    new Internetserviceprovider.InternetServiceObj();
                string soapResult = "";

                MethodName = ConfigurationManager.AppSettings["Fetchuser"];
                var CustomerID = Convert.ToString(form["CustomerId"]);
                Internetserviceprovider.CustomerObj ispObject = new Internetserviceprovider.CustomerObj();

                //var CustomerID = ispObject.CustomerID;
                Internetserviceprovider intnets = new Internetserviceprovider();
                HttpWebRequest          request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName);
                request = Internetserviceprovider.CreateWebRequest(CustomerID, MethodName);
                //var val = ChekMyIP();
                using (WebResponse response = request.GetResponse())
                {
                    using (StreamReader rd = new StreamReader(response.GetResponseStream()))
                    {
                        soapResult = rd.ReadToEnd();
                        soapResult = soapResult.Replace(@"\", "");
                        var soapResults =
                            soapResult.Substring(1);

                        string sp = soapResults.Substring(0, soapResults.Length - 1);
                        // JArray jObj = JArray.Parse(sp);


                        // var value = jObj[0];
                        // soapResult = soapResult.Replace(@"\", "");
                        dynamic jobj = JObject.Parse(sp);
                        if (jobj != null && $"{jobj?.soapenvBody?.ns1processResponse?.processReturn?.errorCode}".ToLower() == "0")
                        {
                            var soapObj   = jobj?.soapenvBody?.ns1processResponse?.processReturn?.keyParam?.keyParam;
                            var lastname  = "";
                            var firstname = "";
                            foreach (var item in soapObj)
                            {
                                var keys = item.key;
                                //if(keys == "lastTotalTime")
                                //{
                                //    var keyvalue = item.value;
                                //}
                                if (keys == "userName")
                                {
                                    cusdataobj.userName = item.value;
                                    var value = item.value;
                                }
                                if (keys == "lastName")
                                {
                                    lastname = item.value;
                                    //var value = item.value;
                                }
                                if (keys == "email")
                                {
                                    cusdataobj.Email = item.value;
                                    var value = item.value;
                                }
                                if (keys == "userId")
                                {
                                    cusdataobj.CustomerID = item.value;
                                }
                                if (keys == "firstName")
                                {
                                    firstname = item.value;
                                    //var value = item.value;
                                }
                                cusdataobj.customerName = firstname + lastname;
                                TempData["cusdataobj"]  = cusdataobj;

                                //return RedirectToAction("");
                            }
                            return(RedirectToAction("Buy"));
                        }
                        else if (jobj == null)
                        {
                            TempData["message"] = "Please Try Again";
                            return(RedirectToAction("Check"));
                        }
                        else if (jobj != null && $"{jobj?.soapenvBody?.ns1processResponse?.processReturn?.errorCode}".ToLower() == "-103")
                        {
                            TempData["Msg"] = $"{jobj?.soapenvBody?.ns1processResponse?.processReturn?.errorMessage}".ToLower();
                            return(RedirectToAction("Check"));
                        }
                    }
                }


                return(View());
            }
            catch (Exception ex)
            {
                WebLog.Log(ex.Message.ToString());
                return(null);
            }
        }