コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["Trackingkey"] != null)
            {
                Trackingkey = Request["Trackingkey"];

                if (!IsPostBack)
                {
                    FillNationality();
                }

                Payment_Process payment = db.Payment_Process.Where(x => x.Payment_Trackingkey == Trackingkey && x.Payment_URL_IsValid == true && x.Payment_IsPaid == false).FirstOrDefault();
                if (payment != null)
                {
                    Div_payment.Visible = true;
                    int student_Id = 0;
                    int.TryParse(payment.Student_Id.ToString(), out student_Id);
                    var student = db.Students.FirstOrDefault(x => x.Student_Id == student_Id);
                    if (student != null)
                    {
                        StudentName.Text  = student.Student_Name_En;
                        StudentEmail.Text = student.Student_Email;
                        UUID = RandomTrackingkey(student.Student_Id);
                    }
                }
                else
                {
                    Div_NotFound.Visible = true;
                }
            }
            else
            {
                Div_invalid.Visible = true;
            }
        }
コード例 #2
0
        public void logfile(Payment_Process payment_process)
        {
            db.Configuration.LazyLoadingEnabled = false;
            /* Add it to log file */
            Payment_Process stdLogFile = db.Payment_Process.Find(payment_process.Payment_Id);

            LogData = "data:" + JsonConvert.SerializeObject(payment_process, logFileModule.settings);
            logFileModule.logfile(10, "تحويل الي تم الدفع بصورة يدوية", "Payment Done Manual", LogData);
        }
コード例 #3
0
        private void ReadyToPay(Student std)
        {
            string         amount = string.Empty, Payment_For = string.Empty;
            int            payment_type_id = 1;
            Specialization spec            = db.Specializations.Find(std.Student_Specialization_Id);

            if (std.Student_Status_Id == 6)
            {
                amount          = spec.Specialization_Registeration_Payment.ToString();
                Payment_For     = "Registration";
                payment_type_id = 1;
            }
            else
            {
                amount          = spec.Specialization_Study_Payment.ToString();
                Payment_For     = "Study";
                payment_type_id = 2;
            }

            int    student_id  = std.Student_Id;
            string entityId    = "";
            string currency    = "SAR";
            string paymentType = "DB";

            Payment_Process payment = db.Payment_Process.Create();

            payment.Student_Id          = student_id;
            payment.Send_Amount         = float.Parse(amount);
            payment.Send_Currency       = currency;
            payment.Send_EntityId       = entityId;
            payment.Send_PaymentType    = paymentType;
            payment.Payment_IsPaid      = false;
            payment.Payment_Type_Id     = payment_type_id;
            payment.DateCreation        = DateTime.Now;
            payment.Comment             = Payment_For + " Fees";
            payment.Payment_Trackingkey = StringCipher.RandomString(5) + student_id + StringCipher.RandomString(3) + DateTime.Now.GetHashCode() + StringCipher.RandomString(5);
            payment.Payment_URL_IsValid = true;
            db.Payment_Process.Add(payment);
            db.SaveChanges();

            //Send Email
            send_ReadyToPay(std, payment, Payment_For);

            // Send SMS
            SendSMS send_sms   = new SendSMS();
            string  sever_name = Request.Url.Authority.ToString();
            string  URL        = sever_name + "/Payment/PaymentProcessDetails.aspx?Trackingkey=" + payment.Payment_Trackingkey;

            if (URL.Substring(0, 4).ToLower() != "http".ToLower())
            {
                URL = "http://" + URL;
            }

            string Text          = "Dear " + std.Student_Name_En + "\nNow you can pay the fees of " + Payment_For + "\nPlease use this link: " + URL;
            string number_Phone  = std.Student_Phone;
            string reslt_message = send_sms.SendMessage(Text, number_Phone);
        }
