Esempio n. 1
0
        private static string AGAIN_URL  = Config.WebsiteAppPath + "/PayO.aspx";  //Config.WebsiteAppPath + "AccOnePayO.aspx";



        public static string Trans2OnePay(string OrderID, decimal Total, string vpc_BankType, string vpc_MerchTxnRef, int vpc_Bank)
        {
            // Thao tác sau khi bấm thanh toán
            // InitValues
            int vpc_order_id = nClientID;
            //string vpc_MerchTxnRef = getMerchantTntRef(OrderID, vpc_BankType);
            string  vpc_Merchant  = MERCHANT_ID;
            string  vpc_OrderInfo = OrderID;
            decimal vpc_Amount    = Total * 100;
            string  vpc_TicketNo  = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();

            // Update Database
            if (!TransManager.Insert(vpc_MerchTxnRef, vpc_Merchant, vpc_OrderInfo, Total, vpc_TicketNo, vpc_BankType))
            {
                throw new ApplicationException("Lỗi cập nhật Data!!!");
            }

            // Onepay nội địa

            // Khoi tao lop thu vien va gan gia tri cac tham so gui sang cong thanh toan
            VPCRequest conn = new VPCRequest(ONEPAY_URL);

            conn.SetSecureSecret(SECURE_SECRET);
            // Add the Digital Order Fields for the functionality you wish to use
            // Core Transaction Fields
            conn.AddDigitalOrderField("Title", "onepay paygate");
            conn.AddDigitalOrderField("vpc_Locale", "vn");//Chon ngon ngu hien thi tren cong thanh toan (vn/en)
            conn.AddDigitalOrderField("vpc_Version", "2");
            conn.AddDigitalOrderField("vpc_Command", "pay");
            conn.AddDigitalOrderField("vpc_Merchant", MERCHANT_ID);
            conn.AddDigitalOrderField("vpc_AccessCode", ACCESS_CODE);
            conn.AddDigitalOrderField("vpc_MerchTxnRef", vpc_MerchTxnRef);
            conn.AddDigitalOrderField("vpc_OrderInfo", vpc_OrderInfo);
            conn.AddDigitalOrderField("vpc_Amount", vpc_Amount.ToString());
            conn.AddDigitalOrderField("vpc_Currency", "VND");
            conn.AddDigitalOrderField("vpc_ReturnURL", RETURN_URL);
            // Thong tin them ve khach hang. De trong neu khong co thong tin
            conn.AddDigitalOrderField("vpc_SHIP_Street01", "194 Tran Quang Khai");
            conn.AddDigitalOrderField("vpc_SHIP_Provice", "Hanoi");
            conn.AddDigitalOrderField("vpc_SHIP_City", "Hanoi");
            conn.AddDigitalOrderField("vpc_SHIP_Country", "Vietnam");
            conn.AddDigitalOrderField("vpc_Customer_Phone", "043966668");
            conn.AddDigitalOrderField("vpc_Customer_Email", "*****@*****.**");
            conn.AddDigitalOrderField("vpc_Customer_Id", "onepay_paygate");
            // Dia chi IP cua khach hang
            conn.AddDigitalOrderField("vpc_TicketNo", vpc_TicketNo);
            conn.AddDigitalOrderField("vpc_Bank", vpc_Bank.ToString());
            // Chuyen huong trinh duyet sang cong thanh toan
            String url = conn.Create3PartyQueryString();

            return(url);
        }
Esempio n. 2
0
        public static bool verifyOPIUrl()
        {
            string hashvalidateResult = "";
            // Khoi tao lop thu vien
            VPCRequest conn = new VPCRequest("http://onepay.vn");

            conn.SetSecureSecret(OPI_SECURE_SECRET);
            // Xu ly tham so tra ve va kiem tra chuoi du lieu ma hoa
            hashvalidateResult = conn.Process3PartyResponse(HttpContext.Current.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");
            if (hashvalidateResult == "INVALIDATED")
            {
                // vpc_Result.Text = "Transaction is pending";
                //hashvalidateResult = "INVALIDATED";
                // Response.Write("Hash value is equal=> Transaction is successful");
                return(false);
            }
            else
            {
                //if (txnResponseCode.Trim() == "0")
                //{
                //    vpc_Result.Text = "Transaction was paid successful";
                //}
                //else
                //{
                //    vpc_Result.Text = "Transaction was not paid successful";
                //}
                //  hashvalidateResult = "CORRECTED";
                // Response.Write("Hash value is not equal=> Transaction is unsuccessful");
                return(true);
            }
        }
Esempio n. 3
0
        //public static string Trans2OPI(string OrderID, decimal Total, string vpc_BankType, string vpc_MerchTxnRef)
        //{
        //    // Thao tác sau khi bấm thanh toán
        //    // InitValues
        //    int vpc_order_id = nClientID;
        //    //string vpc_MerchTxnRef = getMerchantTntRef(OrderID, vpc_BankType);
        //    string vpc_Merchant = OPI_MERCHANT_ID;
        //    string vpc_OrderInfo = OrderID;
        //    string vpc_Amount = Math.Round((Total * 100),0).ToString();// Math.Round((Total / SettingManager.SelectCode("USDPAYPAL").SettingValue), 2) * 100;
        //    string vpc_TicketNo = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
        //    string vpc_SHIP_Country = "";
        //    string vpc_SHIP_City = "";
        //    string vpc_SHIP_Provice = "";
        //    string vpc_SHIP_Street01 = "";
        //    string vpc_Customer_Email = "";
        //    string vpc_Customer_Id = "";
        //    string vpc_Customer_Phone = "";
        //    if (Authentication.CurrentMember != null)
        //    {
        //        vpc_SHIP_Country = "";// Authentication.CurrentMember.CountryID != int.MinValue ? Util.VietNamese2Varchar(CountryManager.Select(Authentication.CurrentMember.CountryID).CountryName, false) : "";
        //        vpc_SHIP_City = "";// Authentication.CurrentMember.ProvinceID != int.MinValue ? Util.VietNamese2Varchar(ProvinceManager.Select(Authentication.CurrentMember.ProvinceID).ProvinceName, false) : "";
        //        vpc_SHIP_Provice = "";// Authentication.CurrentMember.DistrictID != int.MinValue ? Util.VietNamese2Varchar(DistrictManager.Select(Authentication.CurrentMember.DistrictID).DistrictName, false) : "";
        //        vpc_SHIP_Street01 = "";// Authentication.CurrentMember.Address != null ? Util.VietNamese2Varchar(Authentication.CurrentMember.Address, false) : "";
        //        vpc_Customer_Email = Authentication.CurrentMember.Email;
        //        vpc_Customer_Id = Authentication.CurrentMember.AccountNo;
        //        vpc_Customer_Phone = Authentication.CurrentMember.Mobile;
        //    }

        //    // Update Database
        //    if (!TransManager.Insert(vpc_MerchTxnRef, vpc_Merchant, vpc_OrderInfo, Total, vpc_TicketNo, vpc_BankType))
        //        throw new ApplicationException("Lỗi cập nhật Data!!!");

        //    // Onepay quốc tế

        //    // Khoi tao lop thu vien va gan gia tri cac tham so gui sang cong thanh toan
        //    VPCRequest conn = new VPCRequest(OPI_ONEPAY_URL);
        //    conn.SetSecureSecret(OPI_SECURE_SECRET);
        //    // Add the Digital Order Fields for the functionality you wish to use
        //    // Core Transaction Fields
        //    conn.AddDigitalOrderField("AgainLink", "http://onepay.vn");
        //    conn.AddDigitalOrderField("Title", "onepay paygate");
        //    conn.AddDigitalOrderField("vpc_Locale", "vn");//Chon ngon ngu hien thi tren cong thanh toan (vn/en)
        //    conn.AddDigitalOrderField("vpc_Version", "2");
        //    conn.AddDigitalOrderField("vpc_Command", "pay");
        //    conn.AddDigitalOrderField("vpc_Merchant", OPI_MERCHANT_ID);
        //    conn.AddDigitalOrderField("vpc_AccessCode", OPI_ACCESS_CODE);
        //    conn.AddDigitalOrderField("vpc_MerchTxnRef", vpc_MerchTxnRef);
        //    conn.AddDigitalOrderField("vpc_OrderInfo", vpc_OrderInfo);
        //    conn.AddDigitalOrderField("vpc_Amount", vpc_Amount);
        //    conn.AddDigitalOrderField("vpc_ReturnURL", RETURN_URL);
        //    // Thong tin them ve khach hang. De trong neu khong co thong tin
        //    conn.AddDigitalOrderField("vpc_SHIP_Street01", vpc_SHIP_Street01);
        //    conn.AddDigitalOrderField("vpc_SHIP_Provice", vpc_SHIP_Provice);
        //    conn.AddDigitalOrderField("vpc_SHIP_City", vpc_SHIP_City);
        //    conn.AddDigitalOrderField("vpc_SHIP_Country", vpc_SHIP_Country);
        //    conn.AddDigitalOrderField("vpc_Customer_Phone", vpc_Customer_Phone);
        //    conn.AddDigitalOrderField("vpc_Customer_Email", vpc_Customer_Email);
        //    conn.AddDigitalOrderField("vpc_Customer_Id", vpc_Customer_Id);
        //    // Dia chi IP cua khach hang
        //    conn.AddDigitalOrderField("vpc_TicketNo", vpc_TicketNo);
        //    // Chuyen huong trinh duyet sang cong thanh toan
        //    String url = conn.Create3PartyQueryString();
        //    return url;
        //}

        public static bool verifyPaymentUrl()
        {
            NameValueCollection colQuery = HttpContext.Current.Request.QueryString;

            if (colQuery.Count == 0)
            {
                HttpContext.Current.Response.Redirect("/PayO.aspx");
                return(false);
            }

            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(HttpContext.Current.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 cardBin = 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 txnResponseCode = vpc_TxnResponseCode;
            //string message = conn.GetResultField("vpc_Message", "Unknown");

            if (hashvalidateResult == "INVALIDATED")
            {
                // hashvalidateResult = "INVALIDATED";
                return(false);
            }
            else
            {
                // hashvalidateResult = "CORRECTED";
                return(true);
            }
        }