Beispiel #1
0
        private SmartlinkQueryInfo FillData(IDataReader r)
        {
            SmartlinkQueryInfo info = new SmartlinkQueryInfo();

            if (!r.IsDBNull(r.GetOrdinal("id")))
            {
                info.id = r.GetInt32(r.GetOrdinal("id"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_Version")))
            {
                info.vpc_Version = r.GetString(r.GetOrdinal("vpc_Version"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_Command")))
            {
                info.vpc_Command = r.GetString(r.GetOrdinal("vpc_Command"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_AccessCode")))
            {
                info.vpc_AccessCode = r.GetString(r.GetOrdinal("vpc_AccessCode"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_Merchant")))
            {
                info.vpc_Merchant = r.GetString(r.GetOrdinal("vpc_Merchant"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_MerchTxnRef")))
            {
                info.vpc_MerchTxnRef = r.GetString(r.GetOrdinal("vpc_MerchTxnRef"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_SecureHash")))
            {
                info.vpc_SecureHash = r.GetString(r.GetOrdinal("vpc_SecureHash"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_DRExists")))
            {
                info.vpc_DRExists = (Object)r["vpc_DRExists"];
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_FoundMultipleDRs")))
            {
                info.vpc_FoundMultipleDRs = (Object)r["vpc_FoundMultipleDRs"];
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_TxnResponseCode")))
            {
                info.vpc_TxnResponseCode = r.GetString(r.GetOrdinal("vpc_TxnResponseCode"));
            }
            if (!r.IsDBNull(r.GetOrdinal("vpc_Message")))
            {
                info.vpc_Message = r.GetString(r.GetOrdinal("vpc_Message"));
            }
            if (!r.IsDBNull(r.GetOrdinal("CreateDate")))
            {
                info.CreateDate = r.GetDateTime(r.GetOrdinal("CreateDate"));
            }

            return(info);
        }
Beispiel #2
0
 public int Add(SmartlinkQueryInfo info)
 {
     SqlParameter[] param =
     {
         new SqlParameter("@vpc_Version",          info.vpc_Version),
         new SqlParameter("@vpc_Command",          info.vpc_Command),
         new SqlParameter("@vpc_AccessCode",       info.vpc_AccessCode),
         new SqlParameter("@vpc_Merchant",         info.vpc_Merchant),
         new SqlParameter("@vpc_MerchTxnRef",      info.vpc_MerchTxnRef),
         new SqlParameter("@vpc_SecureHash",       info.vpc_SecureHash),
         new SqlParameter("@vpc_DRExists",         info.vpc_DRExists),
         new SqlParameter("@vpc_FoundMultipleDRs", info.vpc_FoundMultipleDRs),
         new SqlParameter("@vpc_TxnResponseCode",  info.vpc_TxnResponseCode),
         new SqlParameter("@vpc_Message",          info.vpc_Message),
         new SqlParameter("@CreateDate",           info.CreateDate)
     };
     return(int.Parse(DataHelper.ExecuteScalar(Config.ConnectString, "usp_SmartlinkQuery_Add", param).ToString()));
 }
Beispiel #3
0
        public static string GetQuery(string sTransId, ref SmartlinkQueryInfo oQueryInfo)
        {
            Hashtable hash = new Hashtable();

            hash.Add("vpc_Version", Config.vpc_Version);
            hash.Add("vpc_Command", "queryDr");
            hash.Add("vpc_Merchant", Config.vpc_Merchant);
            hash.Add("vpc_AccessCode", Config.vpc_AccessCode);
            hash.Add("vpc_MerchTxnRef", sTransId);

            //
            oQueryInfo.vpc_Version     = Config.vpc_Version;
            oQueryInfo.vpc_Command     = Config.vpc_Command;
            oQueryInfo.vpc_Merchant    = Config.vpc_Merchant;
            oQueryInfo.vpc_AccessCode  = Config.vpc_AccessCode;
            oQueryInfo.vpc_MerchTxnRef = sTransId;
            //
            return(GetHtmlPage(getRedirectUrl(hash, Config.VirtualPaymentClientQueryUrl)));
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sTranId = Request.QueryString["code"];

            if (string.IsNullOrEmpty(sTranId))
            {
                Response.Redirect("/SmartLink/", true);
            }

            CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserSmartlink, sTranId));

            if (oCache == null)
            {
                Response.Redirect("/SmartLink/", true);
            }

            SmartlinkQueryInfo oQueryInfo = new SmartlinkQueryInfo()
            {
                CreateDate = DateTime.Now
            };

            try
            {
                string sStatus = SmartLinkHelper.GetQuery(sTranId, ref oQueryInfo);
                if (!string.IsNullOrEmpty(sStatus))
                {
                    String[] arr = sStatus.Split('&');
                    foreach (String item in arr)
                    {
                        String[] temp = item.Split('=');
                        if ("vpc_DRExists".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_DRExists = temp[1];
                        }
                        if ("vpc_FoundMultipleDRs".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_FoundMultipleDRs = temp[1];
                        }
                        if ("vpc_Message".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_Message = temp[1];
                        }
                        if ("vpc_SecureHash".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_SecureHash = temp[1];
                        }
                        if ("vpc_TxnResponseCode".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_TxnResponseCode = temp[1];
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                oQueryInfo.vpc_TxnResponseCode = ex.GetHashCode().ToString();
                oQueryInfo.vpc_Message         = ex.Message;
                //throw;
            }
            finally
            {
                CacheProvider.Remove(string.Format(KeyCache.KeyUserSmartlink, sTranId));
                SmartlinkQueryData.instance.Add(oQueryInfo);
                //Session[Config.GetSessionsResultFail] =oQueryInfo.vpc_TxnResponseCode==null?"Giao dịch bị hủy bỏ": SmartLinkHelper.getResponseDescription(oQueryInfo.vpc_TxnResponseCode);
                Session[Config.GetSessionsResultFail] = "Giao dịch không thành công";
                Response.Redirect("/SmartLink/#" + sTranId + "|F", false);
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sTranId = Request.QueryString["vpc_MerchTxnRef"];

            if (string.IsNullOrEmpty(sTranId))
            {
                Response.Redirect("/SmartLink/", true);
            }

            //Check info Smartlink
            Hashtable hash = new Hashtable();

            foreach (String key in Request.QueryString.AllKeys)
            {
                if (key.StartsWith("vpc_"))
                {
                    hash.Add(key, Request.QueryString[key]);
                }
            }

            bool isEmptysecureSecret;
            bool isValidsecureHash = SmartLinkHelper.checkSum(hash, out isEmptysecureSecret);

            if (isEmptysecureSecret)
            {
                Response.Redirect("/SmartLink/", true);
            }
            if (!isValidsecureHash)
            {
                Response.Redirect("/SmartLink/", true);
            }

            //check info AV
            CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserSmartlink, sTranId));

            if (oCache == null)
            {
                Response.Redirect("/SmartLink/", true);
            }

            string sDerection = "";

            SmartlinkQueryInfo oQueryInfo = new SmartlinkQueryInfo()
            {
                CreateDate = DateTime.Now
            };

            try
            {
                string sStatus = SmartLinkHelper.GetQuery(sTranId, ref oQueryInfo);//chư thấy trả về
                if (!string.IsNullOrEmpty(sStatus))
                {
                    String[] arr = sStatus.Split('&');
                    foreach (String item in arr)
                    {
                        String[] temp = item.Split('=');
                        if ("vpc_DRExists".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_DRExists = temp[1];
                        }
                        if ("vpc_FoundMultipleDRs".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_FoundMultipleDRs = temp[1];
                        }
                        if ("vpc_Message".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_Message = temp[1];
                        }
                        if ("vpc_SecureHash".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_SecureHash = temp[1];
                        }
                        if ("vpc_TxnResponseCode".ToUpper().Equals(temp[0].ToUpper()))
                        {
                            oQueryInfo.vpc_TxnResponseCode = temp[1];
                        }
                    }

                    //giao dịch thành công
                    if (oQueryInfo.vpc_TxnResponseCode == "0")
                    {
                        //submit voucher
                        SubmitVoucherInfo oSVInfo = new SubmitVoucherInfo()
                        {
                            GatePayId  = Config.ClientIdSmartLink,
                            UserId     = oCache.User.subnum,
                            Amount     = int.Parse(oCache.Voucher.vouchervalue),
                            CreateDate = DateTime.Now,
                            TransId    = sTranId
                        };
                        try
                        {
                            WSClient wsclient = new WSClient();
                            var      cred     = new credential {
                                clientId = Config.ClientIdSmartLink
                            };
                            var wsResult = wsclient.submitVoucher(cred, oSVInfo.UserId, oSVInfo.Amount.ToString(), oSVInfo.TransId);

                            oSVInfo.returnCode            = wsResult.returnCode;
                            oSVInfo.returnCodeDescription = wsResult.returnCodeDescription;
                            string sResultDate = XMLReader.ReadResultVocher(wsResult.responseData);//dt
                            oSVInfo.responseData = sResultDate;
                            oSVInfo.signature    = wsResult.signature;

                            if (oSVInfo.returnCode == "")
                            {
                                Session[Config.GetSessionsResultDate] = sResultDate;//ss

                                sDerection = "/SmartLink/#" + sTranId + "|T";
                            }
                            else
                            {
                                //Session[Config.GetSessionsResultFail] = wsResult.returnCodeDescription;//ss
                                Session[Config.GetSessionsResultFail] = "Giao dịch không thành công";
                                sDerection = "/SmartLink/#" + sTranId + "|F|Y";
                            }
                        }
                        catch (Exception ex)
                        {
                            //log error
                            Session[Config.GetSessionsResultFail] = ex.Message;
                            oSVInfo.returnCode            = ex.GetHashCode().ToString();
                            oSVInfo.returnCodeDescription = ex.Message;
                            sDerection = "/SmartLink/#" + sTranId + "|F|Y";
                        }
                        finally
                        {
                            SubmitVoucherData.instance.Add(oSVInfo);
                            //Response.Redirect(sDerection);
                        }
                    }
                    else
                    {
                        //Session[Config.GetSessionsResultFail] = SmartLinkHelper.getResponseDescription(oQueryInfo.vpc_TxnResponseCode??"");
                        Session[Config.GetSessionsResultFail] = "Giao dịch không thành công";
                        sDerection = "/SmartLink/#" + sTranId + "|F";
                    }
                }
                else
                {
                    sDerection = "/SmartLink/#" + sTranId + "|F";
                }
            }
            catch (Exception ex)
            {
                oQueryInfo.vpc_TxnResponseCode = ex.GetHashCode().ToString();
                oQueryInfo.vpc_Message         = ex.Message;
                sDerection = "/SmartLink/#" + sTranId + "|F";
            }
            finally
            {
                CacheProvider.Remove(string.Format(KeyCache.KeyUserSmartlink, sTranId));
                SmartlinkQueryData.instance.Add(oQueryInfo);
                if (sDerection != "")
                {
                    Response.Redirect(sDerection);
                }
            }
        }