public ActionResult BuyAirtime() { try { string user = LoggedInuser.LoggedInUser(); if (user == null || user == "") { user = LoggedInuser.getDefaultUser(); } if (user != null) { Classes.Internetserviceprovider.InternetServiceObj _ptv = new Classes.Internetserviceprovider.InternetServiceObj(); // if (TempData["message"] != null) if (TempData["PaytvObj"] != null) { _ptv = (Internetserviceprovider.InternetServiceObj)TempData["PaytvObj"]; var a = TempData["message"]; var b = TempData["BillerName"]; //TempData["Msg"] = "No Internet Connection"; return(View(_ptv)); } } return(View()); } catch (Exception ex) { WebLog.Log(ex.Message.ToString()); return(null); } }
public ActionResult Checkout(Classes.Paytv.PaytvObj _pv) { try { int PayMethod = PaymentMethod(_pv.paymethod); string user = LoggedInuser.LoggedInUser(); if (user != null && PayMethod == 0) { 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 = _pv.CustomerID; string Email = _pv.CustomerID; string PhoneNumber = _pv.CustomerID; string Amount = _pv.Amount; string ConvFee = _pv.ConvFee; //string ConvFee = ConfigurationManager.AppSettings["ConvFee"]; var TotalAmt = Convert.ToDecimal(Amount) + Convert.ToDecimal(ConvFee); string TotalAmts = TotalAmt.ToString(); var TranNum = _pv.transactionlNo; // i have to uncomment out this Line int paymenttype = _dr.GetCustomerpaytype(TranNum); // int paymenttype = 1; int paymentplanId = _dr.GetPaymentPlanID(_pv.Bouquet); 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["PavicePaymentReturnUrl"]; PayObj.PaymentPlanID = paymentplanId; //PayObj.returnUrl = GetReturnUrl(PayObj.returnUrl); string formObject = PaymentManager.GetPaymentPageDatails(PayObj); if (formObject != "") { 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"; } } else { if (user != null && PayMethod == 1) { var userid = _dr.getUserID(user); var WalletBalance = _dr.WalletBalance(userid.id); double Amount = Convert.ToDouble(_pv.Amount); if (WalletBalance >= Amount) { dynamic response = paySubscribtion(_pv.transactionlNo); TempData["ErrMsg"] = "Transaction Successful!"; Receipt(response, _pv.transactionlNo); _tL.ReferenceNumber = _pv.transactionlNo; var id = _dc.InsertCustomerWallet(_tL); } else if (WalletBalance < Amount) { Classes.Internetserviceprovider.InternetServiceObj _ptv = new Classes.Internetserviceprovider.InternetServiceObj(); _ptv.Amount = _pv.Amount; _ptv.CustomerID = _pv.CustomerID; _ptv.transactionlNo = _pv.transactionlNo; _ptv.Service = _pv.Service; _pv.ConvFee = "0"; TempData["TotalAmt"] = _pv.Amount; TempData["PaytvObj"] = _ptv; TempData["Msg"] = "Low Balance In Wallet !"; return(Redirect("/Airtime/Checkout/")); } return(RedirectToAction("WalletReceipt", new { @RefNum = _tL.ReferenceNumber })); } } return(View()); } catch (Exception ex) { WebLog.Log(ex.Message.ToString()); return(null); } }
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); } }