private dynamic NapierService(string TxtnId, string MRNO, double Amount, string ReceiptDate, string Remark)
    {
        var details = (dynamic)null;

        details = objPatIndex.SaveDeposit("JEEVAPG", "JEEVAPG@16", TxtnId, MRNO, Amount, ReceiptDate, Remark);
        return(details);
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            spnStatus.Visible = true;

            lblMsg.Visible = false;
            string secret_key   = "ed70df7a017654499542ff0a5515812824b74142";
            string data         = "";
            string txnId        = Request["TxId"];
            string txnStatus    = Request["TxStatus"];
            string amount       = Request["amount"];
            string pgTxnId      = Request["pgTxnNo"];
            string issuerRefNo  = Request["issuerRefNo"];
            string authIdCode   = Request["authIdCode"];
            string firstName    = Request["firstName"];
            string lastName     = Request["lastName"];
            string pgRespCode   = Request["pgRespCode"];
            string zipCode      = Request["addressZip"];
            string resSignature = Request["signature"];

            bool flag = true;
            if (txnId != null)
            {
                data += txnId;
            }
            if (txnStatus != null)
            {
                data += txnStatus;
            }
            if (amount != null)
            {
                data += amount;
            }
            if (pgTxnId != null)
            {
                data += pgTxnId;
            }
            if (issuerRefNo != null)
            {
                data += issuerRefNo;
            }
            if (authIdCode != null)
            {
                data += authIdCode;
            }
            if (firstName != null)
            {
                data += firstName;
            }
            if (lastName != null)
            {
                data += lastName;
            }
            if (pgRespCode != null)
            {
                data += pgRespCode;
            }
            if (zipCode != null)
            {
                data += zipCode;
            }

            System.Security.Cryptography.HMACSHA1 myhmacsha1 = new System.Security.Cryptography.HMACSHA1(Encoding.ASCII.GetBytes(secret_key));

            System.IO.MemoryStream stream = new System.IO.MemoryStream(Encoding.ASCII.GetBytes(data));
            string signature = BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();

            if (resSignature != null && !signature.Equals(resSignature))
            {
                flag = false;
            }
            if (flag == true)
            {
                //Response.Write("Thank You for using citrus payment Your Unique Transaction Status:" + Convert.ToString(txnStatus));
                if (Session["Bed"] != null || Session["Surgery"] != null || Session["AppointmentDetail"] != null || Session["HealthCheck-upComprehensive"] != null || Session["OutstandingBillPayment"] != null || Session["permenantRegistration"] != null || Session["ConsultationAppointment"] != null)
                {
                    DataAccessEntities sessionData = new DataAccessEntities();
                    if (Session["Bed"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["Bed"];
                    }
                    else if (Session["Surgery"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["Surgery"];
                    }
                    else if (Session["AppointmentDetail"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["AppointmentDetail"];
                    }
                    else if (Session["HealthCheck-upComprehensive"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["HealthCheck-upComprehensive"];
                    }
                    else if (Session["OutstandingBillPayment"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["OutstandingBillPayment"];
                    }
                    else if (Session["permenantRegistration"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["permenantRegistration"];
                    }
                    else if (Session["ConsultationAppointment"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["ConsultationAppointment"];
                    }

                    //double Damount = Convert.ToDouble(amount);

                    sessionData.Tranrefid  = Convert.ToString(issuerRefNo);
                    sessionData.Transtatus = Convert.ToString(txnStatus);
                    sessionData.Amount     = Convert.ToInt32(Session["Amount"]);
                    sessionData.UserId     = user.UserID;

                    lblUserName.Text    = user.DisplayName;
                    lblMNo.Text         = user.Username; //= Convert.ToString(user.UserID);
                    lblTxtnId.Text      = sessionData.Transactionid = Convert.ToString(txnId);
                    lblPaidAgainst.Text = sessionData.FacilityName;
                    lblDateTime.Text    = Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy"));
                    lblAmount.Text      = Convert.ToString(Session["Amount"]) + ".00 INR";

                    if (txnStatus != null)
                    {
                        PatIndex objDeposit = new PatIndex();
                        if (Session["Bed"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["Bed"] = null;
                                Response.Redirect("/Bed-Booking");
                            }
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            ServiceBookingSendEmail(user.DisplayName, user.Email, sessionData.FacilityName, sessionData.Category, lblDateTime.Text, Convert.ToString(Session["Amount"]) + ".00 INR", "BedBookingPayment");
                            Session["Bed"] = null;
                        }

                        else if (Session["Surgery"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["Surgery"] = null;
                                Response.Redirect("/surgery-booking");
                            }
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            ServiceBookingSendEmail(user.DisplayName, user.Email, sessionData.FacilityName, sessionData.Category, lblDateTime.Text, Convert.ToString(Session["Amount"]) + ".00 INR", "SurgeryBookingPayment");
                            Session["Surgery"] = null;
                        }
                        else if (Session["HealthCheck-upComprehensive"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["HealthCheck-upComprehensive"] = null;
                                Response.Redirect("/health-check-up-comprehensive");
                            }
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            string _categoryName = sessionData.Category;
                            if (_categoryName == "Male" || _categoryName == "Female")
                            {
                                _categoryName = "Package B (" + sessionData.Category + ")";
                            }
                            ServiceBookingSendEmail(user.DisplayName, user.Email, sessionData.FacilityName, _categoryName, lblDateTime.Text, Convert.ToString(Session["Amount"]) + ".00 INR", "HealthCheckPayment");
                            Session["HealthCheck-upComprehensive"] = null;
                        }
                        else if (Session["OutstandingBillPayment"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["OutstandingBillPayment"] = null;
                                Response.Redirect("/outstandingbillpayment");
                            }

                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            OutStandingSendEmail(sessionData.FacilityName, Convert.ToString(Session["Amount"]) + ".00 INR", "OutstandingPayment");
                            Session["OutstandingBillPayment"] = null;
                        }
                        else if (Session["permenantRegistration"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["permenantRegistration"] = null;
                                Response.Redirect("/");
                            }
                            Session["permenantRegistration"] = null;
                            lblMsg.Visible = true;



                            string Gender = user.Profile.GetPropertyValue("Gender");
                            if (Gender == "Male")
                            {
                                Gender = "M";
                            }
                            else
                            {
                                Gender = "F";
                            }
                            string Age         = user.Profile.GetPropertyValue("Age");
                            string Address     = user.Profile.GetPropertyValue("Address");
                            string PhoneNumber = user.Profile.GetPropertyValue("PhoneNumber");

                            string[] X = PhoneNumber.Split('-');
                            PhoneNumber = X[1];

                            string Username;
                            string Fname;
                            string Lname;
                            string Email;

                            if (user.Username.Length > 20)
                            {
                                Username = user.Username.Substring(0, 20);
                            }
                            else
                            {
                                Username = user.Username;
                            }

                            if (user.FirstName.Length > 30)
                            {
                                Fname = user.FirstName.Substring(0, 30);
                            }
                            else
                            {
                                Fname = user.FirstName;
                            }

                            if (user.LastName.Length > 30)
                            {
                                Lname = user.LastName.Substring(0, 30);
                            }
                            else
                            {
                                Lname = user.LastName;
                            }
                            if (user.Email.Length > 50)
                            {
                                Email = user.Email.Substring(0, 50);
                            }
                            else
                            {
                                Email = user.Email;
                            }
                            if (Address.Length > 30)
                            {
                                Address = Address.Substring(0, 30);
                            }

                            if (PhoneNumber.Length > 12)
                            {
                                PhoneNumber = PhoneNumber.Substring(0, 12);
                            }


                            var PatientDetails = objPatIndex.UpdateorInsertPatient(user.Username, user.FirstName, user.LastName, Gender, Age, "01/01/2000", Address, Address, Address, PhoneNumber, Email);

                            if (!string.IsNullOrEmpty(PatientDetails.WEBPWD))
                            {
                                DataSet ds = objBusinessLogic.IsExistMRNumber(PatientDetails.MRNO);
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    Clear();
                                    lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                    lblMsg.Text      = "You Are Allready Registered As A permanent User!";
                                }
                                else
                                {
                                    bool IsUserExist = objBusinessLogic.IsUserExist(PatientDetails.MRNO);
                                    if (!IsUserExist)
                                    {
                                        if (PatientDetails.PatSex == "M")
                                        {
                                            PatientDetails.PatSex = "Male";
                                        }
                                        else
                                        {
                                            PatientDetails.PatSex = "Female";
                                        }
                                        DataSet dsVal = InsertUpdateUserDetails(PatientDetails.MRNO, PatientDetails.PatFName, PatientDetails.PatLName, PatientDetails.PatEmail, PatientDetails.WEBPWD, PatientDetails.PatMobile, PatientDetails.PatSex, PatientDetails.PatAddr1, PatientDetails.PatAge);
                                        lblMNo.Text = PatientDetails.MRNO;


                                        var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                                        if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                                        {
                                            sessionData.JeevaStatus = detaisl.MRNO;
                                        }

                                        objBusinessLogic.SavePaymentBedSurgery(sessionData);


                                        if (dsVal.Tables[0].Rows.Count > 0)
                                        {
                                            // SendMail & MSG

                                            try
                                            {
                                                PermanentUserSendEmail(PatientDetails.PatFName, PatientDetails.PatEmail, PatientDetails.MRNO, PatientDetails.WEBPWD, PhoneNumber, "PermanentRegistration");
                                                lblMsg.Text      = "You are now the permanent user! Please login with your MR Number that has been sent to your registered mobile number";
                                                lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#008000");
                                            }
                                            catch (Exception ex)
                                            {
                                                lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                                lblMsg.Text      = "SMS Service is stoped Due to technical problem!";
                                            }
                                            UserController.DeleteUser(ref user, false, false);
                                            UserController.RemoveUser(user);
                                            if (user.UserID != -1)
                                            {
                                                secure.SignOut();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Clear();
                                        lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                        lblMsg.Text      = "UserName allready exist!";
                                    }
                                }
                            }
                            else
                            {
                                Clear();
                                lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                lblMsg.Text      = "You are already register as a permanent user, Please login with MR Number";
                            }
                        }
                        else if (Session["ConsultationAppointment"] != null || Session["AppointmentDetail"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["ConsultationAppointment"] = null;
                                Session["AppointmentDetail"]       = null;
                                Response.Redirect("/");
                            }
                            sessionData.FacilityName = "Appointment";
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }
                            sessionData.FacilityName = "Consultation Appointment";
                            objBusinessLogic.SavePaymentBookAppointment(sessionData);
                            AppointmentSendEmail(Convert.ToString(sessionData.PhoneNo), Convert.ToString(sessionData.MobileNo), Convert.ToString(sessionData.Location), Convert.ToString(sessionData.Address), Convert.ToString(sessionData.TimeDate), Convert.ToString(Session["Amount"]) + ".00 INR", Convert.ToString(sessionData.Description), sessionData.dName, "ConsultationAppointment");
                            Session["ConsultationAppointment"] = null;
                            Session["AppointmentDetail"]       = null;
                        }
                    }
                    else
                    {
                        plcDivSucces.Visible          = false;
                        plcDivError.Visible           = true;
                        spnStatus.Attributes["Class"] = "highlight";
                        spnStatus.InnerText           = "Payment Fail !";
                    }
                    Session["Amount"] = null;
                }
                else
                {
                    plcDivSucces.Visible          = false;
                    plcDivError.Visible           = true;
                    spnStatus.Attributes["Class"] = "highlight";
                    spnStatus.InnerText           = "Payment Fail !";
                }
            }
            else
            {
                Response.Write("Citrus Response Signature and Our (Merchant)Signature Mis - Match");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }