Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int sectionId = Int32.Parse(Request.QueryString["SectionId"]);

            Section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId);

            string SECURE_SECRET      = "6D0870CDE5F24F34F3915FB0045120DB";
            string hashvalidateResult = "";
            // Khoi tao lop thu vien
            VPCRequest conn = new VPCRequest("http://onepay.vn");

            conn.SetSecureSecret(SECURE_SECRET);
            // Xu ly tham so tra ve va kiem tra chuoi du lieu ma hoa
            hashvalidateResult = conn.Process3PartyResponse(Page.Request.QueryString);
            // Lay gia tri tham so tra ve tu cong thanh toan
            String vpc_TxnResponseCode = conn.GetResultField("vpc_TxnResponseCode", "Unknown");
            string amount          = conn.GetResultField("vpc_Amount", "Unknown");
            string localed         = conn.GetResultField("vpc_Locale", "Unknown");
            string command         = conn.GetResultField("vpc_Command", "Unknown");
            string version         = conn.GetResultField("vpc_Version", "Unknown");
            string cardType        = conn.GetResultField("vpc_Card", "Unknown");
            string orderInfo       = conn.GetResultField("vpc_OrderInfo", "Unknown");
            string merchantID      = conn.GetResultField("vpc_Merchant", "Unknown");
            string authorizeID     = conn.GetResultField("vpc_AuthorizeId", "Unknown");
            string merchTxnRef     = conn.GetResultField("vpc_MerchTxnRef", "Unknown");
            string transactionNo   = conn.GetResultField("vpc_TransactionNo", "Unknown");
            string acqResponseCode = conn.GetResultField("vpc_AcqResponseCode", "Unknown");
            string txnResponseCode = vpc_TxnResponseCode;
            string message         = conn.GetResultField("vpc_Message", "Unknown");

            var bookingId  = merchTxnRef;
            var pBookingId = Int32.Parse(bookingId);

            if (hashvalidateResult == "CORRECTED" && txnResponseCode.Trim() == "0")
            {
                SendSuccessEmail();
                NSession.Save(new CheckingTransaction()
                {
                    MerchTxnRef = merchTxnRef, Processed = true
                });
                Response.Write("responsecode=1&desc=confirm-success");
            }
            else
            {
                SendFailedEmail();
                NSession.Save(new CheckingTransaction()
                {
                    MerchTxnRef = merchTxnRef, Processed = true
                });
                Response.Write("responsecode=0&desc=confirm-fail");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int sectionId = Int32.Parse(Request.QueryString["SectionId"]);

            Section = (Section)CoreRepository.GetObjectById(typeof(Section), sectionId);

            string SECURE_SECRET = "A3EFDFABA8653DF2342E8DAC29B51AF0";

            if (Request.QueryString["module"] == "noidia")
            {
                SECURE_SECRET = "" + SECURE_SECRET;
            }

            if (Request.QueryString["module"] == "quocte")
            {
                SECURE_SECRET = "6D0870CDE5F24F34F3915FB0045120DB";
            }

            string hashvalidateResult = "";
            // Khoi tao lop thu vien
            VPCRequest conn = new VPCRequest("http://onepay.vn");

            conn.SetSecureSecret(SECURE_SECRET);
            // Xu ly tham so tra ve va kiem tra chuoi du lieu ma hoa
            hashvalidateResult = conn.Process3PartyResponse(Page.Request.QueryString);
            // Lay gia tri tham so tra ve tu cong thanh toan
            String vpc_TxnResponseCode = conn.GetResultField("vpc_TxnResponseCode", "Unknown");
            string amount          = conn.GetResultField("vpc_Amount", "Unknown");
            string localed         = conn.GetResultField("vpc_Locale", "Unknown");
            string command         = conn.GetResultField("vpc_Command", "Unknown");
            string version         = conn.GetResultField("vpc_Version", "Unknown");
            string cardType        = conn.GetResultField("vpc_Card", "Unknown");
            string orderInfo       = conn.GetResultField("vpc_OrderInfo", "Unknown");
            string merchantID      = conn.GetResultField("vpc_Merchant", "Unknown");
            string authorizeID     = conn.GetResultField("vpc_AuthorizeId", "Unknown");
            string merchTxnRef     = conn.GetResultField("vpc_MerchTxnRef", "Unknown");
            string transactionNo   = conn.GetResultField("vpc_TransactionNo", "Unknown");
            string acqResponseCode = conn.GetResultField("vpc_AcqResponseCode", "Unknown");
            string txnResponseCode = vpc_TxnResponseCode;
            string message         = conn.GetResultField("vpc_Message", "Unknown");

            var bookingId           = merchTxnRef;
            var pBookingId          = Int32.Parse(bookingId);
            var checkingTransaction = NSession.QueryOver <CheckingTransaction>().Where(x => x.MerchTxnRef == merchTxnRef).SingleOrDefault();

            if (checkingTransaction != null)
            {
                if (checkingTransaction.Processed)
                {
                    Page.Response.Redirect("./TransactionResult.aspx?NodeId=1&SectionId=15&status=1&tid=" + transactionNo + "&oi=" + orderInfo + "&ta=" + amount + "&bid=" + merchTxnRef + "&trc=" + txnResponseCode);
                }
            }
            if (hashvalidateResult == "CORRECTED" && txnResponseCode.Trim() == "0")
            {
                SendSuccessEmail();
                NSession.Save(new CheckingTransaction()
                {
                    MerchTxnRef = merchTxnRef, Processed = true
                });
                Page.Response.Redirect("./TransactionResult.aspx?NodeId=1&SectionId=15&status=1&tid=" + transactionNo + "&oi=" + orderInfo + "&ta=" + amount + "&bid=" + merchTxnRef + "&trc=" + txnResponseCode);
            }
            else if (hashvalidateResult == "INVALIDATED" && txnResponseCode.Trim() == "0")
            {
                Page.Response.Redirect("./Pending.aspx");
            }
            else
            {
                SendFailedEmail();
                DeleteBooking(pBookingId);
                NSession.Save(new CheckingTransaction()
                {
                    MerchTxnRef = merchTxnRef, Processed = true
                });
                Page.Response.Redirect("./TransactionResult.aspx?NodeId=1&SectionId=157status=2&b=" + bookingId + "&responsecode=" + txnResponseCode);
            }
        }