public int Add(SubmitVoucherInfo info) { SqlParameter[] param = { new SqlParameter("@GatePayId", info.GatePayId), new SqlParameter("@UserId", info.UserId), new SqlParameter("@Amount", info.Amount), new SqlParameter("@TransId", info.TransId), new SqlParameter("@returnCode", info.returnCode), new SqlParameter("@responseData", info.responseData), new SqlParameter("@returnCodeDescription", info.returnCodeDescription), new SqlParameter("@signature", info.signature), new SqlParameter("@CreateDate", info.CreateDate) }; return(int.Parse(DataHelper.ExecuteScalar(Config.ConnectString, "usp_SubmitVoucher_Add", param).ToString())); }
private SubmitVoucherInfo FillData(IDataReader r) { SubmitVoucherInfo info = new SubmitVoucherInfo(); if (!r.IsDBNull(r.GetOrdinal("id"))) { info.id = r.GetInt32(r.GetOrdinal("id")); } if (!r.IsDBNull(r.GetOrdinal("UserId"))) { info.UserId = r.GetString(r.GetOrdinal("UserId")); } if (!r.IsDBNull(r.GetOrdinal("Amount"))) { info.Amount = r.GetInt32(r.GetOrdinal("Amount")); } if (!r.IsDBNull(r.GetOrdinal("TransId"))) { info.TransId = r.GetString(r.GetOrdinal("TransId")); } if (!r.IsDBNull(r.GetOrdinal("returnCode"))) { info.returnCode = r.GetString(r.GetOrdinal("returnCode")); } if (!r.IsDBNull(r.GetOrdinal("responseData"))) { info.responseData = r.GetString(r.GetOrdinal("responseData")); } if (!r.IsDBNull(r.GetOrdinal("returnCodeDescription"))) { info.returnCodeDescription = r.GetString(r.GetOrdinal("returnCodeDescription")); } if (!r.IsDBNull(r.GetOrdinal("signature"))) { info.signature = r.GetString(r.GetOrdinal("signature")); } if (!r.IsDBNull(r.GetOrdinal("CreateDate"))) { info.CreateDate = r.GetDateTime(r.GetOrdinal("CreateDate")); } return(info); }
public SubmitVoucherInfo GetInfo(int id) { SubmitVoucherInfo info = null; SqlParameter[] param = { new SqlParameter("@id", id) }; var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_SubmitVoucher_GetById", param); if (r != null) { info = new SubmitVoucherInfo(); while (r.Read()) { info = FillData(r); } r.Close(); r.Dispose(); } return(info); }
private void GateFTP(HttpContext context, string UserId, string CardSerials, string CardPin, string sType) { GateCardInfo info = new GateCardInfo() { UserId = UserId, CardId = CardPin, SerialsId = CardSerials, CreateDate = DateTime.Now, ServiceID = sType }; try { AuthenSoapHeader authen = new AuthenSoapHeader(); authen.UserName = Config.UserServicesGate; authen.Password = Config.PassServicesGate; WsGateCardSoapClient client = new WsGateCardSoapClient(); var result = client.CardInputSandbox(authen, sType, CardSerials, CardPin); if (result.ErrorCode == "00") { //Giao dịch GateCard thành công info.ResultId = result.ErrorCode; info.Msg = result.ErrorMessage; info.Amount = int.Parse(result.Amount); info.TransId = result.TransId; SubmitVoucherInfo sbInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdFPT, UserId = UserId, Amount = info.Amount, CreateDate = DateTime.Now, TransId = info.TransId }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdFPT }; var wsResult = wsclient.submitVoucher(cred, UserId, result.Amount, info.TransId); sbInfo.returnCode = wsResult.returnCode; sbInfo.returnCodeDescription = wsResult.returnCodeDescription; sbInfo.responseData = wsResult.responseData; sbInfo.signature = wsResult.signature; if (sbInfo.returnCode == "") { string sDate = ReadResultVocher(sbInfo.responseData); context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", 0, sDate)); return; } else { context.Response.Write(string.Format("{{\"error\":\"{0}\",\"msg\":\"{1}\"}}", sbInfo.returnCode, sbInfo.returnCodeDescription)); return; } } catch (Exception e) { //log error context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", e.GetHashCode(), e.Message)); sbInfo.returnCode = e.GetHashCode().ToString(); sbInfo.returnCodeDescription = e.Message; return; } finally { SubmitVoucherData.instance.Add(sbInfo); } } else { info.ResultId = result.ErrorCode; info.Msg = result.ErrorMessage; context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", result.ErrorCode, result.ErrorMessage)); } } catch (Exception e) { //log error context.Response.Write(string.Format("{{\"error\":{0},\"msg\":\"{1}\"}}", e.GetHashCode(), e.Message)); //if (info.ResultId == "") //{ // info.ResultId = e.GetHashCode().ToString(); // info.Msg = e.Message; //} return; } finally { GateCardData.instance.Add(info); } }
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); } } }
protected void Page_Load(object sender, EventArgs e) { string Good_Code = Request.QueryString["code"]; if (string.IsNullOrEmpty(Good_Code)) { Response.Redirect("/Banknet/", true); } CacheInfo oCache = (CacheInfo)CacheProvider.Get(string.Format(KeyCache.KeyUserBanknet, Good_Code)); if (oCache == null) { Response.Redirect("/Banknet/", true); } string sRedirection = "/Banknet/"; SubmitVoucherInfo oSVInfo = new SubmitVoucherInfo() { GatePayId = Config.ClientIdBanknet, UserId = oCache.User.subnum, Amount = int.Parse(oCache.Voucher.vouchervalue), CreateDate = DateTime.Now, TransId = Good_Code }; try { WSClient wsclient = new WSClient(); var cred = new credential { clientId = Config.ClientIdBanknet }; 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 //confirm ThreadStart newThread = delegate { Confirm(oCache.Merchant_trans_id, oCache.sTrans_Id); }; Thread myThread = new Thread(newThread); myThread.Start(); sRedirection = "/Banknet/#" + Good_Code + "|T"; } else { Session[Config.GetSessionsResultFail] = wsResult.returnCodeDescription;//ss sRedirection = "/Banknet/#" + Good_Code + "|F|Y"; } } catch (Exception ex) { //log error Session[Config.GetSessionsResultFail] = ex.Message; oSVInfo.returnCode = ex.GetHashCode().ToString(); oSVInfo.returnCodeDescription = ex.Message; sRedirection = "/Banknet/#" + Good_Code + "|F|Y"; } finally { SubmitVoucherData.instance.Add(oSVInfo); Response.Redirect(sRedirection); } }