public ActionResult Complete()
        {
            // Payment data comes in url so we have to get it from url

            // This id is razorpay unique payment id which can be use to get the payment details from razorpay server

            string paymentId = Request.Form["rzp_paymentid"];
            //string paymentId = paymentid;
            // This is orderId
            string orderId = Request.Form["rzp_orderid"];


            Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_jgSfZxfkVFDQ0t", "lQz5sINmfOOXXKmM6zPT225T");

            Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId);

            // This code is for capture the payment
            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", payment.Attributes["amount"]);
            Razorpay.Api.Payment paymentCaptured = payment.Capture(options);
            string amt = paymentCaptured.Attributes["amount"];

            //// Check payment made successfully

            if (paymentCaptured.Attributes["status"] == "captured")
            {
                // Create these action method
                return(RedirectToAction("Success"));
            }
            else
            {
                return(RedirectToAction("Failed"));
            }
        }
Esempio n. 2
0
        public IHttpActionResult verifyOrderRazorpay(string paymentId, string orderId)
        {
            // Payment data comes in url so we have to get it from url

            // This id is razorpay unique payment id which can be use to get the payment details from razorpay server
            string _paymentId = paymentId;

            // This is orderId
            string _orderId = orderId;

            Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_9wK0kOoAWrR2GV", "Um9kYEyRcQy8TRKGAUwGFLny");

            Razorpay.Api.Payment payment = client.Payment.Fetch(_paymentId);

            // This code is for capture the payment
            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", payment.Attributes["amount"]);
            Razorpay.Api.Payment paymentCaptured = payment.Capture(options);
            string amt = paymentCaptured.Attributes["amount"];

            //// Check payment made successfully

            if (paymentCaptured.Attributes["status"] == "captured")
            {
                // Create these action method
                return(Ok("Sucessfull"));
            }
            else
            {
                return(Ok("ERROR occured"));
            }
        }
        public async Task <string> CompleteOrderProcess(IHttpContextAccessor _httpContextAccessor)
        {
            try
            {
                string paymentId = _httpContextAccessor.HttpContext.Request.Form["rzp_paymentid"];

                // This is orderId
                string orderId = _httpContextAccessor.HttpContext.Request.Form["rzp_orderid"];

                Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_8P7RhnsImxd2OR", "kD8tw7ECYsTTZnx0OyrKI4kh");

                Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId);

                // This code is for capture the payment
                Dictionary <string, object> options = new Dictionary <string, object>();
                options.Add("amount", payment.Attributes["amount"]);
                Razorpay.Api.Payment paymentCaptured = payment.Capture(options);
                string amt = paymentCaptured.Attributes["amount"];
                return(paymentCaptured.Attributes["status"]);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        public ActionResult Complete()
        {
            // Payment data comes in url so we have to get it from url

            // This id is razorpay unique payment id which can be use to get the payment details from razorpay server

            string paymentId = Request.Form["rzp_paymentid"];
            //string paymentId = paymentid;
            // This is orderId
            string orderId = Request.Form["rzp_orderid"];


            Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient(_keys.SecretKey, _keys.PublishKey);

            Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId);

            // This code is for capture the payment
            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", payment.Attributes["amount"]);
            Razorpay.Api.Payment paymentCaptured = payment.Capture(options);
            string amt = paymentCaptured.Attributes["amount"];

            //// Check payment made successfully

            if (paymentCaptured.Attributes["status"] == "captured")
            {
                string id           = User.FindFirst("id").Value;
                var    dataset      = _unitOfWork.StudentModel.FeeDetailFunction(id);
                var    paymentParam = new DynamicParameters();
                paymentParam.Add("inUserId", id);
                //var dataset = _unitOfWork.SPCall.List<FeeDetails>(SD.FeeDetails, paymentParam);

                foreach (var data in dataset)
                {
                    string emailbody = GetBody("feepayment", data.Name, " ", " ", " ", data.Month.ToString(), data.FeeCharge.ToString());
                    EmailConfig.SendMail(data.Email, "Welcome", emailbody);

                    /*payment.name = data.Name;
                     * payment.email = data.Email;
                     * payment.contactNumber = "9931159589";
                     * payment.address = "Ranchi";
                     * payment.amount = data.FeeCharge;
                     * payment.UserId = Convert.ToInt32(claimvalue);*/
                    // payment.User = user;
                }
                // Create these action method
                // string emailbody = GetBody("feepayment", FirstName, Email, Password);
                //EmailConfig.SendMail(Email, "Welcome", emailbody);
                //_unitOfWork.SPCall.List<FeeDetails>(SD.UpdateFeeDate, paymentParam);
                _unitOfWork.StudentModel.UpdateFeeDateFunction(id);
                return(RedirectToAction("Success"));
            }
            else
            {
                return(RedirectToAction("Failed"));
            }
        }
        public ActionResult Complete()
        {
            // Payment data comes in url so we have to get it from url

            // This id is razorpay unique payment id which can be use to get the payment details from razorpay server
            string paymentId = Request.Form["rzp_paymentid"];

            // This is orderId
            string orderId = Request.Form["rzp_orderid"];

            Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient("rzp_test_E2Zmqlh9v2Dj8U", "NPTQwUFJV6R36LW2fPir43pG");

            Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId);

            // This code is for capture the payment
            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", payment.Attributes["amount"]);
            Razorpay.Api.Payment paymentCaptured = payment.Capture(options);
            string amt = paymentCaptured.Attributes["amount"];

            //// Check payment made successfully
            int      userId   = _session.GetInt32("UserID").Value;
            Business business = _businessService.GetBusinessByUserID(userId);

            business.Payment.TransactionNumber = paymentId;
            _businessService.UpdatePayment(business);
            //_businessService.UpdateBusiness("PaymentID", paymentId, userId);

            if (paymentCaptured.Attributes["status"] == "captured")
            {
                _businessService.UpdateBusiness("Payment", "SUCCESSFULL", userId);
                // Create these action method
                ViewBag.Message = "Payment Successfull.Thanks for registering with TownerTown.";
                return(RedirectToAction("ViewProfile"));
            }
            else
            {
                _businessService.UpdateBusiness("Payment", "FAILED", userId);
                ViewBag.Message = "Sorry Payment Failed.Please try again later";
                return(RedirectToAction("LogIn", "Home"));
            }
        }