コード例 #4
0
        // POST: api/Rosom
        public string Post([FromBody] Rosom_Response Rosom)
        {
            Rosom_Request rosom_resquest = db.Rosom_Request.Where(x => x.Response_SADADNumber == Rosom.SADADNumber).FirstOrDefault();

            if (rosom_resquest != null)
            {
                Rosom.Trackingkey        = rosom_resquest.Trackingkey;
                Rosom.Payment_Process_Id = rosom_resquest.Payment_Process_Id;
                Rosom.Rosom_Request_Id   = rosom_resquest.Id;
                db.Rosom_Response.Add(Rosom);
                db.SaveChanges();

                Payment_Process Pay_process = rosom_resquest.Payment_Process;
                Pay_process.Payment_IsPaid      = true;
                Pay_process.Payment_URL_IsValid = false;
                db.Entry(Pay_process).State     = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                Student std           = Pay_process.Student;
                int     new_Status_Id = (int)std.Student_Status_Id + 1;
                std.Student_Status_Id = new_Status_Id;
                db.Entry(std).State   = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                // isnert new Sequences record to paid
                Sequence seq = db.Sequences.Create();
                seq.Emp_Id       = 1;
                seq.Status_Id    = new_Status_Id;
                seq.Student_Id   = std.Student_Id;
                seq.Note         = "Auto payment";
                seq.DateCreation = DateTime.Now;
                db.Sequences.Add(seq);
                db.SaveChanges();


                db.Configuration.LazyLoadingEnabled = false;
                /* Add it to log file */
                Student stdLogFile = db.Students.Find(std.Student_Id);
                stdLogFile.Employee = db.Employees.Find(seq.Emp_Id);
                stdLogFile.Status   = db.Status.Find(seq.Status_Id);

                LogData = "data:" + JsonConvert.SerializeObject(stdLogFile, logFileModule.settings);
                logFileModule.logfile(10, "تغير الحالة تلقائي", "Update Status Automatic", LogData);

                Payment_Process paymentLogFile = db.Payment_Process.Find(Pay_process.Payment_Id);
                LogData = "data:" + JsonConvert.SerializeObject(paymentLogFile, logFileModule.settings);
                logFileModule.logfile(10, "اضافة عملية دفع", "add payment process", LogData);

                return("{'Status': {'Code': 0,'Description': 'Success','Severity': 'Info'}}");
            }

            return("{'Status': {'Code': 2000,'Description': 'Bill not found','Severity': 'Info'}}");
        }
コード例 #5
0
        public bool send_ReadyToPay(Student std, Payment_Process payment, string Payment_For)
        {
            string sever_name = Request.Url.Authority.ToString();
            string URL        = sever_name + "/Payment/PaymentProcessDetails.aspx?Trackingkey=" + payment.Payment_Trackingkey;

            if (URL.Substring(0, 4).ToLower() != "http".ToLower())
            {
                URL = "http://" + URL;
            }
            string    StudentEmail = std.Student_Email; // "*****@*****.**";//
            SendEmail send         = new SendEmail();

            string Text   = " <Strong style='font-size:18;'>Dear " + std.Student_Name_En + "</Strong><br /><br /><Strong>Now you can pay the fees of " + Payment_For + ": </Strong> " + URL + " <br /> <Strong>Current Status:</Strong> " + std.Status.Status_Name_En + " <br /> <Strong>Date:</Strong> " + DateTime.Now.ToShortDateString() + "<br /><br /><Strong>Elm University Riyadh<br />Admission System</Strong> ";
            bool   result = send.TextEmail("Ready To Pay", StudentEmail, Text, sever_name);

            return(result);
        }
コード例 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SessionWrapper.LoggedUser == null)
            {
                Response.Redirect("~/Pages/Auth/Login.aspx");
            }

            if (Request["Payment_Process_ID"] != null)
            {
                int.TryParse(Request["Payment_Process_ID"], out Payment_Process_ID);
                if (Payment_Process_ID != 0)
                {
                    Payment_Process payment_process = db.Payment_Process.Find(Payment_Process_ID);
                    if (payment_process != null && payment_process.Payment_IsPaid == false)
                    {
                        payment_process.Payment_IsPaid      = true;
                        payment_process.Payment_URL_IsValid = false;
                        payment_process.Result_Description  = "Manual";
                        db.Entry(payment_process).State     = System.Data.EntityState.Modified;
                        db.SaveChanges();
                        logfile(payment_process);
                        Response.Redirect("~/Payment/StudentsPaid.aspx");
                    }
                    else if (payment_process != null && payment_process.Payment_IsPaid == true)
                    {
                        payment_process.Payment_SMS_Result = "Done";
                        db.Entry(payment_process).State    = System.Data.EntityState.Modified;
                        db.SaveChanges();
                        logfile(payment_process);
                        Response.Redirect("~/Payment/StudentsPaid.aspx");
                    }
                }
            }

            if (!IsPostBack)
            {
                PaymentProcessList = db.Payment_Process.ToList();

                LoadStudent();
                //Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "exportdata();", true);
            }
        }
