Inheritance: Entity
コード例 #1
0
        public ActionResult Charge()
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 3000); // this amount should be same as transaction amount

            string key    = "<Enter your Api Key here>";
            string secret = "<Enter your Api Secret here>";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);

            Refund refund = new Razorpay.Api.Payment((string)paymentId).Refund();

            Console.WriteLine(refund["id"]);
            return(View());
        }
コード例 #2
0
ファイル: Charge.aspx.cs プロジェクト: raushan790/Echo
        protected void Page_Load(object sender, EventArgs e)
        {
            string paymentId = Request.Form["razorpay_payment_id"];

            Dictionary <string, object> input = new Dictionary <string, object>();

            input.Add("amount", 100); // this amount should be same as transaction amount

            string key    = "rzp_test_WWMX02RJxJbpRZ";
            string secret = "9Zg6KhCALHF5fGBtmn54xo6S";

            RazorpayClient client = new RazorpayClient(key, secret);

            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes.Add("razorpay_payment_id", paymentId);
            attributes.Add("razorpay_order_id", Request.Form["razorpay_order_id"]);
            attributes.Add("razorpay_signature", Request.Form["razorpay_signature"]);

            Utils.verifyPaymentSignature(attributes);

            Refund refund = new Razorpay.Api.Payment((string)paymentId).Refund();

            Console.WriteLine(refund["id"]);
        }
コード例 #3
0
        public ViewResult CapturePayment(string paymentId)
        {
            RazorpayClient client = new RazorpayClient(_key, _secret);

            Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId);
            var amount   = payment.Attributes["amount"];
            var currency = payment.Attributes["currency"];

            Dictionary <string, object> options = new Dictionary <string, object>();

            options.Add("amount", amount);
            options.Add("currency", currency);
            Razorpay.Api.Payment paymentCaptured = payment.Capture(options);
            ViewBag.Message = "Payment capatured!";
            return(View("Success"));
        }
コード例 #4
0
        public ActionResult PaymentComplete()
        {
            string paymentId = Request.Params["rzp_paymentid"];
            // This is orderId
            string orderId = Request.Params["rzp_orderid"];

            Razorpay.Api.RazorpayClient client = new Razorpay.Api.RazorpayClient(razorKey, razorSecred);

            Razorpay.Api.Payment payment = client.Payment.Fetch(paymentId);
            PreBookingDtl        obj     = Session["OrderDetails"] as PreBookingDtl;
            // 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"];



            if (paymentCaptured.Attributes["status"] == "captured")
            {
                obj.BookingStatus      = "Booked";
                obj.PaymentGatewayCode = paymentId;
                string jsonStr = JsonConvert.SerializeObject(obj);
                string result  = objAPI.PostRecordtoApI("webrequest", "PayNow", jsonStr);
                TempData["ErrMsg"] = result;
                return(RedirectToAction("PaymentSuccess", "Home", new { BookingID = result }));
            }
            else
            {
                obj.BookingStatus = "Failed";
                //obj.PaymentGatewayCode = paymentId;
                //string jsonStr = JsonConvert.SerializeObject(obj);
                //string result = objAPI.PostRecordtoApI("webrequest", "PayNow", jsonStr);
                TempData["ErrMsg"] = "Failed";
                return(RedirectToAction("PaymentFailed", "Home", new { obj.HotelID }));
            }
        }
コード例 #5
0
        private bool CapturePayment(ref Model.PaymentModel pViewModel)
        {
            try
            {
                decimal netPrice = pViewModel.AmountCharged;
                if (netPrice > 0)
                {
                    string paymentId = pViewModel.GatewayResponse;
                    Dictionary <string, object> input = new Dictionary <string, object>();
                    input.Add("amount", netPrice * 100); // this amount should be same as transaction amount
                    string               key             = ImTech.Service.Common.ConfigurationManager.PaymentGatewayKey;
                    string               secret          = ImTech.Service.Common.ConfigurationManager.PaymentGatewaySecret;
                    RazorpayClient       client          = new RazorpayClient(key, secret);
                    Razorpay.Api.Payment payment         = client.Payment.Fetch(paymentId);
                    Razorpay.Api.Payment capturedPayment = payment.Capture(input);

                    string        json   = capturedPayment.Attributes.ToString();
                    dynamic       JsonDe = JsonConvert.DeserializeObject(json);
                    PaymentStatus status = JsonDe.status.ToString().ToUpper() == "captured".ToUpper() ? PaymentStatus.Capture : PaymentStatus.CaptureFailed;
                    pViewModel.GatewayResponse = paymentId + "-->ResponseJson-->" + json;
                    if (status == PaymentStatus.Capture)
                    {
                        if (WebCommon.NotificationEnabled)
                        {
                            var consultationDetails = _dataServices.ConsultationService.GetConsultationDetails(pViewModel.ConsultationID, pViewModel.TenantID);
                            var doctor = _dataServices.DoctorService.GetDoctor(consultationDetails.DoctorId, pViewModel.TenantID);
                            if (consultationDetails != null)
                            {
                                var           userDetails          = _dataServices.UserService.GetUser(consultationDetails.CreatedBy, pViewModel.TenantID);
                                List <object> additionalParameters = new List <object>();
                                additionalParameters.Add(userDetails.Email);
                                additionalParameters.Add(userDetails.PhoneNumber);
                                additionalParameters.Add(doctor.EmailAddress);
                                additionalParameters.Add(doctor.PhoneNumber);
                                additionalParameters.Add(consultationDetails.Patient.PatientName);
                                additionalParameters.Add(doctor.FirstName + " " + doctor.LastName);
                                additionalParameters.Add(pViewModel.AmountCharged);
                                additionalParameters.Add(consultationDetails.ConsultationMode);
                                NotificationClient.Instance.SendMessage(null, ImTech.Notification.Messages.MessageType.Consultation_User, additionalParameters);
                                NotificationClient.Instance.SendMessage(null, ImTech.Notification.Messages.MessageType.Consultation_Doctor, additionalParameters);
                            }
                        }
                        return(true);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                string errorMsg = string.Empty;
                if (ex.InnerException != null)
                {
                    errorMsg = ex.InnerException.Message;
                }
                else
                {
                    errorMsg = ex.Message;
                }
                _logger.LogError(new LogMessage
                {
                    Summary     = errorMsg,
                    Exception   = Convert.ToString(ex.StackTrace),
                    UserId      = 0,
                    UserType    = 0,
                    Application = "Web"
                });
                return(true);
            }
        }