Пример #1
0
        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"));
        }