コード例 #7
0
        // POST: api/Rosom
        public string Post([FromBody] Rosom_Response Rosom)
        {
            try
            {
                Rosom_Request rosom_resquest = db.Rosom_Request.Where(x => x.Response_SADADNumber == Rosom.SADADNumber).FirstOrDefault();
                if (rosom_resquest != null)
                {
                    Rosom.Trackingkey        = rosom_resquest.Trackingkey;
                    Rosom.Payment_Process_Id = rosom_resquest.Payment_Process_Id;
                    Rosom.Rosom_Request_Id   = rosom_resquest.Id;
                    db.Rosom_Response.Add(Rosom);
                    //db.SaveChanges();

                    Payment_Process Pay_process = rosom_resquest.Payment_Process;
                    if (Pay_process.Payment_IsPaid == true && Pay_process.Payment_URL_IsValid == false)
                    {
                        return("{'Status': {'Code': 0,'Description': 'Success','Severity': 'Info'}}");
                    }

                    Pay_process.Payment_IsPaid      = true;
                    Pay_process.Payment_URL_IsValid = false;
                    db.Entry(Pay_process).State     = System.Data.EntityState.Modified;
                    db.SaveChanges();

                    Student std           = Pay_process.Student;
                    int     new_Status_Id = (int)std.Student_Status_Id + 1;
                    std.Student_Status_Id = new_Status_Id;
                    db.Entry(std).State   = System.Data.EntityState.Modified;
                    db.SaveChanges();

                    // isnert new Sequences record to paid
                    Sequence seq = db.Sequences.Create();
                    seq.Emp_Id       = 1;
                    seq.Status_Id    = new_Status_Id;
                    seq.Student_Id   = std.Student_Id;
                    seq.Note         = "Auto payment";
                    seq.DateCreation = DateTime.Now;
                    db.Sequences.Add(seq);
                    db.SaveChanges();


                    db.Configuration.LazyLoadingEnabled = false;
                    /* Add it to log file */
                    Student stdLogFile = db.Students.Find(std.Student_Id);
                    stdLogFile.Employee = db.Employees.Find(seq.Emp_Id);
                    stdLogFile.Status   = db.Status.Find(seq.Status_Id);

                    LogData = "data:" + JsonConvert.SerializeObject(stdLogFile, logFileModule.settings);
                    logFileModule.logfile(10, "تغير الحالة تلقائي", "Update Status Automatic", LogData);

                    Payment_Process paymentLogFile = db.Payment_Process.Find(Pay_process.Payment_Id);
                    LogData = "data:" + JsonConvert.SerializeObject(paymentLogFile, logFileModule.settings);
                    logFileModule.logfile(10, "اضافة عملية دفع", "add payment process", LogData);

                    bool            Make_Equation = false;
                    List <Sequence> seq_Check     = db.Sequences.Where(x => x.Student_Id == std.Student_Id && x.Status_Id == 1016).ToList(); // 1016 : Certificate Equation Completed
                    if (seq_Check.Count > 0)
                    {
                        Make_Equation = true;
                    }

                    // InCase if student not new
                    if (std.Student_Status_Id == 7 && std.Student_Type_Id != 1 && !Make_Equation)
                    {
                        try
                        {
                            // Update student record to Equation
                            int new_Status_Id_Tran = 19;//معادلة الشهادة
                            std.Student_Status_Id = new_Status_Id_Tran;
                            db.Entry(std).State   = System.Data.EntityState.Modified;
                            db.SaveChanges();

                            // isnert new Sequences record to paid
                            Sequence seq2 = db.Sequences.Create();
                            seq2.Emp_Id       = 1;
                            seq2.Status_Id    = new_Status_Id_Tran;
                            seq2.Student_Id   = std.Student_Id;
                            seq2.Note         = "Auto Transaction";
                            seq2.DateCreation = DateTime.Now;
                            db.Sequences.Add(seq2);
                            db.SaveChanges();


                            db.Configuration.LazyLoadingEnabled = false;
                            /* Add it to log file */
                            Student stdLogFile2 = db.Students.Find(std.Student_Id);
                            stdLogFile2.Employee = db.Employees.Find(seq2.Emp_Id);
                            stdLogFile2.Status   = db.Status.Find(seq2.Status_Id);

                            LogData = "data:" + JsonConvert.SerializeObject(stdLogFile2, logFileModule.settings);
                            logFileModule.logfile(10, "تغير الحالة تلقائي", "Update Status Automatic", LogData);
                        }
                        catch (Exception er)
                        {
                            db.Configuration.LazyLoadingEnabled = false;
                            /* Add it to log file */

                            LogData = "data:" + JsonConvert.SerializeObject(er, logFileModule.settings);
                            logFileModule.logfile(10, "خطأ جديد التحقق من  للدفع", "New Exception in checkPayment Status", LogData);
                        }
                    }

                    return("{'Status': {'Code': 0,'Description': 'Success','Severity': 'Info'}}");
                }

                return("{'Status': {'Code': 2000,'Description': 'Bill not found','Severity': 'Info'}}");
            }
            catch (Exception er) { return("{'Status': {'Code': 2000,'Description': 'Bill not found','Severity': 'Info'}}"); }
        }
