예제 #1
0
 public PaymentController(Model.PaymentModel paymentModel, View.PaymentForm payment, Main.View.CMS cms)
 {
     this.paymentModel = paymentModel;
     this.payment = payment;
     cms.setPanel2(this.payment);
     this.payment.setBtnClearEventHandler(this.btnClear);
     this.payment.setBtnMoveAllEventHandler(this.btnMoveAll);
     this.payment.setBtnMoveBackAllEventHandler(this.btnMoveBackAll);
     this.payment.setBtnMoveBackSelectedEventHandler(this.btnMoveBackSelected);
     this.payment.setBtnMoveSelectedEventHandler(this.btnMoveSelected);
     this.payment.setBtnSaveEventHandler(this.btnSave);
     this.payment.dataAmortization_CellValueChanged(this.showPenalties);
     this.payment.txtAmountDue_TextChanged(this.showTotalAmortization);
     this.payment.txtPenalty_TextChanged(this.showTotalAmortization);
     this.payment.txtAccountNo_TextChanged(this.searchMember);
     this.payment.txtMemberName_TextChanged(this.searchMember);
     this.payment.classGridSearch(this.paymentModel.selectActiveMembershipUnpaid());
     if (this.paymentModel.checkEmpty != 0) this.payment.noRowsSelected();
     this.paymentModel.checkEmpty = 0;
     this.payment.clearLoanFields();
 }
예제 #2
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);
            }
        }