public async Task <ActionResult> Pay(string type)
        {
            if (!String.IsNullOrWhiteSpace(type))
            {
                string secretKey = ConfigurationManager.AppSettings["PayStackSec"];
                var    paystackTransactionAPI = new PaystackTransaction(secretKey);
                string email = User.Identity.GetUserName();

                int amount = type == "kilo" ? 100000 :
                             type == "mega" ? 360000 : 960000;

                var response = await paystackTransactionAPI.InitializeTransaction(email, amount,
                                                                                  callbackUrl : "https://localhost:44363/Subscription/VerifyPayment");

                if (response.status)
                {
                    Session["type"] = type;
                    Response.AddHeader("Access-Control-Allow-Origin", "*");
                    Response.AppendHeader("Access-Control-Allow-Origin", "*");
                    return(Redirect(response.data.authorization_url));
                }

                return(RedirectToAction("Failed"));
            }
            return(View());
        }
        public async Task <JsonResult> InitializeMoviePaymentFM(string Fullname, string phoneNo, string email, string NoOfPersons
                                                                , string MovieCategory, string Amount, string MovieDay, string MovieTime, string MovieName,
                                                                string siteId, string orderId, string showtimeId, string MovieCategoryText)
        {
            oGenericViewModel.rv = new ReturnValues();
            string[] id   = MovieCategory.Split('_');
            string[] mDay = MovieDay.Split('_');


            TicketRequestModel ct = new TicketRequestModel();

            ct.Fullname    = Fullname;
            ct.phoneNo     = phoneNo;
            ct.email       = email;
            ct.NoOfPersons = Convert.ToInt32(NoOfPersons);
            ct.Amount      = Amount;
            //ct.Amount = "2.00";
            ct.MovieDate = MovieDay;
            ct.MovieTime = MovieTime;
            ct.siteId    = siteId;
            ct.orderId   = orderId;

            ct.cat            = MovieCategoryText;
            ct.showtimeId     = showtimeId;
            ct.MovieName      = MovieName;
            ct.TicketCategory = id[1];
            var BatchCounter = oMoviesModelClass.GetCurrentCounter();
            var Reference    = RefferenceGenerator.GenerateReference(BatchCounter);
            var rtn          = oMoviesModelClass.SaveTicketDetailsFm(ct, Reference);

            if (rtn.sErrorText == "Success")
            {
                var tk = await oMoviesModelClass.GetClientProfileDetails("001");

                int PayStackAmount = oMoviesModelClass.CalculatePayStackAmount(Amount, Convert.ToInt32(NoOfPersons), "");
                //int PayStackAmount = oMoviesModelClass.CalculatePayStackAmount("5.00", Convert.ToInt32(NoOfPersons), "");
                PayStackRequestModel rt = new PayStackRequestModel();
                rt.amount = PayStackAmount;
                rt.email  = email;

                rt.firstName = Fullname;
                rt.lastName  = Fullname;


                var paystackTransactionAPI = new PaystackTransaction(tk.ClientPayStackSecretKey);
                var response = await paystackTransactionAPI.InitializeTransaction(rt.email, rt.amount, rt.firstName, rt.lastName, "https://www.ticketplanet.ng/Movies/PaymentConfirmationFM", Reference);

                //Note that callback url is optional
                if (response.status == true)
                {
                    oMoviesModelClass.UpdatePayStackReference(Reference, response.data.reference);
                    return(Json(new { error = false, result = response }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { error = true }, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public async Task <JsonResult> InitializePayment(PaystackCustomerModel model)
        {
            string secretKey = ConfigurationManager.AppSettings["PaystackSecret"];
            var    paystackTransactionAPI = new PaystackTransaction(secretKey);
            var    response = await paystackTransactionAPI.InitializeTransaction(model.email, model.amount, model.firstName, model.lastName, "https://localhost:44348/callback");

            //Note that callback url is optional
            if (response.status == true)
            {
                return(Json(new { error = false, result = response }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { error = true, result = response }, JsonRequestBehavior.AllowGet));
        }
Exemple #4
0
        public async Task <JsonResult> InitializeEventPayment(string Fullname, string phoneNo, string email, string NoOfPersons
                                                              , string TicketCategory, string Amount, string comments, int TicketType, string TicketCategoryName, string CouponValue, string ReferalId)
        {
            oGenericViewModel.rv = new ReturnValues();

            TicketRequestModel ct = new TicketRequestModel();

            ct.Fullname = Fullname;
            ct.phoneNo  = phoneNo;

            ct.email          = email;
            ct.NoOfPersons    = Convert.ToInt32(NoOfPersons);
            ct.TicketCategory = TicketCategory;
            ct.Amount         = Amount;
            //ct.comments = comments;
            ct.TicketType = TicketType;
            //ct.Validated = Validated;
            ct.ReferalId = ReferalId;

            var BatchCounter = oEventClassModel.GetCurrentCounter();
            var Reference    = RefferenceGenerator.GenerateReference(BatchCounter);
            var rtn          = oEventClassModel.SaveTicketDetails(ct, Reference);

            if (rtn.sErrorText == "Success")
            {
                var tk             = oEventClassModel.GetClientProfileDetails("001");
                int PayStackAmount = oEventClassModel.CalculatePayStackAmount(Convert.ToInt32(TicketCategory), TicketCategoryName, Convert.ToInt32(NoOfPersons), CouponValue);

                PayStackRequestModel rt = new PayStackRequestModel();
                rt.amount = PayStackAmount;
                //rt.amount = 5;
                rt.email = email;

                rt.firstName = Fullname;
                rt.lastName  = Fullname;


                var paystackTransactionAPI = new PaystackTransaction(tk.ClientPayStackSecretKey);
                var response = await paystackTransactionAPI.InitializeTransaction(rt.email, rt.amount, rt.firstName, rt.lastName, tk.TicketPlanetFlightCallBackUrl, Reference, null, null, true);

                //Note that callback url is optional
                if (response.status == true)
                {
                    await oEventClassModel.UpdatePayStackReference(Reference, response.data.reference);

                    return(Json(new { error = false, result = response }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { error = true }, JsonRequestBehavior.AllowGet));
        }
        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> InitTransaction()
        {
            var customerDetail = new CustomerViewModel()
            {
                email     = Request.Form.Get("cust_email"),
                firstName = Request.Form.Get("cust_fname"),
                lastName  = Request.Form.Get("cust_lname"),
                phone     = Request.Form.Get("cust_phone")
            };

            var cartCode = Helpers.GetCartId();
            var cartItem = repo.GetCartItem(cartCode);

            var paystackSec_Key = ConfigurationManager.AppSettings["PayStackKey"].ToString();

            var payStackAPI = new PaystackTransaction(paystackSec_Key);

            var amount = (Convert.ToInt32(cartItem.amount) * 100);

            var reqBody = new Paystack.Net.Models.TransactionInitializationRequestModel()
            {
                email     = customerDetail.email,
                firstName = customerDetail.firstName,
                lastName  = customerDetail.lastName,
                amount    = amount
            };

            //Charge Customer

            var initResponse = await payStackAPI.InitializeTransaction(reqBody);

            if (initResponse.status)
            {
                //Create Order and customer
                var custCode = Helpers.GenerateRandomDigitCode(10);

                if (repo.CreateCustomerSubscription(customerDetail.firstName, customerDetail.lastName, customerDetail.email,
                                                    customerDetail.phone, custCode, cartItem.planName, cartItem.amount, initResponse.data.reference, cartItem.planId))
                {
                    repo.RemoveItemFromCart(cartCode);
                    Response.AddHeader("Access-Control-Allow-Origin", "*");
                    Response.AppendHeader("Access-Control-Allow-Origin", "*");
                    Response.Redirect(initResponse.data.authorization_url);
                }
            }

            return(View("OrderError"));
        }
Exemple #7
0
        public async Task <JsonResult> InitializeFathersDayEventPayment(string Fullname, string phoneNo, string email
                                                                        , string TicketCategory, string Amount, string TicketType)
        {
            oGenericViewModel.rv = new ReturnValues();

            TicketRequestModel ct = new TicketRequestModel();

            ct.Fullname       = Fullname;
            ct.phoneNo        = phoneNo;
            ct.TicketType     = Convert.ToInt32(TicketType);
            ct.email          = email;
            ct.TicketCategory = TicketCategory;
            ct.Amount         = Amount;
            //ct.Validated = "N";

            var BatchCounter = oEventClassModel.GetCurrentCounter();
            var Reference    = RefferenceGenerator.GenerateReference(BatchCounter);
            var rtn          = oEventClassModel.SaveFathersTicketDetails(ct, Reference);

            if (rtn.sErrorText == "Success")
            {
                var tk             = oEventClassModel.GetClientProfileDetails("001");
                int PayStackAmount = oEventClassModel.CalculateFathersDayPayStackAmount(Convert.ToInt32(TicketCategory));

                PayStackRequestModel rt = new PayStackRequestModel();
                rt.amount = PayStackAmount;
                rt.email  = email;

                rt.firstName = Fullname;
                rt.lastName  = Fullname;


                var paystackTransactionAPI = new PaystackTransaction(tk.ClientPayStackSecretKey);
                var response = await paystackTransactionAPI.InitializeTransaction(rt.email, rt.amount, rt.firstName, rt.lastName, "https://ticketplanet.ng/Events/FathersDayPaymentConfirmation", Reference, null, null, true);

                //Note that callback url is optional
                if (response.status == true)
                {
                    await oEventClassModel.UpdatePayStackReference(Reference, response.data.reference);

                    return(Json(new { error = false, result = response }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { error = true }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// Implements simple InitializeTransaction with basic parameters
        /// </summary>
        protected async void InitializeTransaction()
        {
            var paystackTransactionAPI = new PaystackTransaction(Credential.Key);
            var response = await paystackTransactionAPI.InitializeTransaction("*****@*****.**", 1000000);

            if (response.status)
            {
                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
            }
            else //not successful
            {
                //Do something else with the info.
                contentDiv.InnerText = response.message;
            }
        }
        // GET: Sub
        public async Task <ActionResult> Index(int value)
        {
            int numb  = 0;
            int month = 0;

            switch (value)
            {
            case 1:
                numb  = 500000;
                month = 1;

                break;

            case 2:
                numb  = 2200000;
                month = 6;
                break;

            case 3:
                numb  = 4000000;
                month = 12;
                break;

            default:
                numb = 0;
                break;
            }

            TempData["month"] = month;
            string secretKey = ConfigurationManager.AppSettings["PayStackSec"];
            var    paystackTransactionAPI = new PaystackTransaction(secretKey);
            string email    = User.Identity.GetUserName();
            var    response = await paystackTransactionAPI.InitializeTransaction(email, numb, callbackUrl : "https://localhost:44377/Suscription/VerifyPayment");

            if (response.status)
            {
                Session["paymentRef"] = response.data.reference;
                Response.AddHeader("Access-Control-Allow-Origin", "*");
                Response.AppendHeader("Access-Control-Allow-Origin", "*");
                return(Redirect(response.data.authorization_url));
            }

            return(RedirectToAction("Failed"));
        }
        /// <summary>
        /// Implements simple InitializeTransaction with full parameters
        /// </summary>
        protected async void InitializeTransaction2()
        {
            var paystackTransactionAPI = new PaystackTransaction(Credential.Key);
            var response = await paystackTransactionAPI.InitializeTransaction(new TransactionRequestModel()
            {
                firstName = "Olorunfemi", callback_url = "http://*****:*****@email.com", metadata = new PayStackDotNetSDK.Models.Transactions.Metadata()
                {
                    referrer = "*****@*****.**"
                }, transaction_charge = 4000
            });

            if (response.status)
            {
                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
            }
            else //not successful
            {
                //Do something else with the info.
            }
        }
Exemple #11
0
        public async Task <ActionResult> InitializePayment(User model)
        {
            string secretKey = ConfigurationManager.AppSettings["PaystackSecret"];
            var    paystackTransactionAPI = new PaystackTransaction(secretKey);
            var    response = await paystackTransactionAPI.InitializeTransaction(model.Email, 5000000, model.Name, model.UserName, $"{Session["CompanyToGo"]}");

            //Note that callback URL is optional

            using (var context = new ApplicationDbContext())
            {
                var payment = new Payment
                {
                    UserId    = model.Id,
                    StartDate = DateTime.Now
                };
                payment.EndDate = payment.StartDate.AddMonths(2);

                context.Payments.Add(payment);
                context.SaveChanges();
            }

            return(Redirect(response.data.authorization_url));
        }
        public async Task <ActionResult> Payment(int id)
        {
            var numb = _db.Amount(id);
            //ViewBag.Message = "Your contact page.";

            var email = (string)Session["Email"];
            var paystackTransactionAPI = new PaystackTransaction("sk_test_4f260b0736ab1d07afe4642756c7868359abb180");
            //var response = await paystackTransactionAPI.InitializeTransaction("*****@*****.**", 500000);
            var response = await paystackTransactionAPI.InitializeTransaction(email, numb, callbackUrl : "https://localhost:44367/");

            if (response.status)
            {
                Response.AddHeader("Access-Control-Allow-Origin", "*");
                Response.AppendHeader("Access-Control-Allow-Origin", "*");

                var currentSub = sub.Get(email);
                if (currentSub == null)
                {
                    sub.AddSub(id, email);
                }

                if (currentSub != null)
                {
                    sub.UpdateSub(id, email);
                }

                Response.Redirect(response.data.authorization_url);
            }
            else
            {
                return(RedirectToAction("Error"));
            }



            return(RedirectToAction("Error"));
        }
        public async Task <JsonResult> InitializeMoviePayment(string Fullname, string phoneNo, string email, string NoOfPersons
                                                              , string MovieCategory, string Amount, string comments, int CinemaLocation, int CinemaCompanyID, string MovieDay, string MovieTime, string MovieName,
                                                              string IsCoupon, string Coupon, string CouponAgentId, string CouponAssignId, string CouponID, string nErrorCode, string CouponValue)
        {
            oGenericViewModel.rv = new ReturnValues();

            TicketRequestModel ct = new TicketRequestModel();

            ct.Fullname    = Fullname;
            ct.phoneNo     = phoneNo;
            ct.email       = email;
            ct.NoOfPersons = Convert.ToInt32(NoOfPersons);

            ct.Amount          = Amount;
            ct.MovieDate       = MovieDay;
            ct.MovieTime       = MovieTime;
            ct.CinemaCompanyID = CinemaCompanyID;
            ct.CinemaLocation  = CinemaLocation;
            ct.MovieName       = MovieName;
            ct.TicketCategory  = MovieCategory;

            if (!string.IsNullOrEmpty(nErrorCode))
            {
                if (nErrorCode == "1")
                {
                    ct.Coupon         = Coupon;
                    ct.CouponAgentId  = !string.IsNullOrEmpty(CouponAgentId) ? Convert.ToInt32(CouponAgentId) : 0;
                    ct.CouponAssignId = !string.IsNullOrEmpty(CouponAssignId) ? Convert.ToInt32(CouponAssignId) : 0;
                    ct.CouponID       = !string.IsNullOrEmpty(CouponID) ? Convert.ToInt32(CouponID) : 0;
                    ct.IsCoupon       = IsCoupon;
                }
            }
            else
            {
                ct.IsCoupon = "N";
            }

            var BatchCounter = oMoviesModelClass.GetCurrentCounter();
            var Reference    = RefferenceGenerator.GenerateReference(BatchCounter);
            var rtn          = oMoviesModelClass.SaveTicketDetails(ct, Reference);

            if (rtn.sErrorText == "Success")
            {
                var tk = await oMoviesModelClass.GetClientProfileDetails("001");

                int PayStackAmount = oMoviesModelClass.CalculatePayStackAmount(Amount, Convert.ToInt32(NoOfPersons), CouponValue);

                PayStackRequestModel rt = new PayStackRequestModel();
                //var percent = 0.1 * PayStackAmount;
                //var decrease = Convert.ToInt32((PayStackAmount - percent));

                rt.amount = PayStackAmount;
                //rt.amount = 50;
                rt.email = email;

                rt.firstName = Fullname;
                rt.lastName  = Fullname;


                //
                var paystackTransactionAPI = new PaystackTransaction(tk.ClientPayStackSecretKey);
                var response = await paystackTransactionAPI.InitializeTransaction(rt.email, rt.amount, rt.firstName, rt.lastName, "https://ticketplanet.ng/Movies/PaymentConfirmation", Reference);

                //Note that callback url is optional
                if (response.status == true)
                {
                    oMoviesModelClass.UpdatePayStackReference(Reference, response.data.reference);
                    return(Json(new { error = false, result = response }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { error = true }, JsonRequestBehavior.AllowGet));
        }