コード例 #8
0
        public bool CheckPaymentStatus(string Trackingkey_local, string entityId, string PaymentId_local)
        {
            bool result = false;

            try
            {
                Dictionary <string, dynamic> responseData = CheckStatusPaymentRequest(PaymentId_local, entityId);
                if (responseData["result"]["code"] == "000.100.110" || responseData["result"]["code"] == "000.100.112")
                {
                    Payment_Process PaymentProcess_update = db.Payment_Process.FirstOrDefault(x => x.Payment_Trackingkey == Trackingkey_local);
                    PaymentProcess_update.Payment_IsPaid      = true;
                    PaymentProcess_update.Payment_URL_IsValid = false;
                    PaymentProcess_update.Payment_Result_Json = JsonConvert.SerializeObject(responseData, logFileModule.settings);
                    PaymentProcess_update.Payment_Date        = DateTime.Now;
                    db.Entry(PaymentProcess_update).State     = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();



                    // Update student record to paid
                    Student std           = db.Students.Find(PaymentProcess_update.Student_Id);
                    int     new_Status_Id = (int)std.Student_Status_Id + 1;
                    std.Student_Status_Id = new_Status_Id;
                    db.Entry(std).State   = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    // isnert new Sequences record to paid
                    Sequence seq = db.Sequences.Create();
                    seq.Emp_Id       = 1;
                    seq.Status_Id    = new_Status_Id;
                    seq.Student_Id   = std.Student_Id;
                    seq.Note         = "Auto payment";
                    seq.DateCreation = DateTime.Now;
                    db.Sequences.Add(seq);
                    db.SaveChanges();


                    db.Configuration.LazyLoadingEnabled = false;
                    /* Add it to log file */
                    Student stdLogFile = db.Students.Find(std.Student_Id);
                    stdLogFile.Employee = db.Employees.Find(seq.Emp_Id);
                    stdLogFile.Status   = db.Status.Find(seq.Status_Id);

                    LogData = "data:" + JsonConvert.SerializeObject(stdLogFile, logFileModule.settings);
                    logFileModule.logfile(10, "تغير الحالة تلقائي", "Update Status Automatic", LogData);

                    Payment_Process paymentLogFile = db.Payment_Process.Find(PaymentProcess_update.Payment_Id);
                    LogData = "data:" + JsonConvert.SerializeObject(paymentLogFile, logFileModule.settings);
                    logFileModule.logfile(10, "اضافة عملية دفع", "add payment process", LogData);

                    result = true;
                }
                else
                {
                    Payment_Process PaymentProcess_update = db.Payment_Process.FirstOrDefault(x => x.Payment_Trackingkey == Trackingkey_local);
                    PaymentProcess_update.Payment_Result_Json = JsonConvert.SerializeObject(responseData, logFileModule.settings);
                    db.Entry(PaymentProcess_update).State     = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    /* Add it to log file */
                    db.Configuration.LazyLoadingEnabled = false;
                    Payment_Process paymentLogFile = db.Payment_Process.Find(PaymentProcess_update.Payment_Id);
                    LogData = "data:" + JsonConvert.SerializeObject(paymentLogFile, logFileModule.settings);
                    logFileModule.logfile(10, "اضافة عملية دفع", "add payment process", LogData);
                }
            }
            catch (Exception er) {
                db.Configuration.LazyLoadingEnabled = false;
                /* Add it to log file */

                LogData = "data:" + JsonConvert.SerializeObject(er, logFileModule.settings);
                logFileModule.logfile(10, "خطأ جديد التحقق من  للدفع", "New Exception in checkPayment Status", LogData);
            }
            return(result);
        }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["Trackingkey"] != null)
            {
                if (Request["id"] != null)
                {
                    Trackingkey = Request["Trackingkey"];
                    PaymentId   = Request["id"];

                    Payment_Process payment = db.Payment_Process.Where(x => x.Payment_Trackingkey == Trackingkey).FirstOrDefault();
                    if (payment != null)
                    {
                        if (payment.Payment_IsPaid == false && payment.Payment_URL_IsValid == true)
                        {
                            bool payment_result = CheckPaymentStatus(Trackingkey, payment.Send_EntityId, PaymentId);
                            if (payment_result)
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DisplayDiv(2);", true);
                            }
                            else
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DisplayDiv(3);", true);
                            }
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DisplayDiv(4);", true);
                        }
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DisplayDiv(3);", true);
                    }
                }
                else
                {
                    Trackingkey = Request["Trackingkey"];
                    Payment_Process payment = db.Payment_Process.Where(x => x.Payment_Trackingkey == Trackingkey && x.Payment_URL_IsValid == true && x.Payment_IsPaid == false).FirstOrDefault();
                    if (payment != null)
                    {
                        string sever_name = Request.Url.Authority.ToString();
                        string URL        = sever_name + "/Payment/PaymentProcess.aspx?Trackingkey=" + Trackingkey + "&";
                        if (URL.Substring(0, 4).ToLower() != "http".ToLower())
                        {
                            URL = "http://" + URL;
                        }

                        Payment_Form.Action = URL;
                        render_Payment.Text = "<script src='https://test.oppwa.com/v1/paymentWidgets.js?checkoutId=" + payment.Result_Id + "'></script>";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DisplayDiv(1);", true);
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DisplayDiv(4);", true);
                    }
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "DisplayDiv(4);", true);
            }
        }
コード例 #10
0
        public async void PaymentProcessFunction()
        {
            try
            {
                int counter   = 0;
                int newStatus = 0;
                List <Payment_Process> ListPayment = db.Payment_Process.Where(x => x.Payment_IsPaid == false && x.Payment_URL_IsValid == false).ToList();
                for (int i = 0; i < ListPayment.Count; i++)
                {
                    Dictionary <string, dynamic> responseData = Request(ListPayment[i].Send_EntityId);
                    if (responseData["result"]["code"] == "000.200.100")
                    {
                        Payment_Process PaymentProcess_update = db.Payment_Process.Find(ListPayment[i].Payment_Id);
                        PaymentProcess_update.Payment_IsPaid     = true;
                        PaymentProcess_update.Result_Code        = responseData["result"]["code"];
                        PaymentProcess_update.Result_Description = responseData["result"]["description"];
                        PaymentProcess_update.Result_BuildNumber = responseData["buildNumber"];
                        PaymentProcess_update.Result_Timestamp   = responseData["timestamp"];
                        PaymentProcess_update.Result_Ndc         = responseData["ndc"];
                        PaymentProcess_update.Result_Id          = responseData["id"];
                        PaymentProcess_update.Payment_Date       = DateTime.Now;
                        db.Entry(PaymentProcess_update).State    = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        counter++;


                        Student std = db.Students.Find(PaymentProcess_update.Student_Id);
                        if (std.Student_Status_Id == 6)
                        {
                            newStatus = 7;
                        }
                        else if (std.Student_Status_Id == 11)
                        {
                            newStatus = 10;
                        }

                        std.Student_Status_Id = newStatus;
                        db.Entry(std).State   = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();

                        Sequence seq = db.Sequences.Create();

                        seq.Emp_Id       = 1;
                        seq.Status_Id    = newStatus;
                        seq.Student_Id   = std.Student_Id;
                        seq.Note         = "Student Complate The Payment";
                        seq.DateCreation = DateTime.Now;

                        db.Sequences.Add(seq);
                        db.SaveChanges();

                        db.Configuration.LazyLoadingEnabled = false;
                        /* Add it to log file */
                        Student stdLogFilestd = db.Students.Find(std.Student_Id);
                        stdLogFilestd.Employee = db.Employees.Find(seq.Emp_Id);
                        stdLogFilestd.Status   = db.Status.Find(seq.Status_Id);

                        LogData = "data:" + JsonConvert.SerializeObject(stdLogFilestd, logFileModule.settings);
                        logFileModule.logfile(10, "تغير الحالة", "Update Status", LogData);

                        /* Add it to log file */
                        Payment_Process stdLogFile = db.Payment_Process.Find(PaymentProcess_update.Payment_Id);
                        stdLogFile.Student = db.Students.Find(PaymentProcess_update.Student_Id);

                        LogData = "data:" + JsonConvert.SerializeObject(stdLogFile, logFileModule.settings);
                        logFileModule.logfile(10, "اضافة دفعية جديدة", "Add new payment operation", LogData);
                    }
                }
                LastUpdate lastupdate_exist = db.LastUpdates.FirstOrDefault();
                if (lastupdate_exist != null)
                {
                    lastupdate_exist.CreationDate    = DateTime.Now;
                    lastupdate_exist.Counter         = lastupdate_exist.Counter + counter;
                    db.Entry(lastupdate_exist).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    LastUpdate lastupdate_new = db.LastUpdates.Create();
                    lastupdate_new.CreationDate = DateTime.Now;
                    lastupdate_new.Counter      = counter;
                    db.LastUpdates.Add(lastupdate_new);
                    db.SaveChanges();
                }
            }
            catch (Exception er)
            {
                /* Add it to log file */
                LogData = "data:" + JsonConvert.SerializeObject(er.StackTrace, logFileModule.settings);
                logFileModule.logfile(10, "حدث خطاء في النظام", "Exception in system", LogData);
                return;
            }
        }
コード例 #11
0
        public async System.Threading.Tasks.Task <bool> confirm_To_Payment()
        {
            string Entity_ID = "";
            bool   Response  = false;

            try
            {
                /*  Start Prepare the checkout  */
                Payment_Process checkout_payment = db.Payment_Process.Where(x => x.Payment_Trackingkey == Trackingkey && x.Payment_URL_IsValid == true && x.Payment_IsPaid == false).FirstOrDefault();
                if (checkout_payment != null)
                {
                    if (PaymentType.SelectedValue == "1" || PaymentType.SelectedValue == "2")
                    {
                        Entity_ID = "8acda4ce72e5a3df0172fb754c3c488c";
                    }
                    else if (PaymentType.SelectedValue == "3")
                    {
                        Entity_ID = "8acda4ce72e5a3df0172fb75d45d4891";
                    }

                    if (PaymentType.SelectedValue != "4")
                    {
                        string paymentBrand = "VISA";
                        if (PaymentType.SelectedValue == "1")
                        {
                            paymentBrand = "VISA";
                        }
                        else if (PaymentType.SelectedValue == "2")
                        {
                            paymentBrand = "MASTER";
                        }
                        else if (PaymentType.SelectedValue == "3")
                        {
                            paymentBrand = "MADA";
                        }

                        VISA_MADA NewVM = db.VISA_MADA.Create();
                        NewVM.UUID = UUID;
                        NewVM.PaymentProcess_Id = checkout_payment.Payment_Id;
                        NewVM.Trackingkey       = checkout_payment.Payment_Trackingkey;
                        NewVM.Result_JSON       = string.Empty;
                        NewVM.DateCreation      = DateTime.Now;
                        db.VISA_MADA.Add(NewVM);
                        db.SaveChanges();

                        Dictionary <string, dynamic> responseData =
                            Prepare_Check_Payment_Request(UUID, paymentBrand, Entity_ID, checkout_payment.Send_Amount.ToString(), checkout_payment.Send_Currency, checkout_payment.Send_PaymentType, StudentName.Text, Studentsurname.Text, StudentEmail.Text, StudentCountry.SelectedValue, StudentState.Text, StudentCity.Text, StudentAddress.Text, StudentPostcode.Text);
                        if (responseData["result"]["code"] == "000.200.100")
                        {
                            checkout_payment.Result_Code        = responseData["result"]["code"];
                            checkout_payment.Result_Description = responseData["result"]["description"];
                            checkout_payment.Result_BuildNumber = responseData["buildNumber"];
                            checkout_payment.Result_Timestamp   = responseData["timestamp"];
                            checkout_payment.Result_Ndc         = responseData["ndc"];
                            checkout_payment.Result_Id          = responseData["id"];
                            checkout_payment.Send_EntityId      = Entity_ID;
                            db.Entry(checkout_payment);
                            db.SaveChanges();


                            Response = true;
                        }
                        else
                        {
                            Response = false;
                            //return false;
                        }
                        // Save Result in all cases
                        VISA_MADA VM_UpdateResult = db.VISA_MADA.Where(x => x.UUID == UUID).FirstOrDefault();
                        if (VM_UpdateResult != null)
                        {
                            VM_UpdateResult.Result_JSON     = JsonConvert.SerializeObject(responseData);
                            db.Entry(VM_UpdateResult).State = System.Data.EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                    else
                    {
                        int studentID = 0;
                        int.TryParse(checkout_payment.Student_Id.ToString(), out studentID);
                        string PayeeId = StringCipher.RandomString(10);

                        string Gender = StudentGender.SelectedValue;

                        Dictionary <string, dynamic> responseData = await Prepare_Check_Payment_Request_SADAD(checkout_payment.Payment_Id, PayeeId, UUID, checkout_payment.Send_Amount.ToString(), checkout_payment.Student.Student_SSN, checkout_payment.Send_PaymentType, StudentFirstName.Text, StudentLastName.Text, studentID, Gender);

                        if (responseData["Status"]["Code"] == 0)
                        {
                            checkout_payment.Result_Code        = (responseData["Status"]["Code"]).ToString();
                            checkout_payment.Result_Description = responseData["Status"]["Description"];
                            checkout_payment.Result_BuildNumber = responseData["SADADNumber"];
                            checkout_payment.Result_Timestamp   = responseData["Status"]["Severity"];
                            checkout_payment.Result_Ndc         = responseData["InvoiceId"];
                            db.Entry(checkout_payment).State    = System.Data.EntityState.Modified;
                            db.SaveChanges();

                            string        InvoiceId = responseData["InvoiceId"];
                            Rosom_Request Rosom     = db.Rosom_Request.FirstOrDefault(x => x.Trackingkey == Trackingkey && x.InvoiceId == InvoiceId);
                            Rosom.Response_Status_Code = (responseData["Status"]["Code"]).ToString();
                            // Rosom. = responseData["result"]["description"];
                            Rosom.Response_SADADNumber = responseData["SADADNumber"];
                            Rosom.Result_JSON          = JsonConvert.SerializeObject(responseData);
                            db.Entry(Rosom).State      = System.Data.EntityState.Modified;;
                            db.SaveChanges();

                            SADAD_Number = responseData["SADADNumber"];

                            string Text       = "";
                            string sever_name = Request.Url.Authority.ToString();
                            string StuEmail   = checkout_payment.Student.Student_Email;

                            SendEmail send = new SendEmail();
                            Text = " <Strong style='font-size:16px;'> Dear " + checkout_payment.Student.Student_Name_En + "</Strong><br /><br /> " + "The invoice number of SADAD is:<Strong>" + SADAD_Number + "</Strong>.<br />The total amount: <Strong>" + checkout_payment.Send_Amount + "</Strong> SAR.<br /><br />Please complete the payment before 48 hours." + " <br /> <br />" + "Best Regard," + " <br />";
                            bool R = send.TextEmail("Riyadh Elm University", StuEmail, Text, sever_name);

                            // Send SMS
                            SendSMS send_sms      = new SendSMS();
                            string  smsText       = "Dear " + checkout_payment.Student.Student_Name_En + "\n\n" + "The invoice number of SADAD is:" + SADAD_Number + ".\n\nThe total amount: " + checkout_payment.Send_Amount + " SAR.\n\nPlease complete the payment before 48 hours." + " \n\n" + "Best Regard";
                            string  number_Phone  = checkout_payment.Student.Student_Phone;
                            string  reslt_message = send_sms.SendMessage(smsText, number_Phone);

                            Response = true;
                        }
                        else
                        {
                            Response = false;
                            //return false;
                        }
                    }
                }
                else
                {
                    Response = false;
                    //return Response;
                }
            }
            catch (Exception er)
            {
                db.Configuration.LazyLoadingEnabled = false;
                /* Add it to log file */
                LogData = "data:" + JsonConvert.SerializeObject(er, logFileModule.settings);
                logFileModule.logfile(10, "خطأ جديد للدفع", "New Exception in Payment", LogData);
                return(false);
            }

            return(Response);
            /* End Prepare the checkout */
        }
コード例 #12
0
        public bool confirm_To_Payment()
        {
            string Entity_ID = "";
            bool   Response  = false;

            try
            {
                /*  Start Prepare the checkout  */
                Payment_Process checkout_payment = db.Payment_Process.Where(x => x.Payment_Trackingkey == Trackingkey && x.Payment_URL_IsValid == true && x.Payment_IsPaid == false).FirstOrDefault();
                if (checkout_payment != null)
                {
                    if (PaymentType.SelectedValue == "1" || PaymentType.SelectedValue == "2")
                    {
                        Entity_ID = "8ac7a4c87284f6c901728e6183ff150e";
                    }
                    else if (PaymentType.SelectedValue == "3")
                    {
                        Entity_ID = "8ac7a4c87284f6c901728e633a371512";
                    }

                    if (PaymentType.SelectedValue != "4")
                    {
                        Dictionary <string, dynamic> responseData =
                            Prepare_Check_Payment_Request(Entity_ID, checkout_payment.Send_Amount.ToString(), checkout_payment.Send_Currency, checkout_payment.Send_PaymentType, StudentName.Text, Studentsurname.Text, StudentEmail.Text, StudentCountry.SelectedValue, StudentState.Text, StudentCity.Text, StudentAddress.Text, StudentPostcode.Text);
                        if (responseData["result"]["code"] == "000.200.100")
                        {
                            string        InvoiceId = responseData["InvoiceId"];
                            Rosom_Request Rosom     = db.Rosom_Request.FirstOrDefault(x => x.Trackingkey == Trackingkey && x.InvoiceId == InvoiceId);
                            Rosom.Response_Status_Code = responseData["result"]["code"];
                            // Rosom. = responseData["result"]["description"];
                            Rosom.Response_SADADNumber = responseData["SADADNumber"];
                            Rosom.Result_JSON          = responseData.ToString();
                            db.Entry(Rosom).State      = System.Data.Entity.EntityState.Modified;;
                            db.SaveChanges();

                            SADAD_Number = responseData["SADADNumber"];

                            string Text       = "";
                            string sever_name = Request.Url.Authority.ToString();
                            string StuEmail   = checkout_payment.Student.Student_Email;

                            SendEmail send = new SendEmail();
                            Text = " <Strong style='font-size:16px;'> Dear " + checkout_payment.Student.Student_Name_En + "</Strong><br /><br /> " + "Thank you for completed the application from at Riyadh Elm University. We will contact you within 48 hours." + " <br /> <br />" + "Best Regard," + " <br />" + "Admission System" + " <br /> ";
                            bool R = send.TextEmail("Riyadh Elm University", StuEmail, Text, sever_name);

                            // Send SMS
                            SendSMS send_sms      = new SendSMS();
                            string  smsText       = "Dear " + checkout_payment.Student.Student_Name_En + "\n" + "Thank you for completed the application form at Riyadh Elm University. We will contact you within 48 hours." + " \n" + "Best Regard," + " \n" + "Admission System";
                            string  number_Phone  = checkout_payment.Student.Student_Phone;
                            string  reslt_message = send_sms.SendMessage(smsText, number_Phone);

                            Response = true;
                        }
                        else
                        {
                            Response = false;
                            //return false;
                        }
                    }
                    else
                    {
                        int studentID = 0;
                        int.TryParse(checkout_payment.Student_Id.ToString(), out studentID);
                        Dictionary <string, dynamic> responseData =
                            Prepare_Check_Payment_Request_SADAD(UUID, checkout_payment.Send_Amount.ToString(), checkout_payment.Student.Student_SSN, checkout_payment.Send_PaymentType, StudentFirstName.Text, StudentLastName.Text, studentID);
                        if (responseData["Status"]["Code"] == 0)
                        {
                            checkout_payment.Result_Code        = responseData["InvoiceId"];
                            checkout_payment.Result_Description = responseData["SADADNumber"];
                            checkout_payment.Result_BuildNumber = responseData["Status"]["Code"];
                            checkout_payment.Result_Timestamp   = responseData["Status"]["Description"];
                            checkout_payment.Result_Ndc         = responseData["Status"]["Severity"];
                            db.Entry(checkout_payment).State    = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                            Response = true;
                        }
                        else
                        {
                            Response = false;
                            //return false;
                        }
                    }
                }
                else
                {
                    Response = false;
                    //return Response;
                }
            }
            catch (Exception er)
            {
                db.Configuration.LazyLoadingEnabled = false;
                /* Add it to log file */
                LogData = "data:" + JsonConvert.SerializeObject(er, logFileModule.settings);
                logFileModule.logfile(10, "خطأ جديد التجهيز للدفع", "New Exception in Checkout", LogData);
                return(false);
            }

            return(Response);
            /* End Prepare the checkout */
        }