public async Task <ActionResult> FathersDayPaymentConfirmation() { var tk = oEventClassModel.GetClientProfileDetails("001"); if (tk == null) { return(RedirectToAction("Index", "Home")); } string secretKey = tk.ClientPayStackSecretKey; var paystackTransactionAPI = new PaystackTransaction(secretKey); var tranxRef = HttpContext.Request.QueryString["reference"]; if (tranxRef != null) { var response = await paystackTransactionAPI.VerifyTransaction(tranxRef); if (response.status) { oEventClassModel.UpdatePaymentStatus(tranxRef); oGenericViewModel.tk_EventCustomers = oEventClassModel.GetCustomerInfo(tranxRef); oGenericViewModel.tk_Event = oEventClassModel.GetEventInfo(Convert.ToInt32(oGenericViewModel.tk_EventCustomers.TicketCategory)); oGenericViewModel.TransactionRef = tranxRef; //Insert Into Transaction Log oEventClassModel.SaveIntoTransactionLog(tranxRef); return(View(oGenericViewModel)); } } return(View(oGenericViewModel)); }
public async Task <ActionResult> VerifyPayment() { string reference = (string)Session["paymentRef"]; string secretKey = ConfigurationManager.AppSettings["PayStackSec"]; var paystackTransactionApi = new PaystackTransaction(secretKey); var response = await paystackTransactionApi.VerifyTransaction(reference); if (response.status && response.data.status.Equals("success")) { //string userId = User.Identity.GetUserId(); //var loggedInUser = _repo.GetUserById(userId); //loggedInUser.ActiveSub = true; //Index var month = Convert.ToInt32(TempData["month"]); var startDate = DateTime.Now; var endDate = DateTime.Now.AddDays(month * 31); //UserIdentity.userEmail = User.Identity.GetUserName(); //UserIdentity.ValidityPeriod = endDate - startDate; //_repo.Save(); //int providerId = (int)Session["providerId"]; // Session["paymentRef"] = null; //return RedirectToAction("Details", "Provider", new { id = providerId }); } return(RedirectToAction("Failed")); }
private static async void VerifyTransaction() { var paystackTransactionAPI = new PaystackTransaction("apikey/secret/key"); var response = await paystackTransactionAPI.VerifyTransaction("T262788937392358"); var json = new JavaScriptSerializer().Serialize(response); //contentDiv.InnerText = json; }
private static async void VerifyTransaction() { var paystackTransactionAPI = new PaystackTransaction("apikey/secret/key"); var response = await paystackTransactionAPI.VerifyTransaction("reference"); var json = new JavaScriptSerializer().Serialize(response); Console.WriteLine(json); }
public async Task <ActionResult> PaymentConfirmationFm() { var tk = await oMoviesModelClass.GetClientProfileDetails("001"); if (tk == null) { return(RedirectToAction("Index", "Home")); } string secretKey = tk.ClientPayStackSecretKey; var paystackTransactionAPI = new PaystackTransaction(secretKey); var tranxRef = HttpContext.Request.QueryString["reference"]; if (tranxRef != null) { var response = await paystackTransactionAPI.VerifyTransaction(tranxRef); if (response.status) { oMoviesModelClass.SaveSms(tranxRef); oMoviesModelClass.UpdatePaymentStatus(tranxRef); oGenericViewModel.tk_CinemaTransactionLog = oMoviesModelClass.GetTicketDetails(tranxRef); oGenericViewModel.TransactionRef = tranxRef; var BatchCounter = oMoviesModelClass.GetCurrentCounter(); #region FilmHouse Call for Setting Customer Details and Getting Booking Reference if (oGenericViewModel.tk_CinemaTransactionLog != null) { oGenericViewModel.BookingId = await oMoviesModelClass.CompleteTransaction(oGenericViewModel.tk_CinemaTransactionLog.OrderId, oGenericViewModel.tk_CinemaTransactionLog.ContactFullname, oGenericViewModel.tk_CinemaTransactionLog.ContactEmail, oGenericViewModel.tk_CinemaTransactionLog.ContactPhoneNo, oGenericViewModel.tk_CinemaTransactionLog.TotalAmount.ToString()); if (oGenericViewModel.BookingId != null) { await oMoviesModelClass.UpdateBookingRef(oGenericViewModel.BookingId, tranxRef); var res = oMoviesModelClass.SendFilmHouseEmail((oGenericViewModel.tk_CinemaTransactionLog)); if (res != null) { BackgroundJob.Enqueue(() => EmailNotificationMail.SendEmailPlain(oGenericViewModel.tk_CinemaTransactionLog.ContactEmail, "Payment Receipt - " + oGenericViewModel.BookingId, res, null, "*****@*****.**")); } } } #endregion return(View(oGenericViewModel)); } } return(View(oGenericViewModel)); }
public async Task <ActionResult> Index() { string secretKey = ConfigurationManager.AppSettings["PaystackSecret"]; var paystackTransactionAPI = new PaystackTransaction(secretKey); var tranxRef = HttpContext.Request.QueryString["reference"]; if (tranxRef != null) { var response = await paystackTransactionAPI.VerifyTransaction(tranxRef); if (response.status) { try { using (var db = new LoanComparerModel()) { int currentCount = 0; currentCount = (int)Session["count"]; db.loandetails.Find((int)Session["selectedItemId"]).count = currentCount + 1; db.loandetails.Find((int)Session["selectedItemId"]).date = DateTime.Now; // Update subscription table var user = new subscription { userid = User.Identity.GetUserName().ToLower(), startdate = DateTime.Now, enddate = DateTime.Now.AddMonths(1) }; db.subscriptions.Add(user); db.SaveChanges(); } } catch (Exception e) { return(View("Error")); } return(View(response)); } } return(View("PaymentError")); }
public async Task <ActionResult> Subscribe(decimal amount) { var id = (int)Session["providerId"]; var callbackurl = Request.Url.ToString();; var price = (int)amount * 100; var useremail = User.Identity.GetUserName(); var connectionInstance = new PaystackTransaction(ConfigurationManager.AppSettings["Credential"]); var response = await connectionInstance.InitializeTransaction(useremail, price, callbackUrl : callbackurl); try { if (response.status) { Reference = response.data.reference; Response.AddHeader("Access-Control-Allow-Origin", "*"); Response.AppendHeader("Access-Control-Allow-Origin", "*"); Response.Redirect(response.data.authorization_url); //Redirects your browser to the secure URL } string reference = Reference; string secretKey = ConfigurationManager.AppSettings["Credential"]; var paystackTransactionApi = new PaystackTransaction(secretKey); var response1 = await paystackTransactionApi.VerifyTransaction(reference); if (response1.status && response1.data.status.Equals("success")) { var userid = User.Identity.GetUserId(); var username = User.Identity.GetUserName(); var sub = BusinessLogic.ActivateSubscribed(amount, "success", userid, username); _subscribed.Add(sub); if (_subscribed.comit()) { TempData["subscribe"] = $"subscription successful {sub.SubscribedMonth} months, amount {sub.AmountSubscribed} ,expiries{sub.SubscribtionExpiryDate}"; return(RedirectToAction("SiteDetails", "Loan", new { id = id })); // return RedirectToAction("MyNextAction", // new { r = Request.Url.ToString() }); // return Redirect(ReturnUrl); } } } catch (Exception e) { Console.Write(e.InnerException.ToString() ?? e.Message); } return(RedirectToAction("Failed", "Subscribed")); }
public async Task <ActionResult> VerifyPayment(string reference = null) { if (reference != null) { string secretKey = ConfigurationManager.AppSettings["PayStackSec"]; var paystackTransactionAPI = new PaystackTransaction(secretKey); var response = await paystackTransactionAPI.VerifyTransaction(reference); if (response.status && response.data.status == "success") { string userId = User.Identity.GetUserId(); User loggedInUser = _providerRepository.GetUserById(userId); var type = (string)Session["type"]; int days = type == "kilo" ? 30 : type == "mega" ? 120 : 365; bool[] checks = _subscriptionRepository.CheckUserSubscription(userId); if (checks[0]) { var sub = _subscriptionRepository.GetByUserId(userId); sub.startDate = DateTime.Now; sub.endDate = DateTime.Now.AddDays(days); sub.lastSubDate = DateTime.Now; sub.type = type; _subscriptionRepository.Save(); } else { _subscriptionRepository.Add(new Subscription { startDate = DateTime.Now, endDate = DateTime.Now.AddDays(days), lastSubDate = DateTime.Now, type = type, userId = userId }); _subscriptionRepository.Save(); } int providerId = (int)Session["providerId"]; return(RedirectToAction("Details", "Provider", new { id = providerId })); } return(RedirectToAction("Failed")); } return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> Index() { string secretKey = ConfigurationManager.AppSettings["PaystackSecret"]; var paystackTransactionAPI = new PaystackTransaction(secretKey); var tranxRef = HttpContext.Request.QueryString["reference"]; if (tranxRef != null) { var response = await paystackTransactionAPI.VerifyTransaction(tranxRef); if (response.status) { return(View(response)); } } return(View("PaymentError")); }
public async Task <ActionResult> PaymentConfirmation() { var tk = oEventClassModel.GetClientProfileDetails("001"); if (tk == null) { return(RedirectToAction("Index", "Home")); } string secretKey = tk.ClientPayStackSecretKey; var paystackTransactionAPI = new PaystackTransaction(secretKey); var tranxRef = HttpContext.Request.QueryString["reference"]; if (tranxRef != null) { var response = await paystackTransactionAPI.VerifyTransaction(tranxRef); if (response.status) { oEventClassModel.UpdatePaymentStatus(tranxRef); oGenericViewModel.tk_EventCustomers = oEventClassModel.GetCustomerInfo(tranxRef); oGenericViewModel.tk_Event = oEventClassModel.GetEventInfo(Convert.ToInt32(oGenericViewModel.tk_EventCustomers.EventId)); oGenericViewModel.TransactionRef = tranxRef; oGenericViewModel.eventCategoryName = oEventClassModel.GetTicketCategory((int)oGenericViewModel.tk_EventCustomers.TicketCategory); oGenericViewModel.EventImagePath = oEventClassModel.GetEventImagePath((int)oGenericViewModel.tk_EventCustomers.EventId); //Insert Into Transaction Log oEventClassModel.SaveIntoTransactionLog(tranxRef); var res = oEventClassModel.SendEvent((oGenericViewModel.tk_EventCustomers)); if (res != null) { BackgroundJob.Enqueue(() => EmailNotificationMail.SendEmailPlain(oGenericViewModel.tk_EventCustomers.Email, "Payment Receipt - " + oGenericViewModel.tk_EventCustomers.ReferenceNo, res, null, "*****@*****.**")); } return(View(oGenericViewModel)); } } return(View(oGenericViewModel)); }
public async Task <ActionResult> PaymentCallBack() { var tranxRef = HttpContext.Request.QueryString["reference"]; if (!string.IsNullOrWhiteSpace(tranxRef)) { var paystackSec_Key = ConfigurationManager.AppSettings["PayStackKey"].ToString(); var payStackAPI = new PaystackTransaction(paystackSec_Key); var response = await payStackAPI.VerifyTransaction(tranxRef); if (response.status) { var subscriberInfo = repo.GetSubscription(tranxRef); var planId = subscriberInfo.PlanId; var subscriptionStartDate = DateTime.Now.AddMonths(1); var payStckSubscription = new Paystack.Net.SDK.Subscription.PaystackSubscription(paystackSec_Key); var subscriptionResponse = await payStckSubscription.CreateSubscription(response.data.customer.email, planId, response.data.authorization.authorization_code, subscriptionStartDate.ToString("s")); var customer = repo.GetCustomerByEmail(response.data.customer.email); if (subscriptionResponse.status) { var data = subscriptionResponse.data; repo.CreateSubscriberAccount(response.data.customer.email, "password", planId, data.subscription_code, data.email_token, subscriptionStartDate); repo.UpdateSubscription(tranxRef); } return(RedirectToAction("Success")); } else { return(RedirectToAction("error")); } } return(RedirectToAction("error")); }
public async Task <ActionResult> PaymentConfirmation() { var tk = await oMoviesModelClass.GetClientProfileDetails("001"); if (tk == null) { return(RedirectToAction("Index", "Home")); } string secretKey = tk.ClientPayStackSecretKey; var paystackTransactionAPI = new PaystackTransaction(secretKey); var tranxRef = HttpContext.Request.QueryString["reference"]; if (tranxRef != null) { var response = await paystackTransactionAPI.VerifyTransaction(tranxRef); if (response.status) { oMoviesModelClass.SaveSms(tranxRef); oMoviesModelClass.UpdatePaymentStatus(tranxRef); oGenericViewModel.tk_CinemaTransactionLog = oMoviesModelClass.GetTicketDetails(tranxRef); oGenericViewModel.TransactionRef = tranxRef; var BatchCounter = oMoviesModelClass.GetCurrentCounter(); var res = oMoviesModelClass.SendGenesisMaturionEmail((oGenericViewModel.tk_CinemaTransactionLog)); if (res != null) { BackgroundJob.Enqueue(() => EmailNotificationMail.SendEmailPlain(oGenericViewModel.tk_CinemaTransactionLog.ContactEmail, "Payment Receipt - " + oGenericViewModel.tk_CinemaTransactionLog.ReferenceNo, res, null, "*****@*****.**")); } return(View(oGenericViewModel)); } } return(View(oGenericViewModel)); }