public void UpdateAppUserMobilePayer(long AppUserId, string szMobilePayer) { try { _NGSubscriptionsEntities.UpdateGameZoneAppUserMobilePayer(AppUserId, szMobilePayer); } catch (Exception ex) { throw ex; } }
public ActionResult SubResponse(string resp = null) { try { //Get User ID //Put Valid Login User Data in Session var userData = (LoginAppUserVM)GameUserIdentity.LoggedInUser; if (userData == null) { System.Web.HttpContext.Current.Session["fltwvSubscription"] = "Session timed out. Please try again."; return(RedirectToAction("Subscription", "Home", new { msisdn = "", go = false, mobi = false, heda = 0, frmGame = false, uID = 0 })); } //Check for valid Exisiting Subscription var subscriptionConfirm = _NGSubscriptionsEntities.ConfirmAppUserSubscription(userData.AppUserId, null, svcName, null, null, false).FirstOrDefault(); //Valid Subscription Exists if (subscriptionConfirm.isSuccess) { System.Web.HttpContext.Current.Session["fltwvSubscription"] = "You already have an active Subscription."; return(RedirectToAction("Subscription", "Home", new { msisdn = "", go = false, mobi = false, heda = 0, frmGame = false, uID = userData.AppUserId })); } new Thread(() => { _Log.Info(JsonConvert.SerializeObject(new LogVM() { Message = "User Making Payment", LogData = userData })); }).Start(); var responseJSON = JsonConvert.DeserializeObject <FlutterWaveJSONVM>(resp); #region Confirm Payment var data = new { flw_ref = responseJSON.tx.flwRef, SECKEY = testFlutterwaveSecKey, normalize = "1" }; var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); var responseMessage = client.PostAsJsonAsync("http://flw-pms-dev.eu-west-1.elasticbeanstalk.com/flwv3-pug/getpaidx/api/verify", data).Result; var responseStr = responseMessage.Content.ReadAsStringAsync().Result; var verifyRspJSON = JsonConvert.DeserializeObject <FlutterWavePayVerifyJSONVM>(responseStr); #region Log new Thread(() => { _Log.Info(JsonConvert.SerializeObject(new LogVM() { Message = "Payment Verification Result", LogData = verifyRspJSON.data })); }).Start(); #endregion #region Verify Payment was really successful //Verify Success Status, Amount Paid and chargeResponse if (verifyRspJSON.data.status.ToLower() != "successful" && verifyRspJSON.data.flwMeta.chargeResponse != "00" || verifyRspJSON.data.status.ToLower() != "successful" && verifyRspJSON.data.flwMeta.chargeResponse != "0") { //Transaction Failed System.Web.HttpContext.Current.Session["fltwvSubscription"] = "Sorry. Your subscription failed. Please try again later."; return(RedirectToAction("Subscription", "Home", new { msisdn = "", go = false, mobi = false, heda = 0, frmGame = false, uID = userData.AppUserId })); } else { int subscriptionPeriod = 0; //Daily Subscription if (verifyRspJSON.data.amount >= (int)GameZonePrice.Daily && verifyRspJSON.data.amount < (int)GameZonePrice.Weekly) { subscriptionPeriod = (int)GameZonePrice.Daily; } //Weekly Subscription if (verifyRspJSON.data.amount >= (int)GameZonePrice.Weekly && verifyRspJSON.data.amount < (int)GameZonePrice.Monthly) { subscriptionPeriod = (int)GameZonePrice.Weekly; } //Weekly Subscription if (verifyRspJSON.data.amount >= (int)GameZonePrice.Monthly) { subscriptionPeriod = (int)GameZonePrice.Monthly; } DateTime periodEnd = (subscriptionPeriod == (int)GameZonePrice.Daily) ? DateTime.Now.AddDays(1) : (subscriptionPeriod == (int)GameZonePrice.Weekly) ? DateTime.Now.AddDays(7) : DateTime.Now.AddDays(30); //Save Subscription Data in DB var rezolt = _NGSubscriptionsEntities.AddServiceSubscription(userData.AppUserId, svcName, Enum.GetName(typeof(GameZonePrice), subscriptionPeriod), DateTime.Now, periodEnd, verifyRspJSON.data.amount, true, true, DateTime.Now).FirstOrDefault(); //Update User Mobile Payer Record _NGSubscriptionsEntities.UpdateGameZoneAppUserMobilePayer(userData.AppUserId, null); System.Web.HttpContext.Current.Session["fltwvSubscription"] = "Your subscription was successful."; //ViewBag.subscriptionSuccessful = "Your subscription was successful."; return(RedirectToAction("Subscription", "Home", new { msisdn = "", go = false, mobi = false, heda = 0, frmGame = false, uID = userData.AppUserId })); } #endregion #endregion } catch (Exception ex) { #region Log new Thread(() => { _Log.Error(JsonConvert.SerializeObject(new LogVM() { Message = "Exception", LogData = ex })); }).Start(); #endregion throw ex